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 27 matching lines...) Expand all Loading... |
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 virtual int MaybeGenerateAuthToken(const HttpRequestInfo* request, |
47 const CompletionCallback& callback, | 47 const CompletionCallback& callback, |
48 const BoundNetLog& 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 virtual void AddAuthorizationHeader( |
53 HttpRequestHeaders* authorization_headers); | 53 HttpRequestHeaders* authorization_headers); |
54 | 54 |
55 // Checks for and handles HTTP status code 401 or 407. | 55 // Checks for and handles HTTP status code 401 or 407. |
56 // |HandleAuthChallenge()| returns OK on success, or a network error code | 56 // |HandleAuthChallenge()| returns OK on success, or a network error code |
57 // otherwise. It may also populate |auth_info_|. | 57 // otherwise. It may also populate |auth_info_|. |
58 virtual int HandleAuthChallenge(scoped_refptr<HttpResponseHeaders> headers, | 58 virtual int HandleAuthChallenge(scoped_refptr<HttpResponseHeaders> headers, |
59 const SSLInfo& ssl_info, | 59 const SSLInfo& ssl_info, |
60 bool do_not_send_server_auth, | 60 bool do_not_send_server_auth, |
61 bool establishing_tunnel, | 61 bool establishing_tunnel, |
62 const BoundNetLog& net_log); | 62 const NetLogWithSource& net_log); |
63 | 63 |
64 // Store the supplied credentials and prepare to restart the auth. | 64 // Store the supplied credentials and prepare to restart the auth. |
65 virtual void ResetAuth(const AuthCredentials& credentials); | 65 virtual void ResetAuth(const AuthCredentials& credentials); |
66 | 66 |
67 virtual bool HaveAuthHandler() const; | 67 virtual bool HaveAuthHandler() const; |
68 | 68 |
69 virtual bool HaveAuth() const; | 69 virtual bool HaveAuth() const; |
70 | 70 |
71 virtual scoped_refptr<AuthChallengeInfo> auth_info(); | 71 virtual scoped_refptr<AuthChallengeInfo> auth_info(); |
72 | 72 |
(...skipping 10 matching lines...) Expand all Loading... |
83 }; | 83 }; |
84 | 84 |
85 // So that we can mock this object. | 85 // So that we can mock this object. |
86 friend class base::RefCounted<HttpAuthController>; | 86 friend class base::RefCounted<HttpAuthController>; |
87 | 87 |
88 virtual ~HttpAuthController(); | 88 virtual ~HttpAuthController(); |
89 | 89 |
90 // Searches the auth cache for an entry that encompasses the request's path. | 90 // Searches the auth cache for an entry that encompasses the request's path. |
91 // If such an entry is found, updates |identity_| and |handler_| with the | 91 // If such an entry is found, updates |identity_| and |handler_| with the |
92 // cache entry's data and returns true. | 92 // cache entry's data and returns true. |
93 bool SelectPreemptiveAuth(const BoundNetLog& net_log); | 93 bool SelectPreemptiveAuth(const NetLogWithSource& net_log); |
94 | 94 |
95 // Invalidates the current handler. If |action| is | 95 // Invalidates the current handler. If |action| is |
96 // INVALIDATE_HANDLER_AND_CACHED_CREDENTIALS, then also invalidate | 96 // INVALIDATE_HANDLER_AND_CACHED_CREDENTIALS, then also invalidate |
97 // the cached credentials used by the handler. | 97 // the cached credentials used by the handler. |
98 void InvalidateCurrentHandler(InvalidateHandlerAction action); | 98 void InvalidateCurrentHandler(InvalidateHandlerAction action); |
99 | 99 |
100 // Invalidates any auth cache entries after authentication has failed. | 100 // Invalidates any auth cache entries after authentication has failed. |
101 // The identity that was rejected is |identity_|. | 101 // The identity that was rejected is |identity_|. |
102 void InvalidateRejectedAuthFromCache(); | 102 void InvalidateRejectedAuthFromCache(); |
103 | 103 |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 HttpAuthHandlerFactory* const http_auth_handler_factory_; | 163 HttpAuthHandlerFactory* const http_auth_handler_factory_; |
164 | 164 |
165 std::set<HttpAuth::Scheme> disabled_schemes_; | 165 std::set<HttpAuth::Scheme> disabled_schemes_; |
166 | 166 |
167 CompletionCallback callback_; | 167 CompletionCallback callback_; |
168 }; | 168 }; |
169 | 169 |
170 } // namespace net | 170 } // namespace net |
171 | 171 |
172 #endif // NET_HTTP_HTTP_AUTH_CONTROLLER_H_ | 172 #endif // NET_HTTP_HTTP_AUTH_CONTROLLER_H_ |
OLD | NEW |