summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/main/java/org/onap/aai/modelloader/config/ModelLoaderConfig.java20
-rw-r--r--src/test/java/org/onap/aai/modelloader/config/TestModelLoaderConfig.java21
2 files changed, 35 insertions, 6 deletions
diff --git a/src/main/java/org/onap/aai/modelloader/config/ModelLoaderConfig.java b/src/main/java/org/onap/aai/modelloader/config/ModelLoaderConfig.java
index c81f0dc..1d4f854 100644
--- a/src/main/java/org/onap/aai/modelloader/config/ModelLoaderConfig.java
+++ b/src/main/java/org/onap/aai/modelloader/config/ModelLoaderConfig.java
@@ -172,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
@@ -182,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
@@ -235,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() {
@@ -252,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() {
@@ -301,7 +301,7 @@ public class ModelLoaderConfig implements IConfiguration {
* @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;
@@ -337,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;
+ }
}
diff --git a/src/test/java/org/onap/aai/modelloader/config/TestModelLoaderConfig.java b/src/test/java/org/onap/aai/modelloader/config/TestModelLoaderConfig.java
index bfd793a..5243ac5 100644
--- a/src/test/java/org/onap/aai/modelloader/config/TestModelLoaderConfig.java
+++ b/src/test/java/org/onap/aai/modelloader/config/TestModelLoaderConfig.java
@@ -78,6 +78,9 @@ public class TestModelLoaderConfig {
ModelLoaderConfig config =
createObfuscatedTestConfig(ModelLoaderConfig.PROP_ML_DISTRIBUTION_PASSWORD, password);
assertEquals(password, config.getPassword());
+
+ config = createUnobfuscatedTestConfig(ModelLoaderConfig.PROP_ML_DISTRIBUTION_PASSWORD, password);
+ assertEquals(password, config.getPassword());
}
@Test
@@ -86,6 +89,9 @@ public class TestModelLoaderConfig {
ModelLoaderConfig config =
createObfuscatedTestConfig(ModelLoaderConfig.PROP_ML_DISTRIBUTION_KEYSTORE_PASSWORD, password);
assertEquals(password, config.getKeyStorePassword());
+
+ config = createUnobfuscatedTestConfig(ModelLoaderConfig.PROP_ML_DISTRIBUTION_KEYSTORE_PASSWORD, password);
+ assertEquals(password, config.getKeyStorePassword());
}
@Test
@@ -94,6 +100,9 @@ public class TestModelLoaderConfig {
ModelLoaderConfig config =
createObfuscatedTestConfig(ModelLoaderConfig.PROP_AAI_AUTHENTICATION_PASSWORD, password);
assertEquals(password, config.getAaiAuthenticationPassword());
+
+ config = createUnobfuscatedTestConfig(ModelLoaderConfig.PROP_AAI_AUTHENTICATION_PASSWORD, password);
+ assertEquals(password, config.getAaiAuthenticationPassword());
}
@Test
@@ -101,6 +110,9 @@ public class TestModelLoaderConfig {
String password = "myvoiceismypassword";
ModelLoaderConfig config = createObfuscatedTestConfig(ModelLoaderConfig.PROP_AAI_KEYSTORE_PASSWORD, password);
assertEquals(password, config.getAaiKeyStorePassword());
+
+ config = createUnobfuscatedTestConfig(ModelLoaderConfig.PROP_AAI_KEYSTORE_PASSWORD, password);
+ assertEquals(password, config.getAaiKeyStorePassword());
}
@Test
@@ -117,6 +129,9 @@ public class TestModelLoaderConfig {
String password = "babelpassword";
ModelLoaderConfig config = createObfuscatedTestConfig(ModelLoaderConfig.PROP_BABEL_KEYSTORE_PASSWORD, password);
assertEquals(password, config.getBabelKeyStorePassword());
+
+ config = createUnobfuscatedTestConfig(ModelLoaderConfig.PROP_BABEL_KEYSTORE_PASSWORD, password);
+ assertEquals(password, config.getBabelKeyStorePassword());
}
@Test
@@ -190,4 +205,10 @@ public class TestModelLoaderConfig {
props.put(propertyName, Password.obfuscate(propertyValue));
return new ModelLoaderConfig(props, null);
}
+
+ private ModelLoaderConfig createUnobfuscatedTestConfig(String propertyName, String propertyValue) {
+ Properties props = new Properties();
+ props.put(propertyName, propertyValue);
+ return new ModelLoaderConfig(props, null);
+ }
}