| 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 // TODO(ukai): code is similar with http_network_transaction.cc. We should | 5 // TODO(ukai): code is similar with http_network_transaction.cc. We should |
| 6 // think about ways to share code, if possible. | 6 // think about ways to share code, if possible. |
| 7 | 7 |
| 8 #include "net/socket_stream/socket_stream.h" | 8 #include "net/socket_stream/socket_stream.h" |
| 9 | 9 |
| 10 #include <set> | 10 #include <set> |
| (...skipping 747 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 758 auth_identity_.invalid = false; | 758 auth_identity_.invalid = false; |
| 759 auth_identity_.credentials = AuthCredentials(); | 759 auth_identity_.credentials = AuthCredentials(); |
| 760 auth_handler_.swap(handler_preemptive); | 760 auth_handler_.swap(handler_preemptive); |
| 761 } | 761 } |
| 762 } | 762 } |
| 763 } | 763 } |
| 764 | 764 |
| 765 // Support basic authentication scheme only, because we don't have | 765 // Support basic authentication scheme only, because we don't have |
| 766 // HttpRequestInfo. | 766 // HttpRequestInfo. |
| 767 // TODO(ukai): Add support other authentication scheme. | 767 // TODO(ukai): Add support other authentication scheme. |
| 768 if (auth_handler_.get() && | 768 if (auth_handler_.get() && auth_handler_->auth_scheme() == "basic") { |
| 769 auth_handler_->auth_scheme() == HttpAuth::AUTH_SCHEME_BASIC) { | |
| 770 HttpRequestInfo request_info; | 769 HttpRequestInfo request_info; |
| 771 std::string auth_token; | 770 std::string auth_token; |
| 772 int rv = auth_handler_->GenerateAuthToken( | 771 int rv = auth_handler_->GenerateAuthToken( |
| 773 &auth_identity_.credentials, | 772 &auth_identity_.credentials, |
| 774 &request_info, | 773 &request_info, |
| 775 CompletionCallback(), | 774 CompletionCallback(), |
| 776 &auth_token); | 775 &auth_token); |
| 777 // TODO(cbentzel): Support async auth handlers. | 776 // TODO(cbentzel): Support async auth handlers. |
| 778 DCHECK_NE(ERR_IO_PENDING, rv); | 777 DCHECK_NE(ERR_IO_PENDING, rv); |
| 779 if (rv != OK) | 778 if (rv != OK) |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 898 } | 897 } |
| 899 return OK; | 898 return OK; |
| 900 case 407: // Proxy Authentication Required. | 899 case 407: // Proxy Authentication Required. |
| 901 result = HandleAuthChallenge(headers.get()); | 900 result = HandleAuthChallenge(headers.get()); |
| 902 if (result == ERR_PROXY_AUTH_UNSUPPORTED && | 901 if (result == ERR_PROXY_AUTH_UNSUPPORTED && |
| 903 auth_handler_.get() && delegate_) { | 902 auth_handler_.get() && delegate_) { |
| 904 DCHECK(!proxy_info_.is_empty()); | 903 DCHECK(!proxy_info_.is_empty()); |
| 905 auth_info_ = new AuthChallengeInfo; | 904 auth_info_ = new AuthChallengeInfo; |
| 906 auth_info_->is_proxy = true; | 905 auth_info_->is_proxy = true; |
| 907 auth_info_->challenger = proxy_info_.proxy_server().host_port_pair(); | 906 auth_info_->challenger = proxy_info_.proxy_server().host_port_pair(); |
| 908 auth_info_->scheme = HttpAuth::SchemeToString( | 907 auth_info_->scheme = auth_handler_->auth_scheme(); |
| 909 auth_handler_->auth_scheme()); | |
| 910 auth_info_->realm = auth_handler_->realm(); | 908 auth_info_->realm = auth_handler_->realm(); |
| 911 // Wait until RestartWithAuth or Close is called. | 909 // Wait until RestartWithAuth or Close is called. |
| 912 MessageLoop::current()->PostTask( | 910 MessageLoop::current()->PostTask( |
| 913 FROM_HERE, | 911 FROM_HERE, |
| 914 base::Bind(&SocketStream::DoAuthRequired, this)); | 912 base::Bind(&SocketStream::DoAuthRequired, this)); |
| 915 next_state_ = STATE_AUTH_REQUIRED; | 913 next_state_ = STATE_AUTH_REQUIRED; |
| 916 return ERR_IO_PENDING; | 914 return ERR_IO_PENDING; |
| 917 } | 915 } |
| 918 default: | 916 default: |
| 919 break; | 917 break; |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1156 if (auth_identity_.source != HttpAuth::IDENT_SRC_PATH_LOOKUP) | 1154 if (auth_identity_.source != HttpAuth::IDENT_SRC_PATH_LOOKUP) |
| 1157 auth_cache_.Remove(auth_origin, | 1155 auth_cache_.Remove(auth_origin, |
| 1158 auth_handler_->realm(), | 1156 auth_handler_->realm(), |
| 1159 auth_handler_->auth_scheme(), | 1157 auth_handler_->auth_scheme(), |
| 1160 auth_identity_.credentials); | 1158 auth_identity_.credentials); |
| 1161 auth_handler_.reset(); | 1159 auth_handler_.reset(); |
| 1162 auth_identity_ = HttpAuth::Identity(); | 1160 auth_identity_ = HttpAuth::Identity(); |
| 1163 } | 1161 } |
| 1164 | 1162 |
| 1165 auth_identity_.invalid = true; | 1163 auth_identity_.invalid = true; |
| 1166 std::set<HttpAuth::Scheme> disabled_schemes; | 1164 std::set<std::string> disabled_schemes; |
| 1167 HttpAuth::ChooseBestChallenge(http_auth_handler_factory_, headers, | 1165 HttpAuth::ChooseBestChallenge(http_auth_handler_factory_, headers, |
| 1168 HttpAuth::AUTH_PROXY, | 1166 HttpAuth::AUTH_PROXY, |
| 1169 auth_origin, disabled_schemes, | 1167 auth_origin, disabled_schemes, |
| 1170 net_log_, &auth_handler_); | 1168 net_log_, &auth_handler_); |
| 1171 if (!auth_handler_.get()) { | 1169 if (!auth_handler_.get()) { |
| 1172 LOG(ERROR) << "Can't perform auth to the proxy " << auth_origin; | 1170 LOG(ERROR) << "Can't perform auth to the proxy " << auth_origin; |
| 1173 return ERR_TUNNEL_CONNECTION_FAILED; | 1171 return ERR_TUNNEL_CONNECTION_FAILED; |
| 1174 } | 1172 } |
| 1175 if (auth_handler_->NeedsIdentity()) { | 1173 if (auth_handler_->NeedsIdentity()) { |
| 1176 // We only support basic authentication scheme now. | 1174 // We only support basic authentication scheme now. |
| 1177 // TODO(ukai): Support other authentication scheme. | 1175 // TODO(ukai): Support other authentication scheme. |
| 1178 HttpAuthCache::Entry* entry = auth_cache_.Lookup( | 1176 HttpAuthCache::Entry* entry = auth_cache_.Lookup( |
| 1179 auth_origin, auth_handler_->realm(), HttpAuth::AUTH_SCHEME_BASIC); | 1177 auth_origin, auth_handler_->realm(), "basic"); |
| 1180 if (entry) { | 1178 if (entry) { |
| 1181 auth_identity_.source = HttpAuth::IDENT_SRC_REALM_LOOKUP; | 1179 auth_identity_.source = HttpAuth::IDENT_SRC_REALM_LOOKUP; |
| 1182 auth_identity_.invalid = false; | 1180 auth_identity_.invalid = false; |
| 1183 auth_identity_.credentials = AuthCredentials(); | 1181 auth_identity_.credentials = AuthCredentials(); |
| 1184 // Restart with auth info. | 1182 // Restart with auth info. |
| 1185 } | 1183 } |
| 1186 return ERR_PROXY_AUTH_UNSUPPORTED; | 1184 return ERR_PROXY_AUTH_UNSUPPORTED; |
| 1187 } else { | 1185 } else { |
| 1188 auth_identity_.invalid = false; | 1186 auth_identity_.invalid = false; |
| 1189 } | 1187 } |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1321 | 1319 |
| 1322 SSLConfigService* SocketStream::ssl_config_service() const { | 1320 SSLConfigService* SocketStream::ssl_config_service() const { |
| 1323 return context_->ssl_config_service(); | 1321 return context_->ssl_config_service(); |
| 1324 } | 1322 } |
| 1325 | 1323 |
| 1326 ProxyService* SocketStream::proxy_service() const { | 1324 ProxyService* SocketStream::proxy_service() const { |
| 1327 return context_->proxy_service(); | 1325 return context_->proxy_service(); |
| 1328 } | 1326 } |
| 1329 | 1327 |
| 1330 } // namespace net | 1328 } // namespace net |
| OLD | NEW |