| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef GOOGLE_APIS_GAIA_GAIA_AUTH_FETCHER_H_ | 5 #ifndef GOOGLE_APIS_GAIA_GAIA_AUTH_FETCHER_H_ |
| 6 #define GOOGLE_APIS_GAIA_GAIA_AUTH_FETCHER_H_ | 6 #define GOOGLE_APIS_GAIA_GAIA_AUTH_FETCHER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 // Either OnClientLoginSuccess or OnClientLoginFailure will be | 62 // Either OnClientLoginSuccess or OnClientLoginFailure will be |
| 63 // called on the consumer on the original thread. | 63 // called on the consumer on the original thread. |
| 64 void StartClientLogin(const std::string& username, | 64 void StartClientLogin(const std::string& username, |
| 65 const std::string& password, | 65 const std::string& password, |
| 66 const char* const service, | 66 const char* const service, |
| 67 const std::string& login_token, | 67 const std::string& login_token, |
| 68 const std::string& login_captcha, | 68 const std::string& login_captcha, |
| 69 HostedAccountsSetting allow_hosted_accounts); | 69 HostedAccountsSetting allow_hosted_accounts); |
| 70 | 70 |
| 71 // Start a request to obtain service token for the the account identified by | 71 // Start a request to obtain service token for the the account identified by |
| 72 // |sid| and |lsid| and the service|service|. | 72 // |sid| and |lsid| and the |service|. |
| 73 // | 73 // |
| 74 // Either OnIssueAuthTokenSuccess or OnIssueAuthTokenFailure will be | 74 // Either OnIssueAuthTokenSuccess or OnIssueAuthTokenFailure will be |
| 75 // called on the consumer on the original thread. | 75 // called on the consumer on the original thread. |
| 76 void StartIssueAuthToken(const std::string& sid, | 76 void StartIssueAuthToken(const std::string& sid, |
| 77 const std::string& lsid, | 77 const std::string& lsid, |
| 78 const char* const service); | 78 const char* const service); |
| 79 | 79 |
| 80 // Start a request to obtain |service| token for the the account identified by |
| 81 // |uber_token|. |
| 82 // |
| 83 // Either OnIssueAuthTokenSuccess or OnIssueAuthTokenFailure will be |
| 84 // called on the consumer on the original thread. |
| 85 void StartTokenAuth(const std::string& uber_token, |
| 86 const char* const service); |
| 87 |
| 88 // Start a request to obtain service token for the the account identified by |
| 89 // |oauth2_access_token| and the |service|. |
| 90 // |
| 91 // Either OnIssueAuthTokenSuccess or OnIssueAuthTokenFailure will be |
| 92 // called on the consumer on the original thread. |
| 93 void StartIssueAuthTokenForOAuth2(const std::string& oauth2_access_token, |
| 94 const char* const service); |
| 95 |
| 80 // Start a request to exchange an "lso" service token given by |auth_token| | 96 // Start a request to exchange an "lso" service token given by |auth_token| |
| 81 // for an OAuthLogin-scoped oauth2 token. | 97 // for an OAuthLogin-scoped oauth2 token. |
| 82 // | 98 // |
| 83 // Either OnClientOAuthSuccess or OnClientOAuthFailure will be | 99 // Either OnClientOAuthSuccess or OnClientOAuthFailure will be |
| 84 // called on the consumer on the original thread. | 100 // called on the consumer on the original thread. |
| 85 void StartLsoForOAuthLoginTokenExchange(const std::string& auth_token); | 101 void StartLsoForOAuthLoginTokenExchange(const std::string& auth_token); |
| 86 | 102 |
| 87 // Start a request to exchange the cookies of a signed-in user session | 103 // Start a request to exchange the cookies of a signed-in user session |
| 88 // for an OAuthLogin-scoped oauth2 token. In the case of a session with | 104 // for an OAuthLogin-scoped oauth2 token. In the case of a session with |
| 89 // multiple accounts signed in, |session_index| indicate the which of accounts | 105 // multiple accounts signed in, |session_index| indicate the which of accounts |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 void StartClientOAuthChallengeResponse(GoogleServiceAuthError::State type, | 165 void StartClientOAuthChallengeResponse(GoogleServiceAuthError::State type, |
| 150 const std::string& token, | 166 const std::string& token, |
| 151 const std::string& solution); | 167 const std::string& solution); |
| 152 | 168 |
| 153 // Start a request to exchange an OAuthLogin-scoped oauth2 access token for a | 169 // Start a request to exchange an OAuthLogin-scoped oauth2 access token for a |
| 154 // ClientLogin-style service tokens. The response to this request is the | 170 // ClientLogin-style service tokens. The response to this request is the |
| 155 // same as the response to a ClientLogin request, except that captcha | 171 // same as the response to a ClientLogin request, except that captcha |
| 156 // challenges are never issued. | 172 // challenges are never issued. |
| 157 // | 173 // |
| 158 // Either OnClientLoginSuccess or OnClientLoginFailure will be | 174 // Either OnClientLoginSuccess or OnClientLoginFailure will be |
| 159 // called on the consumer on the original thread. | 175 // called on the consumer on the original thread. If |service| is empty, |
| 176 // the call will attempt to fetch uber auth token. |
| 160 void StartOAuthLogin(const std::string& access_token, | 177 void StartOAuthLogin(const std::string& access_token, |
| 161 const std::string& service); | 178 const std::string& service); |
| 162 | 179 |
| 163 // Implementation of net::URLFetcherDelegate | 180 // Implementation of net::URLFetcherDelegate |
| 164 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; | 181 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; |
| 165 | 182 |
| 166 // StartClientLogin been called && results not back yet? | 183 // StartClientLogin been called && results not back yet? |
| 167 bool HasPendingFetch(); | 184 bool HasPendingFetch(); |
| 168 | 185 |
| 169 // Stop any URL fetches in progress. | 186 // Stop any URL fetches in progress. |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 static const char kCaptchaTokenParam[]; | 235 static const char kCaptchaTokenParam[]; |
| 219 | 236 |
| 220 // Constants for parsing ClientOAuth errors. | 237 // Constants for parsing ClientOAuth errors. |
| 221 static const char kNeedsAdditional[]; | 238 static const char kNeedsAdditional[]; |
| 222 static const char kCaptcha[]; | 239 static const char kCaptcha[]; |
| 223 static const char kTwoFactor[]; | 240 static const char kTwoFactor[]; |
| 224 | 241 |
| 225 // Constants for request/response for OAuth2 requests. | 242 // Constants for request/response for OAuth2 requests. |
| 226 static const char kAuthHeaderFormat[]; | 243 static const char kAuthHeaderFormat[]; |
| 227 static const char kOAuthHeaderFormat[]; | 244 static const char kOAuthHeaderFormat[]; |
| 245 static const char kOAuth2BearerHeaderFormat[]; |
| 228 static const char kClientLoginToOAuth2CookiePartSecure[]; | 246 static const char kClientLoginToOAuth2CookiePartSecure[]; |
| 229 static const char kClientLoginToOAuth2CookiePartHttpOnly[]; | 247 static const char kClientLoginToOAuth2CookiePartHttpOnly[]; |
| 230 static const char kClientLoginToOAuth2CookiePartCodePrefix[]; | 248 static const char kClientLoginToOAuth2CookiePartCodePrefix[]; |
| 231 static const int kClientLoginToOAuth2CookiePartCodePrefixLength; | 249 static const int kClientLoginToOAuth2CookiePartCodePrefixLength; |
| 232 | 250 |
| 233 // Process the results of a ClientLogin fetch. | 251 // Process the results of a ClientLogin fetch. |
| 234 void OnClientLoginFetched(const std::string& data, | 252 void OnClientLoginFetched(const std::string& data, |
| 235 const net::URLRequestStatus& status, | 253 const net::URLRequestStatus& status, |
| 236 int response_code); | 254 int response_code); |
| 237 | 255 |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 397 FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest, ParseOAuth2TokenPairResponse); | 415 FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest, ParseOAuth2TokenPairResponse); |
| 398 FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest, ClientOAuthSuccess); | 416 FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest, ClientOAuthSuccess); |
| 399 FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest, ClientOAuthWithQuote); | 417 FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest, ClientOAuthWithQuote); |
| 400 FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest, ClientOAuthChallengeSuccess); | 418 FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest, ClientOAuthChallengeSuccess); |
| 401 FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest, ClientOAuthChallengeQuote); | 419 FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest, ClientOAuthChallengeQuote); |
| 402 | 420 |
| 403 DISALLOW_COPY_AND_ASSIGN(GaiaAuthFetcher); | 421 DISALLOW_COPY_AND_ASSIGN(GaiaAuthFetcher); |
| 404 }; | 422 }; |
| 405 | 423 |
| 406 #endif // GOOGLE_APIS_GAIA_GAIA_AUTH_FETCHER_H_ | 424 #endif // GOOGLE_APIS_GAIA_GAIA_AUTH_FETCHER_H_ |
| OLD | NEW |