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(HttpAuthChallengeTokenizer* challenge, | 44 int CreateAuthHandler(const HttpAuthChallengeTokenizer& challenge, |
45 HttpAuth::Target target, | 45 HttpAuth::Target target, |
46 const GURL& origin, | 46 const GURL& origin, |
47 CreateReason reason, | 47 CreateReason reason, |
48 int digest_nonce_count, | 48 int digest_nonce_count, |
49 const BoundNetLog& net_log, | 49 const BoundNetLog& net_log, |
50 scoped_ptr<HttpAuthHandler>* handler) override; | 50 scoped_ptr<HttpAuthHandler>* handler) override; |
51 #if defined(NTLM_SSPI) | 51 #if defined(NTLM_SSPI) |
52 // 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 |
53 // 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 |
54 // 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 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 #if defined(NTLM_SSPI) | 100 #if defined(NTLM_SSPI) |
101 HttpAuthHandlerNTLM(SSPILibrary* sspi_library, ULONG max_token_length, | 101 HttpAuthHandlerNTLM(SSPILibrary* sspi_library, ULONG max_token_length, |
102 URLSecurityManager* url_security_manager); | 102 URLSecurityManager* url_security_manager); |
103 #endif | 103 #endif |
104 | 104 |
105 bool NeedsIdentity() override; | 105 bool NeedsIdentity() override; |
106 | 106 |
107 bool AllowsDefaultCredentials() override; | 107 bool AllowsDefaultCredentials() override; |
108 | 108 |
109 HttpAuth::AuthorizationResult HandleAnotherChallenge( | 109 HttpAuth::AuthorizationResult HandleAnotherChallenge( |
110 HttpAuthChallengeTokenizer* challenge) override; | 110 const HttpAuthChallengeTokenizer& challenge) override; |
111 | 111 |
112 protected: | 112 protected: |
113 // This function acquires a credentials handle in the SSPI implementation. | 113 // This function acquires a credentials handle in the SSPI implementation. |
114 // It does nothing in the portable implementation. | 114 // It does nothing in the portable implementation. |
115 int InitializeBeforeFirstChallenge(); | 115 int InitializeBeforeFirstChallenge(); |
116 | 116 |
117 bool Init(HttpAuthChallengeTokenizer* tok) override; | 117 int Init(const HttpAuthChallengeTokenizer& tok) override; |
118 | 118 |
119 int GenerateAuthTokenImpl(const AuthCredentials* credentials, | 119 int GenerateAuthTokenImpl(const AuthCredentials* credentials, |
120 const HttpRequestInfo* request, | 120 const HttpRequestInfo& request, |
121 const CompletionCallback& callback, | 121 const CompletionCallback& callback, |
122 std::string* auth_token) override; | 122 std::string* auth_token) override; |
123 | 123 |
124 private: | 124 private: |
125 ~HttpAuthHandlerNTLM() override; | 125 ~HttpAuthHandlerNTLM() override; |
126 | 126 |
127 #if defined(NTLM_PORTABLE) | 127 #if defined(NTLM_PORTABLE) |
128 // For unit tests to override the GenerateRandom and GetHostName functions. | 128 // For unit tests to override the GenerateRandom and GetHostName functions. |
129 // Returns the old function. | 129 // Returns the old function. |
130 static GenerateRandomProc SetGenerateRandomProc(GenerateRandomProc proc); | 130 static GenerateRandomProc SetGenerateRandomProc(GenerateRandomProc proc); |
131 static HostNameProc SetHostNameProc(HostNameProc proc); | 131 static HostNameProc SetHostNameProc(HostNameProc proc); |
132 #endif | 132 #endif |
133 | 133 |
134 // Parse the challenge, saving the results into this instance. | 134 // Parse the challenge, saving the results into this instance. |
135 HttpAuth::AuthorizationResult ParseChallenge( | 135 HttpAuth::AuthorizationResult ParseChallenge( |
136 HttpAuthChallengeTokenizer* tok, bool initial_challenge); | 136 const HttpAuthChallengeTokenizer& tok, |
| 137 bool initial_challenge); |
137 | 138 |
138 // Given an input token received from the server, generate the next output | 139 // Given an input token received from the server, generate the next output |
139 // token to be sent to the server. | 140 // token to be sent to the server. |
140 int GetNextToken(const void* in_token, | 141 int GetNextToken(const void* in_token, |
141 uint32 in_token_len, | 142 uint32 in_token_len, |
142 void** out_token, | 143 void** out_token, |
143 uint32* out_token_len); | 144 uint32* out_token_len); |
144 | 145 |
145 // Create an NTLM SPN to identify the |origin| server. | 146 // Create an NTLM SPN to identify the |origin| server. |
146 static std::string CreateSPN(const GURL& origin); | 147 static std::string CreateSPN(const GURL& origin); |
(...skipping 15 matching lines...) Expand all Loading... |
162 std::string auth_data_; | 163 std::string auth_data_; |
163 | 164 |
164 #if defined(NTLM_SSPI) | 165 #if defined(NTLM_SSPI) |
165 URLSecurityManager* url_security_manager_; | 166 URLSecurityManager* url_security_manager_; |
166 #endif | 167 #endif |
167 }; | 168 }; |
168 | 169 |
169 } // namespace net | 170 } // namespace net |
170 | 171 |
171 #endif // NET_HTTP_HTTP_AUTH_HANDLER_NTLM_H_ | 172 #endif // NET_HTTP_HTTP_AUTH_HANDLER_NTLM_H_ |
OLD | NEW |