| 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 <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "net/base/net_export.h" | 13 #include "net/base/net_export.h" |
| 14 #include "net/http/http_auth.h" | 14 #include "net/http/http_auth.h" |
| 15 #include "net/http/url_security_manager.h" | 15 #include "net/http/url_security_manager.h" |
| 16 | 16 #include "url/origin.h" |
| 17 class GURL; | |
| 18 | 17 |
| 19 namespace net { | 18 namespace net { |
| 20 | 19 |
| 21 class BoundNetLog; | 20 class BoundNetLog; |
| 22 class HostResolver; | 21 class HostResolver; |
| 23 class HttpAuthChallengeTokenizer; | 22 class HttpAuthChallengeTokenizer; |
| 24 class HttpAuthHandler; | 23 class HttpAuthHandler; |
| 25 class HttpAuthHandlerRegistryFactory; | 24 class HttpAuthHandlerRegistryFactory; |
| 26 | 25 |
| 27 // An HttpAuthHandlerFactory is used to create HttpAuthHandler objects. | 26 // An HttpAuthHandlerFactory is used to create HttpAuthHandler objects. |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 // server nonce challenge. | 68 // server nonce challenge. |
| 70 // | 69 // |
| 71 // For the NTLM and Negotiate handlers: | 70 // For the NTLM and Negotiate handlers: |
| 72 // If |origin| does not match the authentication method's filters for | 71 // If |origin| does not match the authentication method's filters for |
| 73 // the specified |target|, ERR_INVALID_AUTH_CREDENTIALS is returned. | 72 // the specified |target|, ERR_INVALID_AUTH_CREDENTIALS is returned. |
| 74 // NOTE: This will apply to ALL |origin| values if the filters are empty. | 73 // NOTE: This will apply to ALL |origin| values if the filters are empty. |
| 75 // | 74 // |
| 76 // |*challenge| should not be reused after a call to |CreateAuthHandler()|, | 75 // |*challenge| should not be reused after a call to |CreateAuthHandler()|, |
| 77 virtual int CreateAuthHandler(HttpAuthChallengeTokenizer* challenge, | 76 virtual int CreateAuthHandler(HttpAuthChallengeTokenizer* challenge, |
| 78 HttpAuth::Target target, | 77 HttpAuth::Target target, |
| 79 const GURL& origin, | 78 const url::Origin& origin, |
| 80 CreateReason create_reason, | 79 CreateReason create_reason, |
| 81 int digest_nonce_count, | 80 int digest_nonce_count, |
| 82 const BoundNetLog& net_log, | 81 const BoundNetLog& net_log, |
| 83 scoped_ptr<HttpAuthHandler>* handler) = 0; | 82 scoped_ptr<HttpAuthHandler>* handler) = 0; |
| 84 | 83 |
| 85 // Creates an HTTP authentication handler based on the authentication | 84 // Creates an HTTP authentication handler based on the authentication |
| 86 // challenge string |challenge|. | 85 // challenge string |challenge|. |
| 87 // This is a convenience function which creates a ChallengeTokenizer for | 86 // This is a convenience function which creates a ChallengeTokenizer for |
| 88 // |challenge| and calls |CreateAuthHandler|. See |CreateAuthHandler| for | 87 // |challenge| and calls |CreateAuthHandler|. See |CreateAuthHandler| for |
| 89 // more details on return values. | 88 // more details on return values. |
| 90 int CreateAuthHandlerFromString(const std::string& challenge, | 89 int CreateAuthHandlerFromString(const std::string& challenge, |
| 91 HttpAuth::Target target, | 90 HttpAuth::Target target, |
| 92 const GURL& origin, | 91 const url::Origin& origin, |
| 93 const BoundNetLog& net_log, | 92 const BoundNetLog& net_log, |
| 94 scoped_ptr<HttpAuthHandler>* handler); | 93 scoped_ptr<HttpAuthHandler>* handler); |
| 95 | 94 |
| 96 // Creates an HTTP authentication handler based on the authentication | 95 // Creates an HTTP authentication handler based on the authentication |
| 97 // challenge string |challenge|. | 96 // challenge string |challenge|. |
| 98 // This is a convenience function which creates a ChallengeTokenizer for | 97 // This is a convenience function which creates a ChallengeTokenizer for |
| 99 // |challenge| and calls |CreateAuthHandler|. See |CreateAuthHandler| for | 98 // |challenge| and calls |CreateAuthHandler|. See |CreateAuthHandler| for |
| 100 // more details on return values. | 99 // more details on return values. |
| 101 int CreatePreemptiveAuthHandlerFromString( | 100 int CreatePreemptiveAuthHandlerFromString( |
| 102 const std::string& challenge, | 101 const std::string& challenge, |
| 103 HttpAuth::Target target, | 102 HttpAuth::Target target, |
| 104 const GURL& origin, | 103 const url::Origin& origin, |
| 105 int digest_nonce_count, | 104 int digest_nonce_count, |
| 106 const BoundNetLog& net_log, | 105 const BoundNetLog& net_log, |
| 107 scoped_ptr<HttpAuthHandler>* handler); | 106 scoped_ptr<HttpAuthHandler>* handler); |
| 108 | 107 |
| 109 // Creates a standard HttpAuthHandlerRegistryFactory. The caller is | 108 // Creates a standard HttpAuthHandlerRegistryFactory. The caller is |
| 110 // responsible for deleting the factory. | 109 // responsible for deleting the factory. |
| 111 // The default factory supports Basic, Digest, NTLM, and Negotiate schemes. | 110 // The default factory supports Basic, Digest, NTLM, and Negotiate schemes. |
| 112 // | 111 // |
| 113 // |resolver| is used by the Negotiate authentication handler to perform | 112 // |resolver| is used by the Negotiate authentication handler to perform |
| 114 // CNAME lookups to generate a Kerberos SPN for the server. It must be | 113 // CNAME lookups to generate a Kerberos SPN for the server. It must be |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 URLSecurityManager* security_manager, | 177 URLSecurityManager* security_manager, |
| 179 HostResolver* host_resolver, | 178 HostResolver* host_resolver, |
| 180 const std::string& gssapi_library_name, | 179 const std::string& gssapi_library_name, |
| 181 bool negotiate_disable_cname_lookup, | 180 bool negotiate_disable_cname_lookup, |
| 182 bool negotiate_enable_port); | 181 bool negotiate_enable_port); |
| 183 | 182 |
| 184 // Creates an auth handler by dispatching out to the registered factories | 183 // Creates an auth handler by dispatching out to the registered factories |
| 185 // based on the first token in |challenge|. | 184 // based on the first token in |challenge|. |
| 186 int CreateAuthHandler(HttpAuthChallengeTokenizer* challenge, | 185 int CreateAuthHandler(HttpAuthChallengeTokenizer* challenge, |
| 187 HttpAuth::Target target, | 186 HttpAuth::Target target, |
| 188 const GURL& origin, | 187 const url::Origin& origin, |
| 189 CreateReason reason, | 188 CreateReason reason, |
| 190 int digest_nonce_count, | 189 int digest_nonce_count, |
| 191 const BoundNetLog& net_log, | 190 const BoundNetLog& net_log, |
| 192 scoped_ptr<HttpAuthHandler>* handler) override; | 191 scoped_ptr<HttpAuthHandler>* handler) override; |
| 193 | 192 |
| 194 private: | 193 private: |
| 195 typedef std::map<std::string, HttpAuthHandlerFactory*> FactoryMap; | 194 typedef std::map<std::string, HttpAuthHandlerFactory*> FactoryMap; |
| 196 | 195 |
| 197 FactoryMap factory_map_; | 196 FactoryMap factory_map_; |
| 198 DISALLOW_COPY_AND_ASSIGN(HttpAuthHandlerRegistryFactory); | 197 DISALLOW_COPY_AND_ASSIGN(HttpAuthHandlerRegistryFactory); |
| 199 }; | 198 }; |
| 200 | 199 |
| 201 } // namespace net | 200 } // namespace net |
| 202 | 201 |
| 203 #endif // NET_HTTP_HTTP_AUTH_HANDLER_FACTORY_H_ | 202 #endif // NET_HTTP_HTTP_AUTH_HANDLER_FACTORY_H_ |
| OLD | NEW |