| 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_NTLM_H_ | 5 #ifndef NET_HTTP_HTTP_AUTH_HANDLER_NTLM_H_ |
| 6 #define NET_HTTP_HTTP_AUTH_HANDLER_NTLM_H_ | 6 #define NET_HTTP_HTTP_AUTH_HANDLER_NTLM_H_ |
| 7 | 7 |
| 8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
| 9 | 9 |
| 10 // This contains the portable and the SSPI implementations for NTLM. | 10 // This contains the portable and the SSPI implementations for NTLM. |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 class URLSecurityManager; | 34 class URLSecurityManager; |
| 35 | 35 |
| 36 // Code for handling HTTP NTLM authentication. | 36 // Code for handling HTTP NTLM authentication. |
| 37 class NET_EXPORT_PRIVATE HttpAuthHandlerNTLM : public HttpAuthHandler { | 37 class NET_EXPORT_PRIVATE HttpAuthHandlerNTLM : public HttpAuthHandler { |
| 38 public: | 38 public: |
| 39 class Factory : public HttpAuthHandlerFactory { | 39 class Factory : public HttpAuthHandlerFactory { |
| 40 public: | 40 public: |
| 41 Factory(); | 41 Factory(); |
| 42 ~Factory() override; | 42 ~Factory() override; |
| 43 | 43 |
| 44 int CreateAuthHandler(const HttpAuthChallengeTokenizer& challenge, | 44 // HttpAuthHandlerFactory |
| 45 HttpAuth::Target target, | 45 scoped_ptr<HttpAuthHandler> CreateAuthHandlerForScheme( |
| 46 const GURL& origin, | 46 const std::string& scheme) override; |
| 47 CreateReason reason, | 47 scoped_ptr<HttpAuthHandler> CreateAndInitPreemptiveAuthHandler( |
| 48 int digest_nonce_count, | 48 HttpAuthCache::Entry* cache_entry, |
| 49 const BoundNetLog& net_log, | 49 const HttpAuthChallengeTokenizer& tokenizer, |
| 50 scoped_ptr<HttpAuthHandler>* handler) override; | 50 HttpAuth::Target target, |
| 51 const BoundNetLog& net_log) override; |
| 51 #if defined(NTLM_SSPI) | 52 #if defined(NTLM_SSPI) |
| 52 // Set the SSPILibrary to use. Typically the only callers which need to use | 53 // Set the SSPILibrary to use. Typically the only callers which need to use |
| 53 // this are unit tests which pass in a mocked-out version of the SSPI | 54 // this are unit tests which pass in a mocked-out version of the SSPI |
| 54 // library. After the call |sspi_library| will be owned by this Factory and | 55 // library. After the call |sspi_library| will be owned by this Factory and |
| 55 // will be destroyed when the Factory is destroyed. | 56 // will be destroyed when the Factory is destroyed. |
| 56 void set_sspi_library(SSPILibrary* sspi_library) { | 57 void set_sspi_library(SSPILibrary* sspi_library) { |
| 57 sspi_library_.reset(sspi_library); | 58 sspi_library_.reset(sspi_library); |
| 58 } | 59 } |
| 59 #endif // defined(NTLM_SSPI) | 60 #endif // defined(NTLM_SSPI) |
| 60 private: | 61 private: |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 }; | 95 }; |
| 95 #endif | 96 #endif |
| 96 | 97 |
| 97 #if defined(NTLM_PORTABLE) | 98 #if defined(NTLM_PORTABLE) |
| 98 HttpAuthHandlerNTLM(); | 99 HttpAuthHandlerNTLM(); |
| 99 #endif | 100 #endif |
| 100 #if defined(NTLM_SSPI) | 101 #if defined(NTLM_SSPI) |
| 101 HttpAuthHandlerNTLM(SSPILibrary* sspi_library, ULONG max_token_length, | 102 HttpAuthHandlerNTLM(SSPILibrary* sspi_library, ULONG max_token_length, |
| 102 URLSecurityManager* url_security_manager); | 103 URLSecurityManager* url_security_manager); |
| 103 #endif | 104 #endif |
| 105 ~HttpAuthHandlerNTLM() override; |
| 104 | 106 |
| 107 // HttpAuthHandler |
| 105 bool NeedsIdentity() override; | 108 bool NeedsIdentity() override; |
| 106 | |
| 107 bool AllowsDefaultCredentials() override; | 109 bool AllowsDefaultCredentials() override; |
| 108 | |
| 109 HttpAuth::AuthorizationResult HandleAnotherChallenge( | 110 HttpAuth::AuthorizationResult HandleAnotherChallenge( |
| 110 const HttpAuthChallengeTokenizer& challenge) override; | 111 const HttpAuthChallengeTokenizer& challenge) override; |
| 111 | 112 |
| 112 protected: | 113 protected: |
| 113 // This function acquires a credentials handle in the SSPI implementation. | 114 // This function acquires a credentials handle in the SSPI implementation. |
| 114 // It does nothing in the portable implementation. | 115 // It does nothing in the portable implementation. |
| 115 int InitializeBeforeFirstChallenge(); | 116 int InitializeBeforeFirstChallenge(); |
| 116 | 117 |
| 118 // HttpAuthHandler |
| 117 int Init(const HttpAuthChallengeTokenizer& tok) override; | 119 int Init(const HttpAuthChallengeTokenizer& tok) override; |
| 118 | |
| 119 int GenerateAuthTokenImpl(const AuthCredentials* credentials, | 120 int GenerateAuthTokenImpl(const AuthCredentials* credentials, |
| 120 const HttpRequestInfo& request, | 121 const HttpRequestInfo& request, |
| 121 const CompletionCallback& callback, | 122 const CompletionCallback& callback, |
| 122 std::string* auth_token) override; | 123 std::string* auth_token) override; |
| 123 | 124 |
| 124 private: | 125 private: |
| 125 ~HttpAuthHandlerNTLM() override; | |
| 126 | |
| 127 #if defined(NTLM_PORTABLE) | 126 #if defined(NTLM_PORTABLE) |
| 128 // For unit tests to override the GenerateRandom and GetHostName functions. | 127 // For unit tests to override the GenerateRandom and GetHostName functions. |
| 129 // Returns the old function. | 128 // Returns the old function. |
| 130 static GenerateRandomProc SetGenerateRandomProc(GenerateRandomProc proc); | 129 static GenerateRandomProc SetGenerateRandomProc(GenerateRandomProc proc); |
| 131 static HostNameProc SetHostNameProc(HostNameProc proc); | 130 static HostNameProc SetHostNameProc(HostNameProc proc); |
| 132 #endif | 131 #endif |
| 133 | 132 |
| 134 // Parse the challenge, saving the results into this instance. | 133 // Parse the challenge, saving the results into this instance. |
| 135 HttpAuth::AuthorizationResult ParseChallenge( | 134 HttpAuth::AuthorizationResult ParseChallenge( |
| 136 const HttpAuthChallengeTokenizer& tok, | 135 const HttpAuthChallengeTokenizer& tok, |
| (...skipping 26 matching lines...) Expand all Loading... |
| 163 std::string auth_data_; | 162 std::string auth_data_; |
| 164 | 163 |
| 165 #if defined(NTLM_SSPI) | 164 #if defined(NTLM_SSPI) |
| 166 URLSecurityManager* url_security_manager_; | 165 URLSecurityManager* url_security_manager_; |
| 167 #endif | 166 #endif |
| 168 }; | 167 }; |
| 169 | 168 |
| 170 } // namespace net | 169 } // namespace net |
| 171 | 170 |
| 172 #endif // NET_HTTP_HTTP_AUTH_HANDLER_NTLM_H_ | 171 #endif // NET_HTTP_HTTP_AUTH_HANDLER_NTLM_H_ |
| OLD | NEW |