OLD | NEW |
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_basic.h" | 5 #include "net/http/http_auth_handler_basic.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/base64.h" | 9 #include "base/base64.h" |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
11 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
12 #include "net/base/net_errors.h" | 12 #include "net/base/net_errors.h" |
13 #include "net/http/http_auth.h" | 13 #include "net/http/http_auth.h" |
14 | 14 |
15 namespace net { | 15 namespace net { |
16 | 16 |
17 // Note that if a realm was not specified, we will default it to ""; | 17 // Note that if a realm was not specified, we will default it to ""; |
18 // so specifying 'Basic realm=""' is equivalent to 'Basic'. | 18 // so specifying 'Basic realm=""' is equivalent to 'Basic'. |
19 // | 19 // |
20 // This is more generous than RFC 2617, which is pretty clear in the | 20 // This is more generous than RFC 2617, which is pretty clear in the |
21 // production of challenge that realm is required. | 21 // production of challenge that realm is required. |
22 // | 22 // |
23 // We allow it to be compatibility with certain embedded webservers that don't | 23 // We allow it to be compatibility with certain embedded webservers that don't |
24 // include a realm (see http://crbug.com/20984.) | 24 // include a realm (see http://crbug.com/20984.) |
25 bool HttpAuthHandlerBasic::Init(HttpAuth::ChallengeTokenizer* challenge) { | 25 bool HttpAuthHandlerBasic::Init(HttpAuth::ChallengeTokenizer* challenge) { |
26 auth_scheme_ = AUTH_SCHEME_BASIC; | 26 auth_scheme_ = HttpAuth::AUTH_SCHEME_BASIC; |
27 scheme_ = "basic"; | |
28 score_ = 1; | 27 score_ = 1; |
29 properties_ = 0; | 28 properties_ = 0; |
30 return ParseChallenge(challenge); | 29 return ParseChallenge(challenge); |
31 } | 30 } |
32 | 31 |
33 bool HttpAuthHandlerBasic::ParseChallenge( | 32 bool HttpAuthHandlerBasic::ParseChallenge( |
34 HttpAuth::ChallengeTokenizer* challenge) { | 33 HttpAuth::ChallengeTokenizer* challenge) { |
35 // Verify the challenge's auth-scheme. | 34 // Verify the challenge's auth-scheme. |
36 if (!LowerCaseEqualsASCII(challenge->scheme(), "basic")) | 35 if (!LowerCaseEqualsASCII(challenge->scheme(), "basic")) |
37 return false; | 36 return false; |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 // TODO(cbentzel): Move towards model of parsing in the factory | 92 // TODO(cbentzel): Move towards model of parsing in the factory |
94 // method and only constructing when valid. | 93 // method and only constructing when valid. |
95 scoped_ptr<HttpAuthHandler> tmp_handler(new HttpAuthHandlerBasic()); | 94 scoped_ptr<HttpAuthHandler> tmp_handler(new HttpAuthHandlerBasic()); |
96 if (!tmp_handler->InitFromChallenge(challenge, target, origin, net_log)) | 95 if (!tmp_handler->InitFromChallenge(challenge, target, origin, net_log)) |
97 return ERR_INVALID_RESPONSE; | 96 return ERR_INVALID_RESPONSE; |
98 handler->swap(tmp_handler); | 97 handler->swap(tmp_handler); |
99 return OK; | 98 return OK; |
100 } | 99 } |
101 | 100 |
102 } // namespace net | 101 } // namespace net |
OLD | NEW |