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 // See "SSPI Sample Application" at | 5 // See "SSPI Sample Application" at |
6 // http://msdn.microsoft.com/en-us/library/aa918273.aspx | 6 // http://msdn.microsoft.com/en-us/library/aa918273.aspx |
7 | 7 |
8 #include "net/http/http_auth_sspi_win.h" | 8 #include "net/http/http_auth_sspi_win.h" |
9 | 9 |
10 #include "base/base64.h" | 10 #include "base/base64.h" |
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 decoded_server_auth_token_.c_str())), | 273 decoded_server_auth_token_.c_str())), |
274 decoded_server_auth_token_.length(), | 274 decoded_server_auth_token_.length(), |
275 &out_buf, | 275 &out_buf, |
276 &out_buf_len); | 276 &out_buf_len); |
277 if (rv != OK) | 277 if (rv != OK) |
278 return rv; | 278 return rv; |
279 | 279 |
280 // Base64 encode data in output buffer and prepend the scheme. | 280 // Base64 encode data in output buffer and prepend the scheme. |
281 std::string encode_input(static_cast<char*>(out_buf), out_buf_len); | 281 std::string encode_input(static_cast<char*>(out_buf), out_buf_len); |
282 std::string encode_output; | 282 std::string encode_output; |
283 bool base64_rv = base::Base64Encode(encode_input, &encode_output); | 283 base::Base64Encode(encode_input, &encode_output); |
284 // OK, we are done with |out_buf| | 284 // OK, we are done with |out_buf| |
285 free(out_buf); | 285 free(out_buf); |
286 if (!base64_rv) { | |
287 LOG(ERROR) << "Base64 encoding of auth token failed."; | |
288 return ERR_ENCODING_CONVERSION_FAILED; | |
289 } | |
290 *auth_token = scheme_ + " " + encode_output; | 286 *auth_token = scheme_ + " " + encode_output; |
291 return OK; | 287 return OK; |
292 } | 288 } |
293 | 289 |
294 int HttpAuthSSPI::OnFirstRound(const AuthCredentials* credentials) { | 290 int HttpAuthSSPI::OnFirstRound(const AuthCredentials* credentials) { |
295 DCHECK(!SecIsValidHandle(&cred_)); | 291 DCHECK(!SecIsValidHandle(&cred_)); |
296 int rv = OK; | 292 int rv = OK; |
297 if (credentials) { | 293 if (credentials) { |
298 base::string16 domain; | 294 base::string16 domain; |
299 base::string16 user; | 295 base::string16 user; |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
421 int token_length = pkg_info->cbMaxToken; | 417 int token_length = pkg_info->cbMaxToken; |
422 status = library->FreeContextBuffer(pkg_info); | 418 status = library->FreeContextBuffer(pkg_info); |
423 rv = MapFreeContextBufferStatusToError(status); | 419 rv = MapFreeContextBufferStatusToError(status); |
424 if (rv != OK) | 420 if (rv != OK) |
425 return rv; | 421 return rv; |
426 *max_token_length = token_length; | 422 *max_token_length = token_length; |
427 return OK; | 423 return OK; |
428 } | 424 } |
429 | 425 |
430 } // namespace net | 426 } // namespace net |
OLD | NEW |