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" |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 return auth_sspi_.ParseChallenge(tok); | 105 return auth_sspi_.ParseChallenge(tok); |
106 #else | 106 #else |
107 // TODO(cbentzel): Most of the logic between SSPI, GSSAPI, and portable NTLM | 107 // TODO(cbentzel): Most of the logic between SSPI, GSSAPI, and portable NTLM |
108 // authentication parsing could probably be shared - just need to know if | 108 // authentication parsing could probably be shared - just need to know if |
109 // there was previously a challenge round. | 109 // there was previously a challenge round. |
110 // TODO(cbentzel): Write a test case to validate that auth_data_ is left empty | 110 // TODO(cbentzel): Write a test case to validate that auth_data_ is left empty |
111 // in all failure conditions. | 111 // in all failure conditions. |
112 auth_data_.clear(); | 112 auth_data_.clear(); |
113 | 113 |
114 // Verify the challenge's auth-scheme. | 114 // Verify the challenge's auth-scheme. |
115 if (!base::LowerCaseEqualsASCII(tok->scheme(), "ntlm")) | 115 if (!base::LowerCaseEqualsASCII(tok->scheme(), kNtlmAuthScheme)) |
116 return HttpAuth::AUTHORIZATION_RESULT_INVALID; | 116 return HttpAuth::AUTHORIZATION_RESULT_INVALID; |
117 | 117 |
118 std::string base64_param = tok->base64_param(); | 118 std::string base64_param = tok->base64_param(); |
119 if (base64_param.empty()) { | 119 if (base64_param.empty()) { |
120 if (!initial_challenge) | 120 if (!initial_challenge) |
121 return HttpAuth::AUTHORIZATION_RESULT_REJECT; | 121 return HttpAuth::AUTHORIZATION_RESULT_REJECT; |
122 return HttpAuth::AUTHORIZATION_RESULT_ACCEPT; | 122 return HttpAuth::AUTHORIZATION_RESULT_ACCEPT; |
123 } else { | 123 } else { |
124 if (initial_challenge) | 124 if (initial_challenge) |
125 return HttpAuth::AUTHORIZATION_RESULT_INVALID; | 125 return HttpAuth::AUTHORIZATION_RESULT_INVALID; |
126 } | 126 } |
127 | 127 |
128 auth_data_ = base64_param; | 128 auth_data_ = base64_param; |
129 return HttpAuth::AUTHORIZATION_RESULT_ACCEPT; | 129 return HttpAuth::AUTHORIZATION_RESULT_ACCEPT; |
130 #endif // defined(NTLM_SSPI) | 130 #endif // defined(NTLM_SSPI) |
131 } | 131 } |
132 | 132 |
133 // static | 133 // static |
134 std::string HttpAuthHandlerNTLM::CreateSPN(const GURL& origin) { | 134 std::string HttpAuthHandlerNTLM::CreateSPN(const GURL& origin) { |
135 // The service principal name of the destination server. See | 135 // The service principal name of the destination server. See |
136 // http://msdn.microsoft.com/en-us/library/ms677949%28VS.85%29.aspx | 136 // http://msdn.microsoft.com/en-us/library/ms677949%28VS.85%29.aspx |
137 std::string target("HTTP/"); | 137 std::string target("HTTP/"); |
138 target.append(GetHostAndPort(origin)); | 138 target.append(GetHostAndPort(origin)); |
139 return target; | 139 return target; |
140 } | 140 } |
141 | 141 |
142 } // namespace net | 142 } // namespace net |
OLD | NEW |