Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(79)

Side by Side Diff: net/http/http_auth_handler_digest.cc

Issue 1391053002: [net/http auth] Make HttpAuthHandler challenge handling asynchronous. Base URL: https://chromium.googlesource.com/chromium/src.git@auth-handler-init-split
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/http/http_auth_handler_digest.h ('k') | net/http/http_auth_handler_digest_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_digest.h" 5 #include "net/http/http_auth_handler_digest.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/md5.h" 10 #include "base/md5.h"
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 return HttpAuth::AUTHORIZATION_RESULT_STALE; 99 return HttpAuth::AUTHORIZATION_RESULT_STALE;
100 } else if (base::LowerCaseEqualsASCII(parameters.name(), "realm")) { 100 } else if (base::LowerCaseEqualsASCII(parameters.name(), "realm")) {
101 original_realm = parameters.value(); 101 original_realm = parameters.value();
102 } 102 }
103 } 103 }
104 return (original_realm_ != original_realm) ? 104 return (original_realm_ != original_realm) ?
105 HttpAuth::AUTHORIZATION_RESULT_DIFFERENT_REALM : 105 HttpAuth::AUTHORIZATION_RESULT_DIFFERENT_REALM :
106 HttpAuth::AUTHORIZATION_RESULT_REJECT; 106 HttpAuth::AUTHORIZATION_RESULT_REJECT;
107 } 107 }
108 108
109 int HttpAuthHandlerDigest::Init(const HttpAuthChallengeTokenizer& challenge) { 109 int HttpAuthHandlerDigest::InitializeFromChallengeInternal(
110 const HttpAuthChallengeTokenizer& challenge,
111 const HttpResponseInfo&,
112 const CompletionCallback&) {
110 return ParseChallenge(challenge) ? OK : ERR_INVALID_RESPONSE; 113 return ParseChallenge(challenge) ? OK : ERR_INVALID_RESPONSE;
111 } 114 }
112 115
116 int HttpAuthHandlerDigest::InitializeFromCacheEntryInternal(
117 HttpAuthCache::Entry* cache_entry) {
118 HttpAuthChallengeTokenizer challenge(cache_entry->auth_challenge().begin(),
119 cache_entry->auth_challenge().end());
120 return ParseChallenge(challenge) ? OK : ERR_INVALID_RESPONSE;
121 }
122
113 int HttpAuthHandlerDigest::GenerateAuthTokenImpl( 123 int HttpAuthHandlerDigest::GenerateAuthTokenImpl(
114 const AuthCredentials* credentials, 124 const AuthCredentials* credentials,
115 const HttpRequestInfo& request, 125 const HttpRequestInfo& request,
116 const CompletionCallback& callback, 126 const CompletionCallback& callback,
117 std::string* auth_token) { 127 std::string* auth_token) {
118 // Generate a random client nonce. 128 // Generate a random client nonce.
119 std::string cnonce = nonce_generator_->GenerateNonce(); 129 std::string cnonce = nonce_generator_->GenerateNonce();
120 130
121 // Extract the request method and path -- the meaning of 'path' is overloaded 131 // Extract the request method and path -- the meaning of 'path' is overloaded
122 // in certain cases, to be a hostname. 132 // in certain cases, to be a hostname.
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 const std::string& scheme) { 375 const std::string& scheme) {
366 DCHECK(HttpAuth::IsValidNormalizedScheme(scheme)); 376 DCHECK(HttpAuth::IsValidNormalizedScheme(scheme));
367 if (scheme != kDigestSchemeName) 377 if (scheme != kDigestSchemeName)
368 return scoped_ptr<HttpAuthHandler>(); 378 return scoped_ptr<HttpAuthHandler>();
369 return make_scoped_ptr(new HttpAuthHandlerDigest(1, nonce_generator_.get())); 379 return make_scoped_ptr(new HttpAuthHandlerDigest(1, nonce_generator_.get()));
370 } 380 }
371 381
372 scoped_ptr<HttpAuthHandler> 382 scoped_ptr<HttpAuthHandler>
373 HttpAuthHandlerDigest::Factory::CreateAndInitPreemptiveAuthHandler( 383 HttpAuthHandlerDigest::Factory::CreateAndInitPreemptiveAuthHandler(
374 HttpAuthCache::Entry* cache_entry, 384 HttpAuthCache::Entry* cache_entry,
375 const HttpAuthChallengeTokenizer& tokenizer,
376 HttpAuth::Target target, 385 HttpAuth::Target target,
377 const BoundNetLog& net_log) { 386 const BoundNetLog& net_log) {
378 if (cache_entry->scheme() != kDigestSchemeName) 387 if (cache_entry->scheme() != kDigestSchemeName)
379 return scoped_ptr<HttpAuthHandler>(); 388 return scoped_ptr<HttpAuthHandler>();
380 scoped_ptr<HttpAuthHandler> handler(new HttpAuthHandlerDigest( 389 scoped_ptr<HttpAuthHandler> handler(new HttpAuthHandlerDigest(
381 cache_entry->IncrementNonceCount(), nonce_generator_.get())); 390 cache_entry->IncrementNonceCount(), nonce_generator_.get()));
382 int rv = handler->HandleInitialChallenge(tokenizer, target, 391 int rv = handler->InitializeFromCacheEntry(cache_entry, target, net_log);
383 cache_entry->origin(), net_log);
384 if (rv == OK) 392 if (rv == OK)
385 return handler; 393 return handler;
386 return scoped_ptr<HttpAuthHandler>(); 394 return scoped_ptr<HttpAuthHandler>();
387 } 395 }
388 396
389 } // namespace net 397 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_auth_handler_digest.h ('k') | net/http/http_auth_handler_digest_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698