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/auth/extended_authenticator.h" | 5 #include "chrome/browser/chromeos/login/auth/extended_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_loader.h" | 10 #include "chrome/browser/chromeos/boot_times_loader.h" |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 | 101 |
102 RecordStartMarker("MountEx"); | 102 RecordStartMarker("MountEx"); |
103 | 103 |
104 std::string canonicalized = gaia::CanonicalizeEmail(user_id); | 104 std::string canonicalized = gaia::CanonicalizeEmail(user_id); |
105 cryptohome::Identification id(canonicalized); | 105 cryptohome::Identification id(canonicalized); |
106 cryptohome::Authorization auth(keys.front()); | 106 cryptohome::Authorization auth(keys.front()); |
107 cryptohome::MountParameters mount(false); | 107 cryptohome::MountParameters mount(false); |
108 for (size_t i = 0; i < keys.size(); i++) { | 108 for (size_t i = 0; i < keys.size(); i++) { |
109 mount.create_keys.push_back(keys[i]); | 109 mount.create_keys.push_back(keys[i]); |
110 } | 110 } |
111 UserContext context(user_id, keys.front().key, std::string()); | 111 UserContext context(user_id); |
| 112 context.SetPassword(keys.front().key); |
112 context.SetKeyLabel(keys.front().label); | 113 context.SetKeyLabel(keys.front().label); |
113 | 114 |
114 cryptohome::HomedirMethods::GetInstance()->MountEx( | 115 cryptohome::HomedirMethods::GetInstance()->MountEx( |
115 id, | 116 id, |
116 auth, | 117 auth, |
117 mount, | 118 mount, |
118 base::Bind(&ExtendedAuthenticator::OnMountComplete, | 119 base::Bind(&ExtendedAuthenticator::OnMountComplete, |
119 this, | 120 this, |
120 "MountEx", | 121 "MountEx", |
121 context, | 122 context, |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 void ExtendedAuthenticator::OnMountComplete( | 283 void ExtendedAuthenticator::OnMountComplete( |
283 const std::string& time_marker, | 284 const std::string& time_marker, |
284 const UserContext& user_context, | 285 const UserContext& user_context, |
285 const HashSuccessCallback& success_callback, | 286 const HashSuccessCallback& success_callback, |
286 bool success, | 287 bool success, |
287 cryptohome::MountError return_code, | 288 cryptohome::MountError return_code, |
288 const std::string& mount_hash) { | 289 const std::string& mount_hash) { |
289 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 290 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
290 | 291 |
291 RecordEndMarker(time_marker); | 292 RecordEndMarker(time_marker); |
292 UserContext copy; | 293 UserContext copy = user_context; |
293 copy.CopyFrom(user_context); | |
294 copy.SetUserIDHash(mount_hash); | 294 copy.SetUserIDHash(mount_hash); |
295 if (return_code == cryptohome::MOUNT_ERROR_NONE) { | 295 if (return_code == cryptohome::MOUNT_ERROR_NONE) { |
296 if (!success_callback.is_null()) | 296 if (!success_callback.is_null()) |
297 success_callback.Run(mount_hash); | 297 success_callback.Run(mount_hash); |
298 if (old_consumer_) | 298 if (old_consumer_) |
299 old_consumer_->OnLoginSuccess(copy); | 299 old_consumer_->OnLoginSuccess(copy); |
300 return; | 300 return; |
301 } | 301 } |
302 AuthState state = FAILED_MOUNT; | 302 AuthState state = FAILED_MOUNT; |
303 if (return_code == cryptohome::MOUNT_ERROR_TPM_COMM_ERROR || | 303 if (return_code == cryptohome::MOUNT_ERROR_TPM_COMM_ERROR || |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
374 callback), | 374 callback), |
375 system_salt_); | 375 system_salt_); |
376 } | 376 } |
377 } | 377 } |
378 | 378 |
379 void ExtendedAuthenticator::DidTransformContext( | 379 void ExtendedAuthenticator::DidTransformContext( |
380 const UserContext& user_context, | 380 const UserContext& user_context, |
381 const ContextCallback& callback, | 381 const ContextCallback& callback, |
382 const std::string& hashed_password) { | 382 const std::string& hashed_password) { |
383 DCHECK(user_context.DoesNeedPasswordHashing()); | 383 DCHECK(user_context.DoesNeedPasswordHashing()); |
384 UserContext context; | 384 UserContext context = user_context; |
385 context.CopyFrom(user_context); | |
386 context.SetPassword(hashed_password); | 385 context.SetPassword(hashed_password); |
387 context.SetDoesNeedPasswordHashing(false); | 386 context.SetDoesNeedPasswordHashing(false); |
388 callback.Run(context); | 387 callback.Run(context); |
389 } | 388 } |
390 | 389 |
391 void ExtendedAuthenticator::DoHashWithSalt(const std::string& password, | 390 void ExtendedAuthenticator::DoHashWithSalt(const std::string& password, |
392 const HashSuccessCallback& callback, | 391 const HashSuccessCallback& callback, |
393 const std::string& system_salt) { | 392 const std::string& system_salt) { |
394 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 393 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
395 | 394 |
396 if (salt_obtained_) { | 395 if (salt_obtained_) { |
397 std::string hash = | 396 std::string hash = |
398 ParallelAuthenticator::HashPassword(password, system_salt); | 397 ParallelAuthenticator::HashPassword(password, system_salt); |
399 callback.Run(hash); | 398 callback.Run(hash); |
400 return; | 399 return; |
401 } | 400 } |
402 hashing_queue_.push_back(base::Bind( | 401 hashing_queue_.push_back(base::Bind( |
403 &ExtendedAuthenticator::DoHashWithSalt, this, password, callback)); | 402 &ExtendedAuthenticator::DoHashWithSalt, this, password, callback)); |
404 } | 403 } |
405 | 404 |
406 } // namespace chromeos | 405 } // namespace chromeos |
OLD | NEW |