OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 PUBLIC_ACCOUNT_LOGIN, // Logged into a public account. | 66 PUBLIC_ACCOUNT_LOGIN, // Logged into a public account. |
67 LOCALLY_MANAGED_USER_LOGIN, // Logged in as a locally managed user. | 67 LOCALLY_MANAGED_USER_LOGIN, // Logged in as a locally managed user. |
68 LOGIN_FAILED, // Login denied. | 68 LOGIN_FAILED, // Login denied. |
69 OWNER_REQUIRED // Login is restricted to the owner only. | 69 OWNER_REQUIRED // Login is restricted to the owner only. |
70 }; | 70 }; |
71 | 71 |
72 explicit ParallelAuthenticator(LoginStatusConsumer* consumer); | 72 explicit ParallelAuthenticator(LoginStatusConsumer* consumer); |
73 | 73 |
74 // Authenticator overrides. | 74 // Authenticator overrides. |
75 virtual void CompleteLogin(Profile* profile, | 75 virtual void CompleteLogin(Profile* profile, |
76 const std::string& username, | 76 const UserCredentials& credentials) OVERRIDE; |
77 const std::string& password) OVERRIDE; | |
78 | 77 |
79 // Given a |username| and |password|, this method attempts to authenticate to | 78 // Given a |username| and |password|, this method attempts to authenticate to |
80 // the Google accounts servers and your Chrome OS device simultaneously. | 79 // the Google accounts servers and your Chrome OS device simultaneously. |
81 // As soon as we have successfully mounted the encrypted home directory for | 80 // As soon as we have successfully mounted the encrypted home directory for |
82 // |username|, we will call consumer_->OnLoginSuccess() with |username| and a | 81 // |username|, we will call consumer_->OnLoginSuccess() with |username| and a |
83 // vector of authentication cookies. If we're still waiting for an online | 82 // vector of authentication cookies. If we're still waiting for an online |
84 // result at that time, we'll also pass back a flag indicating that more | 83 // result at that time, we'll also pass back a flag indicating that more |
85 // callbacks are on the way; if not, we pass back false. When the pending | 84 // callbacks are on the way; if not, we pass back false. When the pending |
86 // request completes, either consumer_->OnLoginSuccess() with an indication | 85 // request completes, either consumer_->OnLoginSuccess() with an indication |
87 // that no more requests are outstanding will be called, or | 86 // that no more requests are outstanding will be called, or |
88 // consumer_->OnLoginFailure() if appropriate. | 87 // consumer_->OnLoginFailure() if appropriate. |
89 // | 88 // |
90 // Upon failure to login (online fails, then offline fails; | 89 // Upon failure to login (online fails, then offline fails; |
91 // offline fails, then online fails) consumer_->OnLoginFailure() is called | 90 // offline fails, then online fails) consumer_->OnLoginFailure() is called |
92 // with an error message. | 91 // with an error message. |
93 // | 92 // |
94 // In the event that we see an online success and then an offline failure, | 93 // In the event that we see an online success and then an offline failure, |
95 // consumer_->OnPasswordChangeDetected() is called. | 94 // consumer_->OnPasswordChangeDetected() is called. |
96 // | 95 // |
97 // Uses |profile| when doing URL fetches. | 96 // Uses |profile| when doing URL fetches. |
98 // Optionally could pass CAPTCHA challenge token - |login_token| and | 97 // Optionally could pass CAPTCHA challenge token - |login_token| and |
99 // |login_captcha| string that user has entered. | 98 // |login_captcha| string that user has entered. |
100 // | 99 // |
101 // NOTE: We do not allow HOSTED accounts to log in. In the event that | 100 // NOTE: We do not allow HOSTED accounts to log in. In the event that |
102 // we are asked to authenticate valid HOSTED account creds, we will | 101 // we are asked to authenticate valid HOSTED account creds, we will |
103 // call OnLoginFailure() with HOSTED_NOT_ALLOWED. | 102 // call OnLoginFailure() with HOSTED_NOT_ALLOWED. |
104 virtual void AuthenticateToLogin(Profile* profile, | 103 virtual void AuthenticateToLogin(Profile* profile, |
105 const std::string& username, | 104 const UserCredentials& credentials, |
106 const std::string& password, | |
107 const std::string& login_token, | 105 const std::string& login_token, |
108 const std::string& login_captcha) OVERRIDE; | 106 const std::string& login_captcha) OVERRIDE; |
109 | 107 |
110 // Given a |username| and |password|, this method attempts to | 108 // Given |credentials|, this method attempts to authenticate to the cached |
111 // authenticate to the cached credentials. This will never contact | 109 // credentials. This will never contact the server even if it's online. |
112 // the server even if it's online. The auth result is sent to | 110 // The auth result is sent to LoginStatusConsumer in a same way as |
113 // LoginStatusConsumer in a same way as AuthenticateToLogin does. | 111 // AuthenticateToLogin does. |
114 virtual void AuthenticateToUnlock(const std::string& username, | 112 virtual void AuthenticateToUnlock( |
115 const std::string& password) OVERRIDE; | 113 const UserCredentials& credentials) OVERRIDE; |
116 | 114 |
117 // Initiates locally managed user login. | 115 // Initiates locally managed user login. |
118 // Creates cryptohome if missing or mounts existing one and | 116 // Creates cryptohome if missing or mounts existing one and |
119 // notifies consumer on the success/failure. | 117 // notifies consumer on the success/failure. |
120 virtual void LoginAsLocallyManagedUser(const std::string& username, | 118 virtual void LoginAsLocallyManagedUser( |
121 const std::string& password) OVERRIDE; | 119 const UserCredentials& credentials) OVERRIDE; |
122 | 120 |
123 // Initiates retail mode login. | 121 // Initiates retail mode login. |
124 // Mounts tmpfs and notifies consumer on the success/failure. | 122 // Mounts tmpfs and notifies consumer on the success/failure. |
125 virtual void LoginRetailMode() OVERRIDE; | 123 virtual void LoginRetailMode() OVERRIDE; |
126 | 124 |
127 // Initiates incognito ("browse without signing in") login. | 125 // Initiates incognito ("browse without signing in") login. |
128 // Mounts tmpfs and notifies consumer on the success/failure. | 126 // Mounts tmpfs and notifies consumer on the success/failure. |
129 virtual void LoginOffTheRecord() OVERRIDE; | 127 virtual void LoginOffTheRecord() OVERRIDE; |
130 | 128 |
131 // Initiates login into the public account identified by |username|. | 129 // Initiates login into the public account identified by |username|. |
132 // Mounts an ephemeral cryptohome and notifies consumer on the | 130 // Mounts an ephemeral cryptohome and notifies consumer on the |
133 // success/failure. | 131 // success/failure. |
134 virtual void LoginAsPublicAccount(const std::string& username) OVERRIDE; | 132 virtual void LoginAsPublicAccount(const std::string& username) OVERRIDE; |
135 | 133 |
136 // These methods must be called on the UI thread, as they make DBus calls | 134 // These methods must be called on the UI thread, as they make DBus calls |
137 // and also call back to the login UI. | 135 // and also call back to the login UI. |
138 virtual void OnRetailModeLoginSuccess() OVERRIDE; | 136 virtual void OnRetailModeLoginSuccess() OVERRIDE; |
139 virtual void OnLoginSuccess(bool request_pending) OVERRIDE; | 137 virtual void OnLoginSuccess(bool request_pending) OVERRIDE; |
140 virtual void OnLoginFailure(const LoginFailure& error) OVERRIDE; | 138 virtual void OnLoginFailure(const LoginFailure& error) OVERRIDE; |
141 virtual void RecoverEncryptedData( | 139 virtual void RecoverEncryptedData( |
142 const std::string& old_password) OVERRIDE; | 140 const std::string& old_password) OVERRIDE; |
143 virtual void ResyncEncryptedData() OVERRIDE; | 141 virtual void ResyncEncryptedData() OVERRIDE; |
144 virtual void RetryAuth(Profile* profile, | 142 virtual void RetryAuth(Profile* profile, |
145 const std::string& username, | 143 const UserCredentials& credentials, |
146 const std::string& password, | |
147 const std::string& login_token, | 144 const std::string& login_token, |
148 const std::string& login_captcha) OVERRIDE; | 145 const std::string& login_captcha) OVERRIDE; |
149 // AuthAttemptStateResolver overrides. | 146 // AuthAttemptStateResolver overrides. |
150 // Attempts to make a decision and call back |consumer_| based on | 147 // Attempts to make a decision and call back |consumer_| based on |
151 // the state we have gathered at the time of call. If a decision | 148 // the state we have gathered at the time of call. If a decision |
152 // can't be made, defers until the next time this is called. | 149 // can't be made, defers until the next time this is called. |
153 // When a decision is made, will call back to |consumer_| on the UI thread. | 150 // When a decision is made, will call back to |consumer_| on the UI thread. |
154 // | 151 // |
155 // Must be called on the UI thread. | 152 // Must be called on the UI thread. |
156 virtual void Resolve() OVERRIDE; | 153 virtual void Resolve() OVERRIDE; |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 | 267 |
271 // True if we use OAuth-based authentication flow. | 268 // True if we use OAuth-based authentication flow. |
272 bool using_oauth_; | 269 bool using_oauth_; |
273 | 270 |
274 DISALLOW_COPY_AND_ASSIGN(ParallelAuthenticator); | 271 DISALLOW_COPY_AND_ASSIGN(ParallelAuthenticator); |
275 }; | 272 }; |
276 | 273 |
277 } // namespace chromeos | 274 } // namespace chromeos |
278 | 275 |
279 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_PARALLEL_AUTHENTICATOR_H_ | 276 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_PARALLEL_AUTHENTICATOR_H_ |
OLD | NEW |