set server truststore params optionally in champ 24/75224/1
authorDaniel Silverthorn <daniel.silverthorn@amdocs.com>
Thu, 3 Jan 2019 14:17:09 +0000 (09:17 -0500)
committerDaniel Silverthorn <daniel.silverthorn@amdocs.com>
Thu, 3 Jan 2019 14:19:48 +0000 (09:19 -0500)
Change-Id: I20f63834d8bfb3d715d244869e5c1fc4ee9811c9
Issue-ID: AAI-2046
Signed-off-by: Daniel Silverthorn <daniel.silverthorn@amdocs.com>
champ-service/src/main/bin/start.sh
champ-service/src/main/java/org/onap/champ/ChampApplication.java

index 7e6d587..bf29db5 100644 (file)
@@ -58,6 +58,15 @@ PROPS="-DAPP_HOME=$APP_HOME"
 PROPS="$PROPS -DCONFIG_HOME=$CONFIG_HOME"
 PROPS="$PROPS -Dlogging.config=$APP_HOME/bundleconfig/etc/logback.xml"
 PROPS="$PROPS -DKEY_STORE_PASSWORD=$KEY_STORE_PASSWORD"
+
+if [ ! -z "$TRUST_STORE_PASSWORD" ]; then
+   PROPS="$PROPS -DTRUST_STORE_PASSWORD=${TRUST_STORE_PASSWORD}"
+fi
+
+if [ ! -z "$TRUST_STORE_LOCATION" ]; then
+   PROPS="$PROPS -DTRUST_STORE_LOCATION=${TRUST_STORE_LOCATION}"
+fi
+
 JVM_MAX_HEAP=${MAX_HEAP:-1024}
 
 set -x
index 06f3ec7..4477006 100644 (file)
@@ -45,7 +45,17 @@ public class ChampApplication extends SpringBootServletInitializer {
         }
 
         Map<String, Object> props = new HashMap<>();
-        props.put("server.ssl.key-store-password", Password.deobfuscate(keyStorePassword));
+        String deobfuscatedKeyStorePassword = keyStorePassword.startsWith("OBF:") ? Password.deobfuscate(keyStorePassword) : keyStorePassword;
+        props.put("server.ssl.key-store-password", deobfuscatedKeyStorePassword);
+
+        String trustStoreLocation = System.getProperty("TRUST_STORE_LOCATION");
+        String trustStorePassword = System.getProperty("TRUST_STORE_PASSWORD");
+        if (trustStoreLocation != null && trustStorePassword != null) {
+            trustStorePassword = trustStorePassword.startsWith("OBF:") ? Password.deobfuscate(trustStorePassword) : trustStorePassword;
+            props.put("server.ssl.trust-store", trustStoreLocation);
+            props.put("server.ssl.trust-store-password", trustStorePassword);
+        }
+
         new ChampApplication().configure(new SpringApplicationBuilder(ChampApplication.class).properties(props))
                 .run(args);
     }