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 --- .../src/main/java/org/onap/policy/brms/api/BrmsPush.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'BRMSGateway/src') 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; } -- cgit 1.2.3-korg