OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/common/net/gaia/gaia_authenticator.h" | 5 #include "chrome/common/net/gaia/gaia_authenticator.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <utility> | 8 #include <utility> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 | 151 |
152 return PerformGaiaRequest(params, results); | 152 return PerformGaiaRequest(params, results); |
153 } | 153 } |
154 | 154 |
155 bool GaiaAuthenticator::PerformGaiaRequest(const AuthParams& params, | 155 bool GaiaAuthenticator::PerformGaiaRequest(const AuthParams& params, |
156 AuthResults* results) { | 156 AuthResults* results) { |
157 DCHECK_EQ(MessageLoop::current(), message_loop_); | 157 DCHECK_EQ(MessageLoop::current(), message_loop_); |
158 GURL gaia_auth_url(gaia_url_); | 158 GURL gaia_auth_url(gaia_url_); |
159 | 159 |
160 string post_body; | 160 string post_body; |
161 post_body += "Email=" + EscapeUrlEncodedData(params.email); | 161 post_body += "Email=" + EscapeUrlEncodedData(params.email, true); |
162 post_body += "&Passwd=" + EscapeUrlEncodedData(params.password); | 162 post_body += "&Passwd=" + EscapeUrlEncodedData(params.password, true); |
163 post_body += "&source=" + EscapeUrlEncodedData(user_agent_); | 163 post_body += "&source=" + EscapeUrlEncodedData(user_agent_, true); |
164 post_body += "&service=" + service_id_; | 164 post_body += "&service=" + service_id_; |
165 if (!params.captcha_token.empty() && !params.captcha_value.empty()) { | 165 if (!params.captcha_token.empty() && !params.captcha_value.empty()) { |
166 post_body += "&logintoken=" + EscapeUrlEncodedData(params.captcha_token); | 166 post_body += "&logintoken=" + |
167 post_body += "&logincaptcha=" + EscapeUrlEncodedData(params.captcha_value); | 167 EscapeUrlEncodedData(params.captcha_token, true); |
| 168 post_body += "&logincaptcha=" + |
| 169 EscapeUrlEncodedData(params.captcha_value, true); |
168 } | 170 } |
169 post_body += "&PersistentCookie=true"; | 171 post_body += "&PersistentCookie=true"; |
170 // We set it to GOOGLE (and not HOSTED or HOSTED_OR_GOOGLE) because we only | 172 // We set it to GOOGLE (and not HOSTED or HOSTED_OR_GOOGLE) because we only |
171 // allow consumer logins. | 173 // allow consumer logins. |
172 post_body += "&accountType=GOOGLE"; | 174 post_body += "&accountType=GOOGLE"; |
173 | 175 |
174 string message_text; | 176 string message_text; |
175 unsigned long server_response_code; | 177 unsigned long server_response_code; |
176 if (!Post(gaia_auth_url, post_body, &server_response_code, &message_text)) { | 178 if (!Post(gaia_auth_url, post_body, &server_response_code, &message_text)) { |
177 results->auth_error = ConnectionUnavailable; | 179 results->auth_error = ConnectionUnavailable; |
(...skipping 30 matching lines...) Expand all Loading... |
208 // Use the provided Gaia server, but change the path to what V1 expects. | 210 // Use the provided Gaia server, but change the path to what V1 expects. |
209 GURL url(gaia_url_); // Gaia server. | 211 GURL url(gaia_url_); // Gaia server. |
210 GURL::Replacements repl; | 212 GURL::Replacements repl; |
211 // Needs to stay in scope till GURL is out of scope. | 213 // Needs to stay in scope till GURL is out of scope. |
212 string path(kGetUserInfoPath); | 214 string path(kGetUserInfoPath); |
213 repl.SetPathStr(path); | 215 repl.SetPathStr(path); |
214 url = url.ReplaceComponents(repl); | 216 url = url.ReplaceComponents(repl); |
215 | 217 |
216 string post_body; | 218 string post_body; |
217 post_body += "LSID="; | 219 post_body += "LSID="; |
218 post_body += EscapeUrlEncodedData(results->lsid); | 220 post_body += EscapeUrlEncodedData(results->lsid, true); |
219 | 221 |
220 unsigned long server_response_code; | 222 unsigned long server_response_code; |
221 string message_text; | 223 string message_text; |
222 if (!Post(url, post_body, &server_response_code, &message_text)) { | 224 if (!Post(url, post_body, &server_response_code, &message_text)) { |
223 return false; | 225 return false; |
224 } | 226 } |
225 | 227 |
226 // Check if we received a valid AuthToken; if not, ignore it. | 228 // Check if we received a valid AuthToken; if not, ignore it. |
227 if (RC_FORBIDDEN == server_response_code) { | 229 if (RC_FORBIDDEN == server_response_code) { |
228 // Server says we're not authenticated. | 230 // Server says we're not authenticated. |
(...skipping 29 matching lines...) Expand all Loading... |
258 // Use the provided Gaia server, but change the path to what V1 expects. | 260 // Use the provided Gaia server, but change the path to what V1 expects. |
259 GURL url(gaia_url_); // Gaia server. | 261 GURL url(gaia_url_); // Gaia server. |
260 GURL::Replacements repl; | 262 GURL::Replacements repl; |
261 // Needs to stay in scope till GURL is out of scope. | 263 // Needs to stay in scope till GURL is out of scope. |
262 string path(kGaiaV1IssueAuthTokenPath); | 264 string path(kGaiaV1IssueAuthTokenPath); |
263 repl.SetPathStr(path); | 265 repl.SetPathStr(path); |
264 url = url.ReplaceComponents(repl); | 266 url = url.ReplaceComponents(repl); |
265 | 267 |
266 string post_body; | 268 string post_body; |
267 post_body += "LSID="; | 269 post_body += "LSID="; |
268 post_body += EscapeUrlEncodedData(results->lsid); | 270 post_body += EscapeUrlEncodedData(results->lsid, true); |
269 post_body += "&service=" + service_id; | 271 post_body += "&service=" + service_id; |
270 post_body += "&Session=true"; | 272 post_body += "&Session=true"; |
271 | 273 |
272 unsigned long server_response_code; | 274 unsigned long server_response_code; |
273 string message_text; | 275 string message_text; |
274 if (!Post(url, post_body, &server_response_code, &message_text)) { | 276 if (!Post(url, post_body, &server_response_code, &message_text)) { |
275 return false; | 277 return false; |
276 } | 278 } |
277 | 279 |
278 // Check if we received a valid AuthToken; if not, ignore it. | 280 // Check if we received a valid AuthToken; if not, ignore it. |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
388 bool GaiaAuthenticator::Authenticate(const string& user_name, | 390 bool GaiaAuthenticator::Authenticate(const string& user_name, |
389 const string& password) { | 391 const string& password) { |
390 DCHECK_EQ(MessageLoop::current(), message_loop_); | 392 DCHECK_EQ(MessageLoop::current(), message_loop_); |
391 const string empty; | 393 const string empty; |
392 return Authenticate(user_name, password, empty, | 394 return Authenticate(user_name, password, empty, |
393 empty); | 395 empty); |
394 } | 396 } |
395 | 397 |
396 } // namepace gaia | 398 } // namepace gaia |
397 | 399 |
OLD | NEW |