1 // Copyright 2014 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.
5 #ifndef COMPONENTS_DATA_REDUCTION_PROXY_BROWSER_HTTP_AUTH_HANDLER_DATA_REDUCTION_PROXY_H_
6 #define COMPONENTS_DATA_REDUCTION_PROXY_BROWSER_HTTP_AUTH_HANDLER_DATA_REDUCTION_PROXY_H_
11 #include "base/gtest_prod_util.h"
12 #include "net/http/http_auth_handler.h"
13 #include "net/http/http_auth_handler_factory.h"
15 namespace data_reduction_proxy
{
17 // Code for handling http SpdyProxy authentication.
18 class HttpAuthHandlerDataReductionProxy
: public net::HttpAuthHandler
{
20 // Returns the data reduction proxy auth scheme.
21 static std::string
Scheme();
23 class Factory
: public net::HttpAuthHandlerFactory
{
25 // Constructs a new spdyproxy handler factory which mints handlers that
26 // respond to challenges only from the given |authorized_spdyproxy_origins|.
27 explicit Factory(const std::vector
<GURL
>& authorized_spdyproxy_origins
);
30 virtual int CreateAuthHandler(
31 net::HttpAuthChallengeTokenizer
* challenge
,
32 net::HttpAuth::Target target
,
35 int digest_nonce_count
,
36 const net::BoundNetLog
& net_log
,
37 scoped_ptr
<HttpAuthHandler
>* handler
) OVERRIDE
;
40 // The origins for which Chrome will respond to SpdyProxy auth challenges.
41 std::vector
<GURL
> authorized_spdyproxy_origins_
;
44 // Constructs a new spdyproxy handler.
45 HttpAuthHandlerDataReductionProxy() {}
47 // Overrides from net::HttpAuthHandler.
48 virtual net::HttpAuth::AuthorizationResult
HandleAnotherChallenge(
49 net::HttpAuthChallengeTokenizer
* challenge
) OVERRIDE
;
50 virtual bool NeedsIdentity() OVERRIDE
;
51 virtual bool AllowsDefaultCredentials() OVERRIDE
;
52 virtual bool AllowsExplicitCredentials() OVERRIDE
;
55 FRIEND_TEST_ALL_PREFIXES(HttpAuthHandlerDataReductionProxyTest
,
58 virtual ~HttpAuthHandlerDataReductionProxy();
60 virtual bool Init(net::HttpAuthChallengeTokenizer
* challenge
) OVERRIDE
;
62 virtual int GenerateAuthTokenImpl(const net::AuthCredentials
* credentials
,
63 const net::HttpRequestInfo
* request
,
64 const net::CompletionCallback
& callback
,
65 std::string
* auth_token
) OVERRIDE
;
67 bool ParseChallenge(net::HttpAuthChallengeTokenizer
* challenge
);
69 bool ParseChallengeProperty(const std::string
& name
,
70 const std::string
& value
);
72 // Proxy server token, encoded as UTF-8.
73 std::string ps_token_
;
75 DISALLOW_COPY_AND_ASSIGN(HttpAuthHandlerDataReductionProxy
);
78 } // namespace data_reduction_proxy
80 #endif // COMPONENTS_DATA_REDUCTION_PROXY_BROWSER_HTTP_AUTH_HANDLER_DATA_REDUCTION_PROXY_H_