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

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

Powered by Google App Engine
This is Rietveld 408576698