| OLD | NEW |
| 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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 // The authenticator is a cross-platform class that handles authentication for | 5 // The authenticator is a cross-platform class that handles authentication for |
| 6 // the sync client. | 6 // the sync client. |
| 7 // | 7 // |
| 8 // Current State: | 8 // Current State: |
| 9 // The authenticator is currently only used to authenticate tokens using the | 9 // The authenticator is currently only used to authenticate tokens using the |
| 10 // newer protocol buffer request. | 10 // newer protocol buffer request. |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 Authenticator(ServerConnectionManager* manager, UserSettings* settings); | 62 Authenticator(ServerConnectionManager* manager, UserSettings* settings); |
| 63 | 63 |
| 64 // Constructor for a simple authenticator used for programmatic login from | 64 // Constructor for a simple authenticator used for programmatic login from |
| 65 // test programs. | 65 // test programs. |
| 66 explicit Authenticator(ServerConnectionManager* manager); | 66 explicit Authenticator(ServerConnectionManager* manager); |
| 67 | 67 |
| 68 // This version of Authenticate tries to use saved credentials, if we have | 68 // This version of Authenticate tries to use saved credentials, if we have |
| 69 // any. | 69 // any. |
| 70 AuthenticationResult Authenticate(); | 70 AuthenticationResult Authenticate(); |
| 71 | 71 |
| 72 // If save_credentials is set we save the long-lived auth token to local disk. | 72 // We save the username and password in memory (if given) so we |
| 73 // In all cases we save the username and password in memory (if given) so we | |
| 74 // can refresh the long-lived auth token if it expires. | 73 // can refresh the long-lived auth token if it expires. |
| 75 // Also we save a 10-bit hash of the password to allow offline login. | 74 // Also we save a 10-bit hash of the password to allow offline login. |
| 76 // TODO(sync): Make it work as described. | 75 AuthenticationResult Authenticate(std::string username, std::string password); |
| 77 // TODO(sync): Arguments for desired domain. | 76 |
| 78 AuthenticationResult Authenticate(std::string username, std::string password, | |
| 79 bool save_credentials); | |
| 80 // A version of the auth token to authenticate cookie portion of | 77 // A version of the auth token to authenticate cookie portion of |
| 81 // authentication. It uses the new proto buffer based call instead of the HTTP | 78 // authentication. It uses the new proto buffer based call instead of the HTTP |
| 82 // GET based one we currently use. | 79 // GET based one we currently use. |
| 83 // Can return one of SUCCESS, SERVICE_DOWN, CORRUPT_SERVER_RESPONSE, | 80 // Can return one of SUCCESS, SERVICE_DOWN, CORRUPT_SERVER_RESPONSE, |
| 84 // USER_NOT_ACTIVATED or BAD_AUTH_TOKEN. See above for the meaning of these | 81 // USER_NOT_ACTIVATED or BAD_AUTH_TOKEN. See above for the meaning of these |
| 85 // values. | 82 // values. |
| 86 // TODO(sync): Make this function private when we're done. | 83 // TODO(sync): Make this function private when we're done. |
| 87 AuthenticationResult AuthenticateToken(std::string auth_token); | 84 AuthenticationResult AuthenticateToken(std::string auth_token); |
| 88 | 85 |
| 89 const char* display_email() const { return display_email_.c_str(); } | 86 const char* display_email() const { return display_email_.c_str(); } |
| 90 const char* display_name() const { return display_name_.c_str(); } | 87 const char* display_name() const { return display_name_.c_str(); } |
| 91 private: | 88 private: |
| 92 // Stores the information in the UserIdentification returned from the server. | 89 // Stores the information in the UserIdentification returned from the server. |
| 93 AuthenticationResult HandleSuccessfulTokenRequest( | 90 AuthenticationResult HandleSuccessfulTokenRequest( |
| 94 const sync_pb::UserIdentification* user); | 91 const sync_pb::UserIdentification* user); |
| 95 // The server connection manager that we're looking after. | 92 // The server connection manager that we're looking after. |
| 96 ServerConnectionManager* server_connection_manager_; | 93 ServerConnectionManager* server_connection_manager_; |
| 97 // Returns SUCCESS or the value that should be returned to the user. | 94 // Returns SUCCESS or the value that should be returned to the user. |
| 98 std::string display_email_; | 95 std::string display_email_; |
| 99 std::string display_name_; | 96 std::string display_name_; |
| 100 std::string obfuscated_id_; | 97 std::string obfuscated_id_; |
| 101 UserSettings* const settings_; | 98 UserSettings* const settings_; |
| 102 DISALLOW_COPY_AND_ASSIGN(Authenticator); | 99 DISALLOW_COPY_AND_ASSIGN(Authenticator); |
| 103 }; | 100 }; |
| 104 | 101 |
| 105 } // namespace browser_sync | 102 } // namespace browser_sync |
| 106 | 103 |
| 107 #endif // CHROME_BROWSER_SYNC_ENGINE_AUTHENTICATOR_H_ | 104 #endif // CHROME_BROWSER_SYNC_ENGINE_AUTHENTICATOR_H_ |
| OLD | NEW |