| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_handler_ntlm.h" | 5 #include "net/http/http_auth_handler_ntlm.h" |
| 6 | 6 |
| 7 #if !defined(NTLM_SSPI) | 7 #if !defined(NTLM_SSPI) |
| 8 #include "base/base64.h" | 8 #include "base/base64.h" |
| 9 #endif | 9 #endif |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
| 12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
| 13 #include "net/base/net_errors.h" | 13 #include "net/base/net_errors.h" |
| 14 #include "net/base/net_util.h" | 14 #include "net/base/net_util.h" |
| 15 #include "net/http/http_auth_challenge_tokenizer.h" | 15 #include "net/http/http_auth_challenge_tokenizer.h" |
| 16 | 16 |
| 17 namespace net { | 17 namespace net { |
| 18 | 18 |
| 19 HttpAuth::AuthorizationResult HttpAuthHandlerNTLM::HandleAnotherChallenge( | 19 HttpAuth::AuthorizationResult HttpAuthHandlerNTLM::HandleAnotherChallenge( |
| 20 const HttpAuthChallengeTokenizer& challenge) { | 20 const HttpAuthChallengeTokenizer& challenge) { |
| 21 return ParseChallenge(challenge, false); | 21 return ParseChallenge(challenge, false); |
| 22 } | 22 } |
| 23 | 23 |
| 24 int HttpAuthHandlerNTLM::Init(const HttpAuthChallengeTokenizer& tok) { | 24 int HttpAuthHandlerNTLM::InitializeFromChallengeInternal( |
| 25 return ParseChallenge(tok, true) == HttpAuth::AUTHORIZATION_RESULT_ACCEPT | 25 const HttpAuthChallengeTokenizer& challenge, |
| 26 const HttpResponseInfo& response_with_challenge, |
| 27 const CompletionCallback& callback) { |
| 28 return ParseChallenge(challenge, true) == |
| 29 HttpAuth::AUTHORIZATION_RESULT_ACCEPT |
| 26 ? OK | 30 ? OK |
| 27 : ERR_INVALID_RESPONSE; | 31 : ERR_INVALID_RESPONSE; |
| 28 } | 32 } |
| 29 | 33 |
| 34 int HttpAuthHandlerNTLM::InitializeFromCacheEntryInternal( |
| 35 HttpAuthCache::Entry*) { |
| 36 NOTREACHED(); |
| 37 return ERR_UNSUPPORTED_AUTH_SCHEME; |
| 38 } |
| 39 |
| 30 int HttpAuthHandlerNTLM::GenerateAuthTokenImpl( | 40 int HttpAuthHandlerNTLM::GenerateAuthTokenImpl( |
| 31 const AuthCredentials* credentials, | 41 const AuthCredentials* credentials, |
| 32 const HttpRequestInfo& request, | 42 const HttpRequestInfo& request, |
| 33 const CompletionCallback& callback, | 43 const CompletionCallback& callback, |
| 34 std::string* auth_token) { | 44 std::string* auth_token) { |
| 35 #if defined(NTLM_SSPI) | 45 #if defined(NTLM_SSPI) |
| 36 return auth_sspi_.GenerateAuthToken(credentials, CreateSPN(origin_), | 46 return auth_sspi_.GenerateAuthToken(credentials, CreateSPN(origin_), |
| 37 auth_token, callback); | 47 auth_token, callback); |
| 38 #else // !defined(NTLM_SSPI) | 48 #else // !defined(NTLM_SSPI) |
| 39 // TODO(cbentzel): Shouldn't be hitting this case. | 49 // TODO(cbentzel): Shouldn't be hitting this case. |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 // http://msdn.microsoft.com/en-us/library/ms677949%28VS.85%29.aspx | 148 // http://msdn.microsoft.com/en-us/library/ms677949%28VS.85%29.aspx |
| 139 std::string target("HTTP/"); | 149 std::string target("HTTP/"); |
| 140 target.append(GetHostAndPort(origin)); | 150 target.append(GetHostAndPort(origin)); |
| 141 return target; | 151 return target; |
| 142 } | 152 } |
| 143 | 153 |
| 144 // None of the implementations support pre-emptive authentication for NTLM. | 154 // None of the implementations support pre-emptive authentication for NTLM. |
| 145 scoped_ptr<HttpAuthHandler> | 155 scoped_ptr<HttpAuthHandler> |
| 146 HttpAuthHandlerNTLM::Factory::CreateAndInitPreemptiveAuthHandler( | 156 HttpAuthHandlerNTLM::Factory::CreateAndInitPreemptiveAuthHandler( |
| 147 HttpAuthCache::Entry* cache_entry, | 157 HttpAuthCache::Entry* cache_entry, |
| 148 const HttpAuthChallengeTokenizer& tokenizer, | |
| 149 HttpAuth::Target target, | 158 HttpAuth::Target target, |
| 150 const BoundNetLog& net_log) { | 159 const BoundNetLog& net_log) { |
| 151 return scoped_ptr<HttpAuthHandler>(); | 160 return scoped_ptr<HttpAuthHandler>(); |
| 152 } | 161 } |
| 153 | 162 |
| 154 } // namespace net | 163 } // namespace net |
| OLD | NEW |