aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authormichaere <michaere@amdocs.com>2018-09-04 16:57:48 +0100
committermichaere <michaere@amdocs.com>2018-09-04 16:57:48 +0100
commit89a0e48dce48a915682000b90de43b70871aff75 (patch)
treeed30edc8790395bb20e94ff2dd66cd403756c785 /src
parent837e78b35e405bb3a9450e73eb47632089041fb9 (diff)
Update application class to handle https
Provide a secure connection to the event client for async flow Issue-ID: AAI-1562 Change-Id: I686e2e6cf4ba88751455627d2755d18ea571f1f4 Signed-off-by: michaere <michaere@amdocs.com>
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/onap/aai/datarouter/Application.java40
1 files changed, 32 insertions, 8 deletions
diff --git a/src/main/java/org/onap/aai/datarouter/Application.java b/src/main/java/org/onap/aai/datarouter/Application.java
index 5abe7f3..245797c 100644
--- a/src/main/java/org/onap/aai/datarouter/Application.java
+++ b/src/main/java/org/onap/aai/datarouter/Application.java
@@ -21,21 +21,26 @@
package org.onap.aai.datarouter;
import java.util.HashMap;
-
+import javax.annotation.PostConstruct;
import org.apache.camel.component.servlet.CamelHttpTransportServlet;
import org.eclipse.jetty.util.security.Password;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.boot.web.support.SpringBootServletInitializer;
import org.springframework.context.annotation.Bean;
+import org.springframework.core.env.Environment;
@SpringBootApplication
public class Application extends SpringBootServletInitializer{
-
- private static final String CAMEL_URL_MAPPING = "/*";
- private static final String CAMEL_SERVLET_NAME = "CamelServlet";
+
+ private static final String CAMEL_URL_MAPPING = "/*";
+ private static final String CAMEL_SERVLET_NAME = "CamelServlet";
+
+ @Autowired
+ private Environment env;
public static void main(String[] args) {
String keyStorePassword = System.getenv("KEY_STORE_PASSWORD");
@@ -45,10 +50,10 @@ public class Application extends SpringBootServletInitializer{
HashMap<String, Object> props = new HashMap<>();
props.put("server.ssl.key-store-password", Password.deobfuscate(keyStorePassword));
new Application().configure(new SpringApplicationBuilder(Application.class).properties(props)).run(args);
-
-
+
+
}
-
+
@Bean
public ServletRegistrationBean getServletRegistrationBean() {
ServletRegistrationBean registration = new ServletRegistrationBean(new CamelHttpTransportServlet(), CAMEL_URL_MAPPING);
@@ -56,5 +61,24 @@ public class Application extends SpringBootServletInitializer{
return registration;
}
-
+ /**
+ * Set required trust store system properties using values from application.properties
+ */
+ @PostConstruct
+ public void setSystemProperties() {
+ String trustStorePath = env.getProperty("server.ssl.key-store");
+ if (trustStorePath != null) {
+ String trustStorePassword = env.getProperty("server.ssl.key-store-password");
+
+ if (trustStorePassword != null) {
+ System.setProperty("javax.net.ssl.trustStore", trustStorePath);
+ System.setProperty("javax.net.ssl.trustStorePassword", trustStorePassword);
+ } else {
+ throw new IllegalArgumentException("Env property server.ssl.key-store-password not set");
+ }
+ }
+ }
+
+
+
} \ No newline at end of file