Chromium Code Reviews| Index: net/http/http_auth_handler_digest.h |
| =================================================================== |
| --- net/http/http_auth_handler_digest.h (revision 66137) |
| +++ net/http/http_auth_handler_digest.h (working copy) |
| @@ -9,6 +9,7 @@ |
| #include <string> |
| #include "base/gtest_prod_util.h" |
| +#include "base/scoped_ptr.h" |
| #include "base/string16.h" |
| #include "net/http/http_auth_handler.h" |
| #include "net/http/http_auth_handler_factory.h" |
| @@ -18,6 +19,28 @@ |
| // Code for handling http digest authentication. |
| class HttpAuthHandlerDigest : public HttpAuthHandler { |
| public: |
| + class NonceGenerator { |
| + public: |
| + virtual ~NonceGenerator(); |
| + virtual std::string GenerateNonce() const = 0; |
| + }; |
| + |
| + class DynamicNonceGenerator : public NonceGenerator { |
| + public: |
| + virtual std::string GenerateNonce() const; |
| + }; |
| + |
| + // For unit tests |
| + class FixedNonceGenerator : public NonceGenerator { |
| + public: |
| + explicit FixedNonceGenerator(const std::string& nonce); |
| + |
| + virtual std::string GenerateNonce() const; |
| + |
| + private: |
| + std::string nonce_; |
|
eroman
2010/11/16 00:02:35
nit: const
|
| + }; |
| + |
| class Factory : public HttpAuthHandlerFactory { |
| public: |
| Factory(); |
| @@ -30,6 +53,11 @@ |
| int digest_nonce_count, |
| const BoundNetLog& net_log, |
| scoped_ptr<HttpAuthHandler>* handler); |
| + |
| + void set_nonce_generator(const NonceGenerator* nonce_generator); |
|
eroman
2010/11/16 00:02:35
should mention ownership.
(even though it is a co
|
| + |
| + private: |
| + scoped_ptr<const NonceGenerator> nonce_generator_; |
| }; |
| HttpAuth::AuthorizationResult HandleAnotherChallenge( |
| @@ -70,7 +98,7 @@ |
| QOP_AUTH, |
| }; |
| - explicit HttpAuthHandlerDigest(int nonce_count); |
| + HttpAuthHandlerDigest(int nonce_count, const NonceGenerator* nonce_generator); |
|
eroman
2010/11/16 00:02:35
Please mention ownerhsip model.
|
| ~HttpAuthHandlerDigest(); |
| // Parse the challenge, saving the results into this instance. |
| @@ -110,11 +138,6 @@ |
| const std::string& cnonce, |
| int nonce_count) const; |
| - // Forces cnonce to be the same each time. This is used for unit tests. |
| - static void SetFixedCnonce(bool fixed_cnonce) { |
| - fixed_cnonce_ = fixed_cnonce; |
| - } |
| - |
| // Information parsed from the challenge. |
| std::string nonce_; |
| std::string domain_; |
| @@ -124,9 +147,7 @@ |
| QualityOfProtection qop_; |
| int nonce_count_; |
| - |
| - // Forces the cnonce to be the same each time, for unit tests. |
| - static bool fixed_cnonce_; |
| + const NonceGenerator* nonce_generator_; |
| }; |
| } // namespace net |