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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 in_buf = decoded_auth_data.data(); | 82 in_buf = decoded_auth_data.data(); |
83 } | 83 } |
84 | 84 |
85 int rv = GetNextToken(in_buf, in_buf_len, &out_buf, &out_buf_len); | 85 int rv = GetNextToken(in_buf, in_buf_len, &out_buf, &out_buf_len); |
86 if (rv != OK) | 86 if (rv != OK) |
87 return rv; | 87 return rv; |
88 | 88 |
89 // Base64 encode data in output buffer and prepend "NTLM ". | 89 // Base64 encode data in output buffer and prepend "NTLM ". |
90 std::string encode_input(static_cast<char*>(out_buf), out_buf_len); | 90 std::string encode_input(static_cast<char*>(out_buf), out_buf_len); |
91 std::string encode_output; | 91 std::string encode_output; |
92 bool base64_rv = base::Base64Encode(encode_input, &encode_output); | 92 base::Base64Encode(encode_input, &encode_output); |
93 // OK, we are done with |out_buf| | 93 // OK, we are done with |out_buf| |
94 free(out_buf); | 94 free(out_buf); |
95 if (!base64_rv) { | |
96 LOG(ERROR) << "Unexpected problem Base64 encoding."; | |
97 return ERR_UNEXPECTED; | |
98 } | |
99 *auth_token = std::string("NTLM ") + encode_output; | 95 *auth_token = std::string("NTLM ") + encode_output; |
100 return OK; | 96 return OK; |
101 #endif | 97 #endif |
102 } | 98 } |
103 | 99 |
104 // The NTLM challenge header looks like: | 100 // The NTLM challenge header looks like: |
105 // WWW-Authenticate: NTLM auth-data | 101 // WWW-Authenticate: NTLM auth-data |
106 HttpAuth::AuthorizationResult HttpAuthHandlerNTLM::ParseChallenge( | 102 HttpAuth::AuthorizationResult HttpAuthHandlerNTLM::ParseChallenge( |
107 HttpAuth::ChallengeTokenizer* tok, bool initial_challenge) { | 103 HttpAuth::ChallengeTokenizer* tok, bool initial_challenge) { |
108 #if defined(NTLM_SSPI) | 104 #if defined(NTLM_SSPI) |
(...skipping 29 matching lines...) Expand all Loading... |
138 // static | 134 // static |
139 std::string HttpAuthHandlerNTLM::CreateSPN(const GURL& origin) { | 135 std::string HttpAuthHandlerNTLM::CreateSPN(const GURL& origin) { |
140 // The service principal name of the destination server. See | 136 // The service principal name of the destination server. See |
141 // http://msdn.microsoft.com/en-us/library/ms677949%28VS.85%29.aspx | 137 // http://msdn.microsoft.com/en-us/library/ms677949%28VS.85%29.aspx |
142 std::string target("HTTP/"); | 138 std::string target("HTTP/"); |
143 target.append(GetHostAndPort(origin)); | 139 target.append(GetHostAndPort(origin)); |
144 return target; | 140 return target; |
145 } | 141 } |
146 | 142 |
147 } // namespace net | 143 } // namespace net |
OLD | NEW |