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. |
11 // We use NTLM_SSPI for Windows, and NTLM_PORTABLE for other platforms. | 11 // We use NTLM_SSPI for Windows, and NTLM_PORTABLE for other platforms. |
12 #if defined(OS_WIN) | 12 #if defined(OS_WIN) |
13 #define NTLM_SSPI | 13 #define NTLM_SSPI |
14 #else | 14 #else |
15 #define NTLM_PORTABLE | 15 #define NTLM_PORTABLE |
16 #endif | 16 #endif |
17 | 17 |
18 #if defined(NTLM_SSPI) | 18 #if defined(NTLM_SSPI) |
19 #define SECURITY_WIN32 1 | 19 #define SECURITY_WIN32 1 |
20 #include <windows.h> | 20 #include <windows.h> |
21 #include <security.h> | 21 #include <security.h> |
22 #include "net/http/http_auth_sspi_win.h" | 22 #include "net/http/http_auth_sspi_win.h" |
23 #endif | 23 #endif |
24 | 24 |
25 #include <string> | 25 #include <string> |
26 | 26 |
27 #include "base/basictypes.h" | 27 #include "base/basictypes.h" |
| 28 #include "base/message_loop/message_loop.h" |
| 29 #include "base/process/process_handle.h" |
28 #include "base/strings/string16.h" | 30 #include "base/strings/string16.h" |
29 #include "net/http/http_auth_handler.h" | 31 #include "net/http/http_auth_handler.h" |
30 #include "net/http/http_auth_handler_factory.h" | 32 #include "net/http/http_auth_handler_factory.h" |
31 | 33 |
32 namespace net { | 34 namespace net { |
33 | 35 |
34 class URLSecurityManager; | 36 class URLSecurityManager; |
35 | 37 |
36 // Code for handling HTTP NTLM authentication. | 38 // Code for handling HTTP NTLM authentication. |
37 class NET_EXPORT_PRIVATE HttpAuthHandlerNTLM : public HttpAuthHandler { | 39 class NET_EXPORT_PRIVATE HttpAuthHandlerNTLM : public HttpAuthHandler, |
| 40 base::MessageLoopForIO::Watcher { |
38 public: | 41 public: |
39 class Factory : public HttpAuthHandlerFactory { | 42 class Factory : public HttpAuthHandlerFactory { |
40 public: | 43 public: |
41 Factory(); | 44 Factory(); |
42 virtual ~Factory(); | 45 virtual ~Factory(); |
43 | 46 |
44 virtual int CreateAuthHandler( | 47 virtual int CreateAuthHandler( |
45 HttpAuthChallengeTokenizer* challenge, | 48 HttpAuthChallengeTokenizer* challenge, |
46 HttpAuth::Target target, | 49 HttpAuth::Target target, |
47 const GURL& origin, | 50 const GURL& origin, |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 SetHostNameProc(old_host_name_proc_); | 93 SetHostNameProc(old_host_name_proc_); |
91 } | 94 } |
92 | 95 |
93 private: | 96 private: |
94 GenerateRandomProc old_random_proc_; | 97 GenerateRandomProc old_random_proc_; |
95 HostNameProc old_host_name_proc_; | 98 HostNameProc old_host_name_proc_; |
96 }; | 99 }; |
97 #endif | 100 #endif |
98 | 101 |
99 #if defined(NTLM_PORTABLE) | 102 #if defined(NTLM_PORTABLE) |
100 HttpAuthHandlerNTLM(); | 103 HttpAuthHandlerNTLM(URLSecurityManager* url_security_manager); |
101 #endif | 104 #endif |
102 #if defined(NTLM_SSPI) | 105 #if defined(NTLM_SSPI) |
103 HttpAuthHandlerNTLM(SSPILibrary* sspi_library, ULONG max_token_length, | 106 HttpAuthHandlerNTLM(SSPILibrary* sspi_library, ULONG max_token_length, |
104 URLSecurityManager* url_security_manager); | 107 URLSecurityManager* url_security_manager); |
105 #endif | 108 #endif |
106 | 109 |
107 virtual bool NeedsIdentity() OVERRIDE; | 110 virtual bool NeedsIdentity() OVERRIDE; |
108 | 111 |
109 virtual bool AllowsDefaultCredentials() OVERRIDE; | 112 virtual bool AllowsDefaultCredentials() OVERRIDE; |
110 | 113 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 uint32* out_token_len); | 148 uint32* out_token_len); |
146 | 149 |
147 // Create an NTLM SPN to identify the |origin| server. | 150 // Create an NTLM SPN to identify the |origin| server. |
148 static std::string CreateSPN(const GURL& origin); | 151 static std::string CreateSPN(const GURL& origin); |
149 | 152 |
150 #if defined(NTLM_SSPI) | 153 #if defined(NTLM_SSPI) |
151 HttpAuthSSPI auth_sspi_; | 154 HttpAuthSSPI auth_sspi_; |
152 #endif | 155 #endif |
153 | 156 |
154 #if defined(NTLM_PORTABLE) | 157 #if defined(NTLM_PORTABLE) |
| 158 const char *helpername_; |
| 159 int ntlm_write_pipe_; |
| 160 int ntlm_read_pipe_; |
| 161 base::ProcessHandle ntlm_auth_handle_; |
| 162 bool start_ntlm_helper_(); |
| 163 bool try_winbind_; |
| 164 CompletionCallback token_callback_; |
| 165 std::string *callback_auth_token_; |
| 166 base::MessageLoopForIO::FileDescriptorWatcher ntlm_read_watcher_; |
| 167 virtual void OnFileCanReadWithoutBlocking(int fd) OVERRIDE; |
| 168 virtual void OnFileCanWriteWithoutBlocking(int fd) OVERRIDE; |
155 static GenerateRandomProc generate_random_proc_; | 169 static GenerateRandomProc generate_random_proc_; |
156 static HostNameProc get_host_name_proc_; | 170 static HostNameProc get_host_name_proc_; |
157 #endif | 171 #endif |
158 | 172 |
159 base::string16 domain_; | 173 base::string16 domain_; |
160 AuthCredentials credentials_; | 174 AuthCredentials credentials_; |
161 | 175 |
162 // The base64-encoded string following "NTLM" in the "WWW-Authenticate" or | 176 // The base64-encoded string following "NTLM" in the "WWW-Authenticate" or |
163 // "Proxy-Authenticate" response header. | 177 // "Proxy-Authenticate" response header. |
164 std::string auth_data_; | 178 std::string auth_data_; |
165 | 179 |
166 #if defined(NTLM_SSPI) | |
167 URLSecurityManager* url_security_manager_; | 180 URLSecurityManager* url_security_manager_; |
168 #endif | |
169 }; | 181 }; |
170 | 182 |
171 } // namespace net | 183 } // namespace net |
172 | 184 |
173 #endif // NET_HTTP_HTTP_AUTH_HANDLER_NTLM_H_ | 185 #endif // NET_HTTP_HTTP_AUTH_HANDLER_NTLM_H_ |
OLD | NEW |