Chromium Code Reviews| Index: ash/login/lock_screen_controller.cc |
| diff --git a/ash/login/lock_screen_controller.cc b/ash/login/lock_screen_controller.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..b7423303260be032491a555b48659353621a0808 |
| --- /dev/null |
| +++ b/ash/login/lock_screen_controller.cc |
| @@ -0,0 +1,71 @@ |
| +// Copyright 2017 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "ash/login/lock_screen_controller.h" |
| + |
| +#include "chromeos/cryptohome/system_salt_getter.h" |
| +#include "chromeos/login/auth/user_context.h" |
| + |
| +namespace ash { |
| + |
| +LockScreenController::LockScreenController() { |
| + chromeos::SystemSaltGetter::Get()->GetSystemSalt(base::Bind( |
|
xiyuan
2017/05/15 20:39:41
SystemSaltGetter::Get() could return nullptr on te
xiaoyinh(OOO Sep 11-29)
2017/05/16 17:32:50
Done. Added "+chromeos/cryptohome" in ash/mus/DEPS
|
| + &LockScreenController::OnSaltObtained, base::Unretained(this))); |
| +} |
| + |
| +LockScreenController::~LockScreenController() {} |
| + |
| +void LockScreenController::BindRequest(mojom::LockScreenRequest request) { |
| + bindings_.AddBinding(this, std::move(request)); |
| +} |
| + |
| +void LockScreenController::AuthenticateUser(const AccountId& account_id, |
| + const std::string& password, |
| + bool authenticated_by_pin) { |
| + if (!system_salt_.empty()) { |
| + DoAuthenticateUser(account_id, password, authenticated_by_pin, |
| + system_salt_); |
| + return; |
| + } |
| + |
| + chromeos::SystemSaltGetter::Get()->GetSystemSalt(base::Bind( |
| + &LockScreenController::DoAuthenticateUser, base::Unretained(this), |
| + account_id, password, authenticated_by_pin)); |
| +} |
| + |
| +void LockScreenController::SetClient(mojom::LockScreenClientPtr client) { |
| + lock_screen_client_ = std::move(client); |
| +} |
| + |
| +void LockScreenController::ShowErrorMessage() { |
| + NOTIMPLEMENTED(); |
| +} |
| + |
| +void LockScreenController::ClearErrors() { |
| + NOTIMPLEMENTED(); |
| +} |
| + |
| +void LockScreenController::DoAuthenticateUser(const AccountId& account_id, |
| + const std::string& password, |
| + bool authenticated_by_pin, |
| + const std::string& system_salt) { |
| + system_salt_ = system_salt; |
| + |
| + // Hash password before sending through mojo. |
| + // TODO(xiaoyinh@): Pin is hashed differently by using a different salt and |
| + // a different hash algorithm. Update this part in PinStorage. |
| + chromeos::UserContext user_context(account_id); |
|
xiyuan
2017/05/15 20:39:41
|user_context| not used?
xiaoyinh(OOO Sep 11-29)
2017/05/16 17:32:49
Removed, thanks!
|
| + chromeos::Key key(password); |
| + key.Transform(chromeos::Key::KEY_TYPE_SALTED_SHA256_TOP_HALF, system_salt); |
| + if (lock_screen_client_) { |
| + lock_screen_client_->AuthenticateUser(account_id, key.GetSecret(), |
| + authenticated_by_pin); |
| + } |
| +} |
| + |
| +void LockScreenController::OnSaltObtained(const std::string& system_salt) { |
| + system_salt_ = system_salt; |
| +} |
|
James Cook
2017/05/15 21:15:00
Please write a test for this class. It can be some
xiaoyinh(OOO Sep 11-29)
2017/05/16 17:32:49
Thanks!
I wrote a very simple test to verify that
|
| + |
| +} // namespace ash |