| 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 base::Base64Encode(encode_input, &encode_output); | 283 bool base64_rv = 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 } |
| 286 *auth_token = scheme_ + " " + encode_output; | 290 *auth_token = scheme_ + " " + encode_output; |
| 287 return OK; | 291 return OK; |
| 288 } | 292 } |
| 289 | 293 |
| 290 int HttpAuthSSPI::OnFirstRound(const AuthCredentials* credentials) { | 294 int HttpAuthSSPI::OnFirstRound(const AuthCredentials* credentials) { |
| 291 DCHECK(!SecIsValidHandle(&cred_)); | 295 DCHECK(!SecIsValidHandle(&cred_)); |
| 292 int rv = OK; | 296 int rv = OK; |
| 293 if (credentials) { | 297 if (credentials) { |
| 294 base::string16 domain; | 298 base::string16 domain; |
| 295 base::string16 user; | 299 base::string16 user; |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 417 int token_length = pkg_info->cbMaxToken; | 421 int token_length = pkg_info->cbMaxToken; |
| 418 status = library->FreeContextBuffer(pkg_info); | 422 status = library->FreeContextBuffer(pkg_info); |
| 419 rv = MapFreeContextBufferStatusToError(status); | 423 rv = MapFreeContextBufferStatusToError(status); |
| 420 if (rv != OK) | 424 if (rv != OK) |
| 421 return rv; | 425 return rv; |
| 422 *max_token_length = token_length; | 426 *max_token_length = token_length; |
| 423 return OK; | 427 return OK; |
| 424 } | 428 } |
| 425 | 429 |
| 426 } // namespace net | 430 } // namespace net |
| OLD | NEW |