Add the https rest template 30/72030/3 1.3.2
authorKajur, Harish (vk250x) <vk250x@att.com>
Wed, 7 Nov 2018 02:40:50 +0000 (21:40 -0500)
committerKajur, Harish (vk250x) <vk250x@att.com>
Wed, 7 Nov 2018 04:05:33 +0000 (23:05 -0500)
Issue-ID: AAI-1761
Change-Id: I56d423c84bcc0648cca01d0ebd7f20a8bc5a2fd3
Signed-off-by: Kajur, Harish (vk250x) <vk250x@att.com>
aai-annotations/pom.xml
aai-auth/pom.xml
aai-core/pom.xml
aai-core/src/main/java/org/onap/aai/web/EventClientPublisher.java
aai-schema-ingest/pom.xml
aai-schema/pom.xml
aai-utils/pom.xml
pom.xml
version.properties

index 1e03e0e..70ca779 100644 (file)
     <parent>
         <groupId>org.onap.aai.aai-common</groupId>
         <artifactId>aai-common</artifactId>
-        <version>1.3.1-SNAPSHOT</version>
+        <version>1.3.2-SNAPSHOT</version>
     </parent>
     <artifactId>aai-annotations</artifactId>
     <name>aai-annotations</name>
     <packaging>jar</packaging>
-    <version>1.3.1-SNAPSHOT</version>
+    <version>1.3.2-SNAPSHOT</version>
     <properties>
         <onap.nexus.url>https://nexus.onap.org</onap.nexus.url>
     </properties>
index f844cec..a0fd53d 100644 (file)
     <parent>
         <groupId>org.onap.aai.aai-common</groupId>
         <artifactId>aai-common</artifactId>
-        <version>1.3.1-SNAPSHOT</version>
+        <version>1.3.2-SNAPSHOT</version>
     </parent>
     <artifactId>aai-auth</artifactId>
     <name>aai-auth</name>
-    <version>1.3.1-SNAPSHOT</version>
+    <version>1.3.2-SNAPSHOT</version>
 
     <properties>
         <onap.nexus.url>https://nexus.onap.org</onap.nexus.url>
index 74d2f91..261a3e4 100644 (file)
     <parent>
         <groupId>org.onap.aai.aai-common</groupId>
         <artifactId>aai-common</artifactId>
-        <version>1.3.1-SNAPSHOT</version>
+        <version>1.3.2-SNAPSHOT</version>
     </parent>
     <artifactId>aai-core</artifactId>
     <name>aai-core</name>
-    <version>1.3.1-SNAPSHOT</version>
+    <version>1.3.2-SNAPSHOT</version>
     <packaging>jar</packaging>
     <properties>
         <sonar.language>java</sonar.language>
             <artifactId>log4j</artifactId>
             <version>1.2.17</version>
         </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot</artifactId>
+            <version>1.5.15.RELEASE</version>
+            <scope>compile</scope>
+        </dependency>
     </dependencies>
 
     <!-- Plugins and repositories -->
index ac89727..ea614bc 100644 (file)
@@ -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();
     }
 
index dfb6304..54e1041 100644 (file)
     <parent>
         <groupId>org.onap.aai.aai-common</groupId>
         <artifactId>aai-common</artifactId>
-        <version>1.3.1-SNAPSHOT</version>
+        <version>1.3.2-SNAPSHOT</version>
     </parent>
     <artifactId>aai-schema-ingest</artifactId>
     <name>aai-schema-ingest</name>
-    <version>1.3.1-SNAPSHOT</version>
+    <version>1.3.2-SNAPSHOT</version>
     <packaging>jar</packaging>
 
     <build>
index d1c554a..06b28f4 100644 (file)
     <parent>
         <groupId>org.onap.aai.aai-common</groupId>
         <artifactId>aai-common</artifactId>
-        <version>1.3.1-SNAPSHOT</version>
+        <version>1.3.2-SNAPSHOT</version>
     </parent>
     <artifactId>aai-schema</artifactId>
     <name>aai-schema</name>
-    <version>1.3.1-SNAPSHOT</version>
+    <version>1.3.2-SNAPSHOT</version>
     <properties>
         <onap.nexus.url>https://nexus.onap.org</onap.nexus.url>
         <!-- Start of Default ONAP Schema Properties -->
index 087dcc2..1395220 100644 (file)
     <parent>
         <groupId>org.onap.aai.aai-common</groupId>
         <artifactId>aai-common</artifactId>
-        <version>1.3.1-SNAPSHOT</version>
+        <version>1.3.2-SNAPSHOT</version>
     </parent>
     <artifactId>aai-utils</artifactId>
     <name>aai-utils</name>
-    <version>1.3.1-SNAPSHOT</version>
+    <version>1.3.2-SNAPSHOT</version>
 
     <properties>
         <onap.nexus.url>https://nexus.onap.org</onap.nexus.url>
diff --git a/pom.xml b/pom.xml
index 5659674..00925d3 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -30,7 +30,7 @@
 
     <groupId>org.onap.aai.aai-common</groupId>
     <artifactId>aai-common</artifactId>
-    <version>1.3.1-SNAPSHOT</version>
+    <version>1.3.2-SNAPSHOT</version>
     <packaging>pom</packaging>
     <name>aai-aai-common</name>
     <description>Contains all of the common code for resources and traversal repos</description>
index e8911fb..4bec676 100644 (file)
@@ -5,7 +5,7 @@
 
 major_version=1
 minor_version=3
-patch_version=1
+patch_version=2
 
 base_version=${major_version}.${minor_version}.${patch_version}