| 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_controller.h" | 5 #include "net/http/http_auth_controller.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/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 | 151 |
| 152 } // namespace | 152 } // namespace |
| 153 | 153 |
| 154 HttpAuthController::HttpAuthController( | 154 HttpAuthController::HttpAuthController( |
| 155 HttpAuth::Target target, | 155 HttpAuth::Target target, |
| 156 const GURL& auth_url, | 156 const GURL& auth_url, |
| 157 HttpAuthCache* http_auth_cache, | 157 HttpAuthCache* http_auth_cache, |
| 158 HttpAuthHandlerFactory* http_auth_handler_factory) | 158 HttpAuthHandlerFactory* http_auth_handler_factory) |
| 159 : target_(target), | 159 : target_(target), |
| 160 auth_url_(auth_url), | 160 auth_url_(auth_url), |
| 161 auth_origin_(auth_url.GetOrigin()), | 161 auth_origin_(url::Origin(auth_url)), |
| 162 auth_path_(HttpAuth::AUTH_PROXY ? std::string() : auth_url.path()), | 162 auth_path_(HttpAuth::AUTH_PROXY ? std::string() : auth_url.path()), |
| 163 embedded_identity_used_(false), | 163 embedded_identity_used_(false), |
| 164 default_credentials_used_(false), | 164 default_credentials_used_(false), |
| 165 http_auth_cache_(http_auth_cache), | 165 http_auth_cache_(http_auth_cache), |
| 166 http_auth_handler_factory_(http_auth_handler_factory) { | 166 http_auth_handler_factory_(http_auth_handler_factory) { |
| 167 } | 167 } |
| 168 | 168 |
| 169 HttpAuthController::~HttpAuthController() { | 169 HttpAuthController::~HttpAuthController() { |
| 170 DCHECK(CalledOnValidThread()); | 170 DCHECK(CalledOnValidThread()); |
| 171 } | 171 } |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 } | 245 } |
| 246 } | 246 } |
| 247 | 247 |
| 248 int HttpAuthController::HandleAuthChallenge( | 248 int HttpAuthController::HandleAuthChallenge( |
| 249 scoped_refptr<HttpResponseHeaders> headers, | 249 scoped_refptr<HttpResponseHeaders> headers, |
| 250 bool do_not_send_server_auth, | 250 bool do_not_send_server_auth, |
| 251 bool establishing_tunnel, | 251 bool establishing_tunnel, |
| 252 const BoundNetLog& net_log) { | 252 const BoundNetLog& net_log) { |
| 253 DCHECK(CalledOnValidThread()); | 253 DCHECK(CalledOnValidThread()); |
| 254 DCHECK(headers.get()); | 254 DCHECK(headers.get()); |
| 255 DCHECK(auth_origin_.is_valid()); | 255 DCHECK(!auth_origin_.unique()); |
| 256 VLOG(1) << "The " << HttpAuth::GetAuthTargetString(target_) << " " | 256 VLOG(1) << "The " << HttpAuth::GetAuthTargetString(target_) << " " |
| 257 << auth_origin_ << " requested auth " | 257 << auth_origin_ << " requested auth " |
| 258 << AuthChallengeLogMessage(headers.get()); | 258 << AuthChallengeLogMessage(headers.get()); |
| 259 | 259 |
| 260 // Give the existing auth handler first try at the authentication headers. | 260 // Give the existing auth handler first try at the authentication headers. |
| 261 // This will also evict the entry in the HttpAuthCache if the previous | 261 // This will also evict the entry in the HttpAuthCache if the previous |
| 262 // challenge appeared to be rejected, or is using a stale nonce in the Digest | 262 // challenge appeared to be rejected, or is using a stale nonce in the Digest |
| 263 // case. | 263 // case. |
| 264 if (HaveAuth()) { | 264 if (HaveAuth()) { |
| 265 std::string challenge_used; | 265 std::string challenge_used; |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 502 } | 502 } |
| 503 | 503 |
| 504 void HttpAuthController::PopulateAuthChallenge() { | 504 void HttpAuthController::PopulateAuthChallenge() { |
| 505 DCHECK(CalledOnValidThread()); | 505 DCHECK(CalledOnValidThread()); |
| 506 | 506 |
| 507 // Populates response_.auth_challenge with the authentication challenge info. | 507 // Populates response_.auth_challenge with the authentication challenge info. |
| 508 // This info is consumed by URLRequestHttpJob::GetAuthChallengeInfo(). | 508 // This info is consumed by URLRequestHttpJob::GetAuthChallengeInfo(). |
| 509 | 509 |
| 510 auth_info_ = new AuthChallengeInfo; | 510 auth_info_ = new AuthChallengeInfo; |
| 511 auth_info_->is_proxy = (target_ == HttpAuth::AUTH_PROXY); | 511 auth_info_->is_proxy = (target_ == HttpAuth::AUTH_PROXY); |
| 512 auth_info_->challenger = HostPortPair::FromURL(auth_origin_); | 512 auth_info_->challenger = HostPortPair::FromOrigin(auth_origin_); |
| 513 auth_info_->scheme = HttpAuth::SchemeToString(handler_->auth_scheme()); | 513 auth_info_->scheme = HttpAuth::SchemeToString(handler_->auth_scheme()); |
| 514 auth_info_->realm = handler_->realm(); | 514 auth_info_->realm = handler_->realm(); |
| 515 } | 515 } |
| 516 | 516 |
| 517 bool HttpAuthController::DisableOnAuthHandlerResult(int result) { | 517 bool HttpAuthController::DisableOnAuthHandlerResult(int result) { |
| 518 DCHECK(CalledOnValidThread()); | 518 DCHECK(CalledOnValidThread()); |
| 519 | 519 |
| 520 switch (result) { | 520 switch (result) { |
| 521 // Occurs with GSSAPI, if the user has not already logged in. | 521 // Occurs with GSSAPI, if the user has not already logged in. |
| 522 case ERR_MISSING_AUTH_CREDENTIALS: | 522 case ERR_MISSING_AUTH_CREDENTIALS: |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 569 DCHECK(CalledOnValidThread()); | 569 DCHECK(CalledOnValidThread()); |
| 570 disabled_schemes_.insert(scheme); | 570 disabled_schemes_.insert(scheme); |
| 571 } | 571 } |
| 572 | 572 |
| 573 void HttpAuthController::DisableEmbeddedIdentity() { | 573 void HttpAuthController::DisableEmbeddedIdentity() { |
| 574 DCHECK(CalledOnValidThread()); | 574 DCHECK(CalledOnValidThread()); |
| 575 embedded_identity_used_ = true; | 575 embedded_identity_used_ = true; |
| 576 } | 576 } |
| 577 | 577 |
| 578 } // namespace net | 578 } // namespace net |
| OLD | NEW |