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 #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/log/net_log.h" | 13 #include "net/log/net_log.h" |
14 | 14 |
15 namespace net { | 15 namespace net { |
16 | 16 |
17 class HttpAuthChallengeTokenizer; | 17 class HttpAuthChallengeTokenizer; |
18 struct HttpRequestInfo; | 18 struct HttpRequestInfo; |
| 19 class HttpResponseInfo; |
19 | 20 |
20 // HttpAuthHandler is the interface for the authentication schemes | 21 // HttpAuthHandler is the interface for the authentication schemes |
21 // (basic, digest, NTLM, Negotiate). | 22 // (basic, digest, NTLM, Negotiate). |
22 // HttpAuthHandler objects are typically created by an HttpAuthHandlerFactory. | 23 // HttpAuthHandler objects are typically created by an HttpAuthHandlerFactory. |
23 class NET_EXPORT_PRIVATE HttpAuthHandler { | 24 class NET_EXPORT_PRIVATE HttpAuthHandler { |
24 public: | 25 public: |
25 HttpAuthHandler(); | 26 HttpAuthHandler(); |
26 virtual ~HttpAuthHandler(); | 27 virtual ~HttpAuthHandler(); |
27 | 28 |
28 // Initializes the handler using a challenge issued by a server. | 29 // Initializes the handler using a challenge issued by a server. |
29 // |challenge| must be non-NULL and have already tokenized the | 30 // |challenge| must be non-NULL and have already tokenized the |
30 // authentication scheme, but none of the tokens occurring after the | 31 // authentication scheme, but none of the tokens occurring after the |
31 // authentication scheme. |target| and |origin| are both stored | 32 // authentication scheme. |target| and |origin| are both stored |
32 // for later use, and are not part of the initial challenge. | 33 // for later use, and are not part of the initial challenge. |
33 bool InitFromChallenge(HttpAuthChallengeTokenizer* challenge, | 34 bool InitFromChallenge(HttpAuthChallengeTokenizer* challenge, |
34 HttpAuth::Target target, | 35 HttpAuth::Target target, |
| 36 const HttpResponseInfo& response_info, |
35 const GURL& origin, | 37 const GURL& origin, |
36 const BoundNetLog& net_log); | 38 const BoundNetLog& net_log); |
37 | 39 |
38 // Determines how the previous authorization attempt was received. | 40 // Determines how the previous authorization attempt was received. |
39 // | 41 // |
40 // This is called when the server/proxy responds with a 401/407 after an | 42 // This is called when the server/proxy responds with a 401/407 after an |
41 // earlier authorization attempt. Although this normally means that the | 43 // earlier authorization attempt. Although this normally means that the |
42 // previous attempt was rejected, in multi-round schemes such as | 44 // previous attempt was rejected, in multi-round schemes such as |
43 // NTLM+Negotiate it may indicate that another round of challenge+response | 45 // NTLM+Negotiate it may indicate that another round of challenge+response |
44 // is required. For Digest authentication it may also mean that the previous | 46 // is required. For Digest authentication it may also mean that the previous |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 ENCRYPTS_IDENTITY = 1 << 0, | 145 ENCRYPTS_IDENTITY = 1 << 0, |
144 IS_CONNECTION_BASED = 1 << 1, | 146 IS_CONNECTION_BASED = 1 << 1, |
145 }; | 147 }; |
146 | 148 |
147 // Initializes the handler using a challenge issued by a server. | 149 // Initializes the handler using a challenge issued by a server. |
148 // |challenge| must be non-NULL and have already tokenized the | 150 // |challenge| must be non-NULL and have already tokenized the |
149 // authentication scheme, but none of the tokens occurring after the | 151 // authentication scheme, but none of the tokens occurring after the |
150 // authentication scheme. | 152 // authentication scheme. |
151 // Implementations are expected to initialize the following members: | 153 // Implementations are expected to initialize the following members: |
152 // scheme_, realm_, score_, properties_ | 154 // scheme_, realm_, score_, properties_ |
153 virtual bool Init(HttpAuthChallengeTokenizer* challenge) = 0; | 155 virtual bool Init(HttpAuthChallengeTokenizer* challenge, |
| 156 const HttpResponseInfo& response_info) = 0; |
154 | 157 |
155 // |GenerateAuthTokenImpl()} is the auth-scheme specific implementation | 158 // |GenerateAuthTokenImpl()} is the auth-scheme specific implementation |
156 // of generating the next auth token. Callers should use |GenerateAuthToken()| | 159 // of generating the next auth token. Callers should use |GenerateAuthToken()| |
157 // which will in turn call |GenerateAuthTokenImpl()| | 160 // which will in turn call |GenerateAuthTokenImpl()| |
158 virtual int GenerateAuthTokenImpl(const AuthCredentials* credentials, | 161 virtual int GenerateAuthTokenImpl(const AuthCredentials* credentials, |
159 const HttpRequestInfo* request, | 162 const HttpRequestInfo* request, |
160 const CompletionCallback& callback, | 163 const CompletionCallback& callback, |
161 std::string* auth_token) = 0; | 164 std::string* auth_token) = 0; |
162 | 165 |
163 // The auth-scheme as an enumerated value. | 166 // The auth-scheme as an enumerated value. |
(...skipping 24 matching lines...) Expand all Loading... |
188 private: | 191 private: |
189 void OnGenerateAuthTokenComplete(int rv); | 192 void OnGenerateAuthTokenComplete(int rv); |
190 void FinishGenerateAuthToken(); | 193 void FinishGenerateAuthToken(); |
191 | 194 |
192 CompletionCallback callback_; | 195 CompletionCallback callback_; |
193 }; | 196 }; |
194 | 197 |
195 } // namespace net | 198 } // namespace net |
196 | 199 |
197 #endif // NET_HTTP_HTTP_AUTH_HANDLER_H_ | 200 #endif // NET_HTTP_HTTP_AUTH_HANDLER_H_ |
OLD | NEW |