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.h" | 7 #include "base/stl_util.h" |
8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
9 #include "net/base/net_errors.h" | 9 #include "net/base/net_errors.h" |
10 #include "net/http/http_auth_challenge_tokenizer.h" | 10 #include "net/http/http_auth_challenge_tokenizer.h" |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
123 FactoryMap::const_iterator it = factory_map_.find(lower_scheme); | 123 FactoryMap::const_iterator it = factory_map_.find(lower_scheme); |
124 if (it == factory_map_.end()) { | 124 if (it == factory_map_.end()) { |
125 return NULL; // |scheme| is not registered. | 125 return NULL; // |scheme| is not registered. |
126 } | 126 } |
127 return it->second; | 127 return it->second; |
128 } | 128 } |
129 | 129 |
130 // static | 130 // static |
131 HttpAuthHandlerRegistryFactory* HttpAuthHandlerRegistryFactory::Create( | 131 HttpAuthHandlerRegistryFactory* HttpAuthHandlerRegistryFactory::Create( |
132 const std::vector<std::string>& supported_schemes, | 132 const std::vector<std::string>& supported_schemes, |
133 URLSecurityManager* security_manager, | |
134 HostResolver* host_resolver, | 133 HostResolver* host_resolver, |
135 const std::string& gssapi_library_name, | 134 const std::string& gssapi_library_name) { |
136 const std::string& auth_android_negotiate_account_type, | |
137 bool negotiate_disable_cname_lookup, | |
138 bool negotiate_enable_port) { | |
139 HttpAuthHandlerRegistryFactory* registry_factory = | 135 HttpAuthHandlerRegistryFactory* registry_factory = |
140 new HttpAuthHandlerRegistryFactory(); | 136 new HttpAuthHandlerRegistryFactory(); |
141 if (IsSupportedScheme(supported_schemes, "basic")) | 137 if (IsSupportedScheme(supported_schemes, "basic")) |
142 registry_factory->RegisterSchemeFactory( | 138 registry_factory->RegisterSchemeFactory( |
143 "basic", new HttpAuthHandlerBasic::Factory()); | 139 "basic", new HttpAuthHandlerBasic::Factory()); |
144 if (IsSupportedScheme(supported_schemes, "digest")) | 140 if (IsSupportedScheme(supported_schemes, "digest")) |
145 registry_factory->RegisterSchemeFactory( | 141 registry_factory->RegisterSchemeFactory( |
146 "digest", new HttpAuthHandlerDigest::Factory()); | 142 "digest", new HttpAuthHandlerDigest::Factory()); |
147 if (IsSupportedScheme(supported_schemes, "ntlm")) { | 143 if (IsSupportedScheme(supported_schemes, "ntlm")) { |
148 HttpAuthHandlerNTLM::Factory* ntlm_factory = | 144 HttpAuthHandlerNTLM::Factory* ntlm_factory = |
149 new HttpAuthHandlerNTLM::Factory(); | 145 new HttpAuthHandlerNTLM::Factory(); |
150 ntlm_factory->set_url_security_manager(security_manager); | |
151 #if defined(OS_WIN) | 146 #if defined(OS_WIN) |
152 ntlm_factory->set_sspi_library(new SSPILibraryDefault()); | 147 ntlm_factory->set_sspi_library(new SSPILibraryDefault()); |
153 #endif | 148 #endif |
154 registry_factory->RegisterSchemeFactory("ntlm", ntlm_factory); | 149 registry_factory->RegisterSchemeFactory("ntlm", ntlm_factory); |
155 } | 150 } |
156 #if defined(USE_KERBEROS) | 151 #if defined(USE_KERBEROS) |
157 if (IsSupportedScheme(supported_schemes, "negotiate")) { | 152 if (IsSupportedScheme(supported_schemes, "negotiate")) { |
158 HttpAuthHandlerNegotiate::Factory* negotiate_factory = | 153 HttpAuthHandlerNegotiate::Factory* negotiate_factory = |
159 new HttpAuthHandlerNegotiate::Factory(); | 154 new HttpAuthHandlerNegotiate::Factory(); |
160 #if defined(OS_ANDROID) | 155 #if defined(OS_POSIX) && !defined(OS_ANDROID) |
161 negotiate_factory->set_library(&auth_android_negotiate_account_type); | |
162 #elif defined(OS_POSIX) | |
163 negotiate_factory->set_library( | 156 negotiate_factory->set_library( |
164 new GSSAPISharedLibrary(gssapi_library_name)); | 157 new GSSAPISharedLibrary(gssapi_library_name)); |
165 #elif defined(OS_WIN) | 158 #elif defined(OS_WIN) |
166 negotiate_factory->set_library(new SSPILibraryDefault()); | 159 negotiate_factory->set_library(new SSPILibraryDefault()); |
167 #endif | 160 #endif |
168 negotiate_factory->set_url_security_manager(security_manager); | |
169 DCHECK(host_resolver || negotiate_disable_cname_lookup); | |
170 negotiate_factory->set_host_resolver(host_resolver); | 161 negotiate_factory->set_host_resolver(host_resolver); |
171 negotiate_factory->set_disable_cname_lookup(negotiate_disable_cname_lookup); | |
172 negotiate_factory->set_use_port(negotiate_enable_port); | |
173 registry_factory->RegisterSchemeFactory("negotiate", negotiate_factory); | 162 registry_factory->RegisterSchemeFactory("negotiate", negotiate_factory); |
174 } | 163 } |
175 #endif // defined(USE_KERBEROS) | 164 #endif // defined(USE_KERBEROS) |
176 | 165 |
177 return registry_factory; | 166 return registry_factory; |
178 } | 167 } |
179 | 168 |
180 int HttpAuthHandlerRegistryFactory::CreateAuthHandler( | 169 int HttpAuthHandlerRegistryFactory::CreateAuthHandler( |
181 HttpAuthChallengeTokenizer* challenge, | 170 HttpAuthChallengeTokenizer* challenge, |
182 HttpAuth::Target target, | 171 HttpAuth::Target target, |
(...skipping 11 matching lines...) Expand all Loading... | |
194 FactoryMap::iterator it = factory_map_.find(lower_scheme); | 183 FactoryMap::iterator it = factory_map_.find(lower_scheme); |
195 if (it == factory_map_.end()) { | 184 if (it == factory_map_.end()) { |
196 handler->reset(); | 185 handler->reset(); |
197 return ERR_UNSUPPORTED_AUTH_SCHEME; | 186 return ERR_UNSUPPORTED_AUTH_SCHEME; |
198 } | 187 } |
199 DCHECK(it->second); | 188 DCHECK(it->second); |
200 return it->second->CreateAuthHandler(challenge, target, origin, reason, | 189 return it->second->CreateAuthHandler(challenge, target, origin, reason, |
201 digest_nonce_count, net_log, handler); | 190 digest_nonce_count, net_log, handler); |
202 } | 191 } |
203 | 192 |
193 void HttpAuthHandlerRegistryFactory::SetSecurityManager( | |
194 URLSecurityManager* security_manager) { | |
195 HttpAuthHandlerFactory* ntlm_factory = GetSchemeFactory("ntml"); | |
Bernhard Bauer
2015/10/21 09:51:10
ntlm! Would it make sense to extract these to cons
aberent
2015/10/22 17:57:03
Done.
| |
196 if (ntlm_factory) | |
197 ntlm_factory->set_url_security_manager(security_manager); | |
198 HttpAuthHandlerFactory* negotiate_factory = GetSchemeFactory("negotiate"); | |
199 if (negotiate_factory) | |
200 negotiate_factory->set_url_security_manager(security_manager); | |
201 } | |
202 | |
203 void HttpAuthHandlerRegistryFactory::SetAndroidAuthNegotiateAccountType( | |
204 const std::string& account_type) { | |
205 #if defined(OS_ANDROID) | |
206 HttpAuthHandlerNegotiate::Factory* negotiate_factory = | |
207 (HttpAuthHandlerNegotiate::Factory*)GetSchemeFactory("negotiate"); | |
Bernhard Bauer
2015/10/21 09:51:10
Use static_cast<...>() instead of C-style casts.
aberent
2015/10/22 17:57:03
Done.
| |
208 negotiate_factory->set_library(&account_type); | |
209 #endif | |
210 } | |
211 | |
212 void HttpAuthHandlerRegistryFactory::SetNegotiateDisableCnameLookup( | |
213 bool negotiate_disable_cname_lookup) { | |
214 HttpAuthHandlerNegotiate::Factory* negotiate_factory = | |
215 (HttpAuthHandlerNegotiate::Factory*)GetSchemeFactory("negotiate"); | |
216 negotiate_factory->set_disable_cname_lookup(negotiate_disable_cname_lookup); | |
217 } | |
218 | |
219 void HttpAuthHandlerRegistryFactory::SetNegotiateEnablePort( | |
220 bool negotiate_enable_port) { | |
221 HttpAuthHandlerNegotiate::Factory* negotiate_factory = | |
222 (HttpAuthHandlerNegotiate::Factory*)GetSchemeFactory("negotiate"); | |
223 negotiate_factory->set_use_port(negotiate_enable_port); | |
224 } | |
225 | |
204 } // namespace net | 226 } // namespace net |
OLD | NEW |