diff options
author | 2023-04-26 12:14:16 -0400 | |
---|---|---|
committer | 2023-04-26 16:06:08 -0400 | |
commit | 2f4cc180555b1891fb749443449bd969db408d9c (patch) | |
tree | d848df5d9f1e8c1ecdf944c891ee80228a579c4b /ms/blueprintsprocessor/modules/commons/rest-lib/src/main | |
parent | 1007a6658ae1caa365373b6de2ef4e314cd5366b (diff) |
Adding some minor features
* Adding proxy and ssl context to CloseableHttpClient
* Adding paged capability to ResourceDictionary GET API, and adding POST APi to bulk load resource definitions
* Adding more packages to swagger-maven-plugin to get more RestCOntroller generating swagger doc
* Fixing maven artifact versions all places
Issue-ID: CCSDK-3895
Signed-off-by: Singal, Kapil (ks220y) <ks220y@att.com>
Change-Id: I096f80a2326cd00068029330b241da209e46e31d
Diffstat (limited to 'ms/blueprintsprocessor/modules/commons/rest-lib/src/main')
2 files changed, 22 insertions, 1 deletions
diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/BluePrintRestLibData.kt b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/BluePrintRestLibData.kt index a12680e07..6688f34e5 100644 --- a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/BluePrintRestLibData.kt +++ b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/BluePrintRestLibData.kt @@ -26,6 +26,7 @@ open class RestClientProperties { var connectTimeout: Int = 0 var socketTimeout: Int = 0 var connectionRequestTimeout: Int = 0 + var proxy: String? = null var additionalHeaders: Map<String, String>? = null } diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/BaseBlueprintWebClientService.kt b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/BaseBlueprintWebClientService.kt index 1505374be..41426d585 100644 --- a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/BaseBlueprintWebClientService.kt +++ b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/BaseBlueprintWebClientService.kt @@ -24,6 +24,7 @@ import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.withContext import org.apache.commons.io.IOUtils import org.apache.http.HttpEntity +import org.apache.http.HttpHost import org.apache.http.HttpResponse import org.apache.http.HttpStatus import org.apache.http.client.ClientProtocolException @@ -35,6 +36,9 @@ import org.apache.http.client.methods.HttpPatch import org.apache.http.client.methods.HttpPost import org.apache.http.client.methods.HttpPut import org.apache.http.client.methods.HttpUriRequest +import org.apache.http.conn.ssl.NoopHostnameVerifier +import org.apache.http.conn.ssl.SSLContextBuilder +import org.apache.http.conn.ssl.TrustAllStrategy import org.apache.http.entity.StringEntity import org.apache.http.impl.client.CloseableHttpClient import org.apache.http.impl.client.HttpClients @@ -74,8 +78,24 @@ abstract class BaseBlueprintWebClientService<out E : RestClientProperties> : Blu return requestConfigBuilder.build() } + open fun https_proxy(): String? { + return getRestClientProperties().proxy + } + open fun httpClient(): CloseableHttpClient { - return HttpClients.custom() + var httpClients = HttpClients.custom() + if (https_proxy() != null && https_proxy() != "") { + val proxyProtocol = https_proxy()?.split(':')?.get(0) ?: "http" + val proxyUri = https_proxy()?.split(':')?.get(1)?.replace("/", "") ?: "" + val proxyPort = https_proxy()?.split(':')?.get(2)?.toInt() ?: 0 + if (proxyUri != "" && proxyPort != 0) { + val proxy = HttpHost(proxyUri, proxyPort, proxyProtocol) + httpClients = httpClients.setProxy(proxy) + .setSSLContext(SSLContextBuilder().loadTrustMaterial(null, TrustAllStrategy.INSTANCE).build()) + .setSSLHostnameVerifier(NoopHostnameVerifier.INSTANCE) + } + } + return httpClients .addInterceptorFirst(WebClientUtils.logRequest()) .addInterceptorLast(WebClientUtils.logResponse()) .setDefaultRequestConfig(getRequestConfig()) |