OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_PARALLEL_AUTHENTICATOR_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_PARALLEL_AUTHENTICATOR_H_ |
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_PARALLEL_AUTHENTICATOR_H_ | 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_PARALLEL_AUTHENTICATOR_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 14 matching lines...) Expand all Loading... |
25 #include "chrome/common/net/gaia/gaia_auth_consumer.h" | 25 #include "chrome/common/net/gaia/gaia_auth_consumer.h" |
26 | 26 |
27 class GaiaAuthFetcher; | 27 class GaiaAuthFetcher; |
28 class LoginFailure; | 28 class LoginFailure; |
29 class Profile; | 29 class Profile; |
30 | 30 |
31 namespace base { | 31 namespace base { |
32 class Lock; | 32 class Lock; |
33 } | 33 } |
34 | 34 |
| 35 namespace crypto { |
| 36 class SymmetricKey; |
| 37 } |
| 38 |
35 namespace chromeos { | 39 namespace chromeos { |
36 | 40 |
37 class LoginStatusConsumer; | 41 class LoginStatusConsumer; |
38 class ParallelAuthenticator; | 42 class ParallelAuthenticator; |
39 class ResolveChecker; | 43 class ResolveChecker; |
40 | 44 |
41 // Authenticates a Chromium OS user against the Google Accounts ClientLogin API. | 45 // Authenticates a Chromium OS user against the Google Accounts ClientLogin API. |
42 // | 46 // |
43 // Simultaneously attempts authentication both offline and online, failing over | 47 // Simultaneously attempts authentication both offline and online, failing over |
44 // to the "localaccount" in the event that authentication fails. | 48 // to the "localaccount" in the event that authentication fails. |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 const GaiaAuthConsumer::ClientLoginResult& credentials) OVERRIDE; | 146 const GaiaAuthConsumer::ClientLoginResult& credentials) OVERRIDE; |
143 virtual void RetryAuth(Profile* profile, | 147 virtual void RetryAuth(Profile* profile, |
144 const std::string& username, | 148 const std::string& username, |
145 const std::string& password, | 149 const std::string& password, |
146 const std::string& login_token, | 150 const std::string& login_token, |
147 const std::string& login_captcha) OVERRIDE; | 151 const std::string& login_captcha) OVERRIDE; |
148 virtual void VerifyOAuth1AccessToken(const std::string& oauth1_access_token, | 152 virtual void VerifyOAuth1AccessToken(const std::string& oauth1_access_token, |
149 const std::string& oauth1_secret) OVERRIDE; | 153 const std::string& oauth1_secret) OVERRIDE; |
150 virtual std::string EncryptToken(const std::string& token) OVERRIDE; | 154 virtual std::string EncryptToken(const std::string& token) OVERRIDE; |
151 virtual std::string DecryptToken(const std::string& encrypted_token) OVERRIDE; | 155 virtual std::string DecryptToken(const std::string& encrypted_token) OVERRIDE; |
| 156 virtual std::string DecryptLegacyToken( |
| 157 const std::string& encrypted_token) OVERRIDE; |
152 | 158 |
153 // AuthAttemptStateResolver overrides. | 159 // AuthAttemptStateResolver overrides. |
154 // Attempts to make a decision and call back |consumer_| based on | 160 // Attempts to make a decision and call back |consumer_| based on |
155 // the state we have gathered at the time of call. If a decision | 161 // the state we have gathered at the time of call. If a decision |
156 // can't be made, defers until the next time this is called. | 162 // can't be made, defers until the next time this is called. |
157 // When a decision is made, will call back to |consumer_| on the UI thread. | 163 // When a decision is made, will call back to |consumer_| on the UI thread. |
158 // | 164 // |
159 // Must be called on the IO thread. | 165 // Must be called on the IO thread. |
160 virtual void Resolve() OVERRIDE; | 166 virtual void Resolve() OVERRIDE; |
161 | 167 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 current_online_ = attempt; | 219 current_online_ = attempt; |
214 } | 220 } |
215 | 221 |
216 // Resets |current_state_| and then posts a task to the UI thread to | 222 // Resets |current_state_| and then posts a task to the UI thread to |
217 // Initiate() |to_initiate|. | 223 // Initiate() |to_initiate|. |
218 // Call this method on the IO thread. | 224 // Call this method on the IO thread. |
219 void ResyncRecoverHelper(CryptohomeOp* to_initiate); | 225 void ResyncRecoverHelper(CryptohomeOp* to_initiate); |
220 | 226 |
221 // If we don't have the system salt yet, loads it from the CryptohomeLibrary. | 227 // If we don't have the system salt yet, loads it from the CryptohomeLibrary. |
222 void LoadSystemSalt(); | 228 void LoadSystemSalt(); |
| 229 // If we don't have supplemental_user_key_ yet, loads it from the NSS DB. |
| 230 // Returns false if the key can not be loaded/created. |
| 231 bool LoadSupplementalUserKey(); |
223 | 232 |
224 // If we haven't already, looks in a file called |filename| next to | 233 // If we haven't already, looks in a file called |filename| next to |
225 // the browser executable for a "localaccount" name, and retrieves it | 234 // the browser executable for a "localaccount" name, and retrieves it |
226 // if one is present. If someone attempts to authenticate with this | 235 // if one is present. If someone attempts to authenticate with this |
227 // username, we will mount a tmpfs for them and let them use the | 236 // username, we will mount a tmpfs for them and let them use the |
228 // browser. | 237 // browser. |
229 // Should only be called on the FILE thread. | 238 // Should only be called on the FILE thread. |
230 void LoadLocalaccount(const std::string& filename); | 239 void LoadLocalaccount(const std::string& filename); |
231 | 240 |
232 void SetLocalaccount(const std::string& new_name); | 241 void SetLocalaccount(const std::string& new_name); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 scoped_ptr<AuthAttemptState> current_state_; | 277 scoped_ptr<AuthAttemptState> current_state_; |
269 scoped_refptr<OnlineAttempt> current_online_; | 278 scoped_refptr<OnlineAttempt> current_online_; |
270 scoped_refptr<CryptohomeOp> mounter_; | 279 scoped_refptr<CryptohomeOp> mounter_; |
271 scoped_refptr<CryptohomeOp> key_migrator_; | 280 scoped_refptr<CryptohomeOp> key_migrator_; |
272 scoped_refptr<CryptohomeOp> data_remover_; | 281 scoped_refptr<CryptohomeOp> data_remover_; |
273 scoped_refptr<CryptohomeOp> guest_mounter_; | 282 scoped_refptr<CryptohomeOp> guest_mounter_; |
274 scoped_refptr<CryptohomeOp> key_checker_; | 283 scoped_refptr<CryptohomeOp> key_checker_; |
275 | 284 |
276 std::string ascii_hash_; | 285 std::string ascii_hash_; |
277 chromeos::CryptohomeBlob system_salt_; | 286 chromeos::CryptohomeBlob system_salt_; |
| 287 scoped_ptr<crypto::SymmetricKey> supplemental_user_key_; |
278 | 288 |
279 // When the user has changed her password, but gives us the old one, we will | 289 // When the user has changed her password, but gives us the old one, we will |
280 // be able to mount her cryptohome, but online authentication will fail. | 290 // be able to mount her cryptohome, but online authentication will fail. |
281 // This allows us to present the same behavior to the caller, regardless | 291 // This allows us to present the same behavior to the caller, regardless |
282 // of the order in which we receive these results. | 292 // of the order in which we receive these results. |
283 bool already_reported_success_; | 293 bool already_reported_success_; |
284 base::Lock success_lock_; // A lock around already_reported_success_. | 294 base::Lock success_lock_; // A lock around already_reported_success_. |
285 | 295 |
286 // Status relating to the local "backdoor" account. | 296 // Status relating to the local "backdoor" account. |
287 std::string localaccount_; | 297 std::string localaccount_; |
288 bool checked_for_localaccount_; // Needed because empty localaccount_ is ok. | 298 bool checked_for_localaccount_; // Needed because empty localaccount_ is ok. |
289 base::Lock localaccount_lock_; // A lock around checked_for_localaccount_. | 299 base::Lock localaccount_lock_; // A lock around checked_for_localaccount_. |
290 | 300 |
291 // True if we use OAuth-based authentication flow. | 301 // True if we use OAuth-based authentication flow. |
292 bool using_oauth_; | 302 bool using_oauth_; |
293 | 303 |
294 friend class ResolveChecker; | 304 friend class ResolveChecker; |
295 friend class ParallelAuthenticatorTest; | 305 friend class ParallelAuthenticatorTest; |
296 FRIEND_TEST_ALL_PREFIXES(ParallelAuthenticatorTest, SaltToAscii); | 306 FRIEND_TEST_ALL_PREFIXES(ParallelAuthenticatorTest, SaltToAscii); |
297 FRIEND_TEST_ALL_PREFIXES(ParallelAuthenticatorTest, ReadLocalaccount); | 307 FRIEND_TEST_ALL_PREFIXES(ParallelAuthenticatorTest, ReadLocalaccount); |
298 FRIEND_TEST_ALL_PREFIXES(ParallelAuthenticatorTest, | 308 FRIEND_TEST_ALL_PREFIXES(ParallelAuthenticatorTest, |
299 ReadLocalaccountTrailingWS); | 309 ReadLocalaccountTrailingWS); |
300 FRIEND_TEST_ALL_PREFIXES(ParallelAuthenticatorTest, ReadNoLocalaccount); | 310 FRIEND_TEST_ALL_PREFIXES(ParallelAuthenticatorTest, ReadNoLocalaccount); |
301 DISALLOW_COPY_AND_ASSIGN(ParallelAuthenticator); | 311 DISALLOW_COPY_AND_ASSIGN(ParallelAuthenticator); |
302 }; | 312 }; |
303 | 313 |
304 } // namespace chromeos | 314 } // namespace chromeos |
305 | 315 |
306 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_PARALLEL_AUTHENTICATOR_H_ | 316 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_PARALLEL_AUTHENTICATOR_H_ |
OLD | NEW |