From e29f8129b7f012c1405f5be3bbb853116ce9df97 Mon Sep 17 00:00:00 2001 From: Dominik Mizyn Date: Tue, 18 Feb 2020 09:57:40 +0100 Subject: Allow storing database password in environment variables This patch allows to store and get database password from environment variables. This is needed if we want to send those variables by helm secrets. Issue-ID: OOM-2287 Change-Id: I041c3e4dd3b9042b2b6c2b34afc22867bab81b22 Signed-off-by: Dominik Mizyn --- LogParser/src/main/java/org/onap/xacml/parser/ParseLog.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'LogParser/src/main') 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); } -- cgit 1.2.3-korg