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