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" |
11 #include "net/http/http_auth_filter.h" | 11 #include "net/http/http_auth_filter.h" |
12 #include "net/http/http_auth_handler_basic.h" | 12 #include "net/http/http_auth_handler_basic.h" |
13 #include "net/http/http_auth_handler_digest.h" | 13 #include "net/http/http_auth_handler_digest.h" |
14 #include "net/http/http_auth_handler_ntlm.h" | 14 #include "net/http/http_auth_handler_ntlm.h" |
15 | 15 |
16 #if defined(USE_KERBEROS) | 16 #if defined(USE_KERBEROS) |
17 #include "net/http/http_auth_handler_negotiate.h" | 17 #include "net/http/http_auth_handler_negotiate.h" |
18 #endif | 18 #endif |
19 | 19 |
20 namespace net { | 20 namespace net { |
21 | 21 |
22 int HttpAuthHandlerFactory::CreateAuthHandlerFromString( | 22 int HttpAuthHandlerFactory::CreateAuthHandlerFromString( |
23 const std::string& challenge, | 23 const std::string& challenge, |
24 HttpAuth::Target target, | 24 HttpAuth::Target target, |
25 const GURL& origin, | 25 const url::Origin& origin, |
26 const BoundNetLog& net_log, | 26 const BoundNetLog& net_log, |
27 scoped_ptr<HttpAuthHandler>* handler) { | 27 scoped_ptr<HttpAuthHandler>* handler) { |
28 HttpAuthChallengeTokenizer props(challenge.begin(), challenge.end()); | 28 HttpAuthChallengeTokenizer props(challenge.begin(), challenge.end()); |
29 return CreateAuthHandler(&props, target, origin, CREATE_CHALLENGE, 1, | 29 return CreateAuthHandler(&props, target, origin, CREATE_CHALLENGE, 1, |
30 net_log, handler); | 30 net_log, handler); |
31 } | 31 } |
32 | 32 |
33 int HttpAuthHandlerFactory::CreatePreemptiveAuthHandlerFromString( | 33 int HttpAuthHandlerFactory::CreatePreemptiveAuthHandlerFromString( |
34 const std::string& challenge, | 34 const std::string& challenge, |
35 HttpAuth::Target target, | 35 HttpAuth::Target target, |
36 const GURL& origin, | 36 const url::Origin& origin, |
37 int digest_nonce_count, | 37 int digest_nonce_count, |
38 const BoundNetLog& net_log, | 38 const BoundNetLog& net_log, |
39 scoped_ptr<HttpAuthHandler>* handler) { | 39 scoped_ptr<HttpAuthHandler>* handler) { |
40 HttpAuthChallengeTokenizer props(challenge.begin(), challenge.end()); | 40 HttpAuthChallengeTokenizer props(challenge.begin(), challenge.end()); |
41 return CreateAuthHandler(&props, target, origin, CREATE_PREEMPTIVE, | 41 return CreateAuthHandler(&props, target, origin, CREATE_PREEMPTIVE, |
42 digest_nonce_count, net_log, handler); | 42 digest_nonce_count, net_log, handler); |
43 } | 43 } |
44 | 44 |
45 // static | 45 // static |
46 HttpAuthHandlerRegistryFactory* HttpAuthHandlerFactory::CreateDefault( | 46 HttpAuthHandlerRegistryFactory* HttpAuthHandlerFactory::CreateDefault( |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 registry_factory->RegisterSchemeFactory("negotiate", negotiate_factory); | 168 registry_factory->RegisterSchemeFactory("negotiate", negotiate_factory); |
169 } | 169 } |
170 #endif // defined(USE_KERBEROS) | 170 #endif // defined(USE_KERBEROS) |
171 | 171 |
172 return registry_factory; | 172 return registry_factory; |
173 } | 173 } |
174 | 174 |
175 int HttpAuthHandlerRegistryFactory::CreateAuthHandler( | 175 int HttpAuthHandlerRegistryFactory::CreateAuthHandler( |
176 HttpAuthChallengeTokenizer* challenge, | 176 HttpAuthChallengeTokenizer* challenge, |
177 HttpAuth::Target target, | 177 HttpAuth::Target target, |
178 const GURL& origin, | 178 const url::Origin& origin, |
179 CreateReason reason, | 179 CreateReason reason, |
180 int digest_nonce_count, | 180 int digest_nonce_count, |
181 const BoundNetLog& net_log, | 181 const BoundNetLog& net_log, |
182 scoped_ptr<HttpAuthHandler>* handler) { | 182 scoped_ptr<HttpAuthHandler>* handler) { |
183 std::string scheme = challenge->scheme(); | 183 std::string scheme = challenge->scheme(); |
184 if (scheme.empty()) { | 184 if (scheme.empty()) { |
185 handler->reset(); | 185 handler->reset(); |
186 return ERR_INVALID_RESPONSE; | 186 return ERR_INVALID_RESPONSE; |
187 } | 187 } |
188 std::string lower_scheme = base::StringToLowerASCII(scheme); | 188 std::string lower_scheme = base::StringToLowerASCII(scheme); |
189 FactoryMap::iterator it = factory_map_.find(lower_scheme); | 189 FactoryMap::iterator it = factory_map_.find(lower_scheme); |
190 if (it == factory_map_.end()) { | 190 if (it == factory_map_.end()) { |
191 handler->reset(); | 191 handler->reset(); |
192 return ERR_UNSUPPORTED_AUTH_SCHEME; | 192 return ERR_UNSUPPORTED_AUTH_SCHEME; |
193 } | 193 } |
194 DCHECK(it->second); | 194 DCHECK(it->second); |
195 return it->second->CreateAuthHandler(challenge, target, origin, reason, | 195 return it->second->CreateAuthHandler(challenge, target, origin, reason, |
196 digest_nonce_count, net_log, handler); | 196 digest_nonce_count, net_log, handler); |
197 } | 197 } |
198 | 198 |
199 } // namespace net | 199 } // namespace net |
OLD | NEW |