[go: nahoru, domu]

blob: 8b99e6fd7acf0d3f385745d9db2b6a8723ecf888 [file] [log] [blame]
xiaoyinh2bbdd102017-05-18 23:29:421// Copyright 2017 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "ash/login/lock_screen_controller.h"
6
7#include "chromeos/cryptohome/system_salt_getter.h"
8#include "chromeos/login/auth/user_context.h"
9
10namespace ash {
11
12LockScreenController::LockScreenController() = default;
13
14LockScreenController::~LockScreenController() = default;
15
16void LockScreenController::BindRequest(mojom::LockScreenRequest request) {
17 bindings_.AddBinding(this, std::move(request));
18}
19
xiaoyinh2bbdd102017-05-18 23:29:4220void LockScreenController::SetClient(mojom::LockScreenClientPtr client) {
21 lock_screen_client_ = std::move(client);
22}
23
24void LockScreenController::ShowErrorMessage(int32_t login_attempts,
25 const std::string& error_text,
26 const std::string& help_link_text,
27 int32_t help_topic_id) {
28 NOTIMPLEMENTED();
29}
30
31void LockScreenController::ClearErrors() {
32 NOTIMPLEMENTED();
33}
34
xiaoyinh9f6fa0e2017-06-07 19:22:3235void LockScreenController::ShowUserPodCustomIcon(
36 const AccountId& account_id,
37 mojom::UserPodCustomIconOptionsPtr icon) {
38 NOTIMPLEMENTED();
39}
40
41void LockScreenController::HideUserPodCustomIcon(const AccountId& account_id) {
42 NOTIMPLEMENTED();
43}
44
45void LockScreenController::SetAuthType(const AccountId& account_id,
46 mojom::AuthType auth_type,
47 const base::string16& initial_value) {
48 NOTIMPLEMENTED();
49}
50
51void LockScreenController::LoadUsers(std::unique_ptr<base::ListValue> users,
52 bool show_guest) {
53 NOTIMPLEMENTED();
54}
55
56void LockScreenController::AuthenticateUser(const AccountId& account_id,
57 const std::string& password,
58 bool authenticated_by_pin) {
59 if (!lock_screen_client_)
60 return;
61
62 chromeos::SystemSaltGetter::Get()->GetSystemSalt(base::Bind(
63 &LockScreenController::DoAuthenticateUser, base::Unretained(this),
64 account_id, password, authenticated_by_pin));
65}
66
67void LockScreenController::AttemptUnlock(const AccountId& account_id) {
68 if (!lock_screen_client_)
69 return;
70 lock_screen_client_->AttemptUnlock(account_id);
71}
72
73void LockScreenController::HardlockPod(const AccountId& account_id) {
74 if (!lock_screen_client_)
75 return;
76 lock_screen_client_->HardlockPod(account_id);
77}
78
79void LockScreenController::RecordClickOnLockIcon(const AccountId& account_id) {
80 if (!lock_screen_client_)
81 return;
82 lock_screen_client_->RecordClickOnLockIcon(account_id);
83}
84
xiaoyinh2bbdd102017-05-18 23:29:4285void LockScreenController::DoAuthenticateUser(const AccountId& account_id,
86 const std::string& password,
87 bool authenticated_by_pin,
88 const std::string& system_salt) {
89 // Hash password before sending through mojo.
90 // TODO(xiaoyinh): Pin is hashed differently by using a different salt and
91 // a different hash algorithm. Update this part in PinStorage.
92 chromeos::Key key(password);
93 key.Transform(chromeos::Key::KEY_TYPE_SALTED_SHA256_TOP_HALF, system_salt);
94 lock_screen_client_->AuthenticateUser(account_id, key.GetSecret(),
95 authenticated_by_pin);
96}
97
98} // namespace ash