OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "base/strings/string_split.h" |
| 6 #include "net/http/http_auth_filter.h" |
| 7 #include "net/http/http_auth_preferences.h" |
| 8 #include "net/http/url_security_manager.h" |
| 9 |
| 10 namespace net { |
| 11 |
| 12 HttpAuthPreferences::HttpAuthPreferences( |
| 13 const std::vector<std::string>& auth_schemes |
| 14 #if defined(OS_POSIX) && !defined(OS_ANDROID) |
| 15 , |
| 16 const std::string& gssapi_library_name |
| 17 #endif |
| 18 ) |
| 19 : auth_schemes_(auth_schemes.begin(), auth_schemes.end()), |
| 20 negotiate_disable_cname_lookup_(false), |
| 21 negotiate_enable_port_(false), |
| 22 #if defined(OS_POSIX) && !defined(OS_ANDROID) |
| 23 gssapi_library_name_(gssapi_library_name), |
| 24 #endif |
| 25 security_manager_(URLSecurityManager::Create()) { |
| 26 } |
| 27 |
| 28 HttpAuthPreferences::~HttpAuthPreferences() {} |
| 29 |
| 30 bool HttpAuthPreferences::IsSupportedScheme(const std::string& scheme) const { |
| 31 return auth_schemes_.count(scheme) == 1; |
| 32 } |
| 33 |
| 34 bool HttpAuthPreferences::NegotiateDisableCnameLookup() const { |
| 35 return negotiate_disable_cname_lookup_; |
| 36 } |
| 37 |
| 38 bool HttpAuthPreferences::NegotiateEnablePort() const { |
| 39 return negotiate_enable_port_; |
| 40 } |
| 41 |
| 42 #if defined(OS_ANDROID) |
| 43 std::string HttpAuthPreferences::AuthAndroidNegotiateAccountType() const { |
| 44 return auth_android_negotiate_account_type_; |
| 45 } |
| 46 #endif |
| 47 #if defined(OS_POSIX) && !defined(OS_ANDROID) |
| 48 std::string HttpAuthPreferences::GssapiLibraryName() const { |
| 49 return gssapi_library_name_; |
| 50 } |
| 51 #endif |
| 52 |
| 53 bool HttpAuthPreferences::CanUseDefaultCredentials( |
| 54 const GURL& auth_origin) const { |
| 55 return security_manager_->CanUseDefaultCredentials(auth_origin); |
| 56 } |
| 57 |
| 58 bool HttpAuthPreferences::CanDelegate(const GURL& auth_origin) const { |
| 59 return security_manager_->CanDelegate(auth_origin); |
| 60 } |
| 61 |
| 62 void HttpAuthPreferences::set_server_whitelist( |
| 63 const std::string& server_whitelist) { |
| 64 if (server_whitelist.empty()) { |
| 65 security_manager_->SetDefaultWhitelist(scoped_ptr<HttpAuthFilter>()); |
| 66 } else { |
| 67 security_manager_->SetDefaultWhitelist(scoped_ptr<HttpAuthFilter>( |
| 68 new net::HttpAuthFilterWhitelist(server_whitelist))); |
| 69 } |
| 70 } |
| 71 |
| 72 void HttpAuthPreferences::set_delegate_whitelist( |
| 73 const std::string& delegate_whitelist) { |
| 74 if (delegate_whitelist.empty()) { |
| 75 security_manager_->SetDelegateWhitelist(scoped_ptr<HttpAuthFilter>()); |
| 76 } else { |
| 77 security_manager_->SetDelegateWhitelist(scoped_ptr<HttpAuthFilter>( |
| 78 new net::HttpAuthFilterWhitelist(delegate_whitelist))); |
| 79 } |
| 80 } |
| 81 |
| 82 } // namespace net |
OLD | NEW |