Allow storing database password in environment variables
[policy/engine.git] / BRMSGateway / src / main / java / org / onap / policy / brms / api / BrmsPush.java
index 45f6585..8826d56 100644 (file)
@@ -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;
     }