set server truststore params optionally in search
[aai/search-data-service.git] / src / main / java / org / onap / aai / sa / Application.java
index cd253c6..f2b8db1 100644 (file)
@@ -29,15 +29,23 @@ import org.springframework.boot.web.support.SpringBootServletInitializer;
 @SpringBootApplication\r
 public class Application extends SpringBootServletInitializer {\r
 \r
-\r
     public static void main(String[] args) {\r
-\r
         String keyStorePassword = System.getProperty("KEY_STORE_PASSWORD");\r
-        if(keyStorePassword==null || keyStorePassword.isEmpty()){\r
+        if (keyStorePassword == null || keyStorePassword.isEmpty()) {\r
             throw new RuntimeException("Env property KEY_STORE_PASSWORD not set");\r
         }\r
         HashMap<String, Object> props = new HashMap<>();\r
-        props.put("server.ssl.key-store-password", Password.deobfuscate(keyStorePassword));\r
-        new Application().configure(new SpringApplicationBuilder (Application.class).properties(props)).run(args);\r
+        String deobfuscatedKeyStorePassword = keyStorePassword.startsWith("OBF:") ? Password.deobfuscate(keyStorePassword) : keyStorePassword;\r
+        props.put("server.ssl.key-store-password", deobfuscatedKeyStorePassword);\r
+\r
+        String trustStoreLocation = System.getProperty("TRUST_STORE_LOCATION");\r
+        String trustStorePassword = System.getProperty("TRUST_STORE_PASSWORD");\r
+        if (trustStoreLocation != null && trustStorePassword != null) {\r
+            trustStorePassword = trustStorePassword.startsWith("OBF:") ? Password.deobfuscate(trustStorePassword) : trustStorePassword;\r
+            props.put("server.ssl.trust-store", trustStoreLocation);\r
+            props.put("server.ssl.trust-store-password", trustStorePassword);\r
+        }\r
+\r
+        new Application().configure(new SpringApplicationBuilder(Application.class).properties(props)).run(args);\r
     }\r
 }\r