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_DIGEST_H_ | 5 #ifndef NET_HTTP_HTTP_AUTH_HANDLER_DIGEST_H_ |
6 #define NET_HTTP_HTTP_AUTH_HANDLER_DIGEST_H_ | 6 #define NET_HTTP_HTTP_AUTH_HANDLER_DIGEST_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/gtest_prod_util.h" | 12 #include "base/gtest_prod_util.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "base/string16.h" | |
15 #include "net/base/net_export.h" | 14 #include "net/base/net_export.h" |
16 #include "net/http/http_auth_handler.h" | 15 #include "net/http/http_auth_handler.h" |
17 #include "net/http/http_auth_handler_factory.h" | 16 #include "net/http/http_auth_handler_factory.h" |
18 | 17 |
19 namespace net { | 18 namespace net { |
20 | 19 |
21 // Code for handling http digest authentication. | 20 // Code for handling http digest authentication. |
22 class NET_EXPORT_PRIVATE HttpAuthHandlerDigest : public HttpAuthHandler { | 21 class NET_EXPORT_PRIVATE HttpAuthHandlerDigest : public HttpAuthHandler { |
23 public: | 22 public: |
24 // A NonceGenerator is a simple interface for generating client nonces. | 23 // A NonceGenerator is a simple interface for generating client nonces. |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 private: | 76 private: |
78 scoped_ptr<const NonceGenerator> nonce_generator_; | 77 scoped_ptr<const NonceGenerator> nonce_generator_; |
79 }; | 78 }; |
80 | 79 |
81 virtual HttpAuth::AuthorizationResult HandleAnotherChallenge( | 80 virtual HttpAuth::AuthorizationResult HandleAnotherChallenge( |
82 HttpAuth::ChallengeTokenizer* challenge); | 81 HttpAuth::ChallengeTokenizer* challenge); |
83 | 82 |
84 protected: | 83 protected: |
85 virtual bool Init(HttpAuth::ChallengeTokenizer* challenge); | 84 virtual bool Init(HttpAuth::ChallengeTokenizer* challenge); |
86 | 85 |
87 virtual int GenerateAuthTokenImpl(const string16* username, | 86 virtual int GenerateAuthTokenImpl(const AuthCredentials* credentials, |
88 const string16* password, | |
89 const HttpRequestInfo* request, | 87 const HttpRequestInfo* request, |
90 OldCompletionCallback* callback, | 88 OldCompletionCallback* callback, |
91 std::string* auth_token); | 89 std::string* auth_token); |
92 | 90 |
93 private: | 91 private: |
94 FRIEND_TEST_ALL_PREFIXES(HttpAuthHandlerDigestTest, ParseChallenge); | 92 FRIEND_TEST_ALL_PREFIXES(HttpAuthHandlerDigestTest, ParseChallenge); |
95 FRIEND_TEST_ALL_PREFIXES(HttpAuthHandlerDigestTest, AssembleCredentials); | 93 FRIEND_TEST_ALL_PREFIXES(HttpAuthHandlerDigestTest, AssembleCredentials); |
96 FRIEND_TEST_ALL_PREFIXES(HttpNetworkTransactionTest, DigestPreAuthNonceCount); | 94 FRIEND_TEST_ALL_PREFIXES(HttpNetworkTransactionTest, DigestPreAuthNonceCount); |
97 | 95 |
98 // Possible values for the "algorithm" property. | 96 // Possible values for the "algorithm" property. |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 | 139 |
142 // Extract the method and path of the request, as needed by | 140 // Extract the method and path of the request, as needed by |
143 // the 'A2' production. (path may be a hostname for proxy). | 141 // the 'A2' production. (path may be a hostname for proxy). |
144 void GetRequestMethodAndPath(const HttpRequestInfo* request, | 142 void GetRequestMethodAndPath(const HttpRequestInfo* request, |
145 std::string* method, | 143 std::string* method, |
146 std::string* path) const; | 144 std::string* path) const; |
147 | 145 |
148 // Build up the 'response' production. | 146 // Build up the 'response' production. |
149 std::string AssembleResponseDigest(const std::string& method, | 147 std::string AssembleResponseDigest(const std::string& method, |
150 const std::string& path, | 148 const std::string& path, |
151 const string16& username, | 149 const AuthCredentials& credentials, |
152 const string16& password, | |
153 const std::string& cnonce, | 150 const std::string& cnonce, |
154 const std::string& nc) const; | 151 const std::string& nc) const; |
155 | 152 |
156 // Build up the value for (Authorization/Proxy-Authorization). | 153 // Build up the value for (Authorization/Proxy-Authorization). |
157 std::string AssembleCredentials(const std::string& method, | 154 std::string AssembleCredentials(const std::string& method, |
158 const std::string& path, | 155 const std::string& path, |
159 const string16& username, | 156 const AuthCredentials& credentials, |
160 const string16& password, | |
161 const std::string& cnonce, | 157 const std::string& cnonce, |
162 int nonce_count) const; | 158 int nonce_count) const; |
163 | 159 |
164 // Information parsed from the challenge. | 160 // Information parsed from the challenge. |
165 std::string nonce_; | 161 std::string nonce_; |
166 std::string domain_; | 162 std::string domain_; |
167 std::string opaque_; | 163 std::string opaque_; |
168 bool stale_; | 164 bool stale_; |
169 DigestAlgorithm algorithm_; | 165 DigestAlgorithm algorithm_; |
170 QualityOfProtection qop_; | 166 QualityOfProtection qop_; |
171 | 167 |
172 // The realm as initially encoded over-the-wire. This is used in the | 168 // The realm as initially encoded over-the-wire. This is used in the |
173 // challenge text, rather than |realm_| which has been converted to | 169 // challenge text, rather than |realm_| which has been converted to |
174 // UTF-8. | 170 // UTF-8. |
175 std::string original_realm_; | 171 std::string original_realm_; |
176 | 172 |
177 int nonce_count_; | 173 int nonce_count_; |
178 const NonceGenerator* nonce_generator_; | 174 const NonceGenerator* nonce_generator_; |
179 }; | 175 }; |
180 | 176 |
181 } // namespace net | 177 } // namespace net |
182 | 178 |
183 #endif // NET_HTTP_HTTP_AUTH_HANDLER_DIGEST_H_ | 179 #endif // NET_HTTP_HTTP_AUTH_HANDLER_DIGEST_H_ |
OLD | NEW |