OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_negotiate.h" | 5 #include "net/http/http_auth_handler_negotiate.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
(...skipping 24 matching lines...) Expand all Loading... |
35 } | 35 } |
36 | 36 |
37 void HttpAuthHandlerNegotiate::Factory::set_host_resolver( | 37 void HttpAuthHandlerNegotiate::Factory::set_host_resolver( |
38 HostResolver* resolver) { | 38 HostResolver* resolver) { |
39 resolver_ = resolver; | 39 resolver_ = resolver; |
40 } | 40 } |
41 | 41 |
42 scoped_ptr<HttpAuthHandler> | 42 scoped_ptr<HttpAuthHandler> |
43 HttpAuthHandlerNegotiate::Factory::CreateAndInitPreemptiveAuthHandler( | 43 HttpAuthHandlerNegotiate::Factory::CreateAndInitPreemptiveAuthHandler( |
44 HttpAuthCache::Entry* cache_entry, | 44 HttpAuthCache::Entry* cache_entry, |
45 const HttpAuthChallengeTokenizer& tokenizer, | |
46 HttpAuth::Target target, | 45 HttpAuth::Target target, |
47 const BoundNetLog& net_log) { | 46 const BoundNetLog& net_log) { |
48 return scoped_ptr<HttpAuthHandler>(); | 47 return scoped_ptr<HttpAuthHandler>(); |
49 } | 48 } |
50 | 49 |
51 scoped_ptr<HttpAuthHandler> | 50 scoped_ptr<HttpAuthHandler> |
52 HttpAuthHandlerNegotiate::Factory::CreateAuthHandlerForScheme( | 51 HttpAuthHandlerNegotiate::Factory::CreateAuthHandlerForScheme( |
53 const std::string& scheme) { | 52 const std::string& scheme) { |
54 DCHECK(HttpAuth::IsValidNormalizedScheme(scheme)); | 53 DCHECK(HttpAuth::IsValidNormalizedScheme(scheme)); |
55 if (scheme != "negotiate") | 54 if (scheme != "negotiate") |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 return false; | 187 return false; |
189 return url_security_manager_->CanUseDefaultCredentials(origin_); | 188 return url_security_manager_->CanUseDefaultCredentials(origin_); |
190 } | 189 } |
191 | 190 |
192 bool HttpAuthHandlerNegotiate::AllowsExplicitCredentials() { | 191 bool HttpAuthHandlerNegotiate::AllowsExplicitCredentials() { |
193 return auth_system_.AllowsExplicitCredentials(); | 192 return auth_system_.AllowsExplicitCredentials(); |
194 } | 193 } |
195 | 194 |
196 // The Negotiate challenge header looks like: | 195 // The Negotiate challenge header looks like: |
197 // WWW-Authenticate: NEGOTIATE auth-data | 196 // WWW-Authenticate: NEGOTIATE auth-data |
198 int HttpAuthHandlerNegotiate::Init( | 197 int HttpAuthHandlerNegotiate::InitializeFromChallengeInternal( |
199 const HttpAuthChallengeTokenizer& challenge) { | 198 const HttpAuthChallengeTokenizer& challenge, |
| 199 const HttpResponseInfo& response_with_challenge, |
| 200 const CompletionCallback& callback) { |
200 #if defined(OS_POSIX) | 201 #if defined(OS_POSIX) |
201 if (!auth_system_.Init()) { | 202 if (!auth_system_.Init()) { |
202 VLOG(1) << "can't initialize GSSAPI library"; | 203 VLOG(1) << "can't initialize GSSAPI library"; |
203 return ERR_UNSUPPORTED_AUTH_SCHEME; | 204 return ERR_UNSUPPORTED_AUTH_SCHEME; |
204 } | 205 } |
205 // GSSAPI does not provide a way to enter username/password to | 206 // GSSAPI does not provide a way to enter username/password to |
206 // obtain a TGT. If the default credentials are not allowed for | 207 // obtain a TGT. If the default credentials are not allowed for |
207 // a particular site (based on whitelist), fall back to a | 208 // a particular site (based on whitelist), fall back to a |
208 // different scheme. | 209 // different scheme. |
209 if (!AllowsDefaultCredentials()) | 210 if (!AllowsDefaultCredentials()) |
210 return ERR_UNSUPPORTED_AUTH_SCHEME; | 211 return ERR_UNSUPPORTED_AUTH_SCHEME; |
211 #endif | 212 #endif |
212 if (CanDelegate()) | 213 if (CanDelegate()) |
213 auth_system_.Delegate(); | 214 auth_system_.Delegate(); |
214 auth_scheme_ = "negotiate"; | 215 auth_scheme_ = "negotiate"; |
215 HttpAuth::AuthorizationResult auth_result = | 216 HttpAuth::AuthorizationResult auth_result = |
216 auth_system_.ParseChallenge(challenge); | 217 auth_system_.ParseChallenge(challenge); |
217 return auth_result == HttpAuth::AUTHORIZATION_RESULT_ACCEPT | 218 return auth_result == HttpAuth::AUTHORIZATION_RESULT_ACCEPT |
218 ? OK | 219 ? OK |
219 : ERR_INVALID_RESPONSE; | 220 : ERR_INVALID_RESPONSE; |
220 } | 221 } |
221 | 222 |
| 223 int HttpAuthHandlerNegotiate::InitializeFromCacheEntryInternal( |
| 224 HttpAuthCache::Entry*) { |
| 225 NOTREACHED(); |
| 226 return ERR_UNSUPPORTED_AUTH_SCHEME; |
| 227 } |
| 228 |
222 int HttpAuthHandlerNegotiate::GenerateAuthTokenImpl( | 229 int HttpAuthHandlerNegotiate::GenerateAuthTokenImpl( |
223 const AuthCredentials* credentials, | 230 const AuthCredentials* credentials, |
224 const HttpRequestInfo& request, | 231 const HttpRequestInfo& request, |
225 const CompletionCallback& callback, | 232 const CompletionCallback& callback, |
226 std::string* auth_token) { | 233 std::string* auth_token) { |
227 DCHECK(callback_.is_null()); | 234 DCHECK(callback_.is_null()); |
228 DCHECK(auth_token_ == NULL); | 235 DCHECK(auth_token_ == NULL); |
229 auth_token_ = auth_token; | 236 auth_token_ = auth_token; |
230 if (already_called_) { | 237 if (already_called_) { |
231 DCHECK((!has_credentials_ && credentials == NULL) || | 238 DCHECK((!has_credentials_ && credentials == NULL) || |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
344 bool HttpAuthHandlerNegotiate::CanDelegate() const { | 351 bool HttpAuthHandlerNegotiate::CanDelegate() const { |
345 // TODO(cbentzel): Should delegation be allowed on proxies? | 352 // TODO(cbentzel): Should delegation be allowed on proxies? |
346 if (target_ == HttpAuth::AUTH_PROXY) | 353 if (target_ == HttpAuth::AUTH_PROXY) |
347 return false; | 354 return false; |
348 if (!url_security_manager_) | 355 if (!url_security_manager_) |
349 return false; | 356 return false; |
350 return url_security_manager_->CanDelegate(origin_); | 357 return url_security_manager_->CanDelegate(origin_); |
351 } | 358 } |
352 | 359 |
353 } // namespace net | 360 } // namespace net |
OLD | NEW |