| 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 ~Factory() override; | 63 ~Factory() override; |
| 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 int CreateAuthHandler(const HttpAuthChallengeTokenizer& challenge, | 68 // HttpAuthHandlerFactory |
| 69 HttpAuth::Target target, | 69 scoped_ptr<HttpAuthHandler> CreateAuthHandlerForScheme( |
| 70 const GURL& origin, | 70 const std::string& scheme) override; |
| 71 CreateReason reason, | 71 scoped_ptr<HttpAuthHandler> CreateAndInitPreemptiveAuthHandler( |
| 72 int digest_nonce_count, | 72 HttpAuthCache::Entry* cache_entry, |
| 73 const BoundNetLog& net_log, | 73 const HttpAuthChallengeTokenizer& tokenizer, |
| 74 scoped_ptr<HttpAuthHandler>* handler) override; | 74 HttpAuth::Target target, |
| 75 const BoundNetLog& net_log) 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 HttpAuth::AuthorizationResult HandleAnotherChallenge( | 81 HttpAuth::AuthorizationResult HandleAnotherChallenge( |
| 81 const HttpAuthChallengeTokenizer& challenge) override; | 82 const HttpAuthChallengeTokenizer& challenge) override; |
| 83 ~HttpAuthHandlerDigest() override; |
| 82 | 84 |
| 83 protected: | 85 protected: |
| 84 int Init(const HttpAuthChallengeTokenizer& challenge) override; | 86 int Init(const HttpAuthChallengeTokenizer& challenge) override; |
| 85 | 87 |
| 86 int GenerateAuthTokenImpl(const AuthCredentials* credentials, | 88 int GenerateAuthTokenImpl(const AuthCredentials* credentials, |
| 87 const HttpRequestInfo& request, | 89 const HttpRequestInfo& request, |
| 88 const CompletionCallback& callback, | 90 const CompletionCallback& callback, |
| 89 std::string* auth_token) override; | 91 std::string* auth_token) override; |
| 90 | 92 |
| 91 private: | 93 private: |
| (...skipping 21 matching lines...) Expand all Loading... |
| 113 QOP_UNSPECIFIED, | 115 QOP_UNSPECIFIED, |
| 114 QOP_AUTH, | 116 QOP_AUTH, |
| 115 }; | 117 }; |
| 116 | 118 |
| 117 // |nonce_count| indicates how many times the server-specified nonce has | 119 // |nonce_count| indicates how many times the server-specified nonce has |
| 118 // been used so far. | 120 // been used so far. |
| 119 // |nonce_generator| is used to create a client nonce, and is not owned by | 121 // |nonce_generator| is used to create a client nonce, and is not owned by |
| 120 // the handler. The lifetime of the |nonce_generator| must exceed that of this | 122 // the handler. The lifetime of the |nonce_generator| must exceed that of this |
| 121 // handler. | 123 // handler. |
| 122 HttpAuthHandlerDigest(int nonce_count, const NonceGenerator* nonce_generator); | 124 HttpAuthHandlerDigest(int nonce_count, const NonceGenerator* nonce_generator); |
| 123 ~HttpAuthHandlerDigest() override; | |
| 124 | 125 |
| 125 // Parse the challenge, saving the results into this instance. | 126 // Parse the challenge, saving the results into this instance. |
| 126 // Returns true on success. | 127 // Returns true on success. |
| 127 bool ParseChallenge(const HttpAuthChallengeTokenizer& challenge); | 128 bool ParseChallenge(const HttpAuthChallengeTokenizer& challenge); |
| 128 | 129 |
| 129 // Parse an individual property. Returns true on success. | 130 // Parse an individual property. Returns true on success. |
| 130 bool ParseChallengeProperty(const std::string& name, | 131 bool ParseChallengeProperty(const std::string& name, |
| 131 const std::string& value); | 132 const std::string& value); |
| 132 | 133 |
| 133 // Generates a random string, to be used for client-nonce. | 134 // Generates a random string, to be used for client-nonce. |
| (...skipping 36 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 |