Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(425)

Side by Side Diff: remoting/protocol/authenticator.h

Issue 12326090: Third Party authentication protocol. (Closed) Base URL: http://git.chromium.org/chromium/src.git@host_key_pair
Patch Set: Add the missing new files Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef REMOTING_PROTOCOL_AUTHENTICATOR_H_ 5 #ifndef REMOTING_PROTOCOL_AUTHENTICATOR_H_
6 #define REMOTING_PROTOCOL_AUTHENTICATOR_H_ 6 #define REMOTING_PROTOCOL_AUTHENTICATOR_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/callback.h"
10 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
11 12
12 namespace buzz { 13 namespace buzz {
13 class XmlElement; 14 class XmlElement;
14 } // namespace buzz 15 } // namespace buzz
15 16
16 namespace remoting { 17 namespace remoting {
17 namespace protocol { 18 namespace protocol {
18 19
19 class ChannelAuthenticator; 20 class ChannelAuthenticator;
(...skipping 11 matching lines...) Expand all
31 // and session-accept messages or in a session-info 32 // and session-accept messages or in a session-info
32 // message. Session-info messages are used only if authenticators need 33 // message. Session-info messages are used only if authenticators need
33 // to exchange more than one message. 34 // to exchange more than one message.
34 class Authenticator { 35 class Authenticator {
35 public: 36 public:
36 // Allowed state transitions: 37 // Allowed state transitions:
37 // When ProcessMessage() is called: 38 // When ProcessMessage() is called:
38 // WAITING_MESSAGE -> MESSAGE_READY 39 // WAITING_MESSAGE -> MESSAGE_READY
39 // WAITING_MESSAGE -> ACCEPTED 40 // WAITING_MESSAGE -> ACCEPTED
40 // WAITING_MESSAGE -> REJECTED 41 // WAITING_MESSAGE -> REJECTED
42 // WAITING_MESSAGE -> WAITING_EXTERNAL
Wez 2013/02/27 07:05:30 I don't like "external" - can we call this WAITING
rmsousa 2013/03/05 03:30:24 Done in another CL.
41 // When GetNextMessage() is called: 43 // When GetNextMessage() is called:
42 // MESSAGE_READY -> WAITING_MESSAGE 44 // MESSAGE_READY -> WAITING_MESSAGE
43 // MESSAGE_READY -> ACCEPTED 45 // MESSAGE_READY -> ACCEPTED
46 // When PerformExternalAction() is called:
47 // WAITING_EXTERNAL -> MESSAGE_READY
48 // WAITING_EXTERNAL -> ACCEPTED
49 // WAITING_EXTERNAL -> REJECTED
44 enum State { 50 enum State {
45 // Waiting for the next message from the peer. 51 // Waiting for the next message from the peer.
46 WAITING_MESSAGE, 52 WAITING_MESSAGE,
47 53
48 // Next message is ready to be sent to the peer. 54 // Next message is ready to be sent to the peer.
49 MESSAGE_READY, 55 MESSAGE_READY,
50 56
51 // Session is authenticated successufully. 57 // Session is authenticated successufully.
52 ACCEPTED, 58 ACCEPTED,
53 59
54 // Session is rejected. 60 // Session is rejected.
55 REJECTED, 61 REJECTED,
62
63 // Waiting for PerformExternalAction to be called, or its action to finish.
64 WAITING_EXTERNAL,
56 }; 65 };
57 66
58 enum RejectionReason { 67 enum RejectionReason {
59 INVALID_CREDENTIALS, 68 INVALID_CREDENTIALS,
60 PROTOCOL_ERROR, 69 PROTOCOL_ERROR,
61 }; 70 };
62 71
63 // Returns true if |message| is an Authenticator message. 72 // Returns true if |message| is an Authenticator message.
64 static bool IsAuthenticatorMessage(const buzz::XmlElement* message); 73 static bool IsAuthenticatorMessage(const buzz::XmlElement* message);
65 74
(...skipping 16 matching lines...) Expand all
82 91
83 // Called in response to incoming message received from the peer. 92 // Called in response to incoming message received from the peer.
84 // Should only be called when in WAITING_MESSAGE state. Caller 93 // Should only be called when in WAITING_MESSAGE state. Caller
85 // retains ownership of |message|. 94 // retains ownership of |message|.
86 virtual void ProcessMessage(const buzz::XmlElement* message) = 0; 95 virtual void ProcessMessage(const buzz::XmlElement* message) = 0;
87 96
88 // Must be called when in MESSAGE_READY state. Returns next 97 // Must be called when in MESSAGE_READY state. Returns next
89 // authentication message that needs to be sent to the peer. 98 // authentication message that needs to be sent to the peer.
90 virtual scoped_ptr<buzz::XmlElement> GetNextMessage() = 0; 99 virtual scoped_ptr<buzz::XmlElement> GetNextMessage() = 0;
91 100
101 // Must be called when in WAITING_EXTERNAL state. Performs the external action
102 // (e.g. user prompt, network request), and calls |resume_callback| when done.
103 virtual void PerformExternalAction(const base::Closure& resume_callback);
Wez 2013/02/27 07:05:30 nit: We don't provide a no-message default impl fo
rmsousa 2013/03/05 03:30:24 Done in another CL.
104
92 // Creates new authenticator for a channel. Can be called only in 105 // Creates new authenticator for a channel. Can be called only in
93 // the ACCEPTED state. 106 // the ACCEPTED state.
94 virtual scoped_ptr<ChannelAuthenticator> 107 virtual scoped_ptr<ChannelAuthenticator>
95 CreateChannelAuthenticator() const = 0; 108 CreateChannelAuthenticator() const = 0;
96 }; 109 };
97 110
98 // Factory for Authenticator instances. 111 // Factory for Authenticator instances.
99 class AuthenticatorFactory { 112 class AuthenticatorFactory {
100 public: 113 public:
101 AuthenticatorFactory() {} 114 AuthenticatorFactory() {}
(...skipping 10 matching lines...) Expand all
112 virtual scoped_ptr<Authenticator> CreateAuthenticator( 125 virtual scoped_ptr<Authenticator> CreateAuthenticator(
113 const std::string& local_jid, 126 const std::string& local_jid,
114 const std::string& remote_jid, 127 const std::string& remote_jid,
115 const buzz::XmlElement* first_message) = 0; 128 const buzz::XmlElement* first_message) = 0;
116 }; 129 };
117 130
118 } // namespace protocol 131 } // namespace protocol
119 } // namespace remoting 132 } // namespace remoting
120 133
121 #endif // REMOTING_PROTOCOL_AUTHENTICATOR_H_ 134 #endif // REMOTING_PROTOCOL_AUTHENTICATOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698