diff options
author | Singal, Kapil (ks220y) <ks220y@att.com> | 2023-04-26 12:14:16 -0400 |
---|---|---|
committer | Singal, Kapil (ks220y) <ks220y@att.com> | 2023-04-27 09:38:55 -0400 |
commit | ddcc79f9968f65f34bb049e469acfafe0a0aa2e9 (patch) | |
tree | 13fab94982852aee0ab90a4a663073a398d8b527 /ms/blueprintsprocessor/modules/commons/rest-lib/src | |
parent | 6db73002faffaa35caed91c4d440f694ec074ea1 (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
(cherry picked from commit 2f4cc180555b1891fb749443449bd969db408d9c)
Diffstat (limited to 'ms/blueprintsprocessor/modules/commons/rest-lib/src')
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()) |