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_HANDLER_FACTORY_H_ | 5 #ifndef NET_HTTP_HTTP_AUTH_HANDLER_FACTORY_H_ |
6 #define NET_HTTP_HTTP_AUTH_HANDLER_FACTORY_H_ | 6 #define NET_HTTP_HTTP_AUTH_HANDLER_FACTORY_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <memory> | 9 #include <memory> |
10 #include <string> | 10 #include <string> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/macros.h" | 13 #include "base/macros.h" |
14 #include "net/base/net_export.h" | 14 #include "net/base/net_export.h" |
15 #include "net/http/http_auth.h" | 15 #include "net/http/http_auth.h" |
16 #include "net/http/url_security_manager.h" | 16 #include "net/http/url_security_manager.h" |
17 | 17 |
18 class GURL; | 18 class GURL; |
19 | 19 |
20 namespace net { | 20 namespace net { |
21 | 21 |
22 class BoundNetLog; | 22 class NetLogWithSource; |
23 class HttpAuthPreferences; | 23 class HttpAuthPreferences; |
24 class HostResolver; | 24 class HostResolver; |
25 class HttpAuthChallengeTokenizer; | 25 class HttpAuthChallengeTokenizer; |
26 class HttpAuthHandler; | 26 class HttpAuthHandler; |
27 class HttpAuthHandlerRegistryFactory; | 27 class HttpAuthHandlerRegistryFactory; |
28 | 28 |
29 // An HttpAuthHandlerFactory is used to create HttpAuthHandler objects. | 29 // An HttpAuthHandlerFactory is used to create HttpAuthHandler objects. |
30 // The HttpAuthHandlerFactory object _must_ outlive any of the HttpAuthHandler | 30 // The HttpAuthHandlerFactory object _must_ outlive any of the HttpAuthHandler |
31 // objects that it creates. | 31 // objects that it creates. |
32 class NET_EXPORT HttpAuthHandlerFactory { | 32 class NET_EXPORT HttpAuthHandlerFactory { |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 // the specified |target|, ERR_INVALID_AUTH_CREDENTIALS is returned. | 81 // the specified |target|, ERR_INVALID_AUTH_CREDENTIALS is returned. |
82 // NOTE: This will apply to ALL |origin| values if the filters are empty. | 82 // NOTE: This will apply to ALL |origin| values if the filters are empty. |
83 // | 83 // |
84 // |*challenge| should not be reused after a call to |CreateAuthHandler()|, | 84 // |*challenge| should not be reused after a call to |CreateAuthHandler()|, |
85 virtual int CreateAuthHandler(HttpAuthChallengeTokenizer* challenge, | 85 virtual int CreateAuthHandler(HttpAuthChallengeTokenizer* challenge, |
86 HttpAuth::Target target, | 86 HttpAuth::Target target, |
87 const SSLInfo& ssl_info, | 87 const SSLInfo& ssl_info, |
88 const GURL& origin, | 88 const GURL& origin, |
89 CreateReason create_reason, | 89 CreateReason create_reason, |
90 int digest_nonce_count, | 90 int digest_nonce_count, |
91 const BoundNetLog& net_log, | 91 const NetLogWithSource& net_log, |
92 std::unique_ptr<HttpAuthHandler>* handler) = 0; | 92 std::unique_ptr<HttpAuthHandler>* handler) = 0; |
93 | 93 |
94 // Creates an HTTP authentication handler based on the authentication | 94 // Creates an HTTP authentication handler based on the authentication |
95 // challenge string |challenge|. | 95 // challenge string |challenge|. |
96 // This is a convenience function which creates a ChallengeTokenizer for | 96 // This is a convenience function which creates a ChallengeTokenizer for |
97 // |challenge| and calls |CreateAuthHandler|. See |CreateAuthHandler| for | 97 // |challenge| and calls |CreateAuthHandler|. See |CreateAuthHandler| for |
98 // more details on return values. | 98 // more details on return values. |
99 int CreateAuthHandlerFromString(const std::string& challenge, | 99 int CreateAuthHandlerFromString(const std::string& challenge, |
100 HttpAuth::Target target, | 100 HttpAuth::Target target, |
101 const SSLInfo& ssl_info, | 101 const SSLInfo& ssl_info, |
102 const GURL& origin, | 102 const GURL& origin, |
103 const BoundNetLog& net_log, | 103 const NetLogWithSource& net_log, |
104 std::unique_ptr<HttpAuthHandler>* handler); | 104 std::unique_ptr<HttpAuthHandler>* handler); |
105 | 105 |
106 // Creates an HTTP authentication handler based on the authentication | 106 // Creates an HTTP authentication handler based on the authentication |
107 // challenge string |challenge|. | 107 // challenge string |challenge|. |
108 // This is a convenience function which creates a ChallengeTokenizer for | 108 // This is a convenience function which creates a ChallengeTokenizer for |
109 // |challenge| and calls |CreateAuthHandler|. See |CreateAuthHandler| for | 109 // |challenge| and calls |CreateAuthHandler|. See |CreateAuthHandler| for |
110 // more details on return values. | 110 // more details on return values. |
111 int CreatePreemptiveAuthHandlerFromString( | 111 int CreatePreemptiveAuthHandlerFromString( |
112 const std::string& challenge, | 112 const std::string& challenge, |
113 HttpAuth::Target target, | 113 HttpAuth::Target target, |
114 const GURL& origin, | 114 const GURL& origin, |
115 int digest_nonce_count, | 115 int digest_nonce_count, |
116 const BoundNetLog& net_log, | 116 const NetLogWithSource& net_log, |
117 std::unique_ptr<HttpAuthHandler>* handler); | 117 std::unique_ptr<HttpAuthHandler>* handler); |
118 | 118 |
119 // Creates a standard HttpAuthHandlerRegistryFactory. The caller is | 119 // Creates a standard HttpAuthHandlerRegistryFactory. The caller is |
120 // responsible for deleting the factory. | 120 // responsible for deleting the factory. |
121 // The default factory supports Basic, Digest, NTLM, and Negotiate schemes. | 121 // The default factory supports Basic, Digest, NTLM, and Negotiate schemes. |
122 // | 122 // |
123 // |resolver| is used by the Negotiate authentication handler to perform | 123 // |resolver| is used by the Negotiate authentication handler to perform |
124 // CNAME lookups to generate a Kerberos SPN for the server. It must be | 124 // CNAME lookups to generate a Kerberos SPN for the server. It must be |
125 // non-NULL. |resolver| must remain valid for the lifetime of the | 125 // non-NULL. |resolver| must remain valid for the lifetime of the |
126 // HttpAuthHandlerRegistryFactory and any HttpAuthHandlers created by said | 126 // HttpAuthHandlerRegistryFactory and any HttpAuthHandlers created by said |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 const HttpAuthPreferences* prefs, | 179 const HttpAuthPreferences* prefs, |
180 HostResolver* host_resolver); | 180 HostResolver* host_resolver); |
181 // Creates an auth handler by dispatching out to the registered factories | 181 // Creates an auth handler by dispatching out to the registered factories |
182 // based on the first token in |challenge|. | 182 // based on the first token in |challenge|. |
183 int CreateAuthHandler(HttpAuthChallengeTokenizer* challenge, | 183 int CreateAuthHandler(HttpAuthChallengeTokenizer* challenge, |
184 HttpAuth::Target target, | 184 HttpAuth::Target target, |
185 const SSLInfo& ssl_info, | 185 const SSLInfo& ssl_info, |
186 const GURL& origin, | 186 const GURL& origin, |
187 CreateReason reason, | 187 CreateReason reason, |
188 int digest_nonce_count, | 188 int digest_nonce_count, |
189 const BoundNetLog& net_log, | 189 const NetLogWithSource& net_log, |
190 std::unique_ptr<HttpAuthHandler>* handler) override; | 190 std::unique_ptr<HttpAuthHandler>* handler) override; |
191 | 191 |
192 private: | 192 private: |
193 using FactoryMap = | 193 using FactoryMap = |
194 std::map<std::string, std::unique_ptr<HttpAuthHandlerFactory>>; | 194 std::map<std::string, std::unique_ptr<HttpAuthHandlerFactory>>; |
195 | 195 |
196 FactoryMap factory_map_; | 196 FactoryMap factory_map_; |
197 DISALLOW_COPY_AND_ASSIGN(HttpAuthHandlerRegistryFactory); | 197 DISALLOW_COPY_AND_ASSIGN(HttpAuthHandlerRegistryFactory); |
198 }; | 198 }; |
199 | 199 |
200 } // namespace net | 200 } // namespace net |
201 | 201 |
202 #endif // NET_HTTP_HTTP_AUTH_HANDLER_FACTORY_H_ | 202 #endif // NET_HTTP_HTTP_AUTH_HANDLER_FACTORY_H_ |
OLD | NEW |