| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/lock/screen_locker.h" | 5 #include "chrome/browser/chromeos/login/lock/screen_locker.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "ash/login/views/lock_screen.h" | 10 #include "ash/login/views/lock_screen.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 #include "base/message_loop/message_loop.h" | 24 #include "base/message_loop/message_loop.h" |
| 25 #include "base/metrics/histogram_macros.h" | 25 #include "base/metrics/histogram_macros.h" |
| 26 #include "base/metrics/user_metrics.h" | 26 #include "base/metrics/user_metrics.h" |
| 27 #include "base/single_thread_task_runner.h" | 27 #include "base/single_thread_task_runner.h" |
| 28 #include "base/strings/string_number_conversions.h" | 28 #include "base/strings/string_number_conversions.h" |
| 29 #include "base/strings/string_util.h" | 29 #include "base/strings/string_util.h" |
| 30 #include "base/threading/thread_task_runner_handle.h" | 30 #include "base/threading/thread_task_runner_handle.h" |
| 31 #include "chrome/browser/chrome_notification_types.h" | 31 #include "chrome/browser/chrome_notification_types.h" |
| 32 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h" | 32 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h" |
| 33 #include "chrome/browser/chromeos/login/lock/webui_screen_locker.h" | 33 #include "chrome/browser/chromeos/login/lock/webui_screen_locker.h" |
| 34 #include "chrome/browser/chromeos/login/quick_unlock/fingerprint_storage.h" |
| 35 #include "chrome/browser/chromeos/login/quick_unlock/pin_backend.h" |
| 34 #include "chrome/browser/chromeos/login/quick_unlock/quick_unlock_factory.h" | 36 #include "chrome/browser/chromeos/login/quick_unlock/quick_unlock_factory.h" |
| 35 #include "chrome/browser/chromeos/login/quick_unlock/quick_unlock_storage.h" | 37 #include "chrome/browser/chromeos/login/quick_unlock/quick_unlock_storage.h" |
| 36 #include "chrome/browser/chromeos/login/session/user_session_manager.h" | 38 #include "chrome/browser/chromeos/login/session/user_session_manager.h" |
| 37 #include "chrome/browser/chromeos/login/supervised/supervised_user_authenticatio
n.h" | 39 #include "chrome/browser/chromeos/login/supervised/supervised_user_authenticatio
n.h" |
| 38 #include "chrome/browser/chromeos/login/ui/user_adding_screen.h" | 40 #include "chrome/browser/chromeos/login/ui/user_adding_screen.h" |
| 39 #include "chrome/browser/chromeos/login/users/chrome_user_manager.h" | 41 #include "chrome/browser/chromeos/login/users/chrome_user_manager.h" |
| 40 #include "chrome/browser/chromeos/login/users/supervised_user_manager.h" | 42 #include "chrome/browser/chromeos/login/users/supervised_user_manager.h" |
| 41 #include "chrome/browser/lifetime/application_lifetime.h" | 43 #include "chrome/browser/lifetime/application_lifetime.h" |
| 42 #include "chrome/browser/signin/easy_unlock_service.h" | 44 #include "chrome/browser/signin/easy_unlock_service.h" |
| 43 #include "chrome/browser/signin/signin_manager_factory.h" | 45 #include "chrome/browser/signin/signin_manager_factory.h" |
| (...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 user_context.GetAccountId()); | 322 user_context.GetAccountId()); |
| 321 } | 323 } |
| 322 | 324 |
| 323 // Reset the number of PIN attempts available to the user. We always do this | 325 // Reset the number of PIN attempts available to the user. We always do this |
| 324 // because: | 326 // because: |
| 325 // 1. If the user signed in with a PIN, that means they should be able to | 327 // 1. If the user signed in with a PIN, that means they should be able to |
| 326 // continue signing in with a PIN. | 328 // continue signing in with a PIN. |
| 327 // 2. If the user signed in with cryptohome keys, then the PIN timeout is | 329 // 2. If the user signed in with cryptohome keys, then the PIN timeout is |
| 328 // going to be reset as well, so it is safe to reset the unlock attempt | 330 // going to be reset as well, so it is safe to reset the unlock attempt |
| 329 // count. | 331 // count. |
| 332 quick_unlock::PinBackend::NotifyAuthentication(user_context.GetAccountId()); |
| 330 quick_unlock::QuickUnlockStorage* quick_unlock_storage = | 333 quick_unlock::QuickUnlockStorage* quick_unlock_storage = |
| 331 quick_unlock::QuickUnlockFactory::GetForUser(user); | 334 quick_unlock::QuickUnlockFactory::GetForUser(user); |
| 332 if (quick_unlock_storage) { | 335 if (quick_unlock_storage) { |
| 333 quick_unlock_storage->pin_storage()->ResetUnlockAttemptCount(); | |
| 334 quick_unlock_storage->fingerprint_storage()->ResetUnlockAttemptCount(); | 336 quick_unlock_storage->fingerprint_storage()->ResetUnlockAttemptCount(); |
| 335 } | 337 } |
| 336 | 338 |
| 337 UserSessionManager::GetInstance()->UpdateEasyUnlockKeys(user_context); | 339 UserSessionManager::GetInstance()->UpdateEasyUnlockKeys(user_context); |
| 338 } else { | 340 } else { |
| 339 NOTREACHED() << "Logged in user not found."; | 341 NOTREACHED() << "Logged in user not found."; |
| 340 } | 342 } |
| 341 | 343 |
| 342 authentication_capture_.reset(new AuthenticationParametersCapture()); | 344 authentication_capture_.reset(new AuthenticationParametersCapture()); |
| 343 authentication_capture_->user_context = user_context; | 345 authentication_capture_->user_context = user_context; |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 391 if (user) { | 393 if (user) { |
| 392 // Check to see if the user submitted a PIN and it is valid. | 394 // Check to see if the user submitted a PIN and it is valid. |
| 393 const std::string pin = user_context.GetKey()->GetSecret(); | 395 const std::string pin = user_context.GetKey()->GetSecret(); |
| 394 | 396 |
| 395 // We only want to try authenticating the pin if it is a number, | 397 // We only want to try authenticating the pin if it is a number, |
| 396 // otherwise we will timeout PIN if the user enters their account password | 398 // otherwise we will timeout PIN if the user enters their account password |
| 397 // incorrectly more than a few times. | 399 // incorrectly more than a few times. |
| 398 int dummy_value; | 400 int dummy_value; |
| 399 if (unlock_attempt_type_ == AUTH_PIN && | 401 if (unlock_attempt_type_ == AUTH_PIN && |
| 400 base::StringToInt(pin, &dummy_value)) { | 402 base::StringToInt(pin, &dummy_value)) { |
| 401 quick_unlock::QuickUnlockStorage* quick_unlock_storage = | 403 quick_unlock::PinBackend::TryAuthenticate( |
| 402 quick_unlock::QuickUnlockFactory::GetForUser(user); | 404 user_context.GetAccountId(), pin, |
| 403 if (quick_unlock_storage && | 405 base::Bind(&ScreenLocker::OnPinAttemptDone, |
| 404 quick_unlock_storage->TryAuthenticatePin(pin)) { | 406 weak_factory_.GetWeakPtr(), user_context)); |
| 405 OnAuthSuccess(user_context); | 407 return; |
| 406 return; | |
| 407 } | |
| 408 } | 408 } |
| 409 } |
| 409 | 410 |
| 411 ContinueAuthenticate(user_context); |
| 412 } |
| 413 |
| 414 void ScreenLocker::OnPinAttemptDone(const UserContext& user_context, |
| 415 bool success) { |
| 416 if (success) |
| 417 OnAuthSuccess(user_context); |
| 418 else |
| 419 ContinueAuthenticate(user_context); |
| 420 } |
| 421 |
| 422 void ScreenLocker::ContinueAuthenticate( |
| 423 const chromeos::UserContext& user_context) { |
| 424 const user_manager::User* user = FindUnlockUser(user_context.GetAccountId()); |
| 425 if (user) { |
| 410 // Special case: supervised users. Use special authenticator. | 426 // Special case: supervised users. Use special authenticator. |
| 411 if (user->GetType() == user_manager::USER_TYPE_SUPERVISED) { | 427 if (user->GetType() == user_manager::USER_TYPE_SUPERVISED) { |
| 412 UserContext updated_context = ChromeUserManager::Get() | 428 UserContext updated_context = ChromeUserManager::Get() |
| 413 ->GetSupervisedUserManager() | 429 ->GetSupervisedUserManager() |
| 414 ->GetAuthentication() | 430 ->GetAuthentication() |
| 415 ->TransformKey(user_context); | 431 ->TransformKey(user_context); |
| 416 BrowserThread::PostTask( | 432 BrowserThread::PostTask( |
| 417 BrowserThread::UI, FROM_HERE, | 433 BrowserThread::UI, FROM_HERE, |
| 418 base::Bind(&ExtendedAuthenticator::AuthenticateToCheck, | 434 base::Bind(&ExtendedAuthenticator::AuthenticateToCheck, |
| 419 extended_authenticator_.get(), updated_context, | 435 extended_authenticator_.get(), updated_context, |
| (...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 719 } | 735 } |
| 720 } | 736 } |
| 721 | 737 |
| 722 if (auth_status_consumer_) { | 738 if (auth_status_consumer_) { |
| 723 AuthFailure failure(AuthFailure::UNLOCK_FAILED); | 739 AuthFailure failure(AuthFailure::UNLOCK_FAILED); |
| 724 auth_status_consumer_->OnAuthFailure(failure); | 740 auth_status_consumer_->OnAuthFailure(failure); |
| 725 } | 741 } |
| 726 } | 742 } |
| 727 | 743 |
| 728 } // namespace chromeos | 744 } // namespace chromeos |
| OLD | NEW |