9
9
import static org .apache .http .client .config .CookieSpecs .IGNORE_COOKIES ;
10
10
11
11
import com .amazonaws .ClientConfiguration ;
12
- import com .amazonaws .Protocol ;
13
12
import com .google .common .annotations .VisibleForTesting ;
14
13
import com .google .common .base .Strings ;
15
14
import com .microsoft .azure .storage .OperationContext ;
36
35
import net .snowflake .client .jdbc .SnowflakeDriver ;
37
36
import net .snowflake .client .jdbc .SnowflakeSQLException ;
38
37
import net .snowflake .client .jdbc .SnowflakeUtil ;
38
+ import net .snowflake .client .jdbc .cloud .storage .S3HttpUtil ;
39
39
import net .snowflake .client .log .ArgSupplier ;
40
40
import net .snowflake .client .log .SFLogger ;
41
41
import net .snowflake .client .log .SFLoggerFactory ;
@@ -143,19 +143,11 @@ public static void closeExpiredAndIdleConnections() {
143
143
*
144
144
* @param key key to HttpClient map containing OCSP and proxy info
145
145
* @param clientConfig the configuration needed by S3 to set the proxy
146
+ * @deprecated use S3HttpUtil.setProxyForS3(HttpClientSettingsKey, ClientConfiguration) instead
146
147
*/
148
+ @ Deprecated
147
149
public static void setProxyForS3 (HttpClientSettingsKey key , ClientConfiguration clientConfig ) {
148
- if (key != null && key .usesProxy ()) {
149
- clientConfig .setProxyProtocol (key .getProxyProtocol ());
150
- clientConfig .setProxyHost (key .getProxyHost ());
151
- clientConfig .setProxyPort (key .getProxyPort ());
152
- clientConfig .setNonProxyHosts (key .getNonProxyHosts ());
153
- if (!Strings .isNullOrEmpty (key .getProxyUser ())
154
- && !Strings .isNullOrEmpty (key .getProxyPassword ())) {
155
- clientConfig .setProxyUsername (key .getProxyUser ());
156
- clientConfig .setProxyPassword (key .getProxyPassword ());
157
- }
158
- }
150
+ S3HttpUtil .setProxyForS3 (key , clientConfig );
159
151
}
160
152
161
153
/**
@@ -165,51 +157,12 @@ public static void setProxyForS3(HttpClientSettingsKey key, ClientConfiguration
165
157
* @param proxyProperties proxy properties
166
158
* @param clientConfig the configuration needed by S3 to set the proxy
167
159
* @throws SnowflakeSQLException
160
+ * @deprecated use S3HttpUtil.setSessionlessProxyForS3(Properties, ClientConfiguration) instead
168
161
*/
162
+ @ Deprecated
169
163
public static void setSessionlessProxyForS3 (
170
164
Properties proxyProperties , ClientConfiguration clientConfig ) throws SnowflakeSQLException {
171
- // do nothing yet
172
- if (proxyProperties != null
173
- && proxyProperties .size () > 0
174
- && proxyProperties .getProperty (SFSessionProperty .USE_PROXY .getPropertyKey ()) != null ) {
175
- Boolean useProxy =
176
- Boolean .valueOf (
177
- proxyProperties .getProperty (SFSessionProperty .USE_PROXY .getPropertyKey ()));
178
- if (useProxy ) {
179
- // set up other proxy related values.
180
- String proxyHost =
181
- proxyProperties .getProperty (SFSessionProperty .PROXY_HOST .getPropertyKey ());
182
- int proxyPort ;
183
- try {
184
- proxyPort =
185
- Integer .parseInt (
186
- proxyProperties .getProperty (SFSessionProperty .PROXY_PORT .getPropertyKey ()));
187
- } catch (NumberFormatException | NullPointerException e ) {
188
- throw new SnowflakeSQLException (
189
- ErrorCode .INVALID_PROXY_PROPERTIES , "Could not parse port number" );
190
- }
191
- String proxyUser =
192
- proxyProperties .getProperty (SFSessionProperty .PROXY_USER .getPropertyKey ());
193
- String proxyPassword =
194
- proxyProperties .getProperty (SFSessionProperty .PROXY_PASSWORD .getPropertyKey ());
195
- String nonProxyHosts =
196
- proxyProperties .getProperty (SFSessionProperty .NON_PROXY_HOSTS .getPropertyKey ());
197
- String proxyProtocol =
198
- proxyProperties .getProperty (SFSessionProperty .PROXY_PROTOCOL .getPropertyKey ());
199
- Protocol protocolEnum =
200
- (!Strings .isNullOrEmpty (proxyProtocol ) && proxyProtocol .equalsIgnoreCase ("https" ))
201
- ? Protocol .HTTPS
202
- : Protocol .HTTP ;
203
- clientConfig .setProxyHost (proxyHost );
204
- clientConfig .setProxyPort (proxyPort );
205
- clientConfig .setNonProxyHosts (nonProxyHosts );
206
- clientConfig .setProxyProtocol (protocolEnum );
207
- if (!Strings .isNullOrEmpty (proxyUser ) && !Strings .isNullOrEmpty (proxyPassword )) {
208
- clientConfig .setProxyUsername (proxyUser );
209
- clientConfig .setProxyPassword (proxyPassword );
210
- }
211
- }
212
- }
165
+ S3HttpUtil .setSessionlessProxyForS3 (proxyProperties , clientConfig );
213
166
}
214
167
215
168
/**
@@ -324,7 +277,7 @@ public static CloseableHttpClient buildHttpClient(
324
277
HttpHost proxy =
325
278
(key != null && key .usesProxy ())
326
279
? new HttpHost (
327
- key .getProxyHost (), key .getProxyPort (), key .getProxyProtocol ().toString ())
280
+ key .getProxyHost (), key .getProxyPort (), key .getProxyHttpProtocol ().getScheme ())
328
281
: null ;
329
282
// If defaultrequestconfig is not initialized or its proxy settings do not match current proxy
330
283
// settings, re-build it (current or old proxy settings could be null, so null check is
@@ -408,7 +361,7 @@ public static CloseableHttpClient buildHttpClient(
408
361
new SnowflakeMutableProxyRoutePlanner (
409
362
key .getProxyHost (),
410
363
key .getProxyPort (),
411
- key .getProxyProtocol (),
364
+ key .getProxyHttpProtocol (),
412
365
key .getNonProxyHosts ()));
413
366
httpClientBuilder = httpClientBuilder .setProxy (proxy ).setRoutePlanner (sdkProxyRoutePlanner );
414
367
if (!Strings .isNullOrEmpty (key .getProxyUser ())
0 commit comments