OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 CHROMEOS_LOGIN_AUTH_CRYPTOHOME_AUTHENTICATOR_H_ | 5 #ifndef CHROMEOS_LOGIN_AUTH_CRYPTOHOME_AUTHENTICATOR_H_ |
6 #define CHROMEOS_LOGIN_AUTH_CRYPTOHOME_AUTHENTICATOR_H_ | 6 #define CHROMEOS_LOGIN_AUTH_CRYPTOHOME_AUTHENTICATOR_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
11 #include "base/gtest_prod_util.h" | 11 #include "base/gtest_prod_util.h" |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "base/synchronization/lock.h" | 14 #include "base/synchronization/lock.h" |
15 #include "base/task_runner.h" | 15 #include "base/task_runner.h" |
16 #include "chromeos/chromeos_export.h" | 16 #include "chromeos/chromeos_export.h" |
17 #include "chromeos/login/auth/auth_attempt_state.h" | 17 #include "chromeos/login/auth/auth_attempt_state.h" |
18 #include "chromeos/login/auth/auth_attempt_state_resolver.h" | 18 #include "chromeos/login/auth/auth_attempt_state_resolver.h" |
19 #include "chromeos/login/auth/authenticator.h" | 19 #include "chromeos/login/auth/authenticator.h" |
20 #include "chromeos/login/auth/test_attempt_state.h" | 20 #include "chromeos/login/auth/test_attempt_state.h" |
21 #include "google_apis/gaia/gaia_auth_consumer.h" | 21 #include "google_apis/gaia/gaia_auth_consumer.h" |
22 | 22 |
23 class AuthFailure; | 23 class AuthFailure; |
24 | 24 class Profile; |
25 namespace content { | |
26 class BrowserContext; | |
27 } | |
28 | 25 |
29 namespace chromeos { | 26 namespace chromeos { |
30 | 27 |
31 class AuthStatusConsumer; | 28 class AuthStatusConsumer; |
32 | 29 |
33 // Authenticates a Chromium OS user against cryptohome. | 30 // Authenticates a Chromium OS user against cryptohome. |
34 // Relies on the fact that online authentications has been already performed | 31 // Relies on the fact that online authentications has been already performed |
35 // (i.e. using_oauth_ is true). | 32 // (i.e. using_oauth_ is true). |
36 // | 33 // |
37 // At a high, level, here's what happens: | 34 // At a high, level, here's what happens: |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 FAILED_USERNAME_HASH = 22, // Failed GetSanitizedUsername request. | 86 FAILED_USERNAME_HASH = 22, // Failed GetSanitizedUsername request. |
90 KIOSK_ACCOUNT_LOGIN = 23, // Logged into a kiosk account. | 87 KIOSK_ACCOUNT_LOGIN = 23, // Logged into a kiosk account. |
91 REMOVED_DATA_AFTER_FAILURE = 24, // Successfully removed the user's | 88 REMOVED_DATA_AFTER_FAILURE = 24, // Successfully removed the user's |
92 // cryptohome after a login failure. | 89 // cryptohome after a login failure. |
93 }; | 90 }; |
94 | 91 |
95 CryptohomeAuthenticator(scoped_refptr<base::TaskRunner> task_runner, | 92 CryptohomeAuthenticator(scoped_refptr<base::TaskRunner> task_runner, |
96 AuthStatusConsumer* consumer); | 93 AuthStatusConsumer* consumer); |
97 | 94 |
98 // Authenticator overrides. | 95 // Authenticator overrides. |
99 virtual void CompleteLogin(content::BrowserContext* context, | 96 virtual void CompleteLogin(Profile* profile, |
100 const UserContext& user_context) override; | 97 const UserContext& user_context) override; |
101 | 98 |
102 // Given |user_context|, this method attempts to authenticate to your | 99 // Given |user_context|, this method attempts to authenticate to your |
103 // Chrome OS device. As soon as we have successfully mounted the encrypted | 100 // Chrome OS device. As soon as we have successfully mounted the encrypted |
104 // home directory for the user, we will call consumer_->OnAuthSuccess() | 101 // home directory for the user, we will call consumer_->OnAuthSuccess() |
105 // with the username. | 102 // with the username. |
106 // Upon failure to login consumer_->OnAuthFailure() is called | 103 // Upon failure to login consumer_->OnAuthFailure() is called |
107 // with an error message. | 104 // with an error message. |
108 // | 105 // |
109 // Uses |context| when doing URL fetches. | 106 // Uses |profile| when doing URL fetches. |
110 virtual void AuthenticateToLogin(content::BrowserContext* context, | 107 virtual void AuthenticateToLogin(Profile* profile, |
111 const UserContext& user_context) override; | 108 const UserContext& user_context) override; |
112 | 109 |
113 // Given |user_context|, this method attempts to authenticate to the cached | 110 // Given |user_context|, this method attempts to authenticate to the cached |
114 // user_context. This will never contact the server even if it's online. | 111 // user_context. This will never contact the server even if it's online. |
115 // The auth result is sent to AuthStatusConsumer in a same way as | 112 // The auth result is sent to AuthStatusConsumer in a same way as |
116 // AuthenticateToLogin does. | 113 // AuthenticateToLogin does. |
117 virtual void AuthenticateToUnlock(const UserContext& user_context) override; | 114 virtual void AuthenticateToUnlock(const UserContext& user_context) override; |
118 | 115 |
119 // Initiates supervised user login. | 116 // Initiates supervised user login. |
120 // Creates cryptohome if missing or mounts existing one and | 117 // Creates cryptohome if missing or mounts existing one and |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 // When |remove_user_data_on_failure_| is set, we delay calling | 260 // When |remove_user_data_on_failure_| is set, we delay calling |
264 // consumer_->OnAuthFailure() until we removed the user cryptohome. | 261 // consumer_->OnAuthFailure() until we removed the user cryptohome. |
265 const AuthFailure* delayed_login_failure_; | 262 const AuthFailure* delayed_login_failure_; |
266 | 263 |
267 DISALLOW_COPY_AND_ASSIGN(CryptohomeAuthenticator); | 264 DISALLOW_COPY_AND_ASSIGN(CryptohomeAuthenticator); |
268 }; | 265 }; |
269 | 266 |
270 } // namespace chromeos | 267 } // namespace chromeos |
271 | 268 |
272 #endif // CHROMEOS_LOGIN_AUTH_CRYPTOHOME_AUTHENTICATOR_H_ | 269 #endif // CHROMEOS_LOGIN_AUTH_CRYPTOHOME_AUTHENTICATOR_H_ |
OLD | NEW |