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" |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 FAILED_USERNAME_HASH = 21, // Failed GetSanitizedUsername request. | 88 FAILED_USERNAME_HASH = 21, // Failed GetSanitizedUsername request. |
89 KIOSK_ACCOUNT_LOGIN = 22, // Logged into a kiosk account. | 89 KIOSK_ACCOUNT_LOGIN = 22, // Logged into a kiosk account. |
90 REMOVED_DATA_AFTER_FAILURE = 23, // Successfully removed the user's | 90 REMOVED_DATA_AFTER_FAILURE = 23, // Successfully removed the user's |
91 // cryptohome after a login failure. | 91 // cryptohome after a login failure. |
92 }; | 92 }; |
93 | 93 |
94 CryptohomeAuthenticator(scoped_refptr<base::TaskRunner> task_runner, | 94 CryptohomeAuthenticator(scoped_refptr<base::TaskRunner> task_runner, |
95 AuthStatusConsumer* consumer); | 95 AuthStatusConsumer* consumer); |
96 | 96 |
97 // Authenticator overrides. | 97 // Authenticator overrides. |
98 virtual void CompleteLogin(content::BrowserContext* context, | 98 void CompleteLogin(content::BrowserContext* context, |
99 const UserContext& user_context) override; | 99 const UserContext& user_context) override; |
100 | 100 |
101 // Given |user_context|, this method attempts to authenticate to your | 101 // Given |user_context|, this method attempts to authenticate to your |
102 // Chrome OS device. As soon as we have successfully mounted the encrypted | 102 // Chrome OS device. As soon as we have successfully mounted the encrypted |
103 // home directory for the user, we will call consumer_->OnAuthSuccess() | 103 // home directory for the user, we will call consumer_->OnAuthSuccess() |
104 // with the username. | 104 // with the username. |
105 // Upon failure to login consumer_->OnAuthFailure() is called | 105 // Upon failure to login consumer_->OnAuthFailure() is called |
106 // with an error message. | 106 // with an error message. |
107 // | 107 // |
108 // Uses |context| when doing URL fetches. | 108 // Uses |context| when doing URL fetches. |
109 virtual void AuthenticateToLogin(content::BrowserContext* context, | 109 void AuthenticateToLogin(content::BrowserContext* context, |
110 const UserContext& user_context) override; | 110 const UserContext& user_context) override; |
111 | 111 |
112 // Given |user_context|, this method attempts to authenticate to the cached | 112 // Given |user_context|, this method attempts to authenticate to the cached |
113 // user_context. This will never contact the server even if it's online. | 113 // user_context. This will never contact the server even if it's online. |
114 // The auth result is sent to AuthStatusConsumer in a same way as | 114 // The auth result is sent to AuthStatusConsumer in a same way as |
115 // AuthenticateToLogin does. | 115 // AuthenticateToLogin does. |
116 virtual void AuthenticateToUnlock(const UserContext& user_context) override; | 116 void AuthenticateToUnlock(const UserContext& user_context) override; |
117 | 117 |
118 // Initiates supervised user login. | 118 // Initiates supervised user login. |
119 // Creates cryptohome if missing or mounts existing one and | 119 // Creates cryptohome if missing or mounts existing one and |
120 // notifies consumer on the success/failure. | 120 // notifies consumer on the success/failure. |
121 virtual void LoginAsSupervisedUser(const UserContext& user_context) override; | 121 void LoginAsSupervisedUser(const UserContext& user_context) override; |
122 | 122 |
123 // Initiates incognito ("browse without signing in") login. | 123 // Initiates incognito ("browse without signing in") login. |
124 // Mounts tmpfs and notifies consumer on the success/failure. | 124 // Mounts tmpfs and notifies consumer on the success/failure. |
125 virtual void LoginOffTheRecord() override; | 125 void LoginOffTheRecord() override; |
126 | 126 |
127 // Initiates login into a public session. | 127 // Initiates login into a public session. |
128 // Mounts an ephemeral cryptohome and notifies consumer on the | 128 // Mounts an ephemeral cryptohome and notifies consumer on the |
129 // success/failure. | 129 // success/failure. |
130 virtual void LoginAsPublicSession(const UserContext& user_context) override; | 130 void LoginAsPublicSession(const UserContext& user_context) override; |
131 | 131 |
132 // Initiates login into the kiosk mode account identified by |app_user_id|. | 132 // Initiates login into the kiosk mode account identified by |app_user_id|. |
133 // Mounts an ephemeral guest cryptohome if |use_guest_mount| is |true|. | 133 // Mounts an ephemeral guest cryptohome if |use_guest_mount| is |true|. |
134 // Otherwise, mounts a public cryptohome, which will be ephemeral if the | 134 // Otherwise, mounts a public cryptohome, which will be ephemeral if the |
135 // |DeviceEphemeralUsersEnabled| policy is enabled and non-ephemeral | 135 // |DeviceEphemeralUsersEnabled| policy is enabled and non-ephemeral |
136 // otherwise. | 136 // otherwise. |
137 virtual void LoginAsKioskAccount(const std::string& app_user_id, | 137 void LoginAsKioskAccount(const std::string& app_user_id, |
138 bool use_guest_mount) override; | 138 bool use_guest_mount) override; |
139 | 139 |
140 // These methods must be called on the UI thread, as they make DBus calls | 140 // These methods must be called on the UI thread, as they make DBus calls |
141 // and also call back to the login UI. | 141 // and also call back to the login UI. |
142 virtual void OnAuthSuccess() override; | 142 void OnAuthSuccess() override; |
143 virtual void OnAuthFailure(const AuthFailure& error) override; | 143 void OnAuthFailure(const AuthFailure& error) override; |
144 virtual void RecoverEncryptedData(const std::string& old_password) override; | 144 void RecoverEncryptedData(const std::string& old_password) override; |
145 virtual void ResyncEncryptedData() override; | 145 void ResyncEncryptedData() override; |
146 | 146 |
147 // AuthAttemptStateResolver overrides. | 147 // AuthAttemptStateResolver overrides. |
148 // Attempts to make a decision and call back |consumer_| based on | 148 // Attempts to make a decision and call back |consumer_| based on |
149 // the state we have gathered at the time of call. If a decision | 149 // the state we have gathered at the time of call. If a decision |
150 // can't be made, defers until the next time this is called. | 150 // can't be made, defers until the next time this is called. |
151 // When a decision is made, will call back to |consumer_| on the UI thread. | 151 // When a decision is made, will call back to |consumer_| on the UI thread. |
152 // | 152 // |
153 // Must be called on the UI thread. | 153 // Must be called on the UI thread. |
154 virtual void Resolve() override; | 154 void Resolve() override; |
155 | 155 |
156 void OnOffTheRecordAuthSuccess(); | 156 void OnOffTheRecordAuthSuccess(); |
157 void OnPasswordChangeDetected(); | 157 void OnPasswordChangeDetected(); |
158 | 158 |
159 protected: | 159 protected: |
160 virtual ~CryptohomeAuthenticator(); | 160 ~CryptohomeAuthenticator() override; |
161 | 161 |
162 typedef base::Callback<void(bool is_owner)> IsOwnerCallback; | 162 typedef base::Callback<void(bool is_owner)> IsOwnerCallback; |
163 | 163 |
164 // Method to be implemented in child. Return |true| if user specified in | 164 // Method to be implemented in child. Return |true| if user specified in |
165 // |context| exists on device. | 165 // |context| exists on device. |
166 virtual bool IsKnownUser(const UserContext& context) = 0; | 166 virtual bool IsKnownUser(const UserContext& context) = 0; |
167 | 167 |
168 // Method to be implemented in child. Return |true| if device is running | 168 // Method to be implemented in child. Return |true| if device is running |
169 // in safe mode. | 169 // in safe mode. |
170 virtual bool IsSafeMode() = 0; | 170 virtual bool IsSafeMode() = 0; |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 // When |remove_user_data_on_failure_| is set, we delay calling | 257 // When |remove_user_data_on_failure_| is set, we delay calling |
258 // consumer_->OnAuthFailure() until we removed the user cryptohome. | 258 // consumer_->OnAuthFailure() until we removed the user cryptohome. |
259 const AuthFailure* delayed_login_failure_; | 259 const AuthFailure* delayed_login_failure_; |
260 | 260 |
261 DISALLOW_COPY_AND_ASSIGN(CryptohomeAuthenticator); | 261 DISALLOW_COPY_AND_ASSIGN(CryptohomeAuthenticator); |
262 }; | 262 }; |
263 | 263 |
264 } // namespace chromeos | 264 } // namespace chromeos |
265 | 265 |
266 #endif // CHROMEOS_LOGIN_AUTH_CRYPTOHOME_AUTHENTICATOR_H_ | 266 #endif // CHROMEOS_LOGIN_AUTH_CRYPTOHOME_AUTHENTICATOR_H_ |
OLD | NEW |