1 // Copyright 2011 The Chromium Authors 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 "net/http/http_auth_handler_ntlm.h" 6 7 #include "net/base/url_util.h" 8 #include "net/cert/x509_util.h" 9 #include "net/http/http_auth_scheme.h" 10 #include "net/ssl/ssl_info.h" 11 12 namespace net { 13 14 HttpAuthHandlerNTLM::Factory::Factory() = default; 15 16 HttpAuthHandlerNTLM::Factory::~Factory() = default; 17 Init(HttpAuthChallengeTokenizer * tok,const SSLInfo & ssl_info,const NetworkAnonymizationKey & network_anonymization_key)18bool HttpAuthHandlerNTLM::Init( 19 HttpAuthChallengeTokenizer* tok, 20 const SSLInfo& ssl_info, 21 const NetworkAnonymizationKey& network_anonymization_key) { 22 auth_scheme_ = HttpAuth::AUTH_SCHEME_NTLM; 23 score_ = 3; 24 properties_ = ENCRYPTS_IDENTITY | IS_CONNECTION_BASED; 25 26 if (ssl_info.is_valid()) 27 x509_util::GetTLSServerEndPointChannelBinding(*ssl_info.cert, 28 &channel_bindings_); 29 30 return ParseChallenge(tok) == HttpAuth::AUTHORIZATION_RESULT_ACCEPT; 31 } 32 HandleAnotherChallengeImpl(HttpAuthChallengeTokenizer * challenge)33HttpAuth::AuthorizationResult HttpAuthHandlerNTLM::HandleAnotherChallengeImpl( 34 HttpAuthChallengeTokenizer* challenge) { 35 return ParseChallenge(challenge); 36 } 37 38 // static CreateSPN(const url::SchemeHostPort & scheme_host_port)39std::string HttpAuthHandlerNTLM::CreateSPN( 40 const url::SchemeHostPort& scheme_host_port) { 41 // The service principal name of the destination server. See 42 // http://msdn.microsoft.com/en-us/library/ms677949%28VS.85%29.aspx 43 std::string target("HTTP/"); 44 target.append(GetHostAndOptionalPort(scheme_host_port)); 45 return target; 46 } 47 48 } // namespace net 49