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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 | 46 |
47 if (!ConvertToUtf8AndNormalize(parameters.value(), kCharsetLatin1, realm)) { | 47 if (!ConvertToUtf8AndNormalize(parameters.value(), kCharsetLatin1, realm)) { |
48 return false; | 48 return false; |
49 } | 49 } |
50 } | 50 } |
51 return parameters.valid(); | 51 return parameters.valid(); |
52 } | 52 } |
53 | 53 |
54 } // namespace | 54 } // namespace |
55 | 55 |
56 bool HttpAuthHandlerBasic::Init(HttpAuthChallengeTokenizer* challenge) { | 56 bool HttpAuthHandlerBasic::Init(HttpAuthChallengeTokenizer* challenge, |
| 57 const HttpResponseInfo& response_info) { |
57 auth_scheme_ = HttpAuth::AUTH_SCHEME_BASIC; | 58 auth_scheme_ = HttpAuth::AUTH_SCHEME_BASIC; |
58 score_ = 1; | 59 score_ = 1; |
59 properties_ = 0; | 60 properties_ = 0; |
60 return ParseChallenge(challenge); | 61 return ParseChallenge(challenge); |
61 } | 62 } |
62 | 63 |
63 bool HttpAuthHandlerBasic::ParseChallenge( | 64 bool HttpAuthHandlerBasic::ParseChallenge( |
64 HttpAuthChallengeTokenizer* challenge) { | 65 HttpAuthChallengeTokenizer* challenge) { |
65 // Verify the challenge's auth-scheme. | 66 // Verify the challenge's auth-scheme. |
66 if (!base::LowerCaseEqualsASCII(challenge->scheme(), kBasicAuthScheme)) | 67 if (!base::LowerCaseEqualsASCII(challenge->scheme(), kBasicAuthScheme)) |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 | 103 |
103 HttpAuthHandlerBasic::Factory::Factory() { | 104 HttpAuthHandlerBasic::Factory::Factory() { |
104 } | 105 } |
105 | 106 |
106 HttpAuthHandlerBasic::Factory::~Factory() { | 107 HttpAuthHandlerBasic::Factory::~Factory() { |
107 } | 108 } |
108 | 109 |
109 int HttpAuthHandlerBasic::Factory::CreateAuthHandler( | 110 int HttpAuthHandlerBasic::Factory::CreateAuthHandler( |
110 HttpAuthChallengeTokenizer* challenge, | 111 HttpAuthChallengeTokenizer* challenge, |
111 HttpAuth::Target target, | 112 HttpAuth::Target target, |
| 113 const HttpResponseInfo& response_info, |
112 const GURL& origin, | 114 const GURL& origin, |
113 CreateReason reason, | 115 CreateReason reason, |
114 int digest_nonce_count, | 116 int digest_nonce_count, |
115 const BoundNetLog& net_log, | 117 const BoundNetLog& net_log, |
116 scoped_ptr<HttpAuthHandler>* handler) { | 118 scoped_ptr<HttpAuthHandler>* handler) { |
117 // TODO(cbentzel): Move towards model of parsing in the factory | 119 // TODO(cbentzel): Move towards model of parsing in the factory |
118 // method and only constructing when valid. | 120 // method and only constructing when valid. |
119 scoped_ptr<HttpAuthHandler> tmp_handler(new HttpAuthHandlerBasic()); | 121 scoped_ptr<HttpAuthHandler> tmp_handler(new HttpAuthHandlerBasic()); |
120 if (!tmp_handler->InitFromChallenge(challenge, target, origin, net_log)) | 122 if (!tmp_handler->InitFromChallenge(challenge, target, response_info, origin, |
| 123 net_log)) |
121 return ERR_INVALID_RESPONSE; | 124 return ERR_INVALID_RESPONSE; |
122 handler->swap(tmp_handler); | 125 handler->swap(tmp_handler); |
123 return OK; | 126 return OK; |
124 } | 127 } |
125 | 128 |
126 } // namespace net | 129 } // namespace net |
OLD | NEW |