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

Side by Side Diff: net/http/http_auth_handler.h

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_gssapi_posix.cc ('k') | net/http/http_auth_handler.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 #ifndef NET_HTTP_HTTP_AUTH_HANDLER_H_ 5 #ifndef NET_HTTP_HTTP_AUTH_HANDLER_H_
6 #define NET_HTTP_HTTP_AUTH_HANDLER_H_ 6 #define NET_HTTP_HTTP_AUTH_HANDLER_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "net/base/completion_callback.h" 10 #include "net/base/completion_callback.h"
11 #include "net/base/net_export.h" 11 #include "net/base/net_export.h"
12 #include "net/http/http_auth.h" 12 #include "net/http/http_auth.h"
13 #include "net/http/http_auth_cache.h"
13 #include "net/log/net_log.h" 14 #include "net/log/net_log.h"
14 15
15 namespace net { 16 namespace net {
16 17
17 class HttpAuthChallengeTokenizer; 18 class HttpAuthChallengeTokenizer;
18 struct HttpRequestInfo; 19 struct HttpRequestInfo;
20 class HttpResponseInfo;
19 21
20 // HttpAuthHandler is the interface for the authentication schemes 22 // HttpAuthHandler is the interface for the authentication schemes
21 // (basic, digest, NTLM, Negotiate). Each authentication scheme is expected to 23 // (basic, digest, NTLM, Negotiate). Each authentication scheme is expected to
22 // subclass HttpAuthHandler. 24 // subclass HttpAuthHandler.
23 // 25 //
24 // The lifecycle of a HttpAuthHandler -- i.e. how to use HttpAuthHandler --: 26 // The lifecycle of a HttpAuthHandler -- i.e. how to use HttpAuthHandler --:
25 // 27 //
26 // 1. Construct via HttpAuthHandlerFactory::CreateAuthHandlerForScheme() or 28 // 1. Construct via HttpAuthHandlerFactory::CreateAuthHandlerForScheme() or
27 // HttpAuthHandlerFactory::CreateAndInitPreemptiveAuthHandler(). 29 // HttpAuthHandlerFactory::CreateAndInitPreemptiveAuthHandler().
28 // 30 //
(...skipping 23 matching lines...) Expand all
52 // handshake. The AuthorizationResult return value indicates whether the 54 // handshake. The AuthorizationResult return value indicates whether the
53 // handler can continue with the current authentication handshake or if it 55 // handler can continue with the current authentication handshake or if it
54 // has encountered an error. A return value of AUTHORIZATION_RESULT_ACCEPT 56 // has encountered an error. A return value of AUTHORIZATION_RESULT_ACCEPT
55 // indicates that the handler can continue. In all other cases, the handler 57 // indicates that the handler can continue. In all other cases, the handler
56 // should be considered no longer usable. 58 // should be considered no longer usable.
57 // 59 //
58 class NET_EXPORT_PRIVATE HttpAuthHandler { 60 class NET_EXPORT_PRIVATE HttpAuthHandler {
59 public: 61 public:
60 virtual ~HttpAuthHandler(); 62 virtual ~HttpAuthHandler();
61 63
64 int InitializeFromCacheEntry(HttpAuthCache::Entry* cache_entry,
65 HttpAuth::Target target,
66 const BoundNetLog& net_log);
67
62 // Initializes the handler and associates it with the specified |target| and 68 // Initializes the handler and associates it with the specified |target| and
63 // |origin|. The |net_log| parameter indicates BoundNetLog to be used for the 69 // |origin|. The |net_log| parameter indicates BoundNetLog to be used for the
64 // lifetime of this handler. |challenge| is required and *must* match the 70 // lifetime of this handler. |challenge| is required and *must* match the
65 // authentication scheme of this handler. 71 // authentication scheme of this handler.
66 // 72 //
67 // Returns a Error value. The HttpAuthHandler can only be used if the return 73 // Returns a Error value. The HttpAuthHandler can only be used if the return
68 // value is OK. 74 // value is OK.
69 // 75 //
70 // Note: This method *must* be the first method to be invoked on the 76 // Note: This method *must* be the first method to be invoked on the
71 // HttpAuthHandler. 77 // HttpAuthHandler.
72 int HandleInitialChallenge(const HttpAuthChallengeTokenizer& challenge, 78 int HandleInitialChallenge(const HttpAuthChallengeTokenizer& challenge,
79 const HttpResponseInfo& response_info,
73 HttpAuth::Target target, 80 HttpAuth::Target target,
74 const GURL& origin, 81 const GURL& origin,
75 const BoundNetLog& net_log); 82 const BoundNetLog& net_log,
83 const CompletionCallback& callback);
76 84
77 // Generates an authentication token, potentially asynchronously. 85 // Generates an authentication token, potentially asynchronously.
78 // 86 //
79 // If NeedsIdentity() is true, then the value of |credentials| indicates how 87 // If NeedsIdentity() is true, then the value of |credentials| indicates how
80 // the authentication identity is established. 88 // the authentication identity is established.
81 // 89 //
82 // 1. If |credentials| is nullptr, then the handler attempts to use ambient 90 // 1. If |credentials| is nullptr, then the handler attempts to use ambient
83 // credentials to establish an identity. Passing in a nullptr for 91 // credentials to establish an identity. Passing in a nullptr for
84 // |credentials| is only valid if AllowsDefaultCredentials() returns true. 92 // |credentials| is only valid if AllowsDefaultCredentials() returns true.
85 // 93 //
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 181
174 protected: 182 protected:
175 // |scheme| sets the return value for auth_scheme(). 183 // |scheme| sets the return value for auth_scheme().
176 HttpAuthHandler(const std::string& scheme); 184 HttpAuthHandler(const std::string& scheme);
177 185
178 // Initializes the handler using a challenge issued by a server. |challenge| 186 // Initializes the handler using a challenge issued by a server. |challenge|
179 // must be non-NULL and have already tokenized the authentication scheme, but 187 // must be non-NULL and have already tokenized the authentication scheme, but
180 // none of the tokens occurring after the authentication scheme. 188 // none of the tokens occurring after the authentication scheme.
181 // Implementations are expected to initialize the following members: scheme_, 189 // Implementations are expected to initialize the following members: scheme_,
182 // realm_ 190 // realm_
183 virtual int Init(const HttpAuthChallengeTokenizer& challenge) = 0; 191 //
192 // TODO(asanka): Update comment.
193 virtual int InitializeFromChallengeInternal(
194 const HttpAuthChallengeTokenizer& challenge,
195 const HttpResponseInfo& response_with_challenge,
196 const CompletionCallback& callback) = 0;
197
198 // TODO(asanka): Update comment
199 virtual int InitializeFromCacheEntryInternal(
200 HttpAuthCache::Entry* cache_entry) = 0;
184 201
185 // |GenerateAuthTokenImpl()} is the auth-scheme specific implementation 202 // |GenerateAuthTokenImpl()} is the auth-scheme specific implementation
186 // of generating the next auth token. Callers should use |GenerateAuthToken()| 203 // of generating the next auth token. Callers should use |GenerateAuthToken()|
187 // which will in turn call |GenerateAuthTokenImpl()| 204 // which will in turn call |GenerateAuthTokenImpl()|
188 virtual int GenerateAuthTokenImpl(const AuthCredentials* credentials, 205 virtual int GenerateAuthTokenImpl(const AuthCredentials* credentials,
189 const HttpRequestInfo& request, 206 const HttpRequestInfo& request,
190 const CompletionCallback& callback, 207 const CompletionCallback& callback,
191 std::string* auth_token) = 0; 208 std::string* auth_token) = 0;
192 209
193 // The auth-scheme as a lowercase ASCII RFC 2616 2.2 token. 210 // The auth-scheme as a lowercase ASCII RFC 2616 2.2 token.
(...skipping 18 matching lines...) Expand all
212 private: 229 private:
213 void OnGenerateAuthTokenComplete(int rv); 230 void OnGenerateAuthTokenComplete(int rv);
214 void FinishGenerateAuthToken(); 231 void FinishGenerateAuthToken();
215 232
216 CompletionCallback callback_; 233 CompletionCallback callback_;
217 }; 234 };
218 235
219 } // namespace net 236 } // namespace net
220 237
221 #endif // NET_HTTP_HTTP_AUTH_HANDLER_H_ 238 #endif // NET_HTTP_HTTP_AUTH_HANDLER_H_
OLDNEW
« no previous file with comments | « net/http/http_auth_gssapi_posix.cc ('k') | net/http/http_auth_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698