diff options
-rw-r--r-- | src/main/java/org/onap/aai/datarouter/Application.java | 40 |
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 |