Provide the ability to set the truststore properties during model-loader startup 76/84876/1
authorPolavarapu, Chaitanya (cp8128) <cp8128@att.com>
Wed, 10 Apr 2019 12:42:08 +0000 (08:42 -0400)
committerPolavarapu, Chaitanya (cp8128) <cp8128@att.com>
Wed, 10 Apr 2019 12:42:08 +0000 (08:42 -0400)
Issue-ID: AAI-2339
Change-Id: Icb6b35a6bf5bccfd1771a670a0626fe5b0b0cc12
Signed-off-by: Polavarapu, Chaitanya (cp8128) <cp8128@att.com>
src/main/java/org/onap/aai/modelloader/service/ModelLoaderService.java

index 35d8ada..c338e5b 100644 (file)
@@ -83,6 +83,21 @@ public class ModelLoaderService implements ModelLoaderInterface {
         try {
             configProperties.load(Files.newInputStream(Paths.get(configDir, "model-loader.properties")));
             config = new ModelLoaderConfig(configProperties);
+            
+            // Set the truststore for SDC Client to connect to Dmaap central bus if applicable (as in case of TI)
+            if (config.isUseHttpsWithDmaap()) {
+                String trustStorePath = config.getKeyStorePath();
+                String trustStorePassword = config.getKeyStorePassword();
+                if (trustStorePath != null && Paths.get(trustStorePath).toFile().isFile() && trustStorePassword != null
+                        && !trustStorePassword.isEmpty()) {
+                    System.setProperty("javax.net.ssl.trustStore", trustStorePath);
+                    System.setProperty("javax.net.ssl.trustStorePassword", trustStorePassword);
+                } else {
+                    throw new IllegalArgumentException("Model Loader property ml.distribution.KEYSTORE_FILE "
+                               + "or ml.distribution.KEYSTORE_PASSWORD not set or invalid");
+                }
+            }
+            
             if (!config.getASDCConnectionDisabled()) {
                 initSdcClient();
             }