diff options
author | cbentzel@chromium.org <cbentzel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-05 19:13:29 +0000 |
---|---|---|
committer | cbentzel@chromium.org <cbentzel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-05 19:13:29 +0000 |
commit | ac3fa8e2ef53e83b113d726209525f4af4aa46f1 (patch) | |
tree | cf3550a3155d263943062b68ea5b205035d22182 /net/http/http_auth_handler_ntlm.cc | |
parent | 5502208efd91894a34ef43a38d348b7f9acb3770 (diff) | |
download | chromium_src-ac3fa8e2ef53e83b113d726209525f4af4aa46f1.zip chromium_src-ac3fa8e2ef53e83b113d726209525f4af4aa46f1.tar.gz chromium_src-ac3fa8e2ef53e83b113d726209525f4af4aa46f1.tar.bz2 |
Add Single Sign On support to HTTP Authentication handlers.
Currently this is implemented on Windows for the NTLM and Negotiate schemes.
This CL does not introduce the hooks to actually use Single Sign On in response to a 401/407 request - that will come in a later CL.
This behavior is disabled for now as well.
BUG=29862
TEST=Ran unittests, and Chrome against a server with authentication challenges.
Review URL: http://codereview.chromium.org/555174
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@38227 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/http/http_auth_handler_ntlm.cc')
-rw-r--r--[-rwxr-xr-x] | net/http/http_auth_handler_ntlm.cc | 41 |
1 files changed, 21 insertions, 20 deletions
diff --git a/net/http/http_auth_handler_ntlm.cc b/net/http/http_auth_handler_ntlm.cc index 6e10e79..e191ce4 100755..100644 --- a/net/http/http_auth_handler_ntlm.cc +++ b/net/http/http_auth_handler_ntlm.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -10,24 +10,20 @@ namespace net { -std::string HttpAuthHandlerNTLM::GenerateCredentials( +int HttpAuthHandlerNTLM::GenerateAuthToken( const std::wstring& username, const std::wstring& password, const HttpRequestInfo* request, - const ProxyInfo* proxy) { + const ProxyInfo* proxy, + std::string* auth_token) { #if defined(NTLM_SSPI) - std::string auth_credentials; - - int rv = auth_sspi_.GenerateCredentials( - username, - password, + return auth_sspi_.GenerateAuthToken( + &username, + &password, origin_, request, proxy, - &auth_credentials); - if (rv == OK) - return auth_credentials; - return std::string(); + auth_token); #else // !defined(NTLM_SSPI) // TODO(wtc): See if we can use char* instead of void* for in_buf and // out_buf. This change will need to propagate to GetNextToken, @@ -58,7 +54,7 @@ std::string HttpAuthHandlerNTLM::GenerateCredentials( in_buf = NULL; int rv = InitializeBeforeFirstChallenge(); if (rv != OK) - return std::string(); + return rv; } else { // Decode |auth_data_| into the input buffer. int len = auth_data_.length(); @@ -71,25 +67,30 @@ std::string HttpAuthHandlerNTLM::GenerateCredentials( len--; auth_data_.erase(len); - if (!base::Base64Decode(auth_data_, &decoded_auth_data)) - return std::string(); // Improper base64 encoding + if (!base::Base64Decode(auth_data_, &decoded_auth_data)) { + LOG(ERROR) << "Unexpected problem Base64 decoding."; + return ERR_UNEXPECTED; + } in_buf_len = decoded_auth_data.length(); in_buf = decoded_auth_data.data(); } int rv = GetNextToken(in_buf, in_buf_len, &out_buf, &out_buf_len); if (rv != OK) - return std::string(); + return rv; // Base64 encode data in output buffer and prepend "NTLM ". std::string encode_input(static_cast<char*>(out_buf), out_buf_len); std::string encode_output; - bool ok = base::Base64Encode(encode_input, &encode_output); + bool base64_rv = base::Base64Encode(encode_input, &encode_output); // OK, we are done with |out_buf| free(out_buf); - if (!ok) - return std::string(); - return std::string("NTLM ") + encode_output; + if (!base64_rv) { + LOG(ERROR) << "Unexpected problem Base64 encoding."; + return ERR_UNEXPECTED; + } + *auth_token = std::string("NTLM ") + encode_output; + return OK; #endif } |