X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Forg%2Fonap%2Fcrud%2FCrudApplication.java;fp=src%2Fmain%2Fjava%2Forg%2Fonap%2Fcrud%2FCrudApplication.java;h=008ff3f829d46e23a08fcdfa1cecaa3bb6941f59;hb=08ded90b8c72fba3b75eec4dbf6f1603d6ab2340;hp=d1446ba3316b503677358856521cb4627f6768af;hpb=84707925fec2e8998cc66888fbaa8d1960a68ed0;p=aai%2Fgizmo.git diff --git a/src/main/java/org/onap/crud/CrudApplication.java b/src/main/java/org/onap/crud/CrudApplication.java index d1446ba..008ff3f 100644 --- a/src/main/java/org/onap/crud/CrudApplication.java +++ b/src/main/java/org/onap/crud/CrudApplication.java @@ -22,11 +22,14 @@ package org.onap.crud; import java.util.HashMap; import java.util.Map; +import javax.annotation.PostConstruct; 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.support.SpringBootServletInitializer; import org.springframework.context.annotation.ImportResource; +import org.springframework.core.env.Environment; /** * Crud application class - SpringApplication.run @@ -34,6 +37,9 @@ import org.springframework.context.annotation.ImportResource; @SpringBootApplication @ImportResource({"file:${SERVICE_BEANS}/*.xml"}) public class CrudApplication extends SpringBootServletInitializer{// NOSONAR + @Autowired + private Environment env; + public static void main(String[] args) {// NOSONAR String keyStorePassword = System.getProperty("KEY_STORE_PASSWORD"); if(keyStorePassword==null || keyStorePassword.isEmpty()){ @@ -43,4 +49,22 @@ public class CrudApplication extends SpringBootServletInitializer{// NOSONAR props.put("server.ssl.key-store-password", Password.deobfuscate(keyStorePassword)); new CrudApplication().configure(new SpringApplicationBuilder(CrudApplication.class).properties(props)).run(args); } + + /** + * 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"); + } + } + } }