Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(67)

Side by Side Diff: net/http/http_auth_handler_ntlm.cc

Issue 3239009: Merge 57211 - Fail rather than crash if username+password are unspecified for... (Closed) Base URL: svn://svn.chromium.org/chrome/branches/472/src/
Patch Set: Created 10 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 #include "base/base64.h" 7 #include "base/base64.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
11 #include "net/base/net_errors.h" 11 #include "net/base/net_errors.h"
12 #include "net/base/net_util.h" 12 #include "net/base/net_util.h"
13 13
14 namespace net { 14 namespace net {
15 15
16 int HttpAuthHandlerNTLM::GenerateAuthTokenImpl( 16 int HttpAuthHandlerNTLM::GenerateAuthTokenImpl(
17 const std::wstring* username, 17 const std::wstring* username,
18 const std::wstring* password, 18 const std::wstring* password,
19 const HttpRequestInfo* request, 19 const HttpRequestInfo* request,
20 CompletionCallback* callback, 20 CompletionCallback* callback,
21 std::string* auth_token) { 21 std::string* auth_token) {
22 #if defined(NTLM_SSPI) 22 #if defined(NTLM_SSPI)
23 return auth_sspi_.GenerateAuthToken( 23 return auth_sspi_.GenerateAuthToken(
24 username, 24 username,
25 password, 25 password,
26 CreateSPN(origin_), 26 CreateSPN(origin_),
27 auth_token); 27 auth_token);
28 #else // !defined(NTLM_SSPI) 28 #else // !defined(NTLM_SSPI)
29 // TODO(cbentzel): Shouldn't be hitting this case.
30 if (!username || !password) {
31 LOG(ERROR) << "Username and password are expected to be non-NULL.";
32 return ERR_MISSING_AUTH_CREDENTIALS;
33 }
29 // TODO(wtc): See if we can use char* instead of void* for in_buf and 34 // TODO(wtc): See if we can use char* instead of void* for in_buf and
30 // out_buf. This change will need to propagate to GetNextToken, 35 // out_buf. This change will need to propagate to GetNextToken,
31 // GenerateType1Msg, and GenerateType3Msg, and perhaps further. 36 // GenerateType1Msg, and GenerateType3Msg, and perhaps further.
32 const void* in_buf; 37 const void* in_buf;
33 void* out_buf; 38 void* out_buf;
34 uint32 in_buf_len, out_buf_len; 39 uint32 in_buf_len, out_buf_len;
35 std::string decoded_auth_data; 40 std::string decoded_auth_data;
36 41
37 // |username| may be in the form "DOMAIN\user". Parse it into the two 42 // |username| may be in the form "DOMAIN\user". Parse it into the two
38 // components. 43 // components.
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 // static 116 // static
112 std::wstring HttpAuthHandlerNTLM::CreateSPN(const GURL& origin) { 117 std::wstring HttpAuthHandlerNTLM::CreateSPN(const GURL& origin) {
113 // The service principal name of the destination server. See 118 // The service principal name of the destination server. See
114 // http://msdn.microsoft.com/en-us/library/ms677949%28VS.85%29.aspx 119 // http://msdn.microsoft.com/en-us/library/ms677949%28VS.85%29.aspx
115 std::wstring target(L"HTTP/"); 120 std::wstring target(L"HTTP/");
116 target.append(ASCIIToWide(GetHostAndPort(origin))); 121 target.append(ASCIIToWide(GetHostAndPort(origin)));
117 return target; 122 return target;
118 } 123 }
119 124
120 } // namespace net 125 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698