diff options
author | Jim Hahn <jrh3@att.com> | 2020-02-18 16:50:09 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2020-02-18 16:50:09 +0000 |
commit | 9f774daf0c3e317c9542c9fe4108772006b267a9 (patch) | |
tree | d84fddbbfc6801da6aeae0e4a8331925f6ee448c | |
parent | 8f0c0524afb0ebedf5a11a3b68e4624c8168d716 (diff) | |
parent | e29f8129b7f012c1405f5be3bbb853116ce9df97 (diff) |
Merge "Allow storing database password in environment variables"
-rw-r--r-- | BRMSGateway/src/main/java/org/onap/policy/brms/api/BrmsPush.java | 11 | ||||
-rw-r--r-- | LogParser/src/main/java/org/onap/xacml/parser/ParseLog.java | 11 |
2 files changed, 18 insertions, 4 deletions
diff --git a/BRMSGateway/src/main/java/org/onap/policy/brms/api/BrmsPush.java b/BRMSGateway/src/main/java/org/onap/policy/brms/api/BrmsPush.java index 45f65851e..8826d5697 100644 --- a/BRMSGateway/src/main/java/org/onap/policy/brms/api/BrmsPush.java +++ b/BRMSGateway/src/main/java/org/onap/policy/brms/api/BrmsPush.java @@ -256,8 +256,8 @@ public class BrmsPush { repUrlList = new ArrayList<>(); repUrlList.add(repUrl); } - repUserName = config.getProperty("repositoryUsername"); - repPassword = PeCryptoUtils.decrypt(config.getProperty("repositoryPassword")); + repUserName = getValue(config.getProperty("repositoryUsername")); + repPassword = PeCryptoUtils.decrypt(getValue(config.getProperty("repositoryPassword"))); if (repUserName == null || repPassword == null) { LOGGER.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "repostoryUserName and respositoryPassword properties are required."); @@ -367,6 +367,13 @@ public class BrmsPush { } + private String getValue(final String value) { + if (value != null && value.matches("[$][{].*[}]$")) { + return System.getenv(value.substring(2, value.length() - 1)); + } + return value; + } + private static void setBackupMonitor(final BackUpMonitor instance) { bm = instance; } diff --git a/LogParser/src/main/java/org/onap/xacml/parser/ParseLog.java b/LogParser/src/main/java/org/onap/xacml/parser/ParseLog.java index f12522af6..77aafdf7a 100644 --- a/LogParser/src/main/java/org/onap/xacml/parser/ParseLog.java +++ b/LogParser/src/main/java/org/onap/xacml/parser/ParseLog.java @@ -884,11 +884,11 @@ public class ParseLog { setLogFileProperties(splitString); jdbcUrl = config.getProperty("JDBC_URL").replace("'", ""); - jdbcUser = config.getProperty("JDBC_USER"); + jdbcUser = getValue(config.getProperty("JDBC_USER")); jdbcDriver = config.getProperty("JDBC_DRIVER"); PeCryptoUtils.initAesKey(config.getProperty(PROP_AES_KEY)); - jdbcPassword = PeCryptoUtils.decrypt(config.getProperty("JDBC_PASSWORD")); + jdbcPassword = PeCryptoUtils.decrypt(getValue(config.getProperty("JDBC_PASSWORD"))); config.setProperty("javax.persistence.jdbc.password", jdbcPassword); return config; @@ -902,6 +902,13 @@ public class ParseLog { return null; } + private static String getValue(final String value) { + if (value != null && value.matches("[$][{].*[}]$")) { + return System.getenv(value.substring(2, value.length() - 1)); + } + return value; + } + public static Connection getDbConnection() { return dbConnection(jdbcDriver, jdbcUrl, jdbcUser, jdbcPassword); } |