From d2d51c26f4378867d870156a5f211510f8a44a38 Mon Sep 17 00:00:00 2001 From: "Kajur, Harish (vk250x)" Date: Tue, 6 Nov 2018 21:40:50 -0500 Subject: Add the https rest template Issue-ID: AAI-1761 Change-Id: I56d423c84bcc0648cca01d0ebd7f20a8bc5a2fd3 Signed-off-by: Kajur, Harish (vk250x) --- aai-annotations/pom.xml | 4 +-- aai-auth/pom.xml | 4 +-- aai-core/pom.xml | 10 ++++-- .../org/onap/aai/web/EventClientPublisher.java | 42 ++++++++++++++++++++-- aai-schema-ingest/pom.xml | 4 +-- aai-schema/pom.xml | 4 +-- aai-utils/pom.xml | 4 +-- pom.xml | 2 +- version.properties | 2 +- 9 files changed, 59 insertions(+), 17 deletions(-) diff --git a/aai-annotations/pom.xml b/aai-annotations/pom.xml index 1e03e0ef..70ca779c 100644 --- a/aai-annotations/pom.xml +++ b/aai-annotations/pom.xml @@ -27,12 +27,12 @@ org.onap.aai.aai-common aai-common - 1.3.1-SNAPSHOT + 1.3.2-SNAPSHOT aai-annotations aai-annotations jar - 1.3.1-SNAPSHOT + 1.3.2-SNAPSHOT https://nexus.onap.org diff --git a/aai-auth/pom.xml b/aai-auth/pom.xml index f844cece..a0fd53dc 100644 --- a/aai-auth/pom.xml +++ b/aai-auth/pom.xml @@ -26,11 +26,11 @@ org.onap.aai.aai-common aai-common - 1.3.1-SNAPSHOT + 1.3.2-SNAPSHOT aai-auth aai-auth - 1.3.1-SNAPSHOT + 1.3.2-SNAPSHOT https://nexus.onap.org diff --git a/aai-core/pom.xml b/aai-core/pom.xml index 74d2f916..261a3e43 100644 --- a/aai-core/pom.xml +++ b/aai-core/pom.xml @@ -27,11 +27,11 @@ org.onap.aai.aai-common aai-common - 1.3.1-SNAPSHOT + 1.3.2-SNAPSHOT aai-core aai-core - 1.3.1-SNAPSHOT + 1.3.2-SNAPSHOT jar java @@ -1019,6 +1019,12 @@ log4j 1.2.17 + + org.springframework.boot + spring-boot + 1.5.15.RELEASE + compile + diff --git a/aai-core/src/main/java/org/onap/aai/web/EventClientPublisher.java b/aai-core/src/main/java/org/onap/aai/web/EventClientPublisher.java index ac897273..ea614bc9 100644 --- a/aai-core/src/main/java/org/onap/aai/web/EventClientPublisher.java +++ b/aai-core/src/main/java/org/onap/aai/web/EventClientPublisher.java @@ -22,13 +22,21 @@ package org.onap.aai.web; import com.att.eelf.configuration.EELFLogger; import com.att.eelf.configuration.EELFManager; import org.apache.commons.lang.StringUtils; +import org.apache.http.client.HttpClient; +import org.apache.http.impl.client.HttpClients; +import org.apache.http.ssl.SSLContextBuilder; import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.web.client.RestTemplateBuilder; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.http.HttpHeaders; import org.springframework.http.MediaType; +import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; +import org.springframework.util.ResourceUtils; import org.springframework.web.client.RestTemplate; +import javax.net.ssl.SSLContext; +import java.io.FileNotFoundException; import java.io.UnsupportedEncodingException; import java.util.Base64; @@ -61,14 +69,42 @@ public class EventClientPublisher { @Value("${dmaap.ribbon.protocol:http}") private String protocol; - @Value("${dmaap.ribbon.transportType:HTTPNOAUTH}") - private String tranportType; + @Value("${dmaap.ribbon.transportType:http}") + private String transportType; @Value("${dmaap.ribbon.contentType:application/json}") private String contentType; + @Value("${server.ssl.trust-store:aai_keystore}") + private String trustStoreFile; + + @Value("${server.ssl.trust-store-password:somepass}") + private String trustStorePass; + @Bean(name="dmaapRestTemplate") - public RestTemplate dmaapRestTemplate(){ + public RestTemplate dmaapRestTemplate() throws Exception { + + if(transportType.equals("https")){ + + RestTemplateBuilder restTemplateBuilder = new RestTemplateBuilder(); + + SSLContext sslContext = SSLContextBuilder + .create() + .loadTrustMaterial(ResourceUtils.getFile(trustStoreFile), trustStorePass.toCharArray()) + .build(); + + HttpClient client = HttpClients + .custom() + .setSSLContext(sslContext) + .build(); + + LOGGER.info("Creating a dmaap rest template with https using truststore {}", trustStoreFile); + return restTemplateBuilder + .requestFactory(new HttpComponentsClientHttpRequestFactory(client)) + .build(); + } + + LOGGER.info("Creating a dmaap rest template using http"); return new RestTemplate(); } diff --git a/aai-schema-ingest/pom.xml b/aai-schema-ingest/pom.xml index dfb63049..54e10410 100644 --- a/aai-schema-ingest/pom.xml +++ b/aai-schema-ingest/pom.xml @@ -25,11 +25,11 @@ org.onap.aai.aai-common aai-common - 1.3.1-SNAPSHOT + 1.3.2-SNAPSHOT aai-schema-ingest aai-schema-ingest - 1.3.1-SNAPSHOT + 1.3.2-SNAPSHOT jar diff --git a/aai-schema/pom.xml b/aai-schema/pom.xml index d1c554a0..06b28f47 100644 --- a/aai-schema/pom.xml +++ b/aai-schema/pom.xml @@ -27,11 +27,11 @@ org.onap.aai.aai-common aai-common - 1.3.1-SNAPSHOT + 1.3.2-SNAPSHOT aai-schema aai-schema - 1.3.1-SNAPSHOT + 1.3.2-SNAPSHOT https://nexus.onap.org diff --git a/aai-utils/pom.xml b/aai-utils/pom.xml index 087dcc2c..13952203 100644 --- a/aai-utils/pom.xml +++ b/aai-utils/pom.xml @@ -29,11 +29,11 @@ org.onap.aai.aai-common aai-common - 1.3.1-SNAPSHOT + 1.3.2-SNAPSHOT aai-utils aai-utils - 1.3.1-SNAPSHOT + 1.3.2-SNAPSHOT https://nexus.onap.org diff --git a/pom.xml b/pom.xml index 5659674f..00925d35 100644 --- a/pom.xml +++ b/pom.xml @@ -30,7 +30,7 @@ org.onap.aai.aai-common aai-common - 1.3.1-SNAPSHOT + 1.3.2-SNAPSHOT pom aai-aai-common Contains all of the common code for resources and traversal repos diff --git a/version.properties b/version.properties index e8911fbc..4bec6767 100644 --- a/version.properties +++ b/version.properties @@ -5,7 +5,7 @@ major_version=1 minor_version=3 -patch_version=1 +patch_version=2 base_version=${major_version}.${minor_version}.${patch_version} -- cgit 1.2.3-korg