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 #if defined(SPDY_PROXY_AUTH_ORIGIN) && defined(SPDY_PROXY_AUTH_VALUE) | |
11 #include "base/stringprintf.h" | |
12 #endif | |
10 #include "base/string_util.h" | 13 #include "base/string_util.h" |
11 #include "base/threading/platform_thread.h" | 14 #include "base/threading/platform_thread.h" |
12 #include "base/utf_string_conversions.h" | 15 #include "base/utf_string_conversions.h" |
13 #include "net/base/auth.h" | 16 #include "net/base/auth.h" |
14 #include "net/base/net_util.h" | 17 #include "net/base/net_util.h" |
15 #include "net/dns/host_resolver.h" | 18 #include "net/dns/host_resolver.h" |
16 #include "net/http/http_auth_handler.h" | 19 #include "net/http/http_auth_handler.h" |
17 #include "net/http/http_auth_handler_factory.h" | 20 #include "net/http/http_auth_handler_factory.h" |
18 #include "net/http/http_network_session.h" | 21 #include "net/http/http_network_session.h" |
19 #include "net/http/http_request_headers.h" | 22 #include "net/http/http_request_headers.h" |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
167 } | 170 } |
168 | 171 |
169 HttpAuthController::~HttpAuthController() { | 172 HttpAuthController::~HttpAuthController() { |
170 DCHECK(CalledOnValidThread()); | 173 DCHECK(CalledOnValidThread()); |
171 } | 174 } |
172 | 175 |
173 int HttpAuthController::MaybeGenerateAuthToken( | 176 int HttpAuthController::MaybeGenerateAuthToken( |
174 const HttpRequestInfo* request, const CompletionCallback& callback, | 177 const HttpRequestInfo* request, const CompletionCallback& callback, |
175 const BoundNetLog& net_log) { | 178 const BoundNetLog& net_log) { |
176 DCHECK(CalledOnValidThread()); | 179 DCHECK(CalledOnValidThread()); |
180 | |
181 #if defined(SPDY_PROXY_AUTH_ORIGIN) && defined(SPDY_PROXY_AUTH_VALUE) | |
182 if (target_ == HttpAuth::AUTH_PROXY) { | |
183 HttpAuthCache::Entry* entry = | |
184 http_auth_cache_->LookupByPath(auth_origin_, auth_path_); | |
185 if (entry) { | |
186 identity_.source = HttpAuth::IDENT_SRC_REALM_LOOKUP; | |
187 identity_.invalid = false; | |
188 identity_.credentials = entry->credentials(); | |
189 if (!handler_.get()) { | |
190 std::string raw_response_headers = base::StringPrintf( | |
191 "HTTP/1.1 407 Internal Server Error\r\n" | |
192 "Proxy-Authenticate: SpdyProxy realm=\"%s\", ps=\"%s\"\r\n\r\n", | |
193 entry->realm().data(), entry->auth_challenge().data()); | |
asanka
2013/05/22 21:47:43
entry->auth_challenge() is supposed to be the valu
bengr
2013/05/24 01:01:47
Done.
| |
194 HttpAuth::ChooseBestChallenge( | |
195 http_auth_handler_factory_, | |
196 new HttpResponseHeaders(HttpUtil::AssembleRawHeaders( | |
197 raw_response_headers.data(), raw_response_headers.length())), | |
198 target_, auth_origin_, disabled_schemes_, net_log, &handler_); | |
199 } | |
200 } | |
201 } | |
202 #endif | |
203 | |
177 bool needs_auth = HaveAuth() || SelectPreemptiveAuth(net_log); | 204 bool needs_auth = HaveAuth() || SelectPreemptiveAuth(net_log); |
178 if (!needs_auth) | 205 if (!needs_auth) |
179 return OK; | 206 return OK; |
180 const AuthCredentials* credentials = NULL; | 207 const AuthCredentials* credentials = NULL; |
181 if (identity_.source != HttpAuth::IDENT_SRC_DEFAULT_CREDENTIALS) | 208 if (identity_.source != HttpAuth::IDENT_SRC_DEFAULT_CREDENTIALS) |
182 credentials = &identity_.credentials; | 209 credentials = &identity_.credentials; |
183 DCHECK(auth_token_.empty()); | 210 DCHECK(auth_token_.empty()); |
184 DCHECK(callback_.is_null()); | 211 DCHECK(callback_.is_null()); |
185 int rv = handler_->GenerateAuthToken( | 212 int rv = handler_->GenerateAuthToken( |
186 credentials, request, | 213 credentials, request, |
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
557 DCHECK(CalledOnValidThread()); | 584 DCHECK(CalledOnValidThread()); |
558 return disabled_schemes_.find(scheme) != disabled_schemes_.end(); | 585 return disabled_schemes_.find(scheme) != disabled_schemes_.end(); |
559 } | 586 } |
560 | 587 |
561 void HttpAuthController::DisableAuthScheme(HttpAuth::Scheme scheme) { | 588 void HttpAuthController::DisableAuthScheme(HttpAuth::Scheme scheme) { |
562 DCHECK(CalledOnValidThread()); | 589 DCHECK(CalledOnValidThread()); |
563 disabled_schemes_.insert(scheme); | 590 disabled_schemes_.insert(scheme); |
564 } | 591 } |
565 | 592 |
566 } // namespace net | 593 } // namespace net |
OLD | NEW |