| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/threading/non_thread_safe.h" | 13 #include "base/threading/non_thread_safe.h" |
| 14 #include "net/base/completion_callback.h" | 14 #include "net/base/completion_callback.h" |
| 15 #include "net/base/net_export.h" | 15 #include "net/base/net_export.h" |
| 16 #include "net/http/http_auth.h" | 16 #include "net/http/http_auth.h" |
| 17 #include "net/log/net_log.h" | 17 #include "net/log/net_log.h" |
| 18 #include "url/gurl.h" | 18 #include "url/gurl.h" |
| 19 | 19 |
| 20 namespace net { | 20 namespace net { |
| 21 | 21 |
| 22 class AuthChallengeInfo; | 22 class AuthChallengeInfo; |
| 23 class AuthCredentials; | 23 class AuthCredentials; |
| 24 class HttpAuthHandler; | 24 class HttpAuthHandler; |
| 25 class HttpAuthHandlerFactory; | 25 class HttpAuthHandlerFactory; |
| 26 class HttpAuthCache; | 26 class HttpAuthCache; |
| 27 class HttpRequestHeaders; | 27 class HttpRequestHeaders; |
| 28 struct HttpRequestInfo; | 28 struct HttpRequestInfo; |
| 29 class SSLInfo; |
| 29 | 30 |
| 30 class NET_EXPORT_PRIVATE HttpAuthController | 31 class NET_EXPORT_PRIVATE HttpAuthController |
| 31 : public base::RefCounted<HttpAuthController>, | 32 : public base::RefCounted<HttpAuthController>, |
| 32 NON_EXPORTED_BASE(public base::NonThreadSafe) { | 33 NON_EXPORTED_BASE(public base::NonThreadSafe) { |
| 33 public: | 34 public: |
| 34 // The arguments are self explanatory except possibly for |auth_url|, which | 35 // The arguments are self explanatory except possibly for |auth_url|, which |
| 35 // should be both the auth target and auth path in a single url argument. | 36 // should be both the auth target and auth path in a single url argument. |
| 36 HttpAuthController(HttpAuth::Target target, | 37 HttpAuthController(HttpAuth::Target target, |
| 37 const GURL& auth_url, | 38 const GURL& auth_url, |
| 38 HttpAuthCache* http_auth_cache, | 39 HttpAuthCache* http_auth_cache, |
| 39 HttpAuthHandlerFactory* http_auth_handler_factory); | 40 HttpAuthHandlerFactory* http_auth_handler_factory); |
| 40 | 41 |
| 41 // Generate an authentication token for |target| if necessary. The return | 42 // Generate an authentication token for |target| if necessary. The return |
| 42 // value is a net error code. |OK| will be returned both in the case that | 43 // value is a net error code. |OK| will be returned both in the case that |
| 43 // a token is correctly generated synchronously, as well as when no tokens | 44 // a token is correctly generated synchronously, as well as when no tokens |
| 44 // were necessary. | 45 // were necessary. |
| 45 virtual int MaybeGenerateAuthToken(const HttpRequestInfo* request, | 46 virtual int MaybeGenerateAuthToken(const HttpRequestInfo* request, |
| 46 const CompletionCallback& callback, | 47 const CompletionCallback& callback, |
| 47 const BoundNetLog& net_log); | 48 const BoundNetLog& net_log); |
| 48 | 49 |
| 49 // Adds either the proxy auth header, or the origin server auth header, | 50 // Adds either the proxy auth header, or the origin server auth header, |
| 50 // as specified by |target_|. | 51 // as specified by |target_|. |
| 51 virtual void AddAuthorizationHeader( | 52 virtual void AddAuthorizationHeader( |
| 52 HttpRequestHeaders* authorization_headers); | 53 HttpRequestHeaders* authorization_headers); |
| 53 | 54 |
| 54 // Checks for and handles HTTP status code 401 or 407. | 55 // Checks for and handles HTTP status code 401 or 407. |
| 55 // |HandleAuthChallenge()| returns OK on success, or a network error code | 56 // |HandleAuthChallenge()| returns OK on success, or a network error code |
| 56 // otherwise. It may also populate |auth_info_|. | 57 // otherwise. It may also populate |auth_info_|. |
| 57 virtual int HandleAuthChallenge(scoped_refptr<HttpResponseHeaders> headers, | 58 virtual int HandleAuthChallenge(scoped_refptr<HttpResponseHeaders> headers, |
| 59 const SSLInfo& ssl_info, |
| 58 bool do_not_send_server_auth, | 60 bool do_not_send_server_auth, |
| 59 bool establishing_tunnel, | 61 bool establishing_tunnel, |
| 60 const BoundNetLog& net_log); | 62 const BoundNetLog& net_log); |
| 61 | 63 |
| 62 // Store the supplied credentials and prepare to restart the auth. | 64 // Store the supplied credentials and prepare to restart the auth. |
| 63 virtual void ResetAuth(const AuthCredentials& credentials); | 65 virtual void ResetAuth(const AuthCredentials& credentials); |
| 64 | 66 |
| 65 virtual bool HaveAuthHandler() const; | 67 virtual bool HaveAuthHandler() const; |
| 66 | 68 |
| 67 virtual bool HaveAuth() const; | 69 virtual bool HaveAuth() const; |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 HttpAuthHandlerFactory* const http_auth_handler_factory_; | 163 HttpAuthHandlerFactory* const http_auth_handler_factory_; |
| 162 | 164 |
| 163 std::set<HttpAuth::Scheme> disabled_schemes_; | 165 std::set<HttpAuth::Scheme> disabled_schemes_; |
| 164 | 166 |
| 165 CompletionCallback callback_; | 167 CompletionCallback callback_; |
| 166 }; | 168 }; |
| 167 | 169 |
| 168 } // namespace net | 170 } // namespace net |
| 169 | 171 |
| 170 #endif // NET_HTTP_HTTP_AUTH_CONTROLLER_H_ | 172 #endif // NET_HTTP_HTTP_AUTH_CONTROLLER_H_ |
| OLD | NEW |