From 69e393da4cce52a0491fffff2dc81fbe59aeca08 Mon Sep 17 00:00:00 2001 From: Dan Timoney Date: Wed, 17 Feb 2021 15:25:45 -0500 Subject: Add new EnvProperties class Added new class EnvProperties, which extends java.util.Properties and supports property values containing embedded environment variable references. Updated code to use this class to load svclogic.properties, and updated dmaap listener to use that class to load dmaap listener configuration. Issue-ID: SDNC-1482 Signed-off-by: Dan Timoney Change-Id: I7538b719631d8c10c27d059aeb4f70ce92760ebd --- .../org/onap/ccsdk/sli/plugins/prop/PropertiesNode.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'plugins/properties-node') diff --git a/plugins/properties-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/prop/PropertiesNode.java b/plugins/properties-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/prop/PropertiesNode.java index b4bc84747..d5bf4d1dc 100644 --- a/plugins/properties-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/prop/PropertiesNode.java +++ b/plugins/properties-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/prop/PropertiesNode.java @@ -32,6 +32,7 @@ import java.util.Set; import org.onap.ccsdk.sli.core.sli.SvcLogicContext; import org.onap.ccsdk.sli.core.sli.SvcLogicException; import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin; +import org.onap.ccsdk.sli.core.utils.common.EnvProperties; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -41,7 +42,7 @@ public class PropertiesNode implements SvcLogicJavaPlugin { public void readProperties(Map paramMap, SvcLogicContext ctx) throws SvcLogicException { Parameters param = getParameters(paramMap); - Properties prop = new Properties(); + Properties prop = new EnvProperties(); try { File file = new File(param.fileName); try (InputStream in = new FileInputStream(file)) { @@ -63,14 +64,14 @@ public class PropertiesNode implements SvcLogicJavaPlugin { String name = (String) key; String value = prop.getProperty(name); if (value != null && value.trim().length() > 0) { - ctx.setAttribute(pfx + name, getObfuscatedVal(value.trim())); + ctx.setAttribute(pfx + name, EnvProperties.resolveValue(value.trim())); log.info("+++ " + pfx + name + ": [" + maskPassword(pfx + name, value) + "]"); } } } if (mm != null) { for (Map.Entry entry : mm.entrySet()) { - ctx.setAttribute(pfx + entry.getKey(), getObfuscatedVal(entry.getValue())); + ctx.setAttribute(pfx + entry.getKey(), EnvProperties.resolveValue(entry.getValue())); log.info("+++ " + pfx + entry.getKey() + ": [" + maskPassword(pfx + entry.getKey(), entry.getValue()) + "]"); } @@ -81,7 +82,7 @@ public class PropertiesNode implements SvcLogicJavaPlugin { String name = (String) key; String value = prop.getProperty(name); if (value != null && value.trim().length() > 0) { - ctx.setAttribute(pfx + name, getObfuscatedVal(value.trim())); + ctx.setAttribute(pfx + name, EnvProperties.resolveValue(value.trim())); log.info("+++ " + pfx + name + ": [" + maskPassword(pfx + name, value) + "]"); } } @@ -92,7 +93,8 @@ public class PropertiesNode implements SvcLogicJavaPlugin { } } - /* Unobfuscate param value */ + /* Unobfuscate param value + * No longer needed - use EnvProperties.resolveValue instead private static String getObfuscatedVal(String paramValue) { String resValue = paramValue; if (paramValue != null && paramValue.startsWith("${") && paramValue.endsWith("}")) @@ -110,6 +112,7 @@ public class PropertiesNode implements SvcLogicJavaPlugin { } return resValue; } + */ /* * Getting extension has to do the following "" --> "" "name" --> "" "name.txt" --> "txt" -- cgit 1.2.3-korg