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

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

Issue 23684033: Fix device policy recovery on CrOS login (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 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/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/strings/string_number_conversions.h" 11 #include "base/strings/string_number_conversions.h"
12 #include "base/strings/string_util.h" 12 #include "base/strings/string_util.h"
13 #include "chrome/browser/chrome_notification_types.h" 13 #include "chrome/browser/chrome_notification_types.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/login/authentication_notification_details.h" 16 #include "chrome/browser/chromeos/login/authentication_notification_details.h"
17 #include "chrome/browser/chromeos/login/login_status_consumer.h" 17 #include "chrome/browser/chromeos/login/login_status_consumer.h"
18 #include "chrome/browser/chromeos/login/user.h" 18 #include "chrome/browser/chromeos/login/user.h"
19 #include "chrome/browser/chromeos/login/user_manager.h" 19 #include "chrome/browser/chromeos/login/user_manager.h"
20 #include "chrome/browser/chromeos/settings/cros_settings.h" 20 #include "chrome/browser/chromeos/settings/cros_settings.h"
21 #include "chrome/common/chrome_switches.h" 21 #include "chrome/common/chrome_switches.h"
22 #include "chromeos/cryptohome/async_method_caller.h" 22 #include "chromeos/cryptohome/async_method_caller.h"
23 #include "chromeos/cryptohome/cryptohome_library.h" 23 #include "chromeos/cryptohome/cryptohome_library.h"
24 #include "chromeos/dbus/cryptohome_client.h" 24 #include "chromeos/dbus/cryptohome_client.h"
25 #include "chromeos/dbus/dbus_thread_manager.h" 25 #include "chromeos/dbus/dbus_thread_manager.h"
26 #include "chromeos/login/login_state.h"
26 #include "content/public/browser/browser_thread.h" 27 #include "content/public/browser/browser_thread.h"
27 #include "content/public/browser/notification_service.h" 28 #include "content/public/browser/notification_service.h"
28 #include "crypto/sha2.h" 29 #include "crypto/sha2.h"
29 #include "google_apis/gaia/gaia_auth_util.h" 30 #include "google_apis/gaia/gaia_auth_util.h"
30 #include "third_party/cros_system_api/dbus/service_constants.h" 31 #include "third_party/cros_system_api/dbus/service_constants.h"
31 32
32 using content::BrowserThread; 33 using content::BrowserThread;
33 34
34 namespace chromeos { 35 namespace chromeos {
35 36
(...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after
511 CrosSettings::Get()->GetBoolean(kPolicyMissingMitigationMode, &is_safe_mode); 512 CrosSettings::Get()->GetBoolean(kPolicyMissingMitigationMode, &is_safe_mode);
512 if (!is_safe_mode) { 513 if (!is_safe_mode) {
513 // Now we can continue with the login and report mount success. 514 // Now we can continue with the login and report mount success.
514 user_can_login_ = true; 515 user_can_login_ = true;
515 owner_is_verified_ = true; 516 owner_is_verified_ = true;
516 return true; 517 return true;
517 } 518 }
518 // Now we can continue reading the private key. 519 // Now we can continue reading the private key.
519 DeviceSettingsService::Get()->SetUsername( 520 DeviceSettingsService::Get()->SetUsername(
520 current_state_->user_context.username); 521 current_state_->user_context.username);
521 DeviceSettingsService::Get()->GetOwnershipStatusAsync( 522 // This should trigger certificate loading, which is needed in order to
523 // correctly determine if the current user is the owner.
524 if (LoginState::IsInitialized()) {
525 LoginState::Get()->SetLoggedInState(LoginState::LOGGED_IN_SAFE_MODE,
526 LoginState::LOGGED_IN_USER_NONE);
527 }
528 DeviceSettingsService::Get()->IsCurrentUserOwnerAsync(
522 base::Bind(&ParallelAuthenticator::OnOwnershipChecked, this)); 529 base::Bind(&ParallelAuthenticator::OnOwnershipChecked, this));
523 return false; 530 return false;
524 } 531 }
525 532
526 void ParallelAuthenticator::OnOwnershipChecked( 533 void ParallelAuthenticator::OnOwnershipChecked(bool is_owner) {
527 DeviceSettingsService::OwnershipStatus status) {
528 // Now we can check if this user is the owner. 534 // Now we can check if this user is the owner.
529 // TODO(tbarzic): This is broken. At this point, DeviceSettingsService will 535 user_can_login_ = is_owner;
530 // never have private key loaded (http://crbug.com/285450).
531 user_can_login_ = DeviceSettingsService::Get()->HasPrivateOwnerKey();
532 owner_is_verified_ = true; 536 owner_is_verified_ = true;
533 Resolve(); 537 Resolve();
534 } 538 }
535 539
536 void ParallelAuthenticator::Resolve() { 540 void ParallelAuthenticator::Resolve() {
537 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 541 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
538 bool request_pending = false; 542 bool request_pending = false;
539 int mount_flags = cryptohome::MOUNT_FLAGS_NONE; 543 int mount_flags = cryptohome::MOUNT_FLAGS_NONE;
540 ParallelAuthenticator::AuthState state = ResolveState(); 544 ParallelAuthenticator::AuthState state = ResolveState();
541 VLOG(1) << "Resolved state to: " << state; 545 VLOG(1) << "Resolved state to: " << state;
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
836 Resolve(); 840 Resolve();
837 } 841 }
838 842
839 void ParallelAuthenticator::SetOwnerState(bool owner_check_finished, 843 void ParallelAuthenticator::SetOwnerState(bool owner_check_finished,
840 bool check_result) { 844 bool check_result) {
841 owner_is_verified_ = owner_check_finished; 845 owner_is_verified_ = owner_check_finished;
842 user_can_login_ = check_result; 846 user_can_login_ = check_result;
843 } 847 }
844 848
845 } // namespace chromeos 849 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698