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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 | 47 |
48 if (!ConvertToUtf8AndNormalize(parameters.value(), kCharsetLatin1, realm)) { | 48 if (!ConvertToUtf8AndNormalize(parameters.value(), kCharsetLatin1, realm)) { |
49 return false; | 49 return false; |
50 } | 50 } |
51 } | 51 } |
52 return parameters.valid(); | 52 return parameters.valid(); |
53 } | 53 } |
54 | 54 |
55 } // namespace | 55 } // namespace |
56 | 56 |
57 int HttpAuthHandlerBasic::Init(const HttpAuthChallengeTokenizer& challenge) { | 57 int HttpAuthHandlerBasic::InitializeFromChallengeInternal( |
| 58 const HttpAuthChallengeTokenizer& challenge, |
| 59 const HttpResponseInfo&, |
| 60 const CompletionCallback&) { |
58 return ParseChallenge(challenge); | 61 return ParseChallenge(challenge); |
59 } | 62 } |
60 | 63 |
| 64 int HttpAuthHandlerBasic::InitializeFromCacheEntryInternal( |
| 65 HttpAuthCache::Entry* cache_entry) { |
| 66 HttpAuthChallengeTokenizer challenge(cache_entry->auth_challenge().begin(), |
| 67 cache_entry->auth_challenge().end()); |
| 68 return ParseChallenge(challenge); |
| 69 } |
| 70 |
61 HttpAuthHandlerBasic::HttpAuthHandlerBasic() | 71 HttpAuthHandlerBasic::HttpAuthHandlerBasic() |
62 : HttpAuthHandler(kBasicSchemeName) {} | 72 : HttpAuthHandler(kBasicSchemeName) {} |
63 | 73 |
64 int HttpAuthHandlerBasic::ParseChallenge( | 74 int HttpAuthHandlerBasic::ParseChallenge( |
65 const HttpAuthChallengeTokenizer& challenge) { | 75 const HttpAuthChallengeTokenizer& challenge) { |
66 // Verify the challenge's auth-scheme. | 76 // Verify the challenge's auth-scheme. |
67 if (!challenge.SchemeIs(kBasicSchemeName)) | 77 if (!challenge.SchemeIs(kBasicSchemeName)) |
68 return ERR_INVALID_RESPONSE; | 78 return ERR_INVALID_RESPONSE; |
69 | 79 |
70 std::string realm; | 80 std::string realm; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 const std::string& scheme) { | 124 const std::string& scheme) { |
115 DCHECK(HttpAuth::IsValidNormalizedScheme(scheme)); | 125 DCHECK(HttpAuth::IsValidNormalizedScheme(scheme)); |
116 if (scheme == kBasicSchemeName) | 126 if (scheme == kBasicSchemeName) |
117 return make_scoped_ptr(new HttpAuthHandlerBasic()); | 127 return make_scoped_ptr(new HttpAuthHandlerBasic()); |
118 return scoped_ptr<HttpAuthHandler>(); | 128 return scoped_ptr<HttpAuthHandler>(); |
119 } | 129 } |
120 | 130 |
121 scoped_ptr<HttpAuthHandler> | 131 scoped_ptr<HttpAuthHandler> |
122 HttpAuthHandlerBasic::Factory::CreateAndInitPreemptiveAuthHandler( | 132 HttpAuthHandlerBasic::Factory::CreateAndInitPreemptiveAuthHandler( |
123 HttpAuthCache::Entry* cache_entry, | 133 HttpAuthCache::Entry* cache_entry, |
124 const HttpAuthChallengeTokenizer& tokenizer, | |
125 HttpAuth::Target target, | 134 HttpAuth::Target target, |
126 const BoundNetLog& net_log) { | 135 const BoundNetLog& net_log) { |
127 if (cache_entry->scheme() != kBasicSchemeName) | 136 if (cache_entry->scheme() != kBasicSchemeName) |
128 return scoped_ptr<HttpAuthHandler>(); | 137 return scoped_ptr<HttpAuthHandler>(); |
129 scoped_ptr<HttpAuthHandler> handler(new HttpAuthHandlerBasic()); | 138 scoped_ptr<HttpAuthHandler> handler(new HttpAuthHandlerBasic()); |
130 int rv = handler->HandleInitialChallenge(tokenizer, target, | 139 int rv = handler->InitializeFromCacheEntry(cache_entry, target, net_log); |
131 cache_entry->origin(), net_log); | |
132 if (rv == OK) | 140 if (rv == OK) |
133 return handler; | 141 return handler; |
134 return scoped_ptr<HttpAuthHandler>(); | 142 return scoped_ptr<HttpAuthHandler>(); |
135 } | 143 } |
136 | 144 |
137 } // namespace net | 145 } // namespace net |
OLD | NEW |