Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #include "net/http/http_auth_handler_factory.h" | 5 #include "net/http/http_auth_handler_factory.h" |
| 6 | 6 |
| 7 #include "base/stl_util-inl.h" | 7 #include "base/stl_util-inl.h" |
| 8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
| 9 #include "net/base/net_errors.h" | 9 #include "net/base/net_errors.h" |
| 10 #include "net/http/http_auth_filter.h" | 10 #include "net/http/http_auth_filter.h" |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 43 HostResolver* host_resolver) { | 43 HostResolver* host_resolver) { |
| 44 DCHECK(host_resolver); | 44 DCHECK(host_resolver); |
| 45 HttpAuthHandlerRegistryFactory* registry_factory = | 45 HttpAuthHandlerRegistryFactory* registry_factory = |
| 46 new HttpAuthHandlerRegistryFactory(); | 46 new HttpAuthHandlerRegistryFactory(); |
| 47 registry_factory->RegisterSchemeFactory( | 47 registry_factory->RegisterSchemeFactory( |
| 48 "basic", new HttpAuthHandlerBasic::Factory()); | 48 "basic", new HttpAuthHandlerBasic::Factory()); |
| 49 registry_factory->RegisterSchemeFactory( | 49 registry_factory->RegisterSchemeFactory( |
| 50 "digest", new HttpAuthHandlerDigest::Factory()); | 50 "digest", new HttpAuthHandlerDigest::Factory()); |
| 51 HttpAuthHandlerNegotiate::Factory* negotiate_factory = | 51 HttpAuthHandlerNegotiate::Factory* negotiate_factory = |
| 52 new HttpAuthHandlerNegotiate::Factory(); | 52 new HttpAuthHandlerNegotiate::Factory(); |
| 53 #if defined(OS_POSIX) | |
| 54 negotiate_factory->set_library(new GSSAPISharedLibrary("")); | |
|
cbentzel
2010/11/11 03:37:51
I've occasionally seen
std::string()
instead o
Jakob Kummerow (corp)
2010/11/11 11:10:53
Done.
| |
| 55 #elif defined(OS_WIN) | |
| 56 negotiate_factory->set_library(new SSPILibraryDefault()); | |
| 57 #endif | |
| 53 negotiate_factory->set_host_resolver(host_resolver); | 58 negotiate_factory->set_host_resolver(host_resolver); |
| 54 registry_factory->RegisterSchemeFactory("negotiate", negotiate_factory); | 59 registry_factory->RegisterSchemeFactory("negotiate", negotiate_factory); |
| 55 registry_factory->RegisterSchemeFactory( | 60 registry_factory->RegisterSchemeFactory( |
| 56 "ntlm", new HttpAuthHandlerNTLM::Factory()); | 61 "ntlm", new HttpAuthHandlerNTLM::Factory()); |
| 57 return registry_factory; | 62 return registry_factory; |
| 58 } | 63 } |
| 59 | 64 |
| 60 namespace { | 65 namespace { |
| 61 | 66 |
| 62 bool IsSupportedScheme(const std::vector<std::string>& supported_schemes, | 67 bool IsSupportedScheme(const std::vector<std::string>& supported_schemes, |
| 63 const std::string& scheme) { | 68 const std::string& scheme) { |
| 64 std::vector<std::string>::const_iterator it = std::find( | 69 std::vector<std::string>::const_iterator it = std::find( |
| 65 supported_schemes.begin(), supported_schemes.end(), scheme); | 70 supported_schemes.begin(), supported_schemes.end(), scheme); |
| 66 return it != supported_schemes.end(); | 71 return it != supported_schemes.end(); |
| 67 } | 72 } |
| 68 | 73 |
| 69 } // namespace | 74 } // namespace |
| 70 | 75 |
| 71 // static | 76 // static |
| 72 HttpAuthHandlerRegistryFactory* HttpAuthHandlerRegistryFactory::Create( | 77 HttpAuthHandlerRegistryFactory* HttpAuthHandlerRegistryFactory::Create( |
| 73 const std::vector<std::string>& supported_schemes, | 78 const std::vector<std::string>& supported_schemes, |
| 74 URLSecurityManager* security_manager, | 79 URLSecurityManager* security_manager, |
| 75 HostResolver* host_resolver, | 80 HostResolver* host_resolver, |
| 81 const std::string& gssapi_library_name, | |
| 76 bool negotiate_disable_cname_lookup, | 82 bool negotiate_disable_cname_lookup, |
| 77 bool negotiate_enable_port) { | 83 bool negotiate_enable_port) { |
| 78 HttpAuthHandlerRegistryFactory* registry_factory = | 84 HttpAuthHandlerRegistryFactory* registry_factory = |
| 79 new HttpAuthHandlerRegistryFactory(); | 85 new HttpAuthHandlerRegistryFactory(); |
| 80 if (IsSupportedScheme(supported_schemes, "basic")) | 86 if (IsSupportedScheme(supported_schemes, "basic")) |
| 81 registry_factory->RegisterSchemeFactory( | 87 registry_factory->RegisterSchemeFactory( |
| 82 "basic", new HttpAuthHandlerBasic::Factory()); | 88 "basic", new HttpAuthHandlerBasic::Factory()); |
| 83 if (IsSupportedScheme(supported_schemes, "digest")) | 89 if (IsSupportedScheme(supported_schemes, "digest")) |
| 84 registry_factory->RegisterSchemeFactory( | 90 registry_factory->RegisterSchemeFactory( |
| 85 "digest", new HttpAuthHandlerDigest::Factory()); | 91 "digest", new HttpAuthHandlerDigest::Factory()); |
| 86 if (IsSupportedScheme(supported_schemes, "ntlm")) { | 92 if (IsSupportedScheme(supported_schemes, "ntlm")) { |
| 87 HttpAuthHandlerNTLM::Factory* ntlm_factory = | 93 HttpAuthHandlerNTLM::Factory* ntlm_factory = |
| 88 new HttpAuthHandlerNTLM::Factory(); | 94 new HttpAuthHandlerNTLM::Factory(); |
| 89 ntlm_factory->set_url_security_manager(security_manager); | 95 ntlm_factory->set_url_security_manager(security_manager); |
| 90 registry_factory->RegisterSchemeFactory("ntlm", ntlm_factory); | 96 registry_factory->RegisterSchemeFactory("ntlm", ntlm_factory); |
| 91 } | 97 } |
| 92 if (IsSupportedScheme(supported_schemes, "negotiate")) { | 98 if (IsSupportedScheme(supported_schemes, "negotiate")) { |
| 93 HttpAuthHandlerNegotiate::Factory* negotiate_factory = | 99 HttpAuthHandlerNegotiate::Factory* negotiate_factory = |
| 94 new HttpAuthHandlerNegotiate::Factory(); | 100 new HttpAuthHandlerNegotiate::Factory(); |
| 101 #if defined(OS_POSIX) | |
| 102 negotiate_factory->set_library( | |
| 103 new GSSAPISharedLibrary(gssapi_library_name)); | |
| 104 #elif defined(OS_WIN) | |
| 105 negotiate_factory->set_library(new SSPILibraryDefault()); | |
| 106 #endif | |
| 95 negotiate_factory->set_url_security_manager(security_manager); | 107 negotiate_factory->set_url_security_manager(security_manager); |
| 96 DCHECK(host_resolver || negotiate_disable_cname_lookup); | 108 DCHECK(host_resolver || negotiate_disable_cname_lookup); |
| 97 negotiate_factory->set_host_resolver(host_resolver); | 109 negotiate_factory->set_host_resolver(host_resolver); |
| 98 negotiate_factory->set_disable_cname_lookup(negotiate_disable_cname_lookup); | 110 negotiate_factory->set_disable_cname_lookup(negotiate_disable_cname_lookup); |
| 99 negotiate_factory->set_use_port(negotiate_enable_port); | 111 negotiate_factory->set_use_port(negotiate_enable_port); |
| 100 registry_factory->RegisterSchemeFactory("negotiate", negotiate_factory); | 112 registry_factory->RegisterSchemeFactory("negotiate", negotiate_factory); |
| 101 } | 113 } |
| 102 | 114 |
| 103 return registry_factory; | 115 return registry_factory; |
| 104 } | 116 } |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 161 const std::string& scheme) const { | 173 const std::string& scheme) const { |
| 162 std::string lower_scheme = StringToLowerASCII(scheme); | 174 std::string lower_scheme = StringToLowerASCII(scheme); |
| 163 FactoryMap::const_iterator it = factory_map_.find(lower_scheme); | 175 FactoryMap::const_iterator it = factory_map_.find(lower_scheme); |
| 164 if (it == factory_map_.end()) { | 176 if (it == factory_map_.end()) { |
| 165 return NULL; // |scheme| is not registered. | 177 return NULL; // |scheme| is not registered. |
| 166 } | 178 } |
| 167 return it->second; | 179 return it->second; |
| 168 } | 180 } |
| 169 | 181 |
| 170 } // namespace net | 182 } // namespace net |
| OLD | NEW |