| Index: net/http/http_auth_handler_factory.cc
|
| diff --git a/net/http/http_auth_handler_factory.cc b/net/http/http_auth_handler_factory.cc
|
| index 5a89964a80c6d47344e6ab2daa747a92b30b3305..4fc31162da5592b927b5fcf79950d26f59f5398e 100644
|
| --- a/net/http/http_auth_handler_factory.cc
|
| +++ b/net/http/http_auth_handler_factory.cc
|
| @@ -19,6 +19,11 @@
|
|
|
| namespace net {
|
|
|
| +const char kBasic[] = "basic";
|
| +const char kDigest[] = "digest";
|
| +const char kNtlm[] = "ntlm";
|
| +const char kNegotiate[] = "negotiate";
|
| +
|
| int HttpAuthHandlerFactory::CreateAuthHandlerFromString(
|
| const std::string& challenge,
|
| HttpAuth::Target target,
|
| @@ -48,10 +53,10 @@ HttpAuthHandlerFactory::CreateDefault(HostResolver* host_resolver) {
|
| DCHECK(host_resolver);
|
| scoped_ptr<HttpAuthHandlerRegistryFactory> registry_factory =
|
| make_scoped_ptr(new HttpAuthHandlerRegistryFactory());
|
| - registry_factory->RegisterSchemeFactory(
|
| - "basic", new HttpAuthHandlerBasic::Factory());
|
| - registry_factory->RegisterSchemeFactory(
|
| - "digest", new HttpAuthHandlerDigest::Factory());
|
| + registry_factory->RegisterSchemeFactory(kBasic,
|
| + new HttpAuthHandlerBasic::Factory());
|
| + registry_factory->RegisterSchemeFactory(kDigest,
|
| + new HttpAuthHandlerDigest::Factory());
|
|
|
| // On Android Chrome needs an account type configured to enable Kerberos,
|
| // so the default factory should not include Kerberos.
|
| @@ -59,12 +64,13 @@ HttpAuthHandlerFactory::CreateDefault(HostResolver* host_resolver) {
|
| HttpAuthHandlerNegotiate::Factory* negotiate_factory =
|
| new HttpAuthHandlerNegotiate::Factory();
|
| #if defined(OS_POSIX)
|
| - negotiate_factory->set_library(new GSSAPISharedLibrary(std::string()));
|
| + negotiate_factory->set_library(
|
| + make_scoped_ptr(new GSSAPISharedLibrary(std::string())));
|
| #elif defined(OS_WIN)
|
| - negotiate_factory->set_library(new SSPILibraryDefault());
|
| + negotiate_factory->set_library(make_scoped_ptr(new SSPILibraryDefault()));
|
| #endif
|
| negotiate_factory->set_host_resolver(host_resolver);
|
| - registry_factory->RegisterSchemeFactory("negotiate", negotiate_factory);
|
| + registry_factory->RegisterSchemeFactory(kNegotiate, negotiate_factory);
|
| #endif // defined(USE_KERBEROS) && !defined(OS_ANDROID)
|
|
|
| HttpAuthHandlerNTLM::Factory* ntlm_factory =
|
| @@ -72,7 +78,7 @@ HttpAuthHandlerFactory::CreateDefault(HostResolver* host_resolver) {
|
| #if defined(OS_WIN)
|
| ntlm_factory->set_sspi_library(new SSPILibraryDefault());
|
| #endif
|
| - registry_factory->RegisterSchemeFactory("ntlm", ntlm_factory);
|
| + registry_factory->RegisterSchemeFactory(kNtlm, ntlm_factory);
|
| return registry_factory;
|
| }
|
|
|
| @@ -130,47 +136,36 @@ HttpAuthHandlerFactory* HttpAuthHandlerRegistryFactory::GetSchemeFactory(
|
| // static
|
| HttpAuthHandlerRegistryFactory* HttpAuthHandlerRegistryFactory::Create(
|
| const std::vector<std::string>& supported_schemes,
|
| - URLSecurityManager* security_manager,
|
| HostResolver* host_resolver,
|
| - const std::string& gssapi_library_name,
|
| - const std::string& auth_android_negotiate_account_type,
|
| - bool negotiate_disable_cname_lookup,
|
| - bool negotiate_enable_port) {
|
| + const std::string& gssapi_library_name) {
|
| HttpAuthHandlerRegistryFactory* registry_factory =
|
| new HttpAuthHandlerRegistryFactory();
|
| - if (IsSupportedScheme(supported_schemes, "basic"))
|
| + if (IsSupportedScheme(supported_schemes, kBasic))
|
| registry_factory->RegisterSchemeFactory(
|
| - "basic", new HttpAuthHandlerBasic::Factory());
|
| - if (IsSupportedScheme(supported_schemes, "digest"))
|
| + kBasic, new HttpAuthHandlerBasic::Factory());
|
| + if (IsSupportedScheme(supported_schemes, kDigest))
|
| registry_factory->RegisterSchemeFactory(
|
| - "digest", new HttpAuthHandlerDigest::Factory());
|
| - if (IsSupportedScheme(supported_schemes, "ntlm")) {
|
| + kDigest, new HttpAuthHandlerDigest::Factory());
|
| + if (IsSupportedScheme(supported_schemes, kNtlm)) {
|
| HttpAuthHandlerNTLM::Factory* ntlm_factory =
|
| new HttpAuthHandlerNTLM::Factory();
|
| - ntlm_factory->set_url_security_manager(security_manager);
|
| #if defined(OS_WIN)
|
| ntlm_factory->set_sspi_library(new SSPILibraryDefault());
|
| #endif
|
| - registry_factory->RegisterSchemeFactory("ntlm", ntlm_factory);
|
| + registry_factory->RegisterSchemeFactory(kNtlm, ntlm_factory);
|
| }
|
| #if defined(USE_KERBEROS)
|
| - if (IsSupportedScheme(supported_schemes, "negotiate")) {
|
| + if (IsSupportedScheme(supported_schemes, kNegotiate)) {
|
| HttpAuthHandlerNegotiate::Factory* negotiate_factory =
|
| new HttpAuthHandlerNegotiate::Factory();
|
| -#if defined(OS_ANDROID)
|
| - negotiate_factory->set_library(&auth_android_negotiate_account_type);
|
| -#elif defined(OS_POSIX)
|
| +#if defined(OS_POSIX) && !defined(OS_ANDROID)
|
| negotiate_factory->set_library(
|
| - new GSSAPISharedLibrary(gssapi_library_name));
|
| + make_scoped_ptr(new GSSAPISharedLibrary(gssapi_library_name)));
|
| #elif defined(OS_WIN)
|
| - negotiate_factory->set_library(new SSPILibraryDefault());
|
| + negotiate_factory->set_library(make_scoped_ptr(new SSPILibraryDefault()));
|
| #endif
|
| - negotiate_factory->set_url_security_manager(security_manager);
|
| - DCHECK(host_resolver || negotiate_disable_cname_lookup);
|
| negotiate_factory->set_host_resolver(host_resolver);
|
| - negotiate_factory->set_disable_cname_lookup(negotiate_disable_cname_lookup);
|
| - negotiate_factory->set_use_port(negotiate_enable_port);
|
| - registry_factory->RegisterSchemeFactory("negotiate", negotiate_factory);
|
| + registry_factory->RegisterSchemeFactory(kNegotiate, negotiate_factory);
|
| }
|
| #endif // defined(USE_KERBEROS)
|
|
|
| @@ -201,4 +196,40 @@ int HttpAuthHandlerRegistryFactory::CreateAuthHandler(
|
| digest_nonce_count, net_log, handler);
|
| }
|
|
|
| +void HttpAuthHandlerRegistryFactory::SetSecurityManager(
|
| + URLSecurityManager* security_manager) {
|
| + HttpAuthHandlerFactory* ntlm_factory = GetSchemeFactory(kNtlm);
|
| + if (ntlm_factory)
|
| + ntlm_factory->set_url_security_manager(security_manager);
|
| + HttpAuthHandlerFactory* negotiate_factory = GetSchemeFactory(kNegotiate);
|
| + if (negotiate_factory)
|
| + negotiate_factory->set_url_security_manager(security_manager);
|
| +}
|
| +
|
| +void HttpAuthHandlerRegistryFactory::SetAndroidAuthNegotiateAccountType(
|
| + scoped_ptr<std::string> account_type) {
|
| +#if defined(OS_ANDROID)
|
| + auto negotiate_factory = static_cast<HttpAuthHandlerNegotiate::Factory*>(
|
| + GetSchemeFactory(kNegotiate));
|
| + if (negotiate_factory)
|
| + negotiate_factory->set_library(account_type.Pass());
|
| +#endif
|
| +}
|
| +
|
| +void HttpAuthHandlerRegistryFactory::SetNegotiateDisableCnameLookup(
|
| + bool negotiate_disable_cname_lookup) {
|
| + auto negotiate_factory = static_cast<HttpAuthHandlerNegotiate::Factory*>(
|
| + GetSchemeFactory(kNegotiate));
|
| + if (negotiate_factory)
|
| + negotiate_factory->set_disable_cname_lookup(negotiate_disable_cname_lookup);
|
| +}
|
| +
|
| +void HttpAuthHandlerRegistryFactory::SetNegotiateEnablePort(
|
| + bool negotiate_enable_port) {
|
| + auto negotiate_factory = static_cast<HttpAuthHandlerNegotiate::Factory*>(
|
| + GetSchemeFactory(kNegotiate));
|
| + if (negotiate_factory)
|
| + negotiate_factory->set_use_port(negotiate_enable_port);
|
| +}
|
| +
|
| } // namespace net
|
|
|