X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=enrichment-coordinator-service%2Fsrc%2Fmain%2Fjava%2Forg%2Foransc%2Fenrichment%2Fclients%2FAsyncRestClientFactory.java;h=4865df5624125c5ebb6828375894c163f348d6c0;hb=1da5c887797ae8cb715ad0b16b388aae18cda948;hp=07f23e9ea38f6edb59a9046db974fe0e948bdfde;hpb=77e580513eeb2d27f8040588dc1363b94f4afa0d;p=nonrtric.git diff --git a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/clients/AsyncRestClientFactory.java b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/clients/AsyncRestClientFactory.java index 07f23e9e..4865df56 100644 --- a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/clients/AsyncRestClientFactory.java +++ b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/clients/AsyncRestClientFactory.java @@ -42,6 +42,7 @@ import java.util.stream.Collectors; import javax.net.ssl.KeyManagerFactory; import org.oransc.enrichment.configuration.WebClientConfig; +import org.oransc.enrichment.configuration.WebClientConfig.HttpProxyConfig; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.util.ResourceUtils; @@ -53,25 +54,38 @@ public class AsyncRestClientFactory { private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); private final SslContextFactory sslContextFactory; + private final HttpProxyConfig httpProxyConfig; public AsyncRestClientFactory(WebClientConfig clientConfig) { if (clientConfig != null) { this.sslContextFactory = new CachingSslContextFactory(clientConfig); + this.httpProxyConfig = clientConfig.httpProxyConfig(); } else { + logger.warn("No configuration for web client defined, HTTPS will not work"); this.sslContextFactory = null; + this.httpProxyConfig = null; } } - public AsyncRestClient createRestClient(String baseUrl) { + public AsyncRestClient createRestClientNoHttpProxy(String baseUrl) { + return createRestClient(baseUrl, false); + } + + public AsyncRestClient createRestClientUseHttpProxy(String baseUrl) { + return createRestClient(baseUrl, true); + } + + private AsyncRestClient createRestClient(String baseUrl, boolean useHttpProxy) { if (this.sslContextFactory != null) { try { - return new AsyncRestClient(baseUrl, this.sslContextFactory.createSslContext()); + return new AsyncRestClient(baseUrl, this.sslContextFactory.createSslContext(), + useHttpProxy ? httpProxyConfig : null); } catch (Exception e) { String exceptionString = e.toString(); logger.error("Could not init SSL context, reason: {}", exceptionString); } } - return new AsyncRestClient(baseUrl); + return new AsyncRestClient(baseUrl, null, httpProxyConfig); } private class SslContextFactory { @@ -175,5 +189,4 @@ public class AsyncRestClientFactory { } } - }