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 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 virtual std::string GenerateNonce() const = 0; | 31 virtual std::string GenerateNonce() const = 0; |
32 private: | 32 private: |
33 DISALLOW_COPY_AND_ASSIGN(NonceGenerator); | 33 DISALLOW_COPY_AND_ASSIGN(NonceGenerator); |
34 }; | 34 }; |
35 | 35 |
36 // DynamicNonceGenerator does a random shuffle of 16 | 36 // DynamicNonceGenerator does a random shuffle of 16 |
37 // characters to generate a client nonce. | 37 // characters to generate a client nonce. |
38 class DynamicNonceGenerator : public NonceGenerator { | 38 class DynamicNonceGenerator : public NonceGenerator { |
39 public: | 39 public: |
40 DynamicNonceGenerator(); | 40 DynamicNonceGenerator(); |
41 virtual std::string GenerateNonce() const OVERRIDE; | 41 virtual std::string GenerateNonce() const override; |
42 private: | 42 private: |
43 DISALLOW_COPY_AND_ASSIGN(DynamicNonceGenerator); | 43 DISALLOW_COPY_AND_ASSIGN(DynamicNonceGenerator); |
44 }; | 44 }; |
45 | 45 |
46 // FixedNonceGenerator always uses the same string specified at | 46 // FixedNonceGenerator always uses the same string specified at |
47 // construction time as the client nonce. | 47 // construction time as the client nonce. |
48 class NET_EXPORT_PRIVATE FixedNonceGenerator : public NonceGenerator { | 48 class NET_EXPORT_PRIVATE FixedNonceGenerator : public NonceGenerator { |
49 public: | 49 public: |
50 explicit FixedNonceGenerator(const std::string& nonce); | 50 explicit FixedNonceGenerator(const std::string& nonce); |
51 | 51 |
52 virtual std::string GenerateNonce() const OVERRIDE; | 52 virtual std::string GenerateNonce() const override; |
53 | 53 |
54 private: | 54 private: |
55 const std::string nonce_; | 55 const std::string nonce_; |
56 DISALLOW_COPY_AND_ASSIGN(FixedNonceGenerator); | 56 DISALLOW_COPY_AND_ASSIGN(FixedNonceGenerator); |
57 }; | 57 }; |
58 | 58 |
59 class NET_EXPORT_PRIVATE Factory : public HttpAuthHandlerFactory { | 59 class NET_EXPORT_PRIVATE Factory : public HttpAuthHandlerFactory { |
60 public: | 60 public: |
61 Factory(); | 61 Factory(); |
62 virtual ~Factory(); | 62 virtual ~Factory(); |
63 | 63 |
64 // This factory owns the passed in |nonce_generator|. | 64 // This factory owns the passed in |nonce_generator|. |
65 void set_nonce_generator(const NonceGenerator* nonce_generator); | 65 void set_nonce_generator(const NonceGenerator* nonce_generator); |
66 | 66 |
67 virtual int CreateAuthHandler( | 67 virtual int CreateAuthHandler( |
68 HttpAuthChallengeTokenizer* challenge, | 68 HttpAuthChallengeTokenizer* challenge, |
69 HttpAuth::Target target, | 69 HttpAuth::Target target, |
70 const GURL& origin, | 70 const GURL& origin, |
71 CreateReason reason, | 71 CreateReason reason, |
72 int digest_nonce_count, | 72 int digest_nonce_count, |
73 const BoundNetLog& net_log, | 73 const BoundNetLog& net_log, |
74 scoped_ptr<HttpAuthHandler>* handler) OVERRIDE; | 74 scoped_ptr<HttpAuthHandler>* handler) override; |
75 | 75 |
76 private: | 76 private: |
77 scoped_ptr<const NonceGenerator> nonce_generator_; | 77 scoped_ptr<const NonceGenerator> nonce_generator_; |
78 }; | 78 }; |
79 | 79 |
80 virtual HttpAuth::AuthorizationResult HandleAnotherChallenge( | 80 virtual HttpAuth::AuthorizationResult HandleAnotherChallenge( |
81 HttpAuthChallengeTokenizer* challenge) OVERRIDE; | 81 HttpAuthChallengeTokenizer* challenge) override; |
82 | 82 |
83 protected: | 83 protected: |
84 virtual bool Init(HttpAuthChallengeTokenizer* challenge) OVERRIDE; | 84 virtual bool Init(HttpAuthChallengeTokenizer* challenge) override; |
85 | 85 |
86 virtual int GenerateAuthTokenImpl(const AuthCredentials* credentials, | 86 virtual int GenerateAuthTokenImpl(const AuthCredentials* credentials, |
87 const HttpRequestInfo* request, | 87 const HttpRequestInfo* request, |
88 const CompletionCallback& callback, | 88 const CompletionCallback& callback, |
89 std::string* auth_token) OVERRIDE; | 89 std::string* auth_token) override; |
90 | 90 |
91 private: | 91 private: |
92 FRIEND_TEST_ALL_PREFIXES(HttpAuthHandlerDigestTest, ParseChallenge); | 92 FRIEND_TEST_ALL_PREFIXES(HttpAuthHandlerDigestTest, ParseChallenge); |
93 FRIEND_TEST_ALL_PREFIXES(HttpAuthHandlerDigestTest, AssembleCredentials); | 93 FRIEND_TEST_ALL_PREFIXES(HttpAuthHandlerDigestTest, AssembleCredentials); |
94 FRIEND_TEST_ALL_PREFIXES(HttpNetworkTransactionTest, DigestPreAuthNonceCount); | 94 FRIEND_TEST_ALL_PREFIXES(HttpNetworkTransactionTest, DigestPreAuthNonceCount); |
95 | 95 |
96 // Possible values for the "algorithm" property. | 96 // Possible values for the "algorithm" property. |
97 enum DigestAlgorithm { | 97 enum DigestAlgorithm { |
98 // No algorithm was specified. According to RFC 2617 this means | 98 // No algorithm was specified. According to RFC 2617 this means |
99 // we should default to ALGORITHM_MD5. | 99 // we should default to ALGORITHM_MD5. |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 // UTF-8. | 170 // UTF-8. |
171 std::string original_realm_; | 171 std::string original_realm_; |
172 | 172 |
173 int nonce_count_; | 173 int nonce_count_; |
174 const NonceGenerator* nonce_generator_; | 174 const NonceGenerator* nonce_generator_; |
175 }; | 175 }; |
176 | 176 |
177 } // namespace net | 177 } // namespace net |
178 | 178 |
179 #endif // NET_HTTP_HTTP_AUTH_HANDLER_DIGEST_H_ | 179 #endif // NET_HTTP_HTTP_AUTH_HANDLER_DIGEST_H_ |
OLD | NEW |