#include "net/http/http_auth_handler_factory.h"
#include <optional>
#include <set>
#include "base/containers/contains.h"
#include "base/memory/ptr_util.h"
#include "base/strings/string_util.h"
#include "build/build_config.h"
#include "net/base/net_errors.h"
#include "net/dns/host_resolver.h"
#include "net/http/http_auth_challenge_tokenizer.h"
#include "net/http/http_auth_filter.h"
#include "net/http/http_auth_handler_basic.h"
#include "net/http/http_auth_handler_digest.h"
#include "net/http/http_auth_handler_ntlm.h"
#include "net/http/http_auth_preferences.h"
#include "net/http/http_auth_scheme.h"
#include "net/log/net_log_values.h"
#include "net/net_buildflags.h"
#include "net/ssl/ssl_info.h"
#include "url/scheme_host_port.h"
#if BUILDFLAG(USE_KERBEROS)
#include "net/http/http_auth_handler_negotiate.h"
#endif
namespace net {
namespace {
base::Value::Dict NetLogParamsForCreateAuth(
const std::string& scheme,
const std::string& challenge,
const int net_error,
const url::SchemeHostPort& scheme_host_port,
const std::optional<bool>& allows_default_credentials,
NetLogCaptureMode capture_mode) { … }
}
int HttpAuthHandlerFactory::CreateAuthHandlerFromString(
const std::string& challenge,
HttpAuth::Target target,
const SSLInfo& ssl_info,
const NetworkAnonymizationKey& network_anonymization_key,
const url::SchemeHostPort& scheme_host_port,
const NetLogWithSource& net_log,
HostResolver* host_resolver,
std::unique_ptr<HttpAuthHandler>* handler) { … }
int HttpAuthHandlerFactory::CreatePreemptiveAuthHandlerFromString(
const std::string& challenge,
HttpAuth::Target target,
const NetworkAnonymizationKey& network_anonymization_key,
const url::SchemeHostPort& scheme_host_port,
int digest_nonce_count,
const NetLogWithSource& net_log,
HostResolver* host_resolver,
std::unique_ptr<HttpAuthHandler>* handler) { … }
HttpAuthHandlerRegistryFactory::HttpAuthHandlerRegistryFactory(
const HttpAuthPreferences* http_auth_preferences) { … }
HttpAuthHandlerRegistryFactory::~HttpAuthHandlerRegistryFactory() = default;
void HttpAuthHandlerRegistryFactory::SetHttpAuthPreferences(
const std::string& scheme,
const HttpAuthPreferences* prefs) { … }
void HttpAuthHandlerRegistryFactory::RegisterSchemeFactory(
const std::string& scheme,
std::unique_ptr<HttpAuthHandlerFactory> factory) { … }
std::unique_ptr<HttpAuthHandlerRegistryFactory>
HttpAuthHandlerFactory::CreateDefault(
const HttpAuthPreferences* prefs
#if BUILDFLAG(USE_EXTERNAL_GSSAPI)
,
const std::string& gssapi_library_name
#endif
#if BUILDFLAG(USE_KERBEROS)
,
HttpAuthMechanismFactory negotiate_auth_system_factory
#endif
) { … }
std::unique_ptr<HttpAuthHandlerRegistryFactory>
HttpAuthHandlerRegistryFactory::Create(
const HttpAuthPreferences* prefs
#if BUILDFLAG(USE_EXTERNAL_GSSAPI)
,
const std::string& gssapi_library_name
#endif
#if BUILDFLAG(USE_KERBEROS)
,
HttpAuthMechanismFactory negotiate_auth_system_factory
#endif
) { … }
int HttpAuthHandlerRegistryFactory::CreateAuthHandler(
HttpAuthChallengeTokenizer* challenge,
HttpAuth::Target target,
const SSLInfo& ssl_info,
const NetworkAnonymizationKey& network_anonymization_key,
const url::SchemeHostPort& scheme_host_port,
CreateReason reason,
int digest_nonce_count,
const NetLogWithSource& net_log,
HostResolver* host_resolver,
std::unique_ptr<HttpAuthHandler>* handler) { … }
bool HttpAuthHandlerRegistryFactory::IsSchemeAllowedForTesting(
const std::string& scheme) const { … }
bool HttpAuthHandlerRegistryFactory::IsSchemeAllowed(
const std::string& scheme) const { … }
#if BUILDFLAG(USE_KERBEROS) && !BUILDFLAG(IS_ANDROID) && BUILDFLAG(IS_POSIX)
std::optional<std::string>
HttpAuthHandlerRegistryFactory::GetNegotiateLibraryNameForTesting() const { … }
#endif
HttpAuthHandlerFactory* HttpAuthHandlerRegistryFactory::GetSchemeFactory(
const std::string& scheme) const { … }
}