| 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 base::Base64Encode(encode_input, &encode_output); | 92 bool base64_rv = 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 } |
| 95 *auth_token = std::string("NTLM ") + encode_output; | 99 *auth_token = std::string("NTLM ") + encode_output; |
| 96 return OK; | 100 return OK; |
| 97 #endif | 101 #endif |
| 98 } | 102 } |
| 99 | 103 |
| 100 // The NTLM challenge header looks like: | 104 // The NTLM challenge header looks like: |
| 101 // WWW-Authenticate: NTLM auth-data | 105 // WWW-Authenticate: NTLM auth-data |
| 102 HttpAuth::AuthorizationResult HttpAuthHandlerNTLM::ParseChallenge( | 106 HttpAuth::AuthorizationResult HttpAuthHandlerNTLM::ParseChallenge( |
| 103 HttpAuth::ChallengeTokenizer* tok, bool initial_challenge) { | 107 HttpAuth::ChallengeTokenizer* tok, bool initial_challenge) { |
| 104 #if defined(NTLM_SSPI) | 108 #if defined(NTLM_SSPI) |
| (...skipping 29 matching lines...) Expand all Loading... |
| 134 // static | 138 // static |
| 135 std::string HttpAuthHandlerNTLM::CreateSPN(const GURL& origin) { | 139 std::string HttpAuthHandlerNTLM::CreateSPN(const GURL& origin) { |
| 136 // The service principal name of the destination server. See | 140 // The service principal name of the destination server. See |
| 137 // http://msdn.microsoft.com/en-us/library/ms677949%28VS.85%29.aspx | 141 // http://msdn.microsoft.com/en-us/library/ms677949%28VS.85%29.aspx |
| 138 std::string target("HTTP/"); | 142 std::string target("HTTP/"); |
| 139 target.append(GetHostAndPort(origin)); | 143 target.append(GetHostAndPort(origin)); |
| 140 return target; | 144 return target; |
| 141 } | 145 } |
| 142 | 146 |
| 143 } // namespace net | 147 } // namespace net |
| OLD | NEW |