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