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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 HttpAuthHandlerRegistryFactory* HttpAuthHandlerFactory::CreateDefault( | 46 HttpAuthHandlerRegistryFactory* HttpAuthHandlerFactory::CreateDefault( |
47 HostResolver* host_resolver) { | 47 HostResolver* host_resolver) { |
48 DCHECK(host_resolver); | 48 DCHECK(host_resolver); |
49 HttpAuthHandlerRegistryFactory* registry_factory = | 49 HttpAuthHandlerRegistryFactory* registry_factory = |
50 new HttpAuthHandlerRegistryFactory(); | 50 new HttpAuthHandlerRegistryFactory(); |
51 registry_factory->RegisterSchemeFactory( | 51 registry_factory->RegisterSchemeFactory( |
52 "basic", new HttpAuthHandlerBasic::Factory()); | 52 "basic", new HttpAuthHandlerBasic::Factory()); |
53 registry_factory->RegisterSchemeFactory( | 53 registry_factory->RegisterSchemeFactory( |
54 "digest", new HttpAuthHandlerDigest::Factory()); | 54 "digest", new HttpAuthHandlerDigest::Factory()); |
55 | 55 |
56 #if defined(USE_KERBEROS) | 56 // On Android Chrome needs an account type configured to enable Kerberos, |
| 57 // so the default factory should not include Kerberos. |
| 58 #if defined(USE_KERBEROS) && !defined(OS_ANDROID) |
57 HttpAuthHandlerNegotiate::Factory* negotiate_factory = | 59 HttpAuthHandlerNegotiate::Factory* negotiate_factory = |
58 new HttpAuthHandlerNegotiate::Factory(); | 60 new HttpAuthHandlerNegotiate::Factory(); |
59 #if defined(OS_POSIX) | 61 #if defined(OS_POSIX) |
60 negotiate_factory->set_library(new GSSAPISharedLibrary(std::string())); | 62 negotiate_factory->set_library(new GSSAPISharedLibrary(std::string())); |
61 #elif defined(OS_WIN) | 63 #elif defined(OS_WIN) |
62 negotiate_factory->set_library(new SSPILibraryDefault()); | 64 negotiate_factory->set_library(new SSPILibraryDefault()); |
63 #endif | 65 #endif |
64 negotiate_factory->set_host_resolver(host_resolver); | 66 negotiate_factory->set_host_resolver(host_resolver); |
65 registry_factory->RegisterSchemeFactory("negotiate", negotiate_factory); | 67 registry_factory->RegisterSchemeFactory("negotiate", negotiate_factory); |
66 #endif // defined(USE_KERBEROS) | 68 #endif // defined(USE_KERBEROS) && !defined(OS_ANDROID) |
67 | 69 |
68 HttpAuthHandlerNTLM::Factory* ntlm_factory = | 70 HttpAuthHandlerNTLM::Factory* ntlm_factory = |
69 new HttpAuthHandlerNTLM::Factory(); | 71 new HttpAuthHandlerNTLM::Factory(); |
70 #if defined(OS_WIN) | 72 #if defined(OS_WIN) |
71 ntlm_factory->set_sspi_library(new SSPILibraryDefault()); | 73 ntlm_factory->set_sspi_library(new SSPILibraryDefault()); |
72 #endif | 74 #endif |
73 registry_factory->RegisterSchemeFactory("ntlm", ntlm_factory); | 75 registry_factory->RegisterSchemeFactory("ntlm", ntlm_factory); |
74 return registry_factory; | 76 return registry_factory; |
75 } | 77 } |
76 | 78 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 } | 126 } |
125 return it->second; | 127 return it->second; |
126 } | 128 } |
127 | 129 |
128 // static | 130 // static |
129 HttpAuthHandlerRegistryFactory* HttpAuthHandlerRegistryFactory::Create( | 131 HttpAuthHandlerRegistryFactory* HttpAuthHandlerRegistryFactory::Create( |
130 const std::vector<std::string>& supported_schemes, | 132 const std::vector<std::string>& supported_schemes, |
131 URLSecurityManager* security_manager, | 133 URLSecurityManager* security_manager, |
132 HostResolver* host_resolver, | 134 HostResolver* host_resolver, |
133 const std::string& gssapi_library_name, | 135 const std::string& gssapi_library_name, |
| 136 const std::string& auth_android_negotiate_account_type, |
134 bool negotiate_disable_cname_lookup, | 137 bool negotiate_disable_cname_lookup, |
135 bool negotiate_enable_port) { | 138 bool negotiate_enable_port) { |
136 HttpAuthHandlerRegistryFactory* registry_factory = | 139 HttpAuthHandlerRegistryFactory* registry_factory = |
137 new HttpAuthHandlerRegistryFactory(); | 140 new HttpAuthHandlerRegistryFactory(); |
138 if (IsSupportedScheme(supported_schemes, "basic")) | 141 if (IsSupportedScheme(supported_schemes, "basic")) |
139 registry_factory->RegisterSchemeFactory( | 142 registry_factory->RegisterSchemeFactory( |
140 "basic", new HttpAuthHandlerBasic::Factory()); | 143 "basic", new HttpAuthHandlerBasic::Factory()); |
141 if (IsSupportedScheme(supported_schemes, "digest")) | 144 if (IsSupportedScheme(supported_schemes, "digest")) |
142 registry_factory->RegisterSchemeFactory( | 145 registry_factory->RegisterSchemeFactory( |
143 "digest", new HttpAuthHandlerDigest::Factory()); | 146 "digest", new HttpAuthHandlerDigest::Factory()); |
144 if (IsSupportedScheme(supported_schemes, "ntlm")) { | 147 if (IsSupportedScheme(supported_schemes, "ntlm")) { |
145 HttpAuthHandlerNTLM::Factory* ntlm_factory = | 148 HttpAuthHandlerNTLM::Factory* ntlm_factory = |
146 new HttpAuthHandlerNTLM::Factory(); | 149 new HttpAuthHandlerNTLM::Factory(); |
147 ntlm_factory->set_url_security_manager(security_manager); | 150 ntlm_factory->set_url_security_manager(security_manager); |
148 #if defined(OS_WIN) | 151 #if defined(OS_WIN) |
149 ntlm_factory->set_sspi_library(new SSPILibraryDefault()); | 152 ntlm_factory->set_sspi_library(new SSPILibraryDefault()); |
150 #endif | 153 #endif |
151 registry_factory->RegisterSchemeFactory("ntlm", ntlm_factory); | 154 registry_factory->RegisterSchemeFactory("ntlm", ntlm_factory); |
152 } | 155 } |
153 #if defined(USE_KERBEROS) | 156 #if defined(USE_KERBEROS) |
154 if (IsSupportedScheme(supported_schemes, "negotiate")) { | 157 if (IsSupportedScheme(supported_schemes, "negotiate")) { |
155 HttpAuthHandlerNegotiate::Factory* negotiate_factory = | 158 HttpAuthHandlerNegotiate::Factory* negotiate_factory = |
156 new HttpAuthHandlerNegotiate::Factory(); | 159 new HttpAuthHandlerNegotiate::Factory(); |
157 #if defined(OS_POSIX) | 160 #if defined(OS_ANDROID) |
| 161 negotiate_factory->set_library(&auth_android_negotiate_account_type); |
| 162 #elif defined(OS_POSIX) |
158 negotiate_factory->set_library( | 163 negotiate_factory->set_library( |
159 new GSSAPISharedLibrary(gssapi_library_name)); | 164 new GSSAPISharedLibrary(gssapi_library_name)); |
160 #elif defined(OS_WIN) | 165 #elif defined(OS_WIN) |
161 negotiate_factory->set_library(new SSPILibraryDefault()); | 166 negotiate_factory->set_library(new SSPILibraryDefault()); |
162 #endif | 167 #endif |
163 negotiate_factory->set_url_security_manager(security_manager); | 168 negotiate_factory->set_url_security_manager(security_manager); |
164 DCHECK(host_resolver || negotiate_disable_cname_lookup); | 169 DCHECK(host_resolver || negotiate_disable_cname_lookup); |
165 negotiate_factory->set_host_resolver(host_resolver); | 170 negotiate_factory->set_host_resolver(host_resolver); |
166 negotiate_factory->set_disable_cname_lookup(negotiate_disable_cname_lookup); | 171 negotiate_factory->set_disable_cname_lookup(negotiate_disable_cname_lookup); |
167 negotiate_factory->set_use_port(negotiate_enable_port); | 172 negotiate_factory->set_use_port(negotiate_enable_port); |
(...skipping 22 matching lines...) Expand all Loading... |
190 if (it == factory_map_.end()) { | 195 if (it == factory_map_.end()) { |
191 handler->reset(); | 196 handler->reset(); |
192 return ERR_UNSUPPORTED_AUTH_SCHEME; | 197 return ERR_UNSUPPORTED_AUTH_SCHEME; |
193 } | 198 } |
194 DCHECK(it->second); | 199 DCHECK(it->second); |
195 return it->second->CreateAuthHandler(challenge, target, origin, reason, | 200 return it->second->CreateAuthHandler(challenge, target, origin, reason, |
196 digest_nonce_count, net_log, handler); | 201 digest_nonce_count, net_log, handler); |
197 } | 202 } |
198 | 203 |
199 } // namespace net | 204 } // namespace net |
OLD | NEW |