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 <string> |
| 8 |
| 9 #include "base/base64.h" |
7 #include "base/string_util.h" | 10 #include "base/string_util.h" |
8 #include "net/http/http_auth.h" | 11 #include "net/http/http_auth.h" |
9 #include "net/base/base64.h" | |
10 | 12 |
11 namespace net { | 13 namespace net { |
12 | 14 |
13 // Note that if a realm was not specified, we will default it to ""; | 15 // Note that if a realm was not specified, we will default it to ""; |
14 // so specifying 'Basic realm=""' is equivalent to 'Basic'. | 16 // so specifying 'Basic realm=""' is equivalent to 'Basic'. |
15 // | 17 // |
16 // This is more generous than RFC 2617, which is pretty clear in the | 18 // This is more generous than RFC 2617, which is pretty clear in the |
17 // production of challenge that realm is required. | 19 // production of challenge that realm is required. |
18 // | 20 // |
19 // We allow it to be compatibility with certain embedded webservers that don't | 21 // We allow it to be compatibility with certain embedded webservers that don't |
(...skipping 19 matching lines...) Expand all Loading... |
39 return challenge_tok.valid(); | 41 return challenge_tok.valid(); |
40 } | 42 } |
41 | 43 |
42 std::string HttpAuthHandlerBasic::GenerateCredentials( | 44 std::string HttpAuthHandlerBasic::GenerateCredentials( |
43 const std::wstring& username, | 45 const std::wstring& username, |
44 const std::wstring& password, | 46 const std::wstring& password, |
45 const HttpRequestInfo*, | 47 const HttpRequestInfo*, |
46 const ProxyInfo*) { | 48 const ProxyInfo*) { |
47 // TODO(eroman): is this the right encoding of username/password? | 49 // TODO(eroman): is this the right encoding of username/password? |
48 std::string base64_username_password; | 50 std::string base64_username_password; |
49 if (!Base64Encode(WideToUTF8(username) + ":" + WideToUTF8(password), | 51 if (!base::Base64Encode(WideToUTF8(username) + ":" + WideToUTF8(password), |
50 &base64_username_password)) | 52 &base64_username_password)) |
51 return std::string(); // FAIL | 53 return std::string(); // FAIL |
52 return std::string("Basic ") + base64_username_password; | 54 return std::string("Basic ") + base64_username_password; |
53 } | 55 } |
54 | 56 |
55 } // namespace net | 57 } // namespace net |
OLD | NEW |