| OLD | NEW |
| 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 <memory> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 // When GetNextMessage() is called: | 46 // When GetNextMessage() is called: |
| 47 // MESSAGE_READY -> WAITING_MESSAGE | 47 // MESSAGE_READY -> WAITING_MESSAGE |
| 48 // MESSAGE_READY -> ACCEPTED | 48 // MESSAGE_READY -> ACCEPTED |
| 49 enum State { | 49 enum State { |
| 50 // Waiting for the next message from the peer. | 50 // Waiting for the next message from the peer. |
| 51 WAITING_MESSAGE, | 51 WAITING_MESSAGE, |
| 52 | 52 |
| 53 // Next message is ready to be sent to the peer. | 53 // Next message is ready to be sent to the peer. |
| 54 MESSAGE_READY, | 54 MESSAGE_READY, |
| 55 | 55 |
| 56 // Session is authenticated successufully. | 56 // Session is authenticated successfully. |
| 57 ACCEPTED, | 57 ACCEPTED, |
| 58 | 58 |
| 59 // Session is rejected. | 59 // Session is rejected. |
| 60 REJECTED, | 60 REJECTED, |
| 61 | 61 |
| 62 // Asynchronously processing the last message from the peer. | 62 // Asynchronously processing the last message from the peer. |
| 63 PROCESSING_MESSAGE, | 63 PROCESSING_MESSAGE, |
| 64 }; | 64 }; |
| 65 | 65 |
| 66 enum RejectionReason { | 66 enum RejectionReason { |
| 67 // The account credentials were not valid (i.e. incorrect PIN). |
| 67 INVALID_CREDENTIALS, | 68 INVALID_CREDENTIALS, |
| 69 |
| 70 // The client JID was not valid (i.e. violated a policy or was malformed). |
| 68 INVALID_ACCOUNT, | 71 INVALID_ACCOUNT, |
| 72 |
| 73 // Generic error used when something goes wrong establishing a session. |
| 69 PROTOCOL_ERROR, | 74 PROTOCOL_ERROR, |
| 75 |
| 76 // Session was rejected by the user (i.e. via the confirmation dialog). |
| 70 REJECTED_BY_USER, | 77 REJECTED_BY_USER, |
| 78 |
| 79 // Multiple, valid connection requests were received for the same session. |
| 80 TOO_MANY_CONNECTIONS, |
| 71 }; | 81 }; |
| 72 | 82 |
| 73 // Callback used for layered Authenticator implementations, particularly | 83 // Callback used for layered Authenticator implementations, particularly |
| 74 // third-party and pairing authenticators. They use this callback to create | 84 // third-party and pairing authenticators. They use this callback to create |
| 75 // base SPAKE2 authenticators. | 85 // base SPAKE2 authenticators. |
| 76 typedef base::Callback<std::unique_ptr<Authenticator>( | 86 typedef base::Callback<std::unique_ptr<Authenticator>( |
| 77 const std::string& shared_secret, | 87 const std::string& shared_secret, |
| 78 Authenticator::State initial_state)> | 88 Authenticator::State initial_state)> |
| 79 CreateBaseAuthenticatorCallback; | 89 CreateBaseAuthenticatorCallback; |
| 80 | 90 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 // Factory for Authenticator instances. | 137 // Factory for Authenticator instances. |
| 128 class AuthenticatorFactory { | 138 class AuthenticatorFactory { |
| 129 public: | 139 public: |
| 130 AuthenticatorFactory() {} | 140 AuthenticatorFactory() {} |
| 131 virtual ~AuthenticatorFactory() {} | 141 virtual ~AuthenticatorFactory() {} |
| 132 | 142 |
| 133 // Called when session-initiate stanza is received to create | 143 // Called when session-initiate stanza is received to create |
| 134 // authenticator for the new session. |first_message| specifies | 144 // authenticator for the new session. |first_message| specifies |
| 135 // authentication part of the session-initiate stanza so that | 145 // authentication part of the session-initiate stanza so that |
| 136 // appropriate type of Authenticator can be chosen for the session | 146 // appropriate type of Authenticator can be chosen for the session |
| 137 // (useful when multiple authenticators is supported). Returns nullptr | 147 // (useful when multiple authenticators are supported). Returns nullptr |
| 138 // if the |first_message| is invalid and the session should be | 148 // if the |first_message| is invalid and the session should be |
| 139 // rejected. ProcessMessage() should be called with |first_message| | 149 // rejected. ProcessMessage() should be called with |first_message| |
| 140 // for the result of this method. | 150 // for the result of this method. |
| 141 virtual std::unique_ptr<Authenticator> CreateAuthenticator( | 151 virtual std::unique_ptr<Authenticator> CreateAuthenticator( |
| 142 const std::string& local_jid, | 152 const std::string& local_jid, |
| 143 const std::string& remote_jid) = 0; | 153 const std::string& remote_jid) = 0; |
| 144 }; | 154 }; |
| 145 | 155 |
| 146 } // namespace protocol | 156 } // namespace protocol |
| 147 } // namespace remoting | 157 } // namespace remoting |
| 148 | 158 |
| 149 #endif // REMOTING_PROTOCOL_AUTHENTICATOR_H_ | 159 #endif // REMOTING_PROTOCOL_AUTHENTICATOR_H_ |
| OLD | NEW |