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

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: More test fixing... Created 8 years, 4 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/cros_settings.h" 18 #include "chrome/browser/chromeos/cros_settings.h"
19 #include "chrome/browser/chromeos/cryptohome/async_method_caller.h" 19 #include "chrome/browser/chromeos/cryptohome/async_method_caller.h"
20 #include "chrome/browser/chromeos/login/authentication_notification_details.h" 20 #include "chrome/browser/chromeos/login/authentication_notification_details.h"
21 #include "chrome/browser/chromeos/login/login_status_consumer.h" 21 #include "chrome/browser/chromeos/login/login_status_consumer.h"
22 #include "chrome/browser/chromeos/login/ownership_service.h"
23 #include "chrome/browser/chromeos/login/user_manager.h" 22 #include "chrome/browser/chromeos/login/user_manager.h"
24 #include "chrome/common/chrome_notification_types.h" 23 #include "chrome/common/chrome_notification_types.h"
25 #include "chrome/common/chrome_switches.h" 24 #include "chrome/common/chrome_switches.h"
26 #include "chrome/common/net/gaia/gaia_auth_util.h" 25 #include "chrome/common/net/gaia/gaia_auth_util.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 {
pastarmovj 2012/07/30 13:55:02 Remove the {} too.
Mattias Nissler (ping if slow) 2012/08/02 12:01:52 Done.
226 // Reset the verified flag. 222 // Reset the verified flag.
227 base::AutoLock for_this_block(owner_verified_lock_);
228 owner_is_verified_ = false; 223 owner_is_verified_ = false;
229 } 224 }
230 225
231 const bool create_if_missing = false; 226 const bool create_if_missing = false;
232 BrowserThread::PostTask( 227 BrowserThread::PostTask(
233 BrowserThread::UI, FROM_HERE, 228 BrowserThread::UI, FROM_HERE,
234 base::Bind(&Mount, 229 base::Bind(&Mount,
235 current_state_.get(), 230 current_state_.get(),
236 static_cast<AuthAttemptStateResolver*>(this), 231 static_cast<AuthAttemptStateResolver*>(this),
237 create_if_missing)); 232 create_if_missing));
(...skipping 12 matching lines...) Expand all
250 const std::string& username, 245 const std::string& username,
251 const std::string& password) { 246 const std::string& password) {
252 std::string canonicalized = gaia::CanonicalizeEmail(username); 247 std::string canonicalized = gaia::CanonicalizeEmail(username);
253 authentication_profile_ = profile; 248 authentication_profile_ = profile;
254 current_state_.reset( 249 current_state_.reset(
255 new AuthAttemptState( 250 new AuthAttemptState(
256 canonicalized, 251 canonicalized,
257 password, 252 password,
258 HashPassword(password), 253 HashPassword(password),
259 !UserManager::Get()->IsKnownUser(canonicalized))); 254 !UserManager::Get()->IsKnownUser(canonicalized)));
260 { 255
261 // Reset the verified flag. 256 // Reset the verified flag.
262 base::AutoLock for_this_block(owner_verified_lock_); 257 owner_is_verified_ = false;
263 owner_is_verified_ = false;
264 }
265 258
266 const bool create_if_missing = false; 259 const bool create_if_missing = false;
267 BrowserThread::PostTask( 260 BrowserThread::PostTask(
268 BrowserThread::UI, FROM_HERE, 261 BrowserThread::UI, FROM_HERE,
269 base::Bind(&Mount, 262 base::Bind(&Mount,
270 current_state_.get(), 263 current_state_.get(),
271 static_cast<AuthAttemptStateResolver*>(this), 264 static_cast<AuthAttemptStateResolver*>(this),
272 create_if_missing)); 265 create_if_missing));
273 266
274 if (!using_oauth_) { 267 if (!using_oauth_) {
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 remove_attempted_ = true; 401 remove_attempted_ = true;
409 current_state_->ResetCryptohomeStatus(); 402 current_state_->ResetCryptohomeStatus();
410 BrowserThread::PostTask( 403 BrowserThread::PostTask(
411 BrowserThread::UI, FROM_HERE, 404 BrowserThread::UI, FROM_HERE,
412 base::Bind(&Remove, 405 base::Bind(&Remove,
413 current_state_.get(), 406 current_state_.get(),
414 static_cast<AuthAttemptStateResolver*>(this))); 407 static_cast<AuthAttemptStateResolver*>(this)));
415 } 408 }
416 409
417 bool ParallelAuthenticator::VerifyOwner() { 410 bool ParallelAuthenticator::VerifyOwner() {
418 base::AutoLock for_this_block(owner_verified_lock_);
419 if (owner_is_verified_) 411 if (owner_is_verified_)
420 return true; 412 return true;
421 // Check if policy data is fine and continue in safe mode if needed. 413 // Check if policy data is fine and continue in safe mode if needed.
422 bool is_safe_mode = false; 414 bool is_safe_mode = false;
423 CrosSettings::Get()->GetBoolean(kPolicyMissingMitigationMode, &is_safe_mode); 415 CrosSettings::Get()->GetBoolean(kPolicyMissingMitigationMode, &is_safe_mode);
424 if (!is_safe_mode) { 416 if (!is_safe_mode) {
425 // Now we can continue with the login and report mount success. 417 // Now we can continue with the login and report mount success.
426 user_can_login_ = true; 418 user_can_login_ = true;
427 owner_is_verified_ = true; 419 owner_is_verified_ = true;
428 return true; 420 return true;
429 } 421 }
430 // First we have to make sure the current user's cert store is available. 422 // First we have to make sure the current user's cert store is available.
431 CrosLibrary::Get()->GetCertLibrary()->LoadKeyStore(); 423 CrosLibrary::Get()->GetCertLibrary()->LoadKeyStore();
432 // Now we can continue reading the private key. 424 // Now we can continue reading the private key.
433 BrowserThread::PostTask( 425 DeviceSettingsService::Get()->SetUsername(current_state_->username);
434 BrowserThread::FILE, FROM_HERE, 426 DeviceSettingsService::Get()->GetOwnershipStatusAsync(
435 base::Bind(&ParallelAuthenticator::FinishVerifyOwnerOnFileThread, this)); 427 base::Bind(&ParallelAuthenticator::OnOwnershipChecked, this));
436 return false; 428 return false;
437 } 429 }
438 430
439 void ParallelAuthenticator::FinishVerifyOwnerOnFileThread() { 431 void ParallelAuthenticator::OnOwnershipChecked(
440 base::AutoLock for_this_block(owner_verified_lock_); 432 DeviceSettingsService::OwnershipStatus status,
433 bool is_owner) {
441 // Now we can check if this user is the owner. 434 // Now we can check if this user is the owner.
442 user_can_login_ = 435 user_can_login_ = is_owner;
443 OwnershipService::GetSharedInstance()->IsCurrentUserOwner();
444 owner_is_verified_ = true; 436 owner_is_verified_ = true;
445 BrowserThread::PostTask( 437 Resolve();
446 BrowserThread::UI, FROM_HERE,
447 base::Bind(&ParallelAuthenticator::Resolve, this));
448 } 438 }
449 439
450 void ParallelAuthenticator::RetryAuth(Profile* profile, 440 void ParallelAuthenticator::RetryAuth(Profile* profile,
451 const std::string& username, 441 const std::string& username,
452 const std::string& password, 442 const std::string& password,
453 const std::string& login_token, 443 const std::string& login_token,
454 const std::string& login_captcha) { 444 const std::string& login_captcha) {
455 reauth_state_.reset( 445 reauth_state_.reset(
456 new AuthAttemptState( 446 new AuthAttemptState(
457 gaia::CanonicalizeEmail(username), 447 gaia::CanonicalizeEmail(username),
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
796 } 786 }
797 787
798 void ParallelAuthenticator::ResolveLoginCompletionStatus() { 788 void ParallelAuthenticator::ResolveLoginCompletionStatus() {
799 // Shortcut online state resolution process. 789 // Shortcut online state resolution process.
800 current_state_->RecordOnlineLoginStatus(LoginFailure::None()); 790 current_state_->RecordOnlineLoginStatus(LoginFailure::None());
801 Resolve(); 791 Resolve();
802 } 792 }
803 793
804 void ParallelAuthenticator::SetOwnerState(bool owner_check_finished, 794 void ParallelAuthenticator::SetOwnerState(bool owner_check_finished,
805 bool check_result) { 795 bool check_result) {
806 base::AutoLock for_this_block(owner_verified_lock_);
807 owner_is_verified_ = owner_check_finished; 796 owner_is_verified_ = owner_check_finished;
808 user_can_login_ = check_result; 797 user_can_login_ = check_result;
809 } 798 }
810 799
811 } // namespace chromeos 800 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698