| 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 <stddef.h> | 
|  | 9 #include <stdint.h> | 
|  | 10 | 
| 8 #include "build/build_config.h" | 11 #include "build/build_config.h" | 
| 9 | 12 | 
| 10 // This contains the portable and the SSPI implementations for NTLM. | 13 // This contains the portable and the SSPI implementations for NTLM. | 
| 11 // We use NTLM_SSPI for Windows, and NTLM_PORTABLE for other platforms. | 14 // We use NTLM_SSPI for Windows, and NTLM_PORTABLE for other platforms. | 
| 12 #if defined(OS_WIN) | 15 #if defined(OS_WIN) | 
| 13 #define NTLM_SSPI | 16 #define NTLM_SSPI | 
| 14 #else | 17 #else | 
| 15 #define NTLM_PORTABLE | 18 #define NTLM_PORTABLE | 
| 16 #endif | 19 #endif | 
| 17 | 20 | 
| 18 #if defined(NTLM_SSPI) | 21 #if defined(NTLM_SSPI) | 
| 19 #define SECURITY_WIN32 1 | 22 #define SECURITY_WIN32 1 | 
| 20 #include <windows.h> | 23 #include <windows.h> | 
| 21 #include <security.h> | 24 #include <security.h> | 
| 22 #include "net/http/http_auth_sspi_win.h" | 25 #include "net/http/http_auth_sspi_win.h" | 
| 23 #endif | 26 #endif | 
| 24 | 27 | 
| 25 #include <string> | 28 #include <string> | 
| 26 | 29 | 
| 27 #include "base/basictypes.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 HttpAuthPreferences; | 36 class HttpAuthPreferences; | 
| 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 { | 
| (...skipping 22 matching lines...) Expand all  Loading... | 
| 60    private: | 62    private: | 
| 61 #if defined(NTLM_SSPI) | 63 #if defined(NTLM_SSPI) | 
| 62     ULONG max_token_length_; | 64     ULONG max_token_length_; | 
| 63     bool is_unsupported_; | 65     bool is_unsupported_; | 
| 64     scoped_ptr<SSPILibrary> sspi_library_; | 66     scoped_ptr<SSPILibrary> sspi_library_; | 
| 65 #endif  // defined(NTLM_SSPI) | 67 #endif  // defined(NTLM_SSPI) | 
| 66   }; | 68   }; | 
| 67 | 69 | 
| 68 #if defined(NTLM_PORTABLE) | 70 #if defined(NTLM_PORTABLE) | 
| 69   // A function that generates n random bytes in the output buffer. | 71   // A function that generates n random bytes in the output buffer. | 
| 70   typedef void (*GenerateRandomProc)(uint8* output, size_t n); | 72   typedef void (*GenerateRandomProc)(uint8_t* output, size_t n); | 
| 71 | 73 | 
| 72   // A function that returns the local host name. Returns an empty string if | 74   // A function that returns the local host name. Returns an empty string if | 
| 73   // the local host name is not available. | 75   // the local host name is not available. | 
| 74   typedef std::string (*HostNameProc)(); | 76   typedef std::string (*HostNameProc)(); | 
| 75 | 77 | 
| 76   // For unit tests to override and restore the GenerateRandom and | 78   // For unit tests to override and restore the GenerateRandom and | 
| 77   // GetHostName functions. | 79   // GetHostName functions. | 
| 78   class ScopedProcSetter { | 80   class ScopedProcSetter { | 
| 79    public: | 81    public: | 
| 80     ScopedProcSetter(GenerateRandomProc random_proc, | 82     ScopedProcSetter(GenerateRandomProc random_proc, | 
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 132   static HostNameProc SetHostNameProc(HostNameProc proc); | 134   static HostNameProc SetHostNameProc(HostNameProc proc); | 
| 133 #endif | 135 #endif | 
| 134 | 136 | 
| 135   // Parse the challenge, saving the results into this instance. | 137   // Parse the challenge, saving the results into this instance. | 
| 136   HttpAuth::AuthorizationResult ParseChallenge( | 138   HttpAuth::AuthorizationResult ParseChallenge( | 
| 137       HttpAuthChallengeTokenizer* tok, bool initial_challenge); | 139       HttpAuthChallengeTokenizer* tok, bool initial_challenge); | 
| 138 | 140 | 
| 139   // Given an input token received from the server, generate the next output | 141   // Given an input token received from the server, generate the next output | 
| 140   // token to be sent to the server. | 142   // token to be sent to the server. | 
| 141   int GetNextToken(const void* in_token, | 143   int GetNextToken(const void* in_token, | 
| 142                    uint32 in_token_len, | 144                    uint32_t in_token_len, | 
| 143                    void** out_token, | 145                    void** out_token, | 
| 144                    uint32* out_token_len); | 146                    uint32_t* out_token_len); | 
| 145 | 147 | 
| 146   // Create an NTLM SPN to identify the |origin| server. | 148   // Create an NTLM SPN to identify the |origin| server. | 
| 147   static std::string CreateSPN(const GURL& origin); | 149   static std::string CreateSPN(const GURL& origin); | 
| 148 | 150 | 
| 149 #if defined(NTLM_SSPI) | 151 #if defined(NTLM_SSPI) | 
| 150   HttpAuthSSPI auth_sspi_; | 152   HttpAuthSSPI auth_sspi_; | 
| 151 #endif | 153 #endif | 
| 152 | 154 | 
| 153 #if defined(NTLM_PORTABLE) | 155 #if defined(NTLM_PORTABLE) | 
| 154   static GenerateRandomProc generate_random_proc_; | 156   static GenerateRandomProc generate_random_proc_; | 
| 155   static HostNameProc get_host_name_proc_; | 157   static HostNameProc get_host_name_proc_; | 
| 156 #endif | 158 #endif | 
| 157 | 159 | 
| 158   base::string16 domain_; | 160   base::string16 domain_; | 
| 159   AuthCredentials credentials_; | 161   AuthCredentials credentials_; | 
| 160 | 162 | 
| 161   // The base64-encoded string following "NTLM" in the "WWW-Authenticate" or | 163   // The base64-encoded string following "NTLM" in the "WWW-Authenticate" or | 
| 162   // "Proxy-Authenticate" response header. | 164   // "Proxy-Authenticate" response header. | 
| 163   std::string auth_data_; | 165   std::string auth_data_; | 
| 164 | 166 | 
| 165 #if defined(NTLM_SSPI) | 167 #if defined(NTLM_SSPI) | 
| 166   const HttpAuthPreferences* http_auth_preferences_; | 168   const HttpAuthPreferences* http_auth_preferences_; | 
| 167 #endif | 169 #endif | 
| 168 }; | 170 }; | 
| 169 | 171 | 
| 170 }  // namespace net | 172 }  // namespace net | 
| 171 | 173 | 
| 172 #endif  // NET_HTTP_HTTP_AUTH_HANDLER_NTLM_H_ | 174 #endif  // NET_HTTP_HTTP_AUTH_HANDLER_NTLM_H_ | 
| OLD | NEW | 
|---|