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/supervised/supervised_user_authenticator
.h" | 5 #include "chrome/browser/chromeos/login/supervised/supervised_user_authenticator
.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 #include "chrome/browser/chromeos/boot_times_recorder.h" | 10 #include "chrome/browser/chromeos/boot_times_recorder.h" |
11 #include "chromeos/cryptohome/async_method_caller.h" | 11 #include "chromeos/cryptohome/async_method_caller.h" |
12 #include "chromeos/cryptohome/cryptohome_parameters.h" | 12 #include "chromeos/cryptohome/cryptohome_parameters.h" |
13 #include "chromeos/cryptohome/system_salt_getter.h" | 13 #include "chromeos/cryptohome/system_salt_getter.h" |
14 #include "chromeos/dbus/cryptohome_client.h" | 14 #include "chromeos/dbus/cryptohome_client.h" |
15 #include "chromeos/dbus/dbus_thread_manager.h" | 15 #include "chromeos/dbus/dbus_thread_manager.h" |
16 #include "chromeos/login/auth/key.h" | 16 #include "chromeos/login/auth/key.h" |
| 17 #include "components/signin/core/account_id/account_id.h" |
| 18 #include "components/user_manager/known_user.h" |
17 #include "content/public/browser/browser_thread.h" | 19 #include "content/public/browser/browser_thread.h" |
18 #include "crypto/sha2.h" | 20 #include "crypto/sha2.h" |
19 #include "google_apis/gaia/gaia_auth_util.h" | 21 #include "google_apis/gaia/gaia_auth_util.h" |
20 #include "third_party/cros_system_api/dbus/service_constants.h" | 22 #include "third_party/cros_system_api/dbus/service_constants.h" |
21 | 23 |
22 using content::BrowserThread; | 24 using content::BrowserThread; |
23 | 25 |
24 namespace chromeos { | 26 namespace chromeos { |
25 | 27 |
26 namespace { | 28 namespace { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 void Mount(SupervisedUserAuthenticator::AuthAttempt* attempt, | 62 void Mount(SupervisedUserAuthenticator::AuthAttempt* attempt, |
61 scoped_refptr<SupervisedUserAuthenticator> resolver, | 63 scoped_refptr<SupervisedUserAuthenticator> resolver, |
62 int flags, | 64 int flags, |
63 const std::string& system_salt) { | 65 const std::string& system_salt) { |
64 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 66 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
65 chromeos::BootTimesRecorder::Get()->AddLoginTimeMarker( | 67 chromeos::BootTimesRecorder::Get()->AddLoginTimeMarker( |
66 "CryptohomeMount-LMU-Start", false); | 68 "CryptohomeMount-LMU-Start", false); |
67 | 69 |
68 Key key(attempt->password); | 70 Key key(attempt->password); |
69 key.Transform(Key::KEY_TYPE_SALTED_SHA256_TOP_HALF, system_salt); | 71 key.Transform(Key::KEY_TYPE_SALTED_SHA256_TOP_HALF, system_salt); |
| 72 const AccountId account_id = user_manager::known_user::GetAccountId( |
| 73 attempt->username, std::string() /* gaia_id */); |
| 74 const cryptohome::Identification cryptohome_id(account_id); |
70 cryptohome::AsyncMethodCaller::GetInstance()->AsyncMount( | 75 cryptohome::AsyncMethodCaller::GetInstance()->AsyncMount( |
71 attempt->username, | 76 cryptohome_id, key.GetSecret(), flags, |
72 key.GetSecret(), | 77 base::Bind(&TriggerResolveWithLoginTimeMarker, "CryptohomeMount-LMU-End", |
73 flags, | 78 attempt, resolver)); |
74 base::Bind(&TriggerResolveWithLoginTimeMarker, | |
75 "CryptohomeMount-LMU-End", | |
76 attempt, | |
77 resolver)); | |
78 | 79 |
79 cryptohome::AsyncMethodCaller::GetInstance()->AsyncGetSanitizedUsername( | 80 cryptohome::AsyncMethodCaller::GetInstance()->AsyncGetSanitizedUsername( |
80 attempt->username, | 81 cryptohome_id, base::Bind(&TriggerResolveResult, attempt, resolver)); |
81 base::Bind(&TriggerResolveResult, attempt, resolver)); | |
82 } | 82 } |
83 | 83 |
84 // Calls cryptohome's addKey method. | 84 // Calls cryptohome's addKey method. |
85 void AddKey(SupervisedUserAuthenticator::AuthAttempt* attempt, | 85 void AddKey(SupervisedUserAuthenticator::AuthAttempt* attempt, |
86 scoped_refptr<SupervisedUserAuthenticator> resolver, | 86 scoped_refptr<SupervisedUserAuthenticator> resolver, |
87 const std::string& plain_text_master_key, | 87 const std::string& plain_text_master_key, |
88 const std::string& system_salt) { | 88 const std::string& system_salt) { |
89 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 89 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
90 chromeos::BootTimesRecorder::Get()->AddLoginTimeMarker( | 90 chromeos::BootTimesRecorder::Get()->AddLoginTimeMarker( |
91 "CryptohomeAddKey-LMU-Start", false); | 91 "CryptohomeAddKey-LMU-Start", false); |
92 | 92 |
93 Key user_key(attempt->password); | 93 Key user_key(attempt->password); |
94 user_key.Transform(Key::KEY_TYPE_SALTED_SHA256_TOP_HALF, system_salt); | 94 user_key.Transform(Key::KEY_TYPE_SALTED_SHA256_TOP_HALF, system_salt); |
95 Key master_key(plain_text_master_key); | 95 Key master_key(plain_text_master_key); |
96 master_key.Transform(Key::KEY_TYPE_SALTED_SHA256_TOP_HALF, system_salt); | 96 master_key.Transform(Key::KEY_TYPE_SALTED_SHA256_TOP_HALF, system_salt); |
| 97 const AccountId account_id = user_manager::known_user::GetAccountId( |
| 98 attempt->username, std::string() /* gaia_id */); |
97 cryptohome::AsyncMethodCaller::GetInstance()->AsyncAddKey( | 99 cryptohome::AsyncMethodCaller::GetInstance()->AsyncAddKey( |
98 attempt->username, | 100 cryptohome::Identification(account_id), user_key.GetSecret(), |
99 user_key.GetSecret(), | |
100 master_key.GetSecret(), | 101 master_key.GetSecret(), |
101 base::Bind(&TriggerResolveWithLoginTimeMarker, | 102 base::Bind(&TriggerResolveWithLoginTimeMarker, "CryptohomeAddKey-LMU-End", |
102 "CryptohomeAddKey-LMU-End", | 103 attempt, resolver)); |
103 attempt, | |
104 resolver)); | |
105 } | 104 } |
106 | 105 |
107 } // namespace | 106 } // namespace |
108 | 107 |
109 SupervisedUserAuthenticator::SupervisedUserAuthenticator( | 108 SupervisedUserAuthenticator::SupervisedUserAuthenticator( |
110 AuthStatusConsumer* consumer) | 109 AuthStatusConsumer* consumer) |
111 : consumer_(consumer) {} | 110 : consumer_(consumer) {} |
112 | 111 |
113 void SupervisedUserAuthenticator::AuthenticateToMount( | 112 void SupervisedUserAuthenticator::AuthenticateToMount( |
114 const std::string& username, | 113 const std::string& username, |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
337 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 336 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
338 return hash_obtained_; | 337 return hash_obtained_; |
339 } | 338 } |
340 | 339 |
341 std::string SupervisedUserAuthenticator::AuthAttempt::hash() { | 340 std::string SupervisedUserAuthenticator::AuthAttempt::hash() { |
342 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 341 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
343 return hash_; | 342 return hash_; |
344 } | 343 } |
345 | 344 |
346 } // namespace chromeos | 345 } // namespace chromeos |
OLD | NEW |