OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 bool HttpAuthHandlerBasic::Init(HttpAuthChallengeTokenizer* challenge) { | 55 bool HttpAuthHandlerBasic::Init(HttpAuthChallengeTokenizer* challenge) { |
56 auth_scheme_ = HttpAuth::AUTH_SCHEME_BASIC; | 56 auth_scheme_ = HttpAuth::AUTH_SCHEME_BASIC; |
57 score_ = 1; | 57 score_ = 1; |
58 properties_ = 0; | 58 properties_ = 0; |
59 return ParseChallenge(challenge); | 59 return ParseChallenge(challenge); |
60 } | 60 } |
61 | 61 |
62 bool HttpAuthHandlerBasic::ParseChallenge( | 62 bool HttpAuthHandlerBasic::ParseChallenge( |
63 HttpAuthChallengeTokenizer* challenge) { | 63 HttpAuthChallengeTokenizer* challenge) { |
64 // Verify the challenge's auth-scheme. | 64 // Verify the challenge's auth-scheme. |
65 if (!base::LowerCaseEqualsASCII(challenge->scheme(), "basic")) | 65 if (!base::LowerCaseEqualsASCII(challenge->scheme(), kBasicAuthScheme)) |
66 return false; | 66 return false; |
67 | 67 |
68 std::string realm; | 68 std::string realm; |
69 if (!ParseRealm(*challenge, &realm)) | 69 if (!ParseRealm(*challenge, &realm)) |
70 return false; | 70 return false; |
71 | 71 |
72 realm_ = realm; | 72 realm_ = realm; |
73 return true; | 73 return true; |
74 } | 74 } |
75 | 75 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 // TODO(cbentzel): Move towards model of parsing in the factory | 116 // TODO(cbentzel): Move towards model of parsing in the factory |
117 // method and only constructing when valid. | 117 // method and only constructing when valid. |
118 scoped_ptr<HttpAuthHandler> tmp_handler(new HttpAuthHandlerBasic()); | 118 scoped_ptr<HttpAuthHandler> tmp_handler(new HttpAuthHandlerBasic()); |
119 if (!tmp_handler->InitFromChallenge(challenge, target, origin, net_log)) | 119 if (!tmp_handler->InitFromChallenge(challenge, target, origin, net_log)) |
120 return ERR_INVALID_RESPONSE; | 120 return ERR_INVALID_RESPONSE; |
121 handler->swap(tmp_handler); | 121 handler->swap(tmp_handler); |
122 return OK; | 122 return OK; |
123 } | 123 } |
124 | 124 |
125 } // namespace net | 125 } // namespace net |
OLD | NEW |