OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 CHROME_BROWSER_CHROMEOS_LOGIN_GOOGLE_AUTHENTICATOR_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_GOOGLE_AUTHENTICATOR_H_ |
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_GOOGLE_AUTHENTICATOR_H_ | 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_GOOGLE_AUTHENTICATOR_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 21 matching lines...) Expand all Loading... |
32 public: | 32 public: |
33 explicit GoogleAuthenticator(LoginStatusConsumer* consumer); | 33 explicit GoogleAuthenticator(LoginStatusConsumer* consumer); |
34 virtual ~GoogleAuthenticator(); | 34 virtual ~GoogleAuthenticator(); |
35 | 35 |
36 // Given a |username| and |password|, this method attempts to authenticate to | 36 // Given a |username| and |password|, this method attempts to authenticate to |
37 // the Google accounts servers. The ultimate result is either a callback to | 37 // the Google accounts servers. The ultimate result is either a callback to |
38 // consumer_->OnLoginSuccess() with the |username| and a vector of | 38 // consumer_->OnLoginSuccess() with the |username| and a vector of |
39 // authentication cookies or a callback to consumer_->OnLoginFailure() with | 39 // authentication cookies or a callback to consumer_->OnLoginFailure() with |
40 // an error message. Uses |profile| when doing URL fetches. | 40 // an error message. Uses |profile| when doing URL fetches. |
41 // Should be called on the FILE thread! | 41 // Should be called on the FILE thread! |
| 42 // Optionally could pass CAPTCHA challenge token - |login_token| and |
| 43 // |login_captcha| string that user has entered. |
42 // | 44 // |
43 // Returns true if the attempt gets sent successfully and false if not. | 45 // Returns true if the attempt gets sent successfully and false if not. |
44 bool AuthenticateToLogin(Profile* profile, | 46 bool AuthenticateToLogin(Profile* profile, |
45 const std::string& username, | 47 const std::string& username, |
46 const std::string& password); | 48 const std::string& password, |
| 49 const std::string& login_token, |
| 50 const std::string& login_captcha); |
47 | 51 |
48 // Given a |username| and |password|, this method attempts to | 52 // Given a |username| and |password|, this method attempts to |
49 // authenticate to the cached credentials. This will never contact | 53 // authenticate to the cached credentials. This will never contact |
50 // the server even if it's online. The auth result is sent to | 54 // the server even if it's online. The auth result is sent to |
51 // LoginStatusConsumer in a same way as AuthenticateToLogin does. | 55 // LoginStatusConsumer in a same way as AuthenticateToLogin does. |
52 bool AuthenticateToUnlock(const std::string& username, | 56 bool AuthenticateToUnlock(const std::string& username, |
53 const std::string& password); | 57 const std::string& password); |
54 | 58 |
55 // Initiates off the record ("browse without signing in") login. | 59 // Initiates off the record ("browse without signing in") login. |
56 // Mounts tmpfs and notifies consumer on the success/failure. | 60 // Mounts tmpfs and notifies consumer on the success/failure. |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 | 146 |
143 // Constants to use in the ClientLogin request POST body. | 147 // Constants to use in the ClientLogin request POST body. |
144 static const char kCookiePersistence[]; | 148 static const char kCookiePersistence[]; |
145 static const char kAccountType[]; | 149 static const char kAccountType[]; |
146 static const char kSource[]; | 150 static const char kSource[]; |
147 static const char kService[]; | 151 static const char kService[]; |
148 | 152 |
149 // The format of said POST body. | 153 // The format of said POST body. |
150 static const char kFormat[]; | 154 static const char kFormat[]; |
151 | 155 |
| 156 // The format of said POST body when CAPTCHA token & answer are specified. |
| 157 static const char kFormatCaptcha[]; |
| 158 |
152 // Magic string indicating that, while a second factor is still | 159 // Magic string indicating that, while a second factor is still |
153 // needed to complete authentication, the user provided the right password. | 160 // needed to complete authentication, the user provided the right password. |
154 static const char kSecondFactor[]; | 161 static const char kSecondFactor[]; |
155 | 162 |
156 // Chromium OS system salt stored here. | 163 // Chromium OS system salt stored here. |
157 static const char kSystemSalt[]; | 164 static const char kSystemSalt[]; |
158 // String that appears at the start of OpenSSL cipher text with embedded salt. | 165 // String that appears at the start of OpenSSL cipher text with embedded salt. |
159 static const char kOpenSSLMagic[]; | 166 static const char kOpenSSLMagic[]; |
160 | 167 |
161 // Name of a file, next to chrome, that contains a local account username. | 168 // Name of a file, next to chrome, that contains a local account username. |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 FRIEND_TEST_ALL_PREFIXES(GoogleAuthenticatorTest, LoginNetFailureTest); | 207 FRIEND_TEST_ALL_PREFIXES(GoogleAuthenticatorTest, LoginNetFailureTest); |
201 FRIEND_TEST_ALL_PREFIXES(GoogleAuthenticatorTest, LoginDeniedTest); | 208 FRIEND_TEST_ALL_PREFIXES(GoogleAuthenticatorTest, LoginDeniedTest); |
202 FRIEND_TEST_ALL_PREFIXES(GoogleAuthenticatorTest, TwoFactorLoginTest); | 209 FRIEND_TEST_ALL_PREFIXES(GoogleAuthenticatorTest, TwoFactorLoginTest); |
203 | 210 |
204 DISALLOW_COPY_AND_ASSIGN(GoogleAuthenticator); | 211 DISALLOW_COPY_AND_ASSIGN(GoogleAuthenticator); |
205 }; | 212 }; |
206 | 213 |
207 } // namespace chromeos | 214 } // namespace chromeos |
208 | 215 |
209 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_GOOGLE_AUTHENTICATOR_H_ | 216 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_GOOGLE_AUTHENTICATOR_H_ |
OLD | NEW |