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_authenticatio
n.h" | 5 #include "chrome/browser/chromeos/login/supervised/supervised_user_authenticatio
n.h" |
6 | 6 |
7 #include "base/base64.h" | 7 #include "base/base64.h" |
8 #include "base/json/json_file_value_serializer.h" | 8 #include "base/json/json_file_value_serializer.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/metrics/histogram_macros.h" | 10 #include "base/metrics/histogram_macros.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 "base/threading/sequenced_worker_pool.h" | 13 #include "base/task_scheduler/post_task.h" |
14 #include "chrome/browser/chromeos/login/supervised/supervised_user_constants.h" | 14 #include "chrome/browser/chromeos/login/supervised/supervised_user_constants.h" |
15 #include "chrome/browser/chromeos/login/users/supervised_user_manager.h" | 15 #include "chrome/browser/chromeos/login/users/supervised_user_manager.h" |
16 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 16 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
17 #include "chromeos/cryptohome/signed_secret.pb.h" | 17 #include "chromeos/cryptohome/signed_secret.pb.h" |
18 #include "chromeos/login/auth/key.h" | 18 #include "chromeos/login/auth/key.h" |
19 #include "components/user_manager/user.h" | 19 #include "components/user_manager/user.h" |
20 #include "components/user_manager/user_manager.h" | 20 #include "components/user_manager/user_manager.h" |
21 #include "content/public/browser/browser_thread.h" | |
22 #include "crypto/hmac.h" | 21 #include "crypto/hmac.h" |
23 #include "crypto/random.h" | 22 #include "crypto/random.h" |
24 #include "crypto/symmetric_key.h" | 23 #include "crypto/symmetric_key.h" |
25 | 24 |
26 namespace chromeos { | 25 namespace chromeos { |
27 | 26 |
28 namespace { | 27 namespace { |
29 | 28 |
30 // Byte size of hash salt. | 29 // Byte size of hash salt. |
31 const unsigned kSaltSize = 32; | 30 const unsigned kSaltSize = 32; |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 } | 280 } |
282 | 281 |
283 void SupervisedUserAuthentication::LoadPasswordUpdateData( | 282 void SupervisedUserAuthentication::LoadPasswordUpdateData( |
284 const std::string& user_id, | 283 const std::string& user_id, |
285 const PasswordDataCallback& success_callback, | 284 const PasswordDataCallback& success_callback, |
286 const base::Closure& failure_callback) { | 285 const base::Closure& failure_callback) { |
287 const user_manager::User* user = user_manager::UserManager::Get()->FindUser( | 286 const user_manager::User* user = user_manager::UserManager::Get()->FindUser( |
288 AccountId::FromUserEmail(user_id)); | 287 AccountId::FromUserEmail(user_id)); |
289 base::FilePath profile_path = | 288 base::FilePath profile_path = |
290 ProfileHelper::GetProfilePathByUserIdHash(user->username_hash()); | 289 ProfileHelper::GetProfilePathByUserIdHash(user->username_hash()); |
291 PostTaskAndReplyWithResult( | 290 PostTaskWithTraitsAndReplyWithResult( |
292 content::BrowserThread::GetBlockingPool() | 291 FROM_HERE, |
293 ->GetTaskRunnerWithShutdownBehavior( | 292 base::TaskTraits() |
294 base::SequencedWorkerPool::CONTINUE_ON_SHUTDOWN) | 293 .MayBlock() |
295 .get(), | 294 .WithPriority(base::TaskPriority::BACKGROUND) |
296 FROM_HERE, base::Bind(&LoadPasswordData, profile_path), | 295 .WithShutdownBehavior( |
297 base::Bind(&OnPasswordDataLoaded, success_callback, failure_callback)); | 296 base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN), |
| 297 base::BindOnce(&LoadPasswordData, profile_path), |
| 298 base::BindOnce(&OnPasswordDataLoaded, success_callback, |
| 299 failure_callback)); |
298 } | 300 } |
299 | 301 |
300 std::string SupervisedUserAuthentication::BuildPasswordSignature( | 302 std::string SupervisedUserAuthentication::BuildPasswordSignature( |
301 const std::string& password, | 303 const std::string& password, |
302 int revision, | 304 int revision, |
303 const std::string& base64_signature_key) { | 305 const std::string& base64_signature_key) { |
304 ac::chrome::managedaccounts::account::Secret secret; | 306 ac::chrome::managedaccounts::account::Secret secret; |
305 secret.set_revision(revision); | 307 secret.set_revision(revision); |
306 secret.set_secret(password); | 308 secret.set_secret(password); |
307 std::string buffer; | 309 std::string buffer; |
(...skipping 11 matching lines...) Expand all Loading... |
319 LOG(FATAL) << "HMAC::Sign failed"; | 321 LOG(FATAL) << "HMAC::Sign failed"; |
320 | 322 |
321 std::string raw_result(out_bytes, out_bytes + sizeof(out_bytes)); | 323 std::string raw_result(out_bytes, out_bytes + sizeof(out_bytes)); |
322 | 324 |
323 std::string result; | 325 std::string result; |
324 base::Base64Encode(raw_result, &result); | 326 base::Base64Encode(raw_result, &result); |
325 return result; | 327 return result; |
326 } | 328 } |
327 | 329 |
328 } // namespace chromeos | 330 } // namespace chromeos |
OLD | NEW |