OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "google_apis/gaia/fake_gaia.h" | 5 #include "google_apis/gaia/fake_gaia.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/base_paths.h" | 9 #include "base/base_paths.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
378 | 378 |
379 std::string redirect_url = continue_url; | 379 std::string redirect_url = continue_url; |
380 | 380 |
381 std::string email; | 381 std::string email; |
382 if (GetQueryParameter(request.content, "Email", &email) && | 382 if (GetQueryParameter(request.content, "Email", &email) && |
383 saml_account_idp_map_.find(email) != saml_account_idp_map_.end()) { | 383 saml_account_idp_map_.find(email) != saml_account_idp_map_.end()) { |
384 GURL url(saml_account_idp_map_[email]); | 384 GURL url(saml_account_idp_map_[email]); |
385 url = net::AppendQueryParameter(url, "SAMLRequest", "fake_request"); | 385 url = net::AppendQueryParameter(url, "SAMLRequest", "fake_request"); |
386 url = net::AppendQueryParameter(url, "RelayState", continue_url); | 386 url = net::AppendQueryParameter(url, "RelayState", continue_url); |
387 redirect_url = url.spec(); | 387 redirect_url = url.spec(); |
| 388 http_response->AddCustomHeader("Google-Accounts-SAML", "Start"); |
388 } else if (!merge_session_params_.auth_sid_cookie.empty() && | 389 } else if (!merge_session_params_.auth_sid_cookie.empty() && |
389 !merge_session_params_.auth_lsid_cookie.empty()) { | 390 !merge_session_params_.auth_lsid_cookie.empty()) { |
390 SetCookies(http_response, | 391 SetCookies(http_response, |
391 merge_session_params_.auth_sid_cookie, | 392 merge_session_params_.auth_sid_cookie, |
392 merge_session_params_.auth_lsid_cookie); | 393 merge_session_params_.auth_lsid_cookie); |
393 } | 394 } |
394 | 395 |
395 http_response->set_code(net::HTTP_TEMPORARY_REDIRECT); | 396 http_response->set_code(net::HTTP_TEMPORARY_REDIRECT); |
396 http_response->AddCustomHeader("Location", redirect_url); | 397 http_response->AddCustomHeader("Location", redirect_url); |
397 } | 398 } |
398 | 399 |
399 void FakeGaia::HandleSSO(const HttpRequest& request, | 400 void FakeGaia::HandleSSO(const HttpRequest& request, |
400 BasicHttpResponse* http_response) { | 401 BasicHttpResponse* http_response) { |
401 if (!merge_session_params_.auth_sid_cookie.empty() && | 402 if (!merge_session_params_.auth_sid_cookie.empty() && |
402 !merge_session_params_.auth_lsid_cookie.empty()) { | 403 !merge_session_params_.auth_lsid_cookie.empty()) { |
403 SetCookies(http_response, | 404 SetCookies(http_response, |
404 merge_session_params_.auth_sid_cookie, | 405 merge_session_params_.auth_sid_cookie, |
405 merge_session_params_.auth_lsid_cookie); | 406 merge_session_params_.auth_lsid_cookie); |
406 } | 407 } |
407 std::string relay_state; | 408 std::string relay_state; |
408 GetQueryParameter(request.content, "RelayState", &relay_state); | 409 GetQueryParameter(request.content, "RelayState", &relay_state); |
409 std::string redirect_url = relay_state; | 410 std::string redirect_url = relay_state; |
410 http_response->set_code(net::HTTP_TEMPORARY_REDIRECT); | 411 http_response->set_code(net::HTTP_TEMPORARY_REDIRECT); |
411 http_response->AddCustomHeader("Location", redirect_url); | 412 http_response->AddCustomHeader("Location", redirect_url); |
| 413 http_response->AddCustomHeader("Google-Accounts-SAML", "End"); |
412 } | 414 } |
413 | 415 |
414 void FakeGaia::HandleAuthToken(const HttpRequest& request, | 416 void FakeGaia::HandleAuthToken(const HttpRequest& request, |
415 BasicHttpResponse* http_response) { | 417 BasicHttpResponse* http_response) { |
416 std::string scope; | 418 std::string scope; |
417 GetQueryParameter(request.content, "scope", &scope); | 419 GetQueryParameter(request.content, "scope", &scope); |
418 | 420 |
419 std::string grant_type; | 421 std::string grant_type; |
420 if (!GetQueryParameter(request.content, "grant_type", &grant_type)) { | 422 if (!GetQueryParameter(request.content, "grant_type", &grant_type)) { |
421 http_response->set_code(net::HTTP_BAD_REQUEST); | 423 http_response->set_code(net::HTTP_BAD_REQUEST); |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
524 } | 526 } |
525 http_response->set_code(net::HTTP_BAD_REQUEST); | 527 http_response->set_code(net::HTTP_BAD_REQUEST); |
526 } | 528 } |
527 | 529 |
528 void FakeGaia::HandleListAccounts(const HttpRequest& request, | 530 void FakeGaia::HandleListAccounts(const HttpRequest& request, |
529 BasicHttpResponse* http_response) { | 531 BasicHttpResponse* http_response) { |
530 http_response->set_content(base::StringPrintf( | 532 http_response->set_content(base::StringPrintf( |
531 kListAccountsResponseFormat, merge_session_params_.email.c_str())); | 533 kListAccountsResponseFormat, merge_session_params_.email.c_str())); |
532 http_response->set_code(net::HTTP_OK); | 534 http_response->set_code(net::HTTP_OK); |
533 } | 535 } |
OLD | NEW |