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/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" |
11 #include "net/http/http_auth_handler_basic.h" | 11 #include "net/http/http_auth_handler_basic.h" |
12 #include "net/http/http_auth_handler_digest.h" | 12 #include "net/http/http_auth_handler_digest.h" |
13 #if defined(USE_KERBEROS) | |
13 #include "net/http/http_auth_handler_negotiate.h" | 14 #include "net/http/http_auth_handler_negotiate.h" |
15 #endif | |
wtc
2011/08/15 22:43:06
The Chromium Coding Style page recommends that we
Paweł Hajdan Jr.
2011/08/18 17:04:36
Done here: http://codereview.chromium.org/7655046/
| |
14 #include "net/http/http_auth_handler_ntlm.h" | 16 #include "net/http/http_auth_handler_ntlm.h" |
15 | 17 |
16 namespace net { | 18 namespace net { |
17 | 19 |
18 int HttpAuthHandlerFactory::CreateAuthHandlerFromString( | 20 int HttpAuthHandlerFactory::CreateAuthHandlerFromString( |
19 const std::string& challenge, | 21 const std::string& challenge, |
20 HttpAuth::Target target, | 22 HttpAuth::Target target, |
21 const GURL& origin, | 23 const GURL& origin, |
22 const BoundNetLog& net_log, | 24 const BoundNetLog& net_log, |
23 scoped_ptr<HttpAuthHandler>* handler) { | 25 scoped_ptr<HttpAuthHandler>* handler) { |
(...skipping 18 matching lines...) Expand all Loading... | |
42 HttpAuthHandlerRegistryFactory* HttpAuthHandlerFactory::CreateDefault( | 44 HttpAuthHandlerRegistryFactory* HttpAuthHandlerFactory::CreateDefault( |
43 HostResolver* host_resolver) { | 45 HostResolver* host_resolver) { |
44 DCHECK(host_resolver); | 46 DCHECK(host_resolver); |
45 HttpAuthHandlerRegistryFactory* registry_factory = | 47 HttpAuthHandlerRegistryFactory* registry_factory = |
46 new HttpAuthHandlerRegistryFactory(); | 48 new HttpAuthHandlerRegistryFactory(); |
47 registry_factory->RegisterSchemeFactory( | 49 registry_factory->RegisterSchemeFactory( |
48 "basic", new HttpAuthHandlerBasic::Factory()); | 50 "basic", new HttpAuthHandlerBasic::Factory()); |
49 registry_factory->RegisterSchemeFactory( | 51 registry_factory->RegisterSchemeFactory( |
50 "digest", new HttpAuthHandlerDigest::Factory()); | 52 "digest", new HttpAuthHandlerDigest::Factory()); |
51 | 53 |
54 #if defined(USE_KERBEROS) | |
52 HttpAuthHandlerNegotiate::Factory* negotiate_factory = | 55 HttpAuthHandlerNegotiate::Factory* negotiate_factory = |
53 new HttpAuthHandlerNegotiate::Factory(); | 56 new HttpAuthHandlerNegotiate::Factory(); |
54 #if defined(OS_POSIX) | 57 #if defined(OS_POSIX) |
55 negotiate_factory->set_library(new GSSAPISharedLibrary(std::string())); | 58 negotiate_factory->set_library(new GSSAPISharedLibrary(std::string())); |
56 #elif defined(OS_WIN) | 59 #elif defined(OS_WIN) |
57 negotiate_factory->set_library(new SSPILibraryDefault()); | 60 negotiate_factory->set_library(new SSPILibraryDefault()); |
58 #endif | 61 #endif |
59 negotiate_factory->set_host_resolver(host_resolver); | 62 negotiate_factory->set_host_resolver(host_resolver); |
60 registry_factory->RegisterSchemeFactory("negotiate", negotiate_factory); | 63 registry_factory->RegisterSchemeFactory("negotiate", negotiate_factory); |
64 #endif // defined(USE_KERBEROS) | |
61 | 65 |
62 HttpAuthHandlerNTLM::Factory* ntlm_factory = | 66 HttpAuthHandlerNTLM::Factory* ntlm_factory = |
63 new HttpAuthHandlerNTLM::Factory(); | 67 new HttpAuthHandlerNTLM::Factory(); |
64 #if defined(OS_WIN) | 68 #if defined(OS_WIN) |
65 ntlm_factory->set_sspi_library(new SSPILibraryDefault()); | 69 ntlm_factory->set_sspi_library(new SSPILibraryDefault()); |
66 #endif | 70 #endif |
67 registry_factory->RegisterSchemeFactory("ntlm", ntlm_factory); | 71 registry_factory->RegisterSchemeFactory("ntlm", ntlm_factory); |
68 return registry_factory; | 72 return registry_factory; |
69 } | 73 } |
70 | 74 |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
137 "digest", new HttpAuthHandlerDigest::Factory()); | 141 "digest", new HttpAuthHandlerDigest::Factory()); |
138 if (IsSupportedScheme(supported_schemes, "ntlm")) { | 142 if (IsSupportedScheme(supported_schemes, "ntlm")) { |
139 HttpAuthHandlerNTLM::Factory* ntlm_factory = | 143 HttpAuthHandlerNTLM::Factory* ntlm_factory = |
140 new HttpAuthHandlerNTLM::Factory(); | 144 new HttpAuthHandlerNTLM::Factory(); |
141 ntlm_factory->set_url_security_manager(security_manager); | 145 ntlm_factory->set_url_security_manager(security_manager); |
142 #if defined(OS_WIN) | 146 #if defined(OS_WIN) |
143 ntlm_factory->set_sspi_library(new SSPILibraryDefault()); | 147 ntlm_factory->set_sspi_library(new SSPILibraryDefault()); |
144 #endif | 148 #endif |
145 registry_factory->RegisterSchemeFactory("ntlm", ntlm_factory); | 149 registry_factory->RegisterSchemeFactory("ntlm", ntlm_factory); |
146 } | 150 } |
151 #if defined(USE_KERBEROS) | |
147 if (IsSupportedScheme(supported_schemes, "negotiate")) { | 152 if (IsSupportedScheme(supported_schemes, "negotiate")) { |
148 HttpAuthHandlerNegotiate::Factory* negotiate_factory = | 153 HttpAuthHandlerNegotiate::Factory* negotiate_factory = |
149 new HttpAuthHandlerNegotiate::Factory(); | 154 new HttpAuthHandlerNegotiate::Factory(); |
150 #if defined(OS_POSIX) | 155 #if defined(OS_POSIX) |
151 negotiate_factory->set_library( | 156 negotiate_factory->set_library( |
152 new GSSAPISharedLibrary(gssapi_library_name)); | 157 new GSSAPISharedLibrary(gssapi_library_name)); |
153 #elif defined(OS_WIN) | 158 #elif defined(OS_WIN) |
154 negotiate_factory->set_library(new SSPILibraryDefault()); | 159 negotiate_factory->set_library(new SSPILibraryDefault()); |
155 #endif | 160 #endif |
156 negotiate_factory->set_url_security_manager(security_manager); | 161 negotiate_factory->set_url_security_manager(security_manager); |
157 DCHECK(host_resolver || negotiate_disable_cname_lookup); | 162 DCHECK(host_resolver || negotiate_disable_cname_lookup); |
158 negotiate_factory->set_host_resolver(host_resolver); | 163 negotiate_factory->set_host_resolver(host_resolver); |
159 negotiate_factory->set_disable_cname_lookup(negotiate_disable_cname_lookup); | 164 negotiate_factory->set_disable_cname_lookup(negotiate_disable_cname_lookup); |
160 negotiate_factory->set_use_port(negotiate_enable_port); | 165 negotiate_factory->set_use_port(negotiate_enable_port); |
161 registry_factory->RegisterSchemeFactory("negotiate", negotiate_factory); | 166 registry_factory->RegisterSchemeFactory("negotiate", negotiate_factory); |
162 } | 167 } |
168 #endif // defined(USE_KERBEROS) | |
163 | 169 |
164 return registry_factory; | 170 return registry_factory; |
165 } | 171 } |
166 | 172 |
167 int HttpAuthHandlerRegistryFactory::CreateAuthHandler( | 173 int HttpAuthHandlerRegistryFactory::CreateAuthHandler( |
168 HttpAuth::ChallengeTokenizer* challenge, | 174 HttpAuth::ChallengeTokenizer* challenge, |
169 HttpAuth::Target target, | 175 HttpAuth::Target target, |
170 const GURL& origin, | 176 const GURL& origin, |
171 CreateReason reason, | 177 CreateReason reason, |
172 int digest_nonce_count, | 178 int digest_nonce_count, |
173 const BoundNetLog& net_log, | 179 const BoundNetLog& net_log, |
174 scoped_ptr<HttpAuthHandler>* handler) { | 180 scoped_ptr<HttpAuthHandler>* handler) { |
175 std::string scheme = challenge->scheme(); | 181 std::string scheme = challenge->scheme(); |
176 if (scheme.empty()) { | 182 if (scheme.empty()) { |
177 handler->reset(); | 183 handler->reset(); |
178 return ERR_INVALID_RESPONSE; | 184 return ERR_INVALID_RESPONSE; |
179 } | 185 } |
180 std::string lower_scheme = StringToLowerASCII(scheme); | 186 std::string lower_scheme = StringToLowerASCII(scheme); |
181 FactoryMap::iterator it = factory_map_.find(lower_scheme); | 187 FactoryMap::iterator it = factory_map_.find(lower_scheme); |
182 if (it == factory_map_.end()) { | 188 if (it == factory_map_.end()) { |
183 handler->reset(); | 189 handler->reset(); |
184 return ERR_UNSUPPORTED_AUTH_SCHEME; | 190 return ERR_UNSUPPORTED_AUTH_SCHEME; |
185 } | 191 } |
186 DCHECK(it->second); | 192 DCHECK(it->second); |
187 return it->second->CreateAuthHandler(challenge, target, origin, reason, | 193 return it->second->CreateAuthHandler(challenge, target, origin, reason, |
188 digest_nonce_count, net_log, handler); | 194 digest_nonce_count, net_log, handler); |
189 } | 195 } |
190 | 196 |
191 } // namespace net | 197 } // namespace net |
OLD | NEW |