| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_BROWSER_NET_SPDYPROXY_HTTP_AUTH_HANDLER_SPDYPROXY_H_ |
| 6 #define CHROME_BROWSER_NET_SPDYPROXY_HTTP_AUTH_HANDLER_SPDYPROXY_H_ |
| 7 |
| 8 #include <string> |
| 9 |
| 10 #include "base/gtest_prod_util.h" |
| 11 #include "net/http/http_auth_handler.h" |
| 12 #include "net/http/http_auth_handler_factory.h" |
| 13 |
| 14 namespace spdyproxy { |
| 15 |
| 16 // Code for handling http SpdyProxy authentication. |
| 17 class HttpAuthHandlerSpdyProxy : public net::HttpAuthHandler { |
| 18 public: |
| 19 class Factory : public net::HttpAuthHandlerFactory { |
| 20 public: |
| 21 // Constructs a new spdyproxy handler factory which mints handlers that |
| 22 // respond to challenges only from the given |authorized_spdyproxy_origin|. |
| 23 explicit Factory(const GURL& authorized_spdyproxy_origin); |
| 24 virtual ~Factory(); |
| 25 |
| 26 virtual int CreateAuthHandler( |
| 27 net::HttpAuth::ChallengeTokenizer* challenge, |
| 28 net::HttpAuth::Target target, |
| 29 const GURL& origin, |
| 30 CreateReason reason, |
| 31 int digest_nonce_count, |
| 32 const net::BoundNetLog& net_log, |
| 33 scoped_ptr<HttpAuthHandler>* handler) OVERRIDE; |
| 34 |
| 35 private: |
| 36 // The origin for which we will respond to SpdyProxy auth challenges. |
| 37 GURL authorized_spdyproxy_origin_; |
| 38 }; |
| 39 |
| 40 // Constructs a new spdyproxy handler which responds to challenges |
| 41 // from the given |authorized_spdyproxy_origin|. |
| 42 explicit HttpAuthHandlerSpdyProxy( |
| 43 const GURL& authorized_spdyproxy_origin); |
| 44 |
| 45 // Overrides from net::HttpAuthHandler. |
| 46 virtual net::HttpAuth::AuthorizationResult HandleAnotherChallenge( |
| 47 net::HttpAuth::ChallengeTokenizer* challenge) OVERRIDE; |
| 48 virtual bool NeedsIdentity() OVERRIDE; |
| 49 virtual bool AllowsDefaultCredentials() OVERRIDE; |
| 50 virtual bool AllowsExplicitCredentials() OVERRIDE; |
| 51 |
| 52 private: |
| 53 FRIEND_TEST_ALL_PREFIXES(HttpAuthHandlerSpdyProxyTest, ParseChallenge); |
| 54 |
| 55 virtual ~HttpAuthHandlerSpdyProxy() {} |
| 56 |
| 57 virtual bool Init(net::HttpAuth::ChallengeTokenizer* challenge) OVERRIDE; |
| 58 |
| 59 virtual int GenerateAuthTokenImpl(const net::AuthCredentials* credentials, |
| 60 const net::HttpRequestInfo* request, |
| 61 const net::CompletionCallback& callback, |
| 62 std::string* auth_token) OVERRIDE; |
| 63 |
| 64 bool ParseChallenge(net::HttpAuth::ChallengeTokenizer* challenge); |
| 65 |
| 66 bool ParseChallengeProperty(const std::string& name, |
| 67 const std::string& value); |
| 68 |
| 69 // The origin for which we will respond to SpdyProxy auth challenges. |
| 70 GURL authorized_spdyproxy_origin_; |
| 71 |
| 72 // The ps token, encoded as UTF-8. |
| 73 std::string ps_token_; |
| 74 |
| 75 DISALLOW_COPY_AND_ASSIGN(HttpAuthHandlerSpdyProxy); |
| 76 }; |
| 77 |
| 78 } // namespace spdyproxy |
| 79 |
| 80 #endif // CHROME_BROWSER_NET_SPDYPROXY_HTTP_AUTH_HANDLER_SPDYPROXY_H_ |
| OLD | NEW |