OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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_basic.h" | 5 #include "net/http/http_auth_handler_basic.h" |
6 | 6 |
7 #include "base/string_util.h" | 7 #include "base/string_util.h" |
8 #include "net/http/http_auth.h" | 8 #include "net/http/http_auth.h" |
9 #include "net/base/base64.h" | 9 #include "net/base/base64.h" |
10 | 10 |
11 namespace net { | 11 namespace net { |
12 | 12 |
13 bool HttpAuthHandlerBasic::Init(std::string::const_iterator challenge_begin, | 13 bool HttpAuthHandlerBasic::Init(std::string::const_iterator challenge_begin, |
14 std::string::const_iterator challenge_end) { | 14 std::string::const_iterator challenge_end) { |
15 scheme_ = "basic"; | 15 scheme_ = "basic"; |
16 score_ = 1; | 16 score_ = 1; |
| 17 properties_ = 0; |
17 | 18 |
18 // Verify the challenge's auth-scheme. | 19 // Verify the challenge's auth-scheme. |
19 HttpAuth::ChallengeTokenizer challenge_tok(challenge_begin, challenge_end); | 20 HttpAuth::ChallengeTokenizer challenge_tok(challenge_begin, challenge_end); |
20 if (!challenge_tok.valid() || | 21 if (!challenge_tok.valid() || |
21 !LowerCaseEqualsASCII(challenge_tok.scheme(), "basic")) | 22 !LowerCaseEqualsASCII(challenge_tok.scheme(), "basic")) |
22 return false; | 23 return false; |
23 | 24 |
24 // Extract the realm. | 25 // Extract the realm. |
25 while (challenge_tok.GetNext()) { | 26 while (challenge_tok.GetNext()) { |
26 if (LowerCaseEqualsASCII(challenge_tok.name(), "realm")) | 27 if (LowerCaseEqualsASCII(challenge_tok.name(), "realm")) |
(...skipping 10 matching lines...) Expand all Loading... |
37 const ProxyInfo*) { | 38 const ProxyInfo*) { |
38 // TODO(eroman): is this the right encoding of username/password? | 39 // TODO(eroman): is this the right encoding of username/password? |
39 std::string base64_username_password; | 40 std::string base64_username_password; |
40 if (!Base64Encode(WideToUTF8(username) + ":" + WideToUTF8(password), | 41 if (!Base64Encode(WideToUTF8(username) + ":" + WideToUTF8(password), |
41 &base64_username_password)) | 42 &base64_username_password)) |
42 return std::string(); // FAIL | 43 return std::string(); // FAIL |
43 return std::string("Basic ") + base64_username_password; | 44 return std::string("Basic ") + base64_username_password; |
44 } | 45 } |
45 | 46 |
46 } // namespace net | 47 } // namespace net |
OLD | NEW |