Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(206)

Side by Side Diff: chrome/browser/chromeos/login/google_authenticator.cc

Issue 2729020: Show Captcha dialog. (Closed) Base URL: git://codf21.jail/chromium.git
Patch Set: remove debug line Created 10 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 const char GoogleAuthenticator::kService[] = "cp"; 52 const char GoogleAuthenticator::kService[] = "cp";
53 // static 53 // static
54 const char GoogleAuthenticator::kFormat[] = 54 const char GoogleAuthenticator::kFormat[] =
55 "Email=%s&" 55 "Email=%s&"
56 "Passwd=%s&" 56 "Passwd=%s&"
57 "PersistentCookie=%s&" 57 "PersistentCookie=%s&"
58 "accountType=%s&" 58 "accountType=%s&"
59 "source=%s&" 59 "source=%s&"
60 "service=%s"; 60 "service=%s";
61 // static 61 // static
62 const char GoogleAuthenticator::kFormatCaptcha[] =
63 "Email=%s&"
64 "Passwd=%s&"
65 "PersistentCookie=%s&"
66 "accountType=%s&"
67 "source=%s&"
68 "service=%s&"
69 "logintoken=%s&"
70 "logincaptcha=%s";
71 // static
62 const char GoogleAuthenticator::kSecondFactor[] = "Info=InvalidSecondFactor"; 72 const char GoogleAuthenticator::kSecondFactor[] = "Info=InvalidSecondFactor";
63 73
64 // static 74 // static
65 const char GoogleAuthenticator::kSystemSalt[] = "/home/.shadow/salt"; 75 const char GoogleAuthenticator::kSystemSalt[] = "/home/.shadow/salt";
66 // static 76 // static
67 const char GoogleAuthenticator::kOpenSSLMagic[] = "Salted__"; 77 const char GoogleAuthenticator::kOpenSSLMagic[] = "Salted__";
68 // static 78 // static
69 const char GoogleAuthenticator::kLocalaccountFile[] = "localaccount"; 79 const char GoogleAuthenticator::kLocalaccountFile[] = "localaccount";
70 // static 80 // static
71 const char GoogleAuthenticator::kTmpfsTrigger[] = "incognito"; 81 const char GoogleAuthenticator::kTmpfsTrigger[] = "incognito";
(...skipping 23 matching lines...) Expand all
95 URLFetcher::Create(0, 105 URLFetcher::Create(0,
96 GURL(AuthResponseHandler::kClientLoginUrl), 106 GURL(AuthResponseHandler::kClientLoginUrl),
97 URLFetcher::POST, 107 URLFetcher::POST,
98 delegate); 108 delegate);
99 to_return->set_request_context(getter); 109 to_return->set_request_context(getter);
100 to_return->set_load_flags(net::LOAD_DO_NOT_SEND_COOKIES); 110 to_return->set_load_flags(net::LOAD_DO_NOT_SEND_COOKIES);
101 to_return->set_upload_data("application/x-www-form-urlencoded", body); 111 to_return->set_upload_data("application/x-www-form-urlencoded", body);
102 return to_return; 112 return to_return;
103 } 113 }
104 114
105 bool GoogleAuthenticator::AuthenticateToLogin(Profile* profile, 115 bool GoogleAuthenticator::AuthenticateToLogin(
106 const std::string& username, 116 Profile* profile,
107 const std::string& password) { 117 const std::string& username,
118 const std::string& password,
119 const std::string& login_token,
120 const std::string& login_captcha) {
108 unlock_ = false; 121 unlock_ = false;
109 getter_ = profile->GetRequestContext(); 122 getter_ = profile->GetRequestContext();
110 123
111 // TODO(cmasone): be more careful about zeroing memory that stores 124 // TODO(cmasone): be more careful about zeroing memory that stores
112 // the user's password. 125 // the user's password.
113 request_body_ = StringPrintf(kFormat, 126 if (login_token.empty() || login_captcha.empty()) {
114 UrlEncodeString(username).c_str(), 127 request_body_ = StringPrintf(kFormat,
115 UrlEncodeString(password).c_str(), 128 UrlEncodeString(username).c_str(),
116 kCookiePersistence, 129 UrlEncodeString(password).c_str(),
117 kAccountType, 130 kCookiePersistence,
118 kSource, 131 kAccountType,
119 kService); 132 kSource,
133 kService);
134 } else {
135 request_body_ = StringPrintf(kFormatCaptcha,
136 UrlEncodeString(username).c_str(),
137 UrlEncodeString(password).c_str(),
138 kCookiePersistence,
139 kAccountType,
140 kSource,
141 kService,
142 UrlEncodeString(login_token).c_str(),
143 UrlEncodeString(login_captcha).c_str());
144 }
120 // TODO(cmasone): Figure out how to parallelize fetch, username/password 145 // TODO(cmasone): Figure out how to parallelize fetch, username/password
121 // processing without impacting testability. 146 // processing without impacting testability.
122 username_.assign(Canonicalize(username)); 147 username_.assign(Canonicalize(username));
123 StoreHashedPassword(password); 148 StoreHashedPassword(password);
124 TryClientLogin(); 149 TryClientLogin();
125 return true; 150 return true;
126 } 151 }
127 152
128 bool GoogleAuthenticator::AuthenticateToUnlock(const std::string& username, 153 bool GoogleAuthenticator::AuthenticateToUnlock(const std::string& username,
129 const std::string& password) { 154 const std::string& password) {
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 DCHECK_EQ(parts.size(), 2U) << "email_address should have only one @"; 384 DCHECK_EQ(parts.size(), 2U) << "email_address should have only one @";
360 RemoveChars(parts[0], ".", &parts[0]); 385 RemoveChars(parts[0], ".", &parts[0]);
361 if (parts[0].find('+') != std::string::npos) 386 if (parts[0].find('+') != std::string::npos)
362 parts[0].erase(parts[0].find('+')); 387 parts[0].erase(parts[0].find('+'));
363 std::string new_email = StringToLowerASCII(JoinString(parts, at)); 388 std::string new_email = StringToLowerASCII(JoinString(parts, at));
364 LOG(INFO) << "Canonicalized " << email_address << " to " << new_email; 389 LOG(INFO) << "Canonicalized " << email_address << " to " << new_email;
365 return new_email; 390 return new_email;
366 } 391 }
367 392
368 } // namespace chromeos 393 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/google_authenticator.h ('k') | chrome/browser/chromeos/login/google_authenticator_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698