| OLD | NEW |
| 1 // Copyright (c) 2012 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 <memory> | 8 #include <memory> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 // 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. |
| 37 HttpAuthController(HttpAuth::Target target, | 37 HttpAuthController(HttpAuth::Target target, |
| 38 const GURL& auth_url, | 38 const GURL& auth_url, |
| 39 HttpAuthCache* http_auth_cache, | 39 HttpAuthCache* http_auth_cache, |
| 40 HttpAuthHandlerFactory* http_auth_handler_factory); | 40 HttpAuthHandlerFactory* http_auth_handler_factory); |
| 41 | 41 |
| 42 // Generate an authentication token for |target| if necessary. The return | 42 // Generate an authentication token for |target| if necessary. The return |
| 43 // 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 |
| 44 // 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 |
| 45 // were necessary. | 45 // were necessary. |
| 46 virtual int MaybeGenerateAuthToken(const HttpRequestInfo* request, | 46 int MaybeGenerateAuthToken(const HttpRequestInfo* request, |
| 47 const CompletionCallback& callback, | 47 const CompletionCallback& callback, |
| 48 const NetLogWithSource& net_log); | 48 const NetLogWithSource& net_log); |
| 49 | 49 |
| 50 // 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, |
| 51 // as specified by |target_|. | 51 // as specified by |target_|. |
| 52 virtual void AddAuthorizationHeader( | 52 void AddAuthorizationHeader(HttpRequestHeaders* authorization_headers); |
| 53 HttpRequestHeaders* authorization_headers); | |
| 54 | 53 |
| 55 // Checks for and handles HTTP status code 401 or 407. | 54 // Checks for and handles HTTP status code 401 or 407. |
| 56 // |HandleAuthChallenge()| returns OK on success, or a network error code | 55 // |HandleAuthChallenge()| returns OK on success, or a network error code |
| 57 // otherwise. It may also populate |auth_info_|. | 56 // otherwise. It may also populate |auth_info_|. |
| 58 virtual int HandleAuthChallenge(scoped_refptr<HttpResponseHeaders> headers, | 57 int HandleAuthChallenge(scoped_refptr<HttpResponseHeaders> headers, |
| 59 const SSLInfo& ssl_info, | 58 const SSLInfo& ssl_info, |
| 60 bool do_not_send_server_auth, | 59 bool do_not_send_server_auth, |
| 61 bool establishing_tunnel, | 60 bool establishing_tunnel, |
| 62 const NetLogWithSource& net_log); | 61 const NetLogWithSource& net_log); |
| 63 | 62 |
| 64 // Store the supplied credentials and prepare to restart the auth. | 63 // Store the supplied credentials and prepare to restart the auth. |
| 65 virtual void ResetAuth(const AuthCredentials& credentials); | 64 void ResetAuth(const AuthCredentials& credentials); |
| 66 | 65 |
| 67 virtual bool HaveAuthHandler() const; | 66 bool HaveAuthHandler() const; |
| 68 | 67 |
| 69 virtual bool HaveAuth() const; | 68 bool HaveAuth() const; |
| 70 | 69 |
| 71 virtual scoped_refptr<AuthChallengeInfo> auth_info(); | 70 scoped_refptr<AuthChallengeInfo> auth_info(); |
| 72 | 71 |
| 73 virtual bool IsAuthSchemeDisabled(HttpAuth::Scheme scheme) const; | 72 bool IsAuthSchemeDisabled(HttpAuth::Scheme scheme) const; |
| 74 virtual void DisableAuthScheme(HttpAuth::Scheme scheme); | 73 void DisableAuthScheme(HttpAuth::Scheme scheme); |
| 75 virtual void DisableEmbeddedIdentity(); | 74 void DisableEmbeddedIdentity(); |
| 76 | 75 |
| 77 private: | 76 private: |
| 78 // Actions for InvalidateCurrentHandler() | 77 // Actions for InvalidateCurrentHandler() |
| 79 enum InvalidateHandlerAction { | 78 enum InvalidateHandlerAction { |
| 80 INVALIDATE_HANDLER_AND_CACHED_CREDENTIALS, | 79 INVALIDATE_HANDLER_AND_CACHED_CREDENTIALS, |
| 81 INVALIDATE_HANDLER_AND_DISABLE_SCHEME, | 80 INVALIDATE_HANDLER_AND_DISABLE_SCHEME, |
| 82 INVALIDATE_HANDLER | 81 INVALIDATE_HANDLER |
| 83 }; | 82 }; |
| 84 | 83 |
| 85 // So that we can mock this object. | 84 // So that we can mock this object. |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 HttpAuthHandlerFactory* const http_auth_handler_factory_; | 162 HttpAuthHandlerFactory* const http_auth_handler_factory_; |
| 164 | 163 |
| 165 std::set<HttpAuth::Scheme> disabled_schemes_; | 164 std::set<HttpAuth::Scheme> disabled_schemes_; |
| 166 | 165 |
| 167 CompletionCallback callback_; | 166 CompletionCallback callback_; |
| 168 }; | 167 }; |
| 169 | 168 |
| 170 } // namespace net | 169 } // namespace net |
| 171 | 170 |
| 172 #endif // NET_HTTP_HTTP_AUTH_CONTROLLER_H_ | 171 #endif // NET_HTTP_HTTP_AUTH_CONTROLLER_H_ |
| OLD | NEW |