| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/google_authenticator.h" | 5 #include "chrome/browser/chromeos/login/google_authenticator.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
| 11 #include "base/file_util.h" | 11 #include "base/file_util.h" |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/path_service.h" | 13 #include "base/path_service.h" |
| 14 #include "base/string_util.h" | 14 #include "base/string_util.h" |
| 15 #include "base/synchronization/lock.h" | 15 #include "base/synchronization/lock.h" |
| 16 #include "crypto/third_party/nss/blapi.h" | 16 #include "crypto/third_party/nss/blapi.h" |
| 17 #include "crypto/third_party/nss/sha256.h" | 17 #include "crypto/third_party/nss/sha256.h" |
| 18 #include "chrome/browser/chromeos/boot_times_loader.h" | 18 #include "chrome/browser/chromeos/boot_times_loader.h" |
| 19 #include "chrome/browser/chromeos/cros/cryptohome_library.h" | 19 #include "chrome/browser/chromeos/cros/cryptohome_library.h" |
| 20 #include "chrome/browser/chromeos/login/auth_response_handler.h" | 20 #include "chrome/browser/chromeos/login/auth_response_handler.h" |
| 21 #include "chrome/browser/chromeos/login/authentication_notification_details.h" | 21 #include "chrome/browser/chromeos/login/authentication_notification_details.h" |
| 22 #include "chrome/browser/chromeos/login/login_status_consumer.h" | 22 #include "chrome/browser/chromeos/login/login_status_consumer.h" |
| 23 #include "chrome/browser/chromeos/login/ownership_service.h" | 23 #include "chrome/browser/chromeos/login/ownership_service.h" |
| 24 #include "chrome/browser/chromeos/login/user_manager.h" | 24 #include "chrome/browser/chromeos/login/user_manager.h" |
| 25 #include "chrome/browser/profiles/profile.h" | 25 #include "chrome/browser/profiles/profile.h" |
| 26 #include "chrome/browser/profiles/profile_manager.h" | 26 #include "chrome/browser/profiles/profile_manager.h" |
| 27 #include "chrome/common/chrome_notification_types.h" |
| 27 #include "chrome/common/chrome_paths.h" | 28 #include "chrome/common/chrome_paths.h" |
| 28 #include "chrome/common/net/gaia/gaia_auth_fetcher.h" | 29 #include "chrome/common/net/gaia/gaia_auth_fetcher.h" |
| 29 #include "chrome/common/net/gaia/gaia_constants.h" | 30 #include "chrome/common/net/gaia/gaia_constants.h" |
| 30 #include "content/browser/browser_thread.h" | 31 #include "content/browser/browser_thread.h" |
| 31 #include "content/common/notification_service.h" | 32 #include "content/common/notification_service.h" |
| 32 #include "net/base/load_flags.h" | 33 #include "net/base/load_flags.h" |
| 33 #include "net/base/net_errors.h" | 34 #include "net/base/net_errors.h" |
| 34 #include "net/url_request/url_request_status.h" | 35 #include "net/url_request/url_request_status.h" |
| 35 #include "third_party/libjingle/source/talk/base/urlencode.h" | 36 #include "third_party/libjingle/source/talk/base/urlencode.h" |
| 36 | 37 |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 LoginFailure(LoginFailure::UNLOCK_FAILED))); | 159 LoginFailure(LoginFailure::UNLOCK_FAILED))); |
| 159 return true; | 160 return true; |
| 160 } | 161 } |
| 161 | 162 |
| 162 void GoogleAuthenticator::LoginOffTheRecord() { | 163 void GoogleAuthenticator::LoginOffTheRecord() { |
| 163 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 164 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 164 int mount_error = chromeos::kCryptohomeMountErrorNone; | 165 int mount_error = chromeos::kCryptohomeMountErrorNone; |
| 165 if (CrosLibrary::Get()->GetCryptohomeLibrary()->MountForBwsi(&mount_error)) { | 166 if (CrosLibrary::Get()->GetCryptohomeLibrary()->MountForBwsi(&mount_error)) { |
| 166 AuthenticationNotificationDetails details(true); | 167 AuthenticationNotificationDetails details(true); |
| 167 NotificationService::current()->Notify( | 168 NotificationService::current()->Notify( |
| 168 NotificationType::LOGIN_AUTHENTICATION, | 169 chrome::NOTIFICATION_LOGIN_AUTHENTICATION, |
| 169 NotificationService::AllSources(), | 170 NotificationService::AllSources(), |
| 170 Details<AuthenticationNotificationDetails>(&details)); | 171 Details<AuthenticationNotificationDetails>(&details)); |
| 171 consumer_->OnOffTheRecordLoginSuccess(); | 172 consumer_->OnOffTheRecordLoginSuccess(); |
| 172 } else { | 173 } else { |
| 173 LOG(ERROR) << "Could not mount tmpfs: " << mount_error; | 174 LOG(ERROR) << "Could not mount tmpfs: " << mount_error; |
| 174 consumer_->OnLoginFailure( | 175 consumer_->OnLoginFailure( |
| 175 LoginFailure(LoginFailure::COULD_NOT_MOUNT_TMPFS)); | 176 LoginFailure(LoginFailure::COULD_NOT_MOUNT_TMPFS)); |
| 176 } | 177 } |
| 177 } | 178 } |
| 178 | 179 |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 &GoogleAuthenticator::CheckLocalaccount, | 269 &GoogleAuthenticator::CheckLocalaccount, |
| 269 failure_details)); | 270 failure_details)); |
| 270 } | 271 } |
| 271 | 272 |
| 272 void GoogleAuthenticator::OnLoginSuccess( | 273 void GoogleAuthenticator::OnLoginSuccess( |
| 273 const GaiaAuthConsumer::ClientLoginResult& credentials, | 274 const GaiaAuthConsumer::ClientLoginResult& credentials, |
| 274 bool request_pending) { | 275 bool request_pending) { |
| 275 // Send notification of success | 276 // Send notification of success |
| 276 AuthenticationNotificationDetails details(true); | 277 AuthenticationNotificationDetails details(true); |
| 277 NotificationService::current()->Notify( | 278 NotificationService::current()->Notify( |
| 278 NotificationType::LOGIN_AUTHENTICATION, | 279 chrome::NOTIFICATION_LOGIN_AUTHENTICATION, |
| 279 NotificationService::AllSources(), | 280 NotificationService::AllSources(), |
| 280 Details<AuthenticationNotificationDetails>(&details)); | 281 Details<AuthenticationNotificationDetails>(&details)); |
| 281 | 282 |
| 282 int mount_error = chromeos::kCryptohomeMountErrorNone; | 283 int mount_error = chromeos::kCryptohomeMountErrorNone; |
| 283 BootTimesLoader::Get()->AddLoginTimeMarker("CryptohomeMounting", false); | 284 BootTimesLoader::Get()->AddLoginTimeMarker("CryptohomeMounting", false); |
| 284 if (unlock_ || | 285 if (unlock_ || |
| 285 (CrosLibrary::Get()->GetCryptohomeLibrary()->Mount(username_.c_str(), | 286 (CrosLibrary::Get()->GetCryptohomeLibrary()->Mount(username_.c_str(), |
| 286 ascii_hash_.c_str(), | 287 ascii_hash_.c_str(), |
| 287 &mount_error))) { | 288 &mount_error))) { |
| 288 BootTimesLoader::Get()->AddLoginTimeMarker("CryptohomeMounted", true); | 289 BootTimesLoader::Get()->AddLoginTimeMarker("CryptohomeMounted", true); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 343 } | 344 } |
| 344 } else { | 345 } else { |
| 345 OnLoginFailure(error); | 346 OnLoginFailure(error); |
| 346 } | 347 } |
| 347 } | 348 } |
| 348 | 349 |
| 349 void GoogleAuthenticator::OnLoginFailure(const LoginFailure& error) { | 350 void GoogleAuthenticator::OnLoginFailure(const LoginFailure& error) { |
| 350 // Send notification of failure | 351 // Send notification of failure |
| 351 AuthenticationNotificationDetails details(false); | 352 AuthenticationNotificationDetails details(false); |
| 352 NotificationService::current()->Notify( | 353 NotificationService::current()->Notify( |
| 353 NotificationType::LOGIN_AUTHENTICATION, | 354 chrome::NOTIFICATION_LOGIN_AUTHENTICATION, |
| 354 NotificationService::AllSources(), | 355 NotificationService::AllSources(), |
| 355 Details<AuthenticationNotificationDetails>(&details)); | 356 Details<AuthenticationNotificationDetails>(&details)); |
| 356 LOG(WARNING) << "Login failed: " << error.GetErrorString(); | 357 LOG(WARNING) << "Login failed: " << error.GetErrorString(); |
| 357 consumer_->OnLoginFailure(error); | 358 consumer_->OnLoginFailure(error); |
| 358 } | 359 } |
| 359 | 360 |
| 360 void GoogleAuthenticator::RecoverEncryptedData(const std::string& old_password, | 361 void GoogleAuthenticator::RecoverEncryptedData(const std::string& old_password, |
| 361 const GaiaAuthConsumer::ClientLoginResult& credentials) { | 362 const GaiaAuthConsumer::ClientLoginResult& credentials) { |
| 362 | 363 |
| 363 std::string old_hash = HashPassword(old_password); | 364 std::string old_hash = HashPassword(old_password); |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 479 const unsigned int len) { | 480 const unsigned int len) { |
| 480 if (len < 2*binary_len) | 481 if (len < 2*binary_len) |
| 481 return false; | 482 return false; |
| 482 memset(hex_string, 0, len); | 483 memset(hex_string, 0, len); |
| 483 for (uint i = 0, j = 0; i < binary_len; i++, j+=2) | 484 for (uint i = 0, j = 0; i < binary_len; i++, j+=2) |
| 484 snprintf(hex_string + j, len - j, "%02x", binary[i]); | 485 snprintf(hex_string + j, len - j, "%02x", binary[i]); |
| 485 return true; | 486 return true; |
| 486 } | 487 } |
| 487 | 488 |
| 488 } // namespace chromeos | 489 } // namespace chromeos |
| OLD | NEW |