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.
5 #ifndef CHROME_BROWSER_NET_SPDYPROXY_HTTP_AUTH_HANDLER_SPDYPROXY_H_
6 #define CHROME_BROWSER_NET_SPDYPROXY_HTTP_AUTH_HANDLER_SPDYPROXY_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"
17 // Code for handling http SpdyProxy authentication.
18 class HttpAuthHandlerSpdyProxy
: public net::HttpAuthHandler
{
20 class Factory
: public net::HttpAuthHandlerFactory
{
22 // Constructs a new spdyproxy handler factory which mints handlers that
23 // respond to challenges only from the given |authorized_spdyproxy_origins|.
24 explicit Factory(const std::vector
<GURL
>& authorized_spdyproxy_origins
);
27 virtual int CreateAuthHandler(
28 net::HttpAuth::ChallengeTokenizer
* challenge
,
29 net::HttpAuth::Target target
,
32 int digest_nonce_count
,
33 const net::BoundNetLog
& net_log
,
34 scoped_ptr
<HttpAuthHandler
>* handler
) OVERRIDE
;
37 // The origins for which Chrome will respond to SpdyProxy auth challenges.
38 std::vector
<GURL
> authorized_spdyproxy_origins_
;
41 // Constructs a new spdyproxy handler.
42 HttpAuthHandlerSpdyProxy() {}
44 // Overrides from net::HttpAuthHandler.
45 virtual net::HttpAuth::AuthorizationResult
HandleAnotherChallenge(
46 net::HttpAuth::ChallengeTokenizer
* challenge
) OVERRIDE
;
47 virtual bool NeedsIdentity() OVERRIDE
;
48 virtual bool AllowsDefaultCredentials() OVERRIDE
;
49 virtual bool AllowsExplicitCredentials() OVERRIDE
;
52 FRIEND_TEST_ALL_PREFIXES(HttpAuthHandlerSpdyProxyTest
, ParseChallenge
);
54 virtual ~HttpAuthHandlerSpdyProxy();
56 virtual bool Init(net::HttpAuth::ChallengeTokenizer
* challenge
) OVERRIDE
;
58 virtual int GenerateAuthTokenImpl(const net::AuthCredentials
* credentials
,
59 const net::HttpRequestInfo
* request
,
60 const net::CompletionCallback
& callback
,
61 std::string
* auth_token
) OVERRIDE
;
63 bool ParseChallenge(net::HttpAuth::ChallengeTokenizer
* challenge
);
65 bool ParseChallengeProperty(const std::string
& name
,
66 const std::string
& value
);
68 // Proxy server token, encoded as UTF-8.
69 std::string ps_token_
;
71 DISALLOW_COPY_AND_ASSIGN(HttpAuthHandlerSpdyProxy
);
74 } // namespace spdyproxy
76 #endif // CHROME_BROWSER_NET_SPDYPROXY_HTTP_AUTH_HANDLER_SPDYPROXY_H_