Handle non-obfuscated config
[aai/model-loader.git] / src / main / java / org / onap / aai / modelloader / config / ModelLoaderConfig.java
index 6a45f28..1d4f854 100644 (file)
@@ -108,8 +108,10 @@ public class ModelLoaderConfig implements IConfiguration {
     /**
      * Original constructor
      *
-     * @param modelLoaderProperties properties needed to be configured for the model loader
-     * @param certLocation location of the certificate
+     * @param modelLoaderProperties
+     *        properties needed to be configured for the model loader
+     * @param certLocation
+     *        location of the certificate
      */
     public ModelLoaderConfig(Properties modelLoaderProperties, String certLocation) {
         this.modelLoaderProperties = modelLoaderProperties;
@@ -170,7 +172,7 @@ public class ModelLoaderConfig implements IConfiguration {
 
     @Override
     public String getKeyStorePassword() {
-        return Password.deobfuscate(modelLoaderProperties.getProperty(PROP_ML_DISTRIBUTION_KEYSTORE_PASSWORD));
+        return getDeobfuscatedValue(modelLoaderProperties.getProperty(PROP_ML_DISTRIBUTION_KEYSTORE_PASSWORD));
     }
 
     @Override
@@ -180,7 +182,7 @@ public class ModelLoaderConfig implements IConfiguration {
 
     @Override
     public String getPassword() {
-        return Password.deobfuscate(modelLoaderProperties.getProperty(PROP_ML_DISTRIBUTION_PASSWORD));
+        return getDeobfuscatedValue(modelLoaderProperties.getProperty(PROP_ML_DISTRIBUTION_PASSWORD));
     }
 
     @Override
@@ -233,11 +235,11 @@ public class ModelLoaderConfig implements IConfiguration {
     }
 
     public String getAaiKeyStorePassword() {
-        return Password.deobfuscate(modelLoaderProperties.getProperty(PROP_AAI_KEYSTORE_PASSWORD));
+        return getDeobfuscatedValue(modelLoaderProperties.getProperty(PROP_AAI_KEYSTORE_PASSWORD));
     }
 
     public String getBabelKeyStorePassword() {
-        return Password.deobfuscate(modelLoaderProperties.getProperty(PROP_BABEL_KEYSTORE_PASSWORD));
+        return getDeobfuscatedValue(modelLoaderProperties.getProperty(PROP_BABEL_KEYSTORE_PASSWORD));
     }
 
     public String getBabelTrustStorePath() {
@@ -250,7 +252,7 @@ public class ModelLoaderConfig implements IConfiguration {
     }
 
     public String getBabelTrustStorePassword() {
-        return Password.deobfuscate(modelLoaderProperties.getProperty(PROP_BABEL_TRUSTSTORE_PASSWORD));
+        return getDeobfuscatedValue(modelLoaderProperties.getProperty(PROP_BABEL_TRUSTSTORE_PASSWORD));
     }
 
     public String getAaiBaseUrl() {
@@ -292,19 +294,14 @@ public class ModelLoaderConfig implements IConfiguration {
 
     public boolean useGizmo() {
         String useGizmo = modelLoaderProperties.getProperty(PROP_AAI_USE_GIZMO);
-
-        if ( (useGizmo == null) || (!useGizmo.equalsIgnoreCase("true")) ) {
-            return false;
-        }
-
-        return true;
+        return useGizmo != null && useGizmo.equalsIgnoreCase("true");
     }
 
     /**
      * @return password for AAI authentication that has been reverse-engineered from its obfuscated form.
      */
     public String getAaiAuthenticationPassword() {
-        String password = Password.deobfuscate(modelLoaderProperties.getProperty(PROP_AAI_AUTHENTICATION_PASSWORD));
+        String password = getDeobfuscatedValue(modelLoaderProperties.getProperty(PROP_AAI_AUTHENTICATION_PASSWORD));
 
         if (password != null && password.isEmpty()) {
             password = null;
@@ -340,4 +337,12 @@ public class ModelLoaderConfig implements IConfiguration {
 
     }
 
+    private String getDeobfuscatedValue(String property) {
+        if (property.startsWith("OBF:")) {
+            return Password.deobfuscate(property);
+        }
+        
+        // Property is not obfuscated
+        return property;
+    }
 }