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" | 14 #include "base/string16.h" |
15 #include "net/base/net_api.h" | 15 #include "net/base/net_export.h" |
16 #include "net/http/http_auth_handler.h" | 16 #include "net/http/http_auth_handler.h" |
17 #include "net/http/http_auth_handler_factory.h" | 17 #include "net/http/http_auth_handler_factory.h" |
18 | 18 |
19 namespace net { | 19 namespace net { |
20 | 20 |
21 // Code for handling http digest authentication. | 21 // Code for handling http digest authentication. |
22 class NET_TEST HttpAuthHandlerDigest : public HttpAuthHandler { | 22 class NET_EXPORT_PRIVATE HttpAuthHandlerDigest : public HttpAuthHandler { |
23 public: | 23 public: |
24 // A NonceGenerator is a simple interface for generating client nonces. | 24 // A NonceGenerator is a simple interface for generating client nonces. |
25 // Unit tests can override the default client nonce behavior with fixed | 25 // Unit tests can override the default client nonce behavior with fixed |
26 // nonce generation to get reproducible results. | 26 // nonce generation to get reproducible results. |
27 class NET_TEST NonceGenerator { | 27 class NET_EXPORT_PRIVATE NonceGenerator { |
28 public: | 28 public: |
29 NonceGenerator(); | 29 NonceGenerator(); |
30 virtual ~NonceGenerator(); | 30 virtual ~NonceGenerator(); |
31 | 31 |
32 // Generates a client nonce. | 32 // Generates a client nonce. |
33 virtual std::string GenerateNonce() const = 0; | 33 virtual std::string GenerateNonce() const = 0; |
34 private: | 34 private: |
35 DISALLOW_COPY_AND_ASSIGN(NonceGenerator); | 35 DISALLOW_COPY_AND_ASSIGN(NonceGenerator); |
36 }; | 36 }; |
37 | 37 |
38 // DynamicNonceGenerator does a random shuffle of 16 | 38 // DynamicNonceGenerator does a random shuffle of 16 |
39 // characters to generate a client nonce. | 39 // characters to generate a client nonce. |
40 class DynamicNonceGenerator : public NonceGenerator { | 40 class DynamicNonceGenerator : public NonceGenerator { |
41 public: | 41 public: |
42 DynamicNonceGenerator(); | 42 DynamicNonceGenerator(); |
43 virtual std::string GenerateNonce() const; | 43 virtual std::string GenerateNonce() const; |
44 private: | 44 private: |
45 DISALLOW_COPY_AND_ASSIGN(DynamicNonceGenerator); | 45 DISALLOW_COPY_AND_ASSIGN(DynamicNonceGenerator); |
46 }; | 46 }; |
47 | 47 |
48 // FixedNonceGenerator always uses the same string specified at | 48 // FixedNonceGenerator always uses the same string specified at |
49 // construction time as the client nonce. | 49 // construction time as the client nonce. |
50 class NET_TEST FixedNonceGenerator : public NonceGenerator { | 50 class NET_EXPORT_PRIVATE FixedNonceGenerator : public NonceGenerator { |
51 public: | 51 public: |
52 explicit FixedNonceGenerator(const std::string& nonce); | 52 explicit FixedNonceGenerator(const std::string& nonce); |
53 | 53 |
54 virtual std::string GenerateNonce() const; | 54 virtual std::string GenerateNonce() const; |
55 | 55 |
56 private: | 56 private: |
57 const std::string nonce_; | 57 const std::string nonce_; |
58 DISALLOW_COPY_AND_ASSIGN(FixedNonceGenerator); | 58 DISALLOW_COPY_AND_ASSIGN(FixedNonceGenerator); |
59 }; | 59 }; |
60 | 60 |
61 class NET_TEST Factory : public HttpAuthHandlerFactory { | 61 class NET_EXPORT_PRIVATE Factory : public HttpAuthHandlerFactory { |
62 public: | 62 public: |
63 Factory(); | 63 Factory(); |
64 virtual ~Factory(); | 64 virtual ~Factory(); |
65 | 65 |
66 // This factory owns the passed in |nonce_generator|. | 66 // This factory owns the passed in |nonce_generator|. |
67 void set_nonce_generator(const NonceGenerator* nonce_generator); | 67 void set_nonce_generator(const NonceGenerator* nonce_generator); |
68 | 68 |
69 virtual int CreateAuthHandler(HttpAuth::ChallengeTokenizer* challenge, | 69 virtual int CreateAuthHandler(HttpAuth::ChallengeTokenizer* challenge, |
70 HttpAuth::Target target, | 70 HttpAuth::Target target, |
71 const GURL& origin, | 71 const GURL& origin, |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 DigestAlgorithm algorithm_; | 169 DigestAlgorithm algorithm_; |
170 QualityOfProtection qop_; | 170 QualityOfProtection qop_; |
171 | 171 |
172 int nonce_count_; | 172 int nonce_count_; |
173 const NonceGenerator* nonce_generator_; | 173 const NonceGenerator* nonce_generator_; |
174 }; | 174 }; |
175 | 175 |
176 } // namespace net | 176 } // namespace net |
177 | 177 |
178 #endif // NET_HTTP_HTTP_AUTH_HANDLER_DIGEST_H_ | 178 #endif // NET_HTTP_HTTP_AUTH_HANDLER_DIGEST_H_ |
OLD | NEW |