OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/lock.h" | 12 #include "base/lock.h" |
13 #include "base/logging.h" | 13 #include "base/logging.h" |
14 #include "base/path_service.h" | 14 #include "base/path_service.h" |
15 #include "base/sha2.h" | 15 #include "base/sha2.h" |
16 #include "base/string_util.h" | 16 #include "base/string_util.h" |
17 #include "base/third_party/nss/blapi.h" | 17 #include "base/third_party/nss/blapi.h" |
18 #include "base/third_party/nss/sha256.h" | 18 #include "base/third_party/nss/sha256.h" |
19 #include "chrome/browser/browser_process.h" | 19 #include "chrome/browser/browser_process.h" |
20 #include "chrome/browser/chrome_thread.h" | 20 #include "chrome/browser/chrome_thread.h" |
21 #include "chrome/browser/chromeos/cros/cryptohome_library.h" | 21 #include "chrome/browser/chromeos/cros/cryptohome_library.h" |
22 #include "chrome/browser/chromeos/login/auth_response_handler.h" | 22 #include "chrome/browser/chromeos/login/auth_response_handler.h" |
23 #include "chrome/browser/chromeos/login/authentication_notification_details.h" | 23 #include "chrome/browser/chromeos/login/authentication_notification_details.h" |
24 #include "chrome/browser/chromeos/login/login_status_consumer.h" | 24 #include "chrome/browser/chromeos/login/login_status_consumer.h" |
25 #include "chrome/browser/profile.h" | 25 #include "chrome/browser/profile.h" |
26 #include "chrome/browser/profile_manager.h" | 26 #include "chrome/browser/profile_manager.h" |
27 #include "chrome/common/chrome_paths.h" | 27 #include "chrome/common/chrome_paths.h" |
28 #include "chrome/common/net/gaia/gaia_authenticator2.h" | 28 #include "chrome/common/net/gaia/gaia_authenticator2.h" |
| 29 #include "chrome/common/net/gaia/gaia_constants.h" |
29 #include "chrome/common/notification_service.h" | 30 #include "chrome/common/notification_service.h" |
30 #include "net/base/load_flags.h" | 31 #include "net/base/load_flags.h" |
31 #include "net/base/net_errors.h" | 32 #include "net/base/net_errors.h" |
32 #include "net/url_request/url_request_status.h" | 33 #include "net/url_request/url_request_status.h" |
33 #include "third_party/libjingle/source/talk/base/urlencode.h" | 34 #include "third_party/libjingle/source/talk/base/urlencode.h" |
34 | 35 |
35 using base::Time; | 36 using base::Time; |
36 using base::TimeDelta; | 37 using base::TimeDelta; |
37 using file_util::GetFileSize; | 38 using file_util::GetFileSize; |
38 using file_util::PathExists; | 39 using file_util::PathExists; |
(...skipping 25 matching lines...) Expand all Loading... |
64 void GoogleAuthenticator::CancelClientLogin() { | 65 void GoogleAuthenticator::CancelClientLogin() { |
65 if (gaia_authenticator_->HasPendingFetch()) { | 66 if (gaia_authenticator_->HasPendingFetch()) { |
66 gaia_authenticator_->CancelRequest(); | 67 gaia_authenticator_->CancelRequest(); |
67 OnLoginFailure("Login has timed out; please try again!"); | 68 OnLoginFailure("Login has timed out; please try again!"); |
68 } | 69 } |
69 } | 70 } |
70 | 71 |
71 void GoogleAuthenticator::TryClientLogin() { | 72 void GoogleAuthenticator::TryClientLogin() { |
72 gaia_authenticator_->StartClientLogin(username_, | 73 gaia_authenticator_->StartClientLogin(username_, |
73 password_, | 74 password_, |
74 GaiaAuthenticator2::kContactsService, | 75 GaiaConstants::kContactsService, |
75 login_token_, | 76 login_token_, |
76 login_captcha_); | 77 login_captcha_); |
77 ChromeThread::PostDelayedTask( | 78 ChromeThread::PostDelayedTask( |
78 ChromeThread::UI, | 79 ChromeThread::UI, |
79 FROM_HERE, | 80 FROM_HERE, |
80 NewRunnableMethod(this, | 81 NewRunnableMethod(this, |
81 &GoogleAuthenticator::CancelClientLogin), | 82 &GoogleAuthenticator::CancelClientLogin), |
82 kClientLoginTimeoutMs); | 83 kClientLoginTimeoutMs); |
83 } | 84 } |
84 | 85 |
(...skipping 22 matching lines...) Expand all Loading... |
107 const std::string& login_captcha) { | 108 const std::string& login_captcha) { |
108 unlock_ = false; | 109 unlock_ = false; |
109 | 110 |
110 // TODO(cmasone): Figure out how to parallelize fetch, username/password | 111 // TODO(cmasone): Figure out how to parallelize fetch, username/password |
111 // processing without impacting testability. | 112 // processing without impacting testability. |
112 username_.assign(Canonicalize(username)); | 113 username_.assign(Canonicalize(username)); |
113 ascii_hash_.assign(HashPassword(password)); | 114 ascii_hash_.assign(HashPassword(password)); |
114 | 115 |
115 gaia_authenticator_.reset( | 116 gaia_authenticator_.reset( |
116 new GaiaAuthenticator2(this, | 117 new GaiaAuthenticator2(this, |
117 GaiaAuthenticator2::kChromeOSSource, | 118 GaiaConstants::kChromeOSSource, |
118 profile->GetRequestContext())); | 119 profile->GetRequestContext())); |
119 // Will be used for retries. | 120 // Will be used for retries. |
120 PrepareClientLoginAttempt(password, login_token, login_captcha); | 121 PrepareClientLoginAttempt(password, login_token, login_captcha); |
121 TryClientLogin(); | 122 TryClientLogin(); |
122 return true; | 123 return true; |
123 } | 124 } |
124 | 125 |
125 bool GoogleAuthenticator::AuthenticateToUnlock(const std::string& username, | 126 bool GoogleAuthenticator::AuthenticateToUnlock(const std::string& username, |
126 const std::string& password) { | 127 const std::string& password) { |
127 username_.assign(Canonicalize(username)); | 128 username_.assign(Canonicalize(username)); |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
422 DCHECK_EQ(parts.size(), 2U) << "email_address should have only one @"; | 423 DCHECK_EQ(parts.size(), 2U) << "email_address should have only one @"; |
423 RemoveChars(parts[0], ".", &parts[0]); | 424 RemoveChars(parts[0], ".", &parts[0]); |
424 if (parts[0].find('+') != std::string::npos) | 425 if (parts[0].find('+') != std::string::npos) |
425 parts[0].erase(parts[0].find('+')); | 426 parts[0].erase(parts[0].find('+')); |
426 std::string new_email = StringToLowerASCII(JoinString(parts, at)); | 427 std::string new_email = StringToLowerASCII(JoinString(parts, at)); |
427 LOG(INFO) << "Canonicalized " << email_address << " to " << new_email; | 428 LOG(INFO) << "Canonicalized " << email_address << " to " << new_email; |
428 return new_email; | 429 return new_email; |
429 } | 430 } |
430 | 431 |
431 } // namespace chromeos | 432 } // namespace chromeos |
OLD | NEW |