From 1624da4771ddcbf388426c3416baae9d7b8dd29d Mon Sep 17 00:00:00 2001 From: Sergiu Panaite <72495158+sfc-gh-spanaite@users.noreply.github.com> Date: Wed, 6 Mar 2024 18:19:09 +0100 Subject: [PATCH] SNOW-902727: Use proxy user and password from env vars (#1513) --- .../snowflake/client/core/SFBaseSession.java | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/main/java/net/snowflake/client/core/SFBaseSession.java b/src/main/java/net/snowflake/client/core/SFBaseSession.java index 594edde28..364a45ad9 100644 --- a/src/main/java/net/snowflake/client/core/SFBaseSession.java +++ b/src/main/java/net/snowflake/client/core/SFBaseSession.java @@ -392,21 +392,30 @@ public HttpClientSettingsKey getHttpClientKey() throws SnowflakeSQLException { boolean httpUseProxy = Boolean.parseBoolean(systemGetProperty("http.useProxy")); String httpProxyHost = systemGetProperty("http.proxyHost"); String httpProxyPort = systemGetProperty("http.proxyPort"); + String httpProxyUser = systemGetProperty("http.proxyUser"); + String httpProxyPassword = systemGetProperty("http.proxyPassword"); String httpsProxyHost = systemGetProperty("https.proxyHost"); String httpsProxyPort = systemGetProperty("https.proxyPort"); + String httpsProxyUser = systemGetProperty("https.proxyUser"); + String httpsProxyPassword = systemGetProperty("https.proxyPassword"); String httpProxyProtocol = systemGetProperty("http.proxyProtocol"); String noProxy = systemGetEnv("NO_PROXY"); String nonProxyHosts = systemGetProperty("http.nonProxyHosts"); // log the JVM parameters that are being used if (httpUseProxy) { logger.debug( - "http.useProxy={}, http.proxyHost={}, http.proxyPort={}, https.proxyHost={}," - + " https.proxyPort={}, http.nonProxyHosts={}, NO_PROXY={}, http.proxyProtocol={}", + "Proxy environment settings: http.useProxy={}, http.proxyHost={}, http.proxyPort={}, http.proxyUser={}, " + + "http.proxyPassword is {}, https.proxyHost={}, https.proxyPort={}, https.proxyUser={}, " + + "https.proxyPassword is {}, http.nonProxyHosts={}, NO_PROXY={}, http.proxyProtocol={}", httpUseProxy, httpProxyHost, httpProxyPort, + httpProxyUser, + httpProxyPassword == null || httpProxyPassword.isEmpty() ? "not set" : "set", httpsProxyHost, httpsProxyPort, + httpsProxyUser, + httpsProxyPassword == null || httpsProxyPassword.isEmpty() ? "not set" : "set", nonProxyHosts, noProxy, httpProxyProtocol, @@ -447,8 +456,8 @@ public HttpClientSettingsKey getHttpClientKey() throws SnowflakeSQLException { httpsProxyHost, proxyPort, combinedNonProxyHosts, - "", /* user = empty */ - "", /* password = empty */ + httpsProxyUser, + httpsProxyPassword, "https", userAgentSuffix, gzipDisabled); @@ -468,8 +477,8 @@ public HttpClientSettingsKey getHttpClientKey() throws SnowflakeSQLException { httpProxyHost, proxyPort, combinedNonProxyHosts, - "", /* user = empty */ - "", /* password = empty */ + httpProxyUser, + httpProxyPassword, "http", userAgentSuffix, gzipDisabled);