summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorash74268 <ashwin.shyam.sharma@att.com>2021-07-19 16:05:55 -0500
committerash74268 <ashwin.shyam.sharma@att.com>2021-07-19 16:05:55 -0500
commita7685b6edff5374ab5b6386226e7ce1a791f763b (patch)
tree6496bbcd632d420507da9507623172cdd3a1cef6
parentfd3bbca002cd67b431e706a4efee4af7e2ccdda8 (diff)
SDC Distribution Client proxy support to skip IP address lookup when
proxy is configured Issue-ID: SDC-3613 Signed-off-by: ash74268 <ashwin.shyam.sharma@att.com> Change-Id: I7ef553b4daf35ef5213ae7287140537de9f06c26
-rw-r--r--sdc-distribution-client/src/main/java/org/onap/sdc/impl/DistributionClientImpl.java34
1 files changed, 32 insertions, 2 deletions
diff --git a/sdc-distribution-client/src/main/java/org/onap/sdc/impl/DistributionClientImpl.java b/sdc-distribution-client/src/main/java/org/onap/sdc/impl/DistributionClientImpl.java
index c372642..3a25abb 100644
--- a/sdc-distribution-client/src/main/java/org/onap/sdc/impl/DistributionClientImpl.java
+++ b/sdc-distribution-client/src/main/java/org/onap/sdc/impl/DistributionClientImpl.java
@@ -36,6 +36,7 @@ import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
+import org.apache.http.HttpHost;
import org.onap.sdc.api.IDistributionClient;
import org.onap.sdc.api.IDistributionStatusMessageJsonBuilder;
import org.onap.sdc.api.consumer.IComponentDoneStatusMessage;
@@ -706,9 +707,38 @@ public class DistributionClientImpl implements IDistributionClient {
List<String> msgBusAddresses = configuration.getMsgBusAddress();
if (msgBusAddresses.isEmpty()) {
return Either.right(new DistributionClientResultImpl(DistributionActionResultEnum.CONF_MISSING_MSG_BUS_ADDRESS, "Message bus address was not found in the config file"));
- } else {
+ } else if (getHttpProxyHost() == null && getHttpsProxyHost() == null) {
+ // If there is no proxy configured, convert to valid host name
return GeneralUtils.convertToValidHostName(msgBusAddresses);
- }
+ } else {
+ // skip the IP address lookup when proxy is configured and treat all
+ // hosts as valid
+ return Either.left(msgBusAddresses);
+ }
+ }
+
+ private HttpHost getHttpProxyHost() {
+ HttpHost proxyHost = null;
+ if (configuration.isUseSystemProxy() && System.getProperty("http.proxyHost") != null
+ && System.getProperty("http.proxyPort") != null) {
+ proxyHost = new HttpHost(System.getProperty("http.proxyHost"),
+ Integer.valueOf(System.getProperty("http.proxyPort")));
+ } else if (configuration.getHttpProxyHost() != null && configuration.getHttpProxyPort() != 0) {
+ proxyHost = new HttpHost(configuration.getHttpProxyHost(), configuration.getHttpProxyPort());
+ }
+ return proxyHost;
+ }
+
+ private HttpHost getHttpsProxyHost() {
+ HttpHost proxyHost = null;
+ if (configuration.isUseSystemProxy() && System.getProperty("https.proxyHost") != null
+ && System.getProperty("https.proxyPort") != null) {
+ proxyHost = new HttpHost(System.getProperty("https.proxyHost"),
+ Integer.valueOf(System.getProperty("https.proxyPort")));
+ } else if (configuration.getHttpsProxyHost() != null && configuration.getHttpsProxyPort() != 0) {
+ proxyHost = new HttpHost(configuration.getHttpsProxyHost(), configuration.getHttpsProxyPort());
+ }
+ return proxyHost;
}