From 86a7e35913444e56aadb12ee78c0f324617e9f8f Mon Sep 17 00:00:00 2001 From: Kris Leonard Date: Thu, 11 Jul 2019 15:10:47 -0700 Subject: [PATCH] Made it so authentication with the proxy username and password in the config is only done when the requesting host and port matches the proxy host and port in the config. --- src/main/java/com/opendxl/client/DxlClient.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/opendxl/client/DxlClient.java b/src/main/java/com/opendxl/client/DxlClient.java index 4356f69..228393e 100644 --- a/src/main/java/com/opendxl/client/DxlClient.java +++ b/src/main/java/com/opendxl/client/DxlClient.java @@ -1370,8 +1370,15 @@ private synchronized void doConnect(final Map brokers) Authenticator.setDefault(new Authenticator() { @Override protected PasswordAuthentication getPasswordAuthentication() { - return new PasswordAuthentication( - getConfig().getProxyUserName(), getConfig().getProxyPassword()); + // Only use the proxy username and password in the config if the requesting host and port + // matches the proxy host address and port in the config + if (getRequestingHost().equalsIgnoreCase(getConfig().getProxyAddress()) + && getRequestingPort() == getConfig().getProxyPort()) { + return new PasswordAuthentication( + getConfig().getProxyUserName(), getConfig().getProxyPassword()); + } + + return null; } }); }