Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 NET_HTTP_HTTP_AUTH_CONTROLLER_H_ | 5 #ifndef NET_HTTP_HTTP_AUTH_CONTROLLER_H_ |
| 6 #define NET_HTTP_HTTP_AUTH_CONTROLLER_H_ | 6 #define NET_HTTP_HTTP_AUTH_CONTROLLER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 26 class HttpAuthHandler; | 26 class HttpAuthHandler; |
| 27 class HttpAuthHandlerFactory; | 27 class HttpAuthHandlerFactory; |
| 28 class HttpAuthCache; | 28 class HttpAuthCache; |
| 29 class HttpRequestHeaders; | 29 class HttpRequestHeaders; |
| 30 struct HttpRequestInfo; | 30 struct HttpRequestInfo; |
| 31 | 31 |
| 32 class NET_EXPORT_PRIVATE HttpAuthController | 32 class NET_EXPORT_PRIVATE HttpAuthController |
| 33 : public base::RefCounted<HttpAuthController>, | 33 : public base::RefCounted<HttpAuthController>, |
| 34 NON_EXPORTED_BASE(public base::NonThreadSafe) { | 34 NON_EXPORTED_BASE(public base::NonThreadSafe) { |
| 35 public: | 35 public: |
| 36 // Options for the handling of auth challenges. | |
| 37 enum ChallengeOption { | |
| 38 CHALLENGE_OPTION_NONE = 0, | |
| 39 CHALLENGE_OPTION_SEND_SERVER_AUTH = 1, | |
|
cbentzel
2012/02/06 15:55:38
Perhaps 0x1 << 0, 0x1 << 2, etc. to better indicat
Tom Sepez
2012/02/06 18:05:30
Sure, will do.
| |
| 40 CHALLENGE_OPTION_USE_EMBEDDED_AUTH = 2, | |
| 41 CHALLENGE_OPTION_ESTABLISHING_TUNNEL = 4 | |
|
cbentzel
2012/02/06 15:55:38
"ESTABLISHING_TUNNEL" doesn't feel like much of an
Tom Sepez
2012/02/06 18:05:30
Understood. I'd like to keep it here though for t
| |
| 42 }; | |
| 43 | |
| 36 // The arguments are self explanatory except possibly for |auth_url|, which | 44 // The arguments are self explanatory except possibly for |auth_url|, which |
| 37 // should be both the auth target and auth path in a single url argument. | 45 // should be both the auth target and auth path in a single url argument. |
| 38 HttpAuthController(HttpAuth::Target target, | 46 HttpAuthController(HttpAuth::Target target, |
| 39 const GURL& auth_url, | 47 const GURL& auth_url, |
| 40 HttpAuthCache* http_auth_cache, | 48 HttpAuthCache* http_auth_cache, |
| 41 HttpAuthHandlerFactory* http_auth_handler_factory); | 49 HttpAuthHandlerFactory* http_auth_handler_factory); |
| 42 | 50 |
| 43 // Generate an authentication token for |target| if necessary. The return | 51 // Generate an authentication token for |target| if necessary. The return |
| 44 // value is a net error code. |OK| will be returned both in the case that | 52 // value is a net error code. |OK| will be returned both in the case that |
| 45 // a token is correctly generated synchronously, as well as when no tokens | 53 // a token is correctly generated synchronously, as well as when no tokens |
| 46 // were necessary. | 54 // were necessary. |
| 47 virtual int MaybeGenerateAuthToken(const HttpRequestInfo* request, | 55 virtual int MaybeGenerateAuthToken(const HttpRequestInfo* request, |
| 48 const CompletionCallback& callback, | 56 const CompletionCallback& callback, |
| 49 const BoundNetLog& net_log); | 57 const BoundNetLog& net_log); |
| 50 | 58 |
| 51 // Adds either the proxy auth header, or the origin server auth header, | 59 // Adds either the proxy auth header, or the origin server auth header, |
| 52 // as specified by |target_|. | 60 // as specified by |target_|. |
| 53 virtual void AddAuthorizationHeader( | 61 virtual void AddAuthorizationHeader( |
| 54 HttpRequestHeaders* authorization_headers); | 62 HttpRequestHeaders* authorization_headers); |
| 55 | 63 |
| 56 // Checks for and handles HTTP status code 401 or 407. | 64 // Checks for and handles HTTP status code 401 or 407. |
| 57 // |HandleAuthChallenge()| returns OK on success, or a network error code | 65 // |HandleAuthChallenge()| returns OK on success, or a network error code |
| 58 // otherwise. It may also populate |auth_info_|. | 66 // otherwise. It may also populate |auth_info_|. |
| 59 virtual int HandleAuthChallenge(scoped_refptr<HttpResponseHeaders> headers, | 67 virtual int HandleAuthChallenge(scoped_refptr<HttpResponseHeaders> headers, |
| 60 bool do_not_send_server_auth, | 68 int challenge_option_mask, |
|
cbentzel
2012/02/06 15:55:38
ChallengeOption should be fine here.
Tom Sepez
2012/02/06 18:05:30
It's that idiotic way that c++ handles or's of enu
| |
| 61 bool establishing_tunnel, | |
| 62 const BoundNetLog& net_log); | 69 const BoundNetLog& net_log); |
| 63 | 70 |
| 64 // Store the supplied credentials and prepare to restart the auth. | 71 // Store the supplied credentials and prepare to restart the auth. |
| 65 virtual void ResetAuth(const AuthCredentials& credentials); | 72 virtual void ResetAuth(const AuthCredentials& credentials); |
| 66 | 73 |
| 67 virtual bool HaveAuthHandler() const; | 74 virtual bool HaveAuthHandler() const; |
| 68 | 75 |
| 69 virtual bool HaveAuth() const; | 76 virtual bool HaveAuth() const; |
| 70 | 77 |
| 71 virtual scoped_refptr<AuthChallengeInfo> auth_info(); | 78 virtual scoped_refptr<AuthChallengeInfo> auth_info(); |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 96 // the cached credentials used by the handler. | 103 // the cached credentials used by the handler. |
| 97 void InvalidateCurrentHandler(InvalidateHandlerAction action); | 104 void InvalidateCurrentHandler(InvalidateHandlerAction action); |
| 98 | 105 |
| 99 // Invalidates any auth cache entries after authentication has failed. | 106 // Invalidates any auth cache entries after authentication has failed. |
| 100 // The identity that was rejected is |identity_|. | 107 // The identity that was rejected is |identity_|. |
| 101 void InvalidateRejectedAuthFromCache(); | 108 void InvalidateRejectedAuthFromCache(); |
| 102 | 109 |
| 103 // Sets |identity_| to the next identity that the transaction should try. It | 110 // Sets |identity_| to the next identity that the transaction should try. It |
| 104 // chooses candidates by searching the auth cache and the URL for a | 111 // chooses candidates by searching the auth cache and the URL for a |
| 105 // username:password. Returns true if an identity was found. | 112 // username:password. Returns true if an identity was found. |
| 106 bool SelectNextAuthIdentityToTry(); | 113 bool SelectNextAuthIdentityToTry(int challenge_option_mask); |
| 107 | 114 |
| 108 // Populates auth_info_ with the challenge information, so that | 115 // Populates auth_info_ with the challenge information, so that |
| 109 // URLRequestHttpJob can prompt for credentials. | 116 // URLRequestHttpJob can prompt for credentials. |
| 110 void PopulateAuthChallenge(); | 117 void PopulateAuthChallenge(); |
| 111 | 118 |
| 112 // If |result| indicates a permanent failure, disables the current | 119 // If |result| indicates a permanent failure, disables the current |
| 113 // auth scheme for this controller and returns true. Returns false | 120 // auth scheme for this controller and returns true. Returns false |
| 114 // otherwise. | 121 // otherwise. |
| 115 bool DisableOnAuthHandlerResult(int result); | 122 bool DisableOnAuthHandlerResult(int result); |
| 116 | 123 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 162 HttpAuthHandlerFactory* const http_auth_handler_factory_; | 169 HttpAuthHandlerFactory* const http_auth_handler_factory_; |
| 163 | 170 |
| 164 std::set<HttpAuth::Scheme> disabled_schemes_; | 171 std::set<HttpAuth::Scheme> disabled_schemes_; |
| 165 | 172 |
| 166 CompletionCallback callback_; | 173 CompletionCallback callback_; |
| 167 }; | 174 }; |
| 168 | 175 |
| 169 } // namespace net | 176 } // namespace net |
| 170 | 177 |
| 171 #endif // NET_HTTP_HTTP_AUTH_CONTROLLER_H_ | 178 #endif // NET_HTTP_HTTP_AUTH_CONTROLLER_H_ |
| OLD | NEW |