| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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" |
| 8 #include "base/bind_helpers.h" |
| 7 #include "base/logging.h" | 9 #include "base/logging.h" |
| 8 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| 9 #include "base/stringprintf.h" | 11 #include "base/stringprintf.h" |
| 10 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
| 11 #include "net/base/address_family.h" | 13 #include "net/base/address_family.h" |
| 12 #include "net/base/host_resolver.h" | 14 #include "net/base/host_resolver.h" |
| 13 #include "net/base/net_errors.h" | 15 #include "net/base/net_errors.h" |
| 14 #include "net/base/single_request_host_resolver.h" | 16 #include "net/base/single_request_host_resolver.h" |
| 15 #include "net/http/http_auth_filter.h" | 17 #include "net/http/http_auth_filter.h" |
| 16 #include "net/http/url_security_manager.h" | 18 #include "net/http/url_security_manager.h" |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 HostResolver* resolver, | 96 HostResolver* resolver, |
| 95 bool disable_cname_lookup, | 97 bool disable_cname_lookup, |
| 96 bool use_port) | 98 bool use_port) |
| 97 #if defined(OS_WIN) | 99 #if defined(OS_WIN) |
| 98 : auth_system_(auth_library, "Negotiate", NEGOSSP_NAME, max_token_length), | 100 : auth_system_(auth_library, "Negotiate", NEGOSSP_NAME, max_token_length), |
| 99 #elif defined(OS_POSIX) | 101 #elif defined(OS_POSIX) |
| 100 : auth_system_(auth_library, "Negotiate", CHROME_GSS_KRB5_MECH_OID_DESC), | 102 : auth_system_(auth_library, "Negotiate", CHROME_GSS_KRB5_MECH_OID_DESC), |
| 101 #endif | 103 #endif |
| 102 disable_cname_lookup_(disable_cname_lookup), | 104 disable_cname_lookup_(disable_cname_lookup), |
| 103 use_port_(use_port), | 105 use_port_(use_port), |
| 104 ALLOW_THIS_IN_INITIALIZER_LIST(io_callback_( | |
| 105 this, &HttpAuthHandlerNegotiate::OnIOComplete)), | |
| 106 resolver_(resolver), | 106 resolver_(resolver), |
| 107 already_called_(false), | 107 already_called_(false), |
| 108 has_credentials_(false), | 108 has_credentials_(false), |
| 109 user_callback_(NULL), | 109 user_callback_(NULL), |
| 110 auth_token_(NULL), | 110 auth_token_(NULL), |
| 111 next_state_(STATE_NONE), | 111 next_state_(STATE_NONE), |
| 112 url_security_manager_(url_security_manager) { | 112 url_security_manager_(url_security_manager) { |
| 113 } | 113 } |
| 114 | 114 |
| 115 HttpAuthHandlerNegotiate::~HttpAuthHandlerNegotiate() { | 115 HttpAuthHandlerNegotiate::~HttpAuthHandlerNegotiate() { |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 int HttpAuthHandlerNegotiate::DoResolveCanonicalName() { | 286 int HttpAuthHandlerNegotiate::DoResolveCanonicalName() { |
| 287 next_state_ = STATE_RESOLVE_CANONICAL_NAME_COMPLETE; | 287 next_state_ = STATE_RESOLVE_CANONICAL_NAME_COMPLETE; |
| 288 if (disable_cname_lookup_ || !resolver_) | 288 if (disable_cname_lookup_ || !resolver_) |
| 289 return OK; | 289 return OK; |
| 290 | 290 |
| 291 // TODO(cbentzel): Add reverse DNS lookup for numeric addresses. | 291 // TODO(cbentzel): Add reverse DNS lookup for numeric addresses. |
| 292 DCHECK(!single_resolve_.get()); | 292 DCHECK(!single_resolve_.get()); |
| 293 HostResolver::RequestInfo info(HostPortPair(origin_.host(), 0)); | 293 HostResolver::RequestInfo info(HostPortPair(origin_.host(), 0)); |
| 294 info.set_host_resolver_flags(HOST_RESOLVER_CANONNAME); | 294 info.set_host_resolver_flags(HOST_RESOLVER_CANONNAME); |
| 295 single_resolve_.reset(new SingleRequestHostResolver(resolver_)); | 295 single_resolve_.reset(new SingleRequestHostResolver(resolver_)); |
| 296 return single_resolve_->Resolve(info, &address_list_, &io_callback_, | 296 return single_resolve_->Resolve( |
| 297 net_log_); | 297 info, &address_list_, |
| 298 base::Bind(&HttpAuthHandlerNegotiate::OnIOComplete, |
| 299 base::Unretained(this)), |
| 300 net_log_); |
| 298 } | 301 } |
| 299 | 302 |
| 300 int HttpAuthHandlerNegotiate::DoResolveCanonicalNameComplete(int rv) { | 303 int HttpAuthHandlerNegotiate::DoResolveCanonicalNameComplete(int rv) { |
| 301 DCHECK_NE(ERR_IO_PENDING, rv); | 304 DCHECK_NE(ERR_IO_PENDING, rv); |
| 302 if (rv != OK) { | 305 if (rv != OK) { |
| 303 // Even in the error case, try to use origin_.host instead of | 306 // Even in the error case, try to use origin_.host instead of |
| 304 // passing the failure on to the caller. | 307 // passing the failure on to the caller. |
| 305 VLOG(1) << "Problem finding canonical name for SPN for host " | 308 VLOG(1) << "Problem finding canonical name for SPN for host " |
| 306 << origin_.host() << ": " << ErrorToString(rv); | 309 << origin_.host() << ": " << ErrorToString(rv); |
| 307 rv = OK; | 310 rv = OK; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 329 bool HttpAuthHandlerNegotiate::CanDelegate() const { | 332 bool HttpAuthHandlerNegotiate::CanDelegate() const { |
| 330 // TODO(cbentzel): Should delegation be allowed on proxies? | 333 // TODO(cbentzel): Should delegation be allowed on proxies? |
| 331 if (target_ == HttpAuth::AUTH_PROXY) | 334 if (target_ == HttpAuth::AUTH_PROXY) |
| 332 return false; | 335 return false; |
| 333 if (!url_security_manager_) | 336 if (!url_security_manager_) |
| 334 return false; | 337 return false; |
| 335 return url_security_manager_->CanDelegate(origin_); | 338 return url_security_manager_->CanDelegate(origin_); |
| 336 } | 339 } |
| 337 | 340 |
| 338 } // namespace net | 341 } // namespace net |
| OLD | NEW |