Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1350)

Side by Side Diff: chrome/browser/chromeos/login/parallel_authenticator.cc

Issue 10832035: Switch from SignedSettings to DeviceSettingsService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase. Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 #include "chrome/browser/chromeos/login/parallel_authenticator.h" 5 #include "chrome/browser/chromeos/login/parallel_authenticator.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/file_path.h" 9 #include "base/file_path.h"
10 #include "base/file_util.h" 10 #include "base/file_util.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/string_number_conversions.h" 12 #include "base/string_number_conversions.h"
13 #include "base/string_util.h" 13 #include "base/string_util.h"
14 #include "chrome/browser/chromeos/boot_times_loader.h" 14 #include "chrome/browser/chromeos/boot_times_loader.h"
15 #include "chrome/browser/chromeos/cros/cert_library.h" 15 #include "chrome/browser/chromeos/cros/cert_library.h"
16 #include "chrome/browser/chromeos/cros/cros_library.h" 16 #include "chrome/browser/chromeos/cros/cros_library.h"
17 #include "chrome/browser/chromeos/cros/cryptohome_library.h" 17 #include "chrome/browser/chromeos/cros/cryptohome_library.h"
18 #include "chrome/browser/chromeos/login/authentication_notification_details.h" 18 #include "chrome/browser/chromeos/login/authentication_notification_details.h"
19 #include "chrome/browser/chromeos/login/login_status_consumer.h" 19 #include "chrome/browser/chromeos/login/login_status_consumer.h"
20 #include "chrome/browser/chromeos/login/user_manager.h" 20 #include "chrome/browser/chromeos/login/user_manager.h"
21 #include "chrome/browser/chromeos/settings/cros_settings.h" 21 #include "chrome/browser/chromeos/settings/cros_settings.h"
22 #include "chrome/browser/chromeos/settings/ownership_service.h"
23 #include "chrome/common/chrome_notification_types.h" 22 #include "chrome/common/chrome_notification_types.h"
24 #include "chrome/common/chrome_switches.h" 23 #include "chrome/common/chrome_switches.h"
25 #include "chrome/common/net/gaia/gaia_auth_util.h" 24 #include "chrome/common/net/gaia/gaia_auth_util.h"
26 #include "chromeos/cryptohome/async_method_caller.h" 25 #include "chromeos/cryptohome/async_method_caller.h"
27 #include "chromeos/dbus/cryptohome_client.h" 26 #include "chromeos/dbus/cryptohome_client.h"
28 #include "chromeos/dbus/dbus_thread_manager.h" 27 #include "chromeos/dbus/dbus_thread_manager.h"
29 #include "content/public/browser/browser_thread.h" 28 #include "content/public/browser/browser_thread.h"
30 #include "content/public/browser/notification_service.h" 29 #include "content/public/browser/notification_service.h"
31 #include "crypto/sha2.h" 30 #include "crypto/sha2.h"
32 #include "third_party/cros_system_api/dbus/service_constants.h" 31 #include "third_party/cros_system_api/dbus/service_constants.h"
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 migrate_attempted_(false), 193 migrate_attempted_(false),
195 remove_attempted_(false), 194 remove_attempted_(false),
196 mount_guest_attempted_(false), 195 mount_guest_attempted_(false),
197 check_key_attempted_(false), 196 check_key_attempted_(false),
198 already_reported_success_(false), 197 already_reported_success_(false),
199 owner_is_verified_(false), 198 owner_is_verified_(false),
200 user_can_login_(false), 199 user_can_login_(false),
201 using_oauth_( 200 using_oauth_(
202 !CommandLine::ForCurrentProcess()->HasSwitch( 201 !CommandLine::ForCurrentProcess()->HasSwitch(
203 switches::kSkipOAuthLogin)) { 202 switches::kSkipOAuthLogin)) {
204 // If not already owned, this is a no-op. If it is, this loads the owner's
205 // public key off of disk.
206 OwnershipService::GetSharedInstance()->StartLoadOwnerKeyAttempt();
207 } 203 }
208 204
209 void ParallelAuthenticator::AuthenticateToLogin( 205 void ParallelAuthenticator::AuthenticateToLogin(
210 Profile* profile, 206 Profile* profile,
211 const std::string& username, 207 const std::string& username,
212 const std::string& password, 208 const std::string& password,
213 const std::string& login_token, 209 const std::string& login_token,
214 const std::string& login_captcha) { 210 const std::string& login_captcha) {
215 std::string canonicalized = gaia::CanonicalizeEmail(username); 211 std::string canonicalized = gaia::CanonicalizeEmail(username);
216 authentication_profile_ = profile; 212 authentication_profile_ = profile;
217 current_state_.reset( 213 current_state_.reset(
218 new AuthAttemptState( 214 new AuthAttemptState(
219 canonicalized, 215 canonicalized,
220 password, 216 password,
221 HashPassword(password), 217 HashPassword(password),
222 login_token, 218 login_token,
223 login_captcha, 219 login_captcha,
224 !UserManager::Get()->IsKnownUser(canonicalized))); 220 !UserManager::Get()->IsKnownUser(canonicalized)));
225 { 221 // Reset the verified flag.
226 // Reset the verified flag. 222 owner_is_verified_ = false;
227 base::AutoLock for_this_block(owner_verified_lock_);
228 owner_is_verified_ = false;
229 }
230 223
231 const bool create_if_missing = false; 224 const bool create_if_missing = false;
232 BrowserThread::PostTask( 225 BrowserThread::PostTask(
233 BrowserThread::UI, FROM_HERE, 226 BrowserThread::UI, FROM_HERE,
234 base::Bind(&Mount, 227 base::Bind(&Mount,
235 current_state_.get(), 228 current_state_.get(),
236 static_cast<AuthAttemptStateResolver*>(this), 229 static_cast<AuthAttemptStateResolver*>(this),
237 create_if_missing)); 230 create_if_missing));
238 // ClientLogin authentication check should happen immediately here. 231 // ClientLogin authentication check should happen immediately here.
239 // We should not try OAuthLogin check until the profile loads. 232 // We should not try OAuthLogin check until the profile loads.
(...skipping 10 matching lines...) Expand all
250 const std::string& username, 243 const std::string& username,
251 const std::string& password) { 244 const std::string& password) {
252 std::string canonicalized = gaia::CanonicalizeEmail(username); 245 std::string canonicalized = gaia::CanonicalizeEmail(username);
253 authentication_profile_ = profile; 246 authentication_profile_ = profile;
254 current_state_.reset( 247 current_state_.reset(
255 new AuthAttemptState( 248 new AuthAttemptState(
256 canonicalized, 249 canonicalized,
257 password, 250 password,
258 HashPassword(password), 251 HashPassword(password),
259 !UserManager::Get()->IsKnownUser(canonicalized))); 252 !UserManager::Get()->IsKnownUser(canonicalized)));
260 { 253
261 // Reset the verified flag. 254 // Reset the verified flag.
262 base::AutoLock for_this_block(owner_verified_lock_); 255 owner_is_verified_ = false;
263 owner_is_verified_ = false;
264 }
265 256
266 const bool create_if_missing = false; 257 const bool create_if_missing = false;
267 BrowserThread::PostTask( 258 BrowserThread::PostTask(
268 BrowserThread::UI, FROM_HERE, 259 BrowserThread::UI, FROM_HERE,
269 base::Bind(&Mount, 260 base::Bind(&Mount,
270 current_state_.get(), 261 current_state_.get(),
271 static_cast<AuthAttemptStateResolver*>(this), 262 static_cast<AuthAttemptStateResolver*>(this),
272 create_if_missing)); 263 create_if_missing));
273 264
274 if (!using_oauth_) { 265 if (!using_oauth_) {
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 remove_attempted_ = true; 399 remove_attempted_ = true;
409 current_state_->ResetCryptohomeStatus(); 400 current_state_->ResetCryptohomeStatus();
410 BrowserThread::PostTask( 401 BrowserThread::PostTask(
411 BrowserThread::UI, FROM_HERE, 402 BrowserThread::UI, FROM_HERE,
412 base::Bind(&Remove, 403 base::Bind(&Remove,
413 current_state_.get(), 404 current_state_.get(),
414 static_cast<AuthAttemptStateResolver*>(this))); 405 static_cast<AuthAttemptStateResolver*>(this)));
415 } 406 }
416 407
417 bool ParallelAuthenticator::VerifyOwner() { 408 bool ParallelAuthenticator::VerifyOwner() {
418 base::AutoLock for_this_block(owner_verified_lock_);
419 if (owner_is_verified_) 409 if (owner_is_verified_)
420 return true; 410 return true;
421 // Check if policy data is fine and continue in safe mode if needed. 411 // Check if policy data is fine and continue in safe mode if needed.
422 bool is_safe_mode = false; 412 bool is_safe_mode = false;
423 CrosSettings::Get()->GetBoolean(kPolicyMissingMitigationMode, &is_safe_mode); 413 CrosSettings::Get()->GetBoolean(kPolicyMissingMitigationMode, &is_safe_mode);
424 if (!is_safe_mode) { 414 if (!is_safe_mode) {
425 // Now we can continue with the login and report mount success. 415 // Now we can continue with the login and report mount success.
426 user_can_login_ = true; 416 user_can_login_ = true;
427 owner_is_verified_ = true; 417 owner_is_verified_ = true;
428 return true; 418 return true;
429 } 419 }
430 // First we have to make sure the current user's cert store is available. 420 // First we have to make sure the current user's cert store is available.
431 CrosLibrary::Get()->GetCertLibrary()->LoadKeyStore(); 421 CrosLibrary::Get()->GetCertLibrary()->LoadKeyStore();
432 // Now we can continue reading the private key. 422 // Now we can continue reading the private key.
433 BrowserThread::PostTask( 423 DeviceSettingsService::Get()->SetUsername(current_state_->username);
434 BrowserThread::FILE, FROM_HERE, 424 DeviceSettingsService::Get()->GetOwnershipStatusAsync(
435 base::Bind(&ParallelAuthenticator::FinishVerifyOwnerOnFileThread, this)); 425 base::Bind(&ParallelAuthenticator::OnOwnershipChecked, this));
436 return false; 426 return false;
437 } 427 }
438 428
439 void ParallelAuthenticator::FinishVerifyOwnerOnFileThread() { 429 void ParallelAuthenticator::OnOwnershipChecked(
440 base::AutoLock for_this_block(owner_verified_lock_); 430 DeviceSettingsService::OwnershipStatus status,
431 bool is_owner) {
441 // Now we can check if this user is the owner. 432 // Now we can check if this user is the owner.
442 user_can_login_ = 433 user_can_login_ = is_owner;
443 OwnershipService::GetSharedInstance()->IsCurrentUserOwner();
444 owner_is_verified_ = true; 434 owner_is_verified_ = true;
445 BrowserThread::PostTask( 435 Resolve();
446 BrowserThread::UI, FROM_HERE,
447 base::Bind(&ParallelAuthenticator::Resolve, this));
448 } 436 }
449 437
450 void ParallelAuthenticator::RetryAuth(Profile* profile, 438 void ParallelAuthenticator::RetryAuth(Profile* profile,
451 const std::string& username, 439 const std::string& username,
452 const std::string& password, 440 const std::string& password,
453 const std::string& login_token, 441 const std::string& login_token,
454 const std::string& login_captcha) { 442 const std::string& login_captcha) {
455 reauth_state_.reset( 443 reauth_state_.reset(
456 new AuthAttemptState( 444 new AuthAttemptState(
457 gaia::CanonicalizeEmail(username), 445 gaia::CanonicalizeEmail(username),
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
796 } 784 }
797 785
798 void ParallelAuthenticator::ResolveLoginCompletionStatus() { 786 void ParallelAuthenticator::ResolveLoginCompletionStatus() {
799 // Shortcut online state resolution process. 787 // Shortcut online state resolution process.
800 current_state_->RecordOnlineLoginStatus(LoginFailure::None()); 788 current_state_->RecordOnlineLoginStatus(LoginFailure::None());
801 Resolve(); 789 Resolve();
802 } 790 }
803 791
804 void ParallelAuthenticator::SetOwnerState(bool owner_check_finished, 792 void ParallelAuthenticator::SetOwnerState(bool owner_check_finished,
805 bool check_result) { 793 bool check_result) {
806 base::AutoLock for_this_block(owner_verified_lock_);
807 owner_is_verified_ = owner_check_finished; 794 owner_is_verified_ = owner_check_finished;
808 user_can_login_ = check_result; 795 user_can_login_ = check_result;
809 } 796 }
810 797
811 } // namespace chromeos 798 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698