Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(287)

Side by Side Diff: net/http/http_auth_handler_factory.cc

Issue 4560001: Support specifying the GSSAPI library that will be used. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: address comments; port to ToT Created 10 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 GSSAPILibrary* gssapi_library =
55 new GSSAPISharedLibrary("");
56 negotiate_factory->set_library(gssapi_library);
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 GSSAPILibrary* gssapi_library =
103 new GSSAPISharedLibrary(gssapi_library_name);
104 negotiate_factory->set_library(gssapi_library);
105 #endif
95 negotiate_factory->set_url_security_manager(security_manager); 106 negotiate_factory->set_url_security_manager(security_manager);
96 DCHECK(host_resolver || negotiate_disable_cname_lookup); 107 DCHECK(host_resolver || negotiate_disable_cname_lookup);
97 negotiate_factory->set_host_resolver(host_resolver); 108 negotiate_factory->set_host_resolver(host_resolver);
98 negotiate_factory->set_disable_cname_lookup(negotiate_disable_cname_lookup); 109 negotiate_factory->set_disable_cname_lookup(negotiate_disable_cname_lookup);
99 negotiate_factory->set_use_port(negotiate_enable_port); 110 negotiate_factory->set_use_port(negotiate_enable_port);
100 registry_factory->RegisterSchemeFactory("negotiate", negotiate_factory); 111 registry_factory->RegisterSchemeFactory("negotiate", negotiate_factory);
101 } 112 }
102 113
103 return registry_factory; 114 return registry_factory;
104 } 115 }
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 const std::string& scheme) const { 172 const std::string& scheme) const {
162 std::string lower_scheme = StringToLowerASCII(scheme); 173 std::string lower_scheme = StringToLowerASCII(scheme);
163 FactoryMap::const_iterator it = factory_map_.find(lower_scheme); 174 FactoryMap::const_iterator it = factory_map_.find(lower_scheme);
164 if (it == factory_map_.end()) { 175 if (it == factory_map_.end()) {
165 return NULL; // |scheme| is not registered. 176 return NULL; // |scheme| is not registered.
166 } 177 }
167 return it->second; 178 return it->second;
168 } 179 }
169 180
170 } // namespace net 181 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698