OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_BROWSER_SYNC_NOTIFIER_GAIA_AUTH_GAIAHELPER_H__ |
| 6 #define CHROME_BROWSER_SYNC_NOTIFIER_GAIA_AUTH_GAIAHELPER_H__ |
| 7 |
| 8 #include <string> |
| 9 |
| 10 namespace talk_base { |
| 11 class CryptString; |
| 12 class HttpClient; |
| 13 } |
| 14 |
| 15 namespace buzz { |
| 16 |
| 17 /////////////////////////////////////////////////////////////////////////////// |
| 18 |
| 19 class CaptchaAnswer { |
| 20 public: |
| 21 CaptchaAnswer() {} |
| 22 CaptchaAnswer(const std::string& token, const std::string& answer) |
| 23 : captcha_token_(token), captcha_answer_(answer) { |
| 24 } |
| 25 const std::string& captcha_token() const { return captcha_token_; } |
| 26 const std::string& captcha_answer() const { return captcha_answer_; } |
| 27 |
| 28 private: |
| 29 std::string captcha_token_; |
| 30 std::string captcha_answer_; |
| 31 }; |
| 32 |
| 33 class GaiaServer { |
| 34 public: |
| 35 GaiaServer(); |
| 36 |
| 37 bool SetServer(const char* url); // protocol://server:port |
| 38 bool SetDebugServer(const char* server); // server:port |
| 39 |
| 40 const std::string& hostname() const { return hostname_; } |
| 41 int port() const { return port_; } |
| 42 bool use_ssl() const { return use_ssl_; } |
| 43 |
| 44 std::string http_prefix() const; |
| 45 |
| 46 private: |
| 47 std::string hostname_; |
| 48 int port_; |
| 49 bool use_ssl_; |
| 50 }; |
| 51 |
| 52 /////////////////////////////////////////////////////////////////////////////// |
| 53 // Gaia Authentication Helper Functions |
| 54 /////////////////////////////////////////////////////////////////////////////// |
| 55 |
| 56 enum GaiaResponse { GR_ERROR, GR_UNAUTHORIZED, GR_SUCCESS }; |
| 57 |
| 58 bool GaiaRequestSid(talk_base::HttpClient* client, |
| 59 const std::string& username, |
| 60 const talk_base::CryptString& password, |
| 61 const std::string& signature, |
| 62 const std::string& service, |
| 63 const CaptchaAnswer& captcha_answer, |
| 64 const GaiaServer& gaia_server); |
| 65 |
| 66 GaiaResponse GaiaParseSidResponse(const talk_base::HttpClient& client, |
| 67 const GaiaServer& gaia_server, |
| 68 std::string* captcha_token, |
| 69 std::string* captcha_url, |
| 70 std::string* sid, |
| 71 std::string* lsid, |
| 72 std::string* auth); |
| 73 |
| 74 bool GaiaRequestAuthToken(talk_base::HttpClient* client, |
| 75 const std::string& sid, |
| 76 const std::string& lsid, |
| 77 const std::string& service, |
| 78 const GaiaServer& gaia_server); |
| 79 |
| 80 GaiaResponse GaiaParseAuthTokenResponse(const talk_base::HttpClient& client, |
| 81 std::string* auth_token); |
| 82 |
| 83 /////////////////////////////////////////////////////////////////////////////// |
| 84 |
| 85 } // namespace buzz |
| 86 |
| 87 #endif // CHROME_BROWSER_SYNC_NOTIFIER_GAIA_AUTH_GAIAHELPER_H__ |
OLD | NEW |