diff options
author | cbentzel@chromium.org <cbentzel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-22 16:41:01 +0000 |
---|---|---|
committer | cbentzel@chromium.org <cbentzel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-22 16:41:01 +0000 |
commit | 5b9eb6cd8f4428c4647e1546aa2461d0062e0301 (patch) | |
tree | d2ecf90ec66cfb7d1b6d3503f46973e9e4c381fe /net/http/http_auth_sspi_win.cc | |
parent | 74d1423427b9665b5506e8fdc285597358ed3cf6 (diff) | |
download | chromium_src-5b9eb6cd8f4428c4647e1546aa2461d0062e0301.zip chromium_src-5b9eb6cd8f4428c4647e1546aa2461d0062e0301.tar.gz chromium_src-5b9eb6cd8f4428c4647e1546aa2461d0062e0301.tar.bz2 |
Validate that an SSPI scheme is supported before generating a handler.
When SSPI is used (for Windows builds), the NTLM and Negotiate handler
factories determine the maximum token length the first time it is used.
The SSPI call to determinine the maximum length also returns an error code
if the scheme is unsupported. The factories remember if the scheme is
unsupported and will not attempt to create any handlers. If the token length
is found, it is remembered. If a different error occurs, don't create a
handler this round, but try again in the future.
BUG=None
TEST=Manually used an incorrect auth scheme and validated that it worked. Working on a mock SSPI Library I can use for unit testing.
Review URL: http://codereview.chromium.org/600129
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@39600 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/http/http_auth_sspi_win.cc')
-rw-r--r-- | net/http/http_auth_sspi_win.cc | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/net/http/http_auth_sspi_win.cc b/net/http/http_auth_sspi_win.cc index d8a22c2..39d87af 100644 --- a/net/http/http_auth_sspi_win.cc +++ b/net/http/http_auth_sspi_win.cc @@ -98,10 +98,11 @@ int AcquireDefaultCredentials(const SEC_WCHAR* package, CredHandle* cred) { } // anonymous namespace HttpAuthSSPI::HttpAuthSSPI(const std::string& scheme, - SEC_WCHAR* security_package) + SEC_WCHAR* security_package, + ULONG max_token_length) : scheme_(scheme), security_package_(security_package), - max_token_length_(0) { + max_token_length_(max_token_length) { SecInvalidateHandle(&cred_); SecInvalidateHandle(&ctxt_); } @@ -196,11 +197,7 @@ int HttpAuthSSPI::GenerateAuthToken(const std::wstring* username, int HttpAuthSSPI::OnFirstRound(const std::wstring* username, const std::wstring* password) { DCHECK((username == NULL) == (password == NULL)); - - int rv = DetermineMaxTokenLength(security_package_, &max_token_length_); - if (rv != OK) - return rv; - + int rv = OK; if (username) { std::wstring domain; std::wstring user; @@ -335,7 +332,7 @@ int DetermineMaxTokenLength(const std::wstring& package, else return ERR_UNEXPECTED; } - *max_token_length = pkg_info->cbMaxToken; + int token_length = pkg_info->cbMaxToken; status = FreeContextBuffer(pkg_info); if (status != SEC_E_OK) { // The documentation at @@ -347,8 +344,8 @@ int DetermineMaxTokenLength(const std::wstring& package, << status; return ERR_UNEXPECTED; } + *max_token_length = token_length; return OK; } - } // namespace net |