summaryrefslogtreecommitdiffstats
path: root/models-provider
diff options
context:
space:
mode:
authorRam Krishna Verma <ram_krishna.verma@bell.ca>2020-02-18 17:49:40 +0000
committerGerrit Code Review <gerrit@onap.org>2020-02-18 17:49:40 +0000
commitba3a17c58088a016b3ed2948b0c33502fdbc84ec (patch)
tree2a8fd335e12033553db8eb3d50dd500188308c9c /models-provider
parent1bb549251599ce7866e1143158a68b5f259d22b1 (diff)
parent6c494d06a7a0c0492f4c7bc42cebd42222fa44f1 (diff)
Merge "Allow storing database password in environment variables"
Diffstat (limited to 'models-provider')
-rw-r--r--models-provider/src/main/java/org/onap/policy/models/provider/impl/DatabasePolicyModelsProviderImpl.java9
1 files changed, 8 insertions, 1 deletions
diff --git a/models-provider/src/main/java/org/onap/policy/models/provider/impl/DatabasePolicyModelsProviderImpl.java b/models-provider/src/main/java/org/onap/policy/models/provider/impl/DatabasePolicyModelsProviderImpl.java
index 08c01b68f..50c739059 100644
--- a/models-provider/src/main/java/org/onap/policy/models/provider/impl/DatabasePolicyModelsProviderImpl.java
+++ b/models-provider/src/main/java/org/onap/policy/models/provider/impl/DatabasePolicyModelsProviderImpl.java
@@ -101,7 +101,7 @@ public class DatabasePolicyModelsProviderImpl implements PolicyModelsProvider {
daoParameters.setPersistenceUnit(parameters.getPersistenceUnit());
// Decode the password using Base64
- String decodedPassword = new String(Base64.getDecoder().decode(parameters.getDatabasePassword()));
+ String decodedPassword = new String(Base64.getDecoder().decode(getValue(parameters.getDatabasePassword())));
// @formatter:off
Properties jdbcProperties = new Properties();
@@ -125,6 +125,13 @@ public class DatabasePolicyModelsProviderImpl implements PolicyModelsProvider {
}
}
+ private String getValue(final String value) {
+ if (value != null && value.matches("[$][{].*[}]$")) {
+ return System.getenv(value.substring(2, value.length() - 1));
+ }
+ return value;
+ }
+
@Override
public void close() throws PfModelException {
LOGGER.debug("closing the database connection to {} using persistence unit {}", parameters.getDatabaseUrl(),