diff options
author | Agarwal, Ruchira (ra1926) <ra1926@att.com> | 2019-07-22 20:26:50 +0000 |
---|---|---|
committer | Agarwal, Ruchira (ra1926) <ra1926@att.com> | 2019-07-23 14:55:23 +0000 |
commit | 57bfbb05e485fb11b620b1bf12e70aa063aaa3c8 (patch) | |
tree | 434a13e13cf45004a91f309e86c76038cf1d27af /properties-node/provider/src/main | |
parent | 1201ff98e4c7856b03b268302e4aed2cdc6e1dbb (diff) |
configurable param resolution
support config parameter resolution to k8s secret value
Issue-ID: CCSDK-1502
Signed-off-by: Agarwal, Ruchira (ra1926) <ra1926@att.com>
Change-Id: I8acc98fa3fdd9ba46c617b4d0113086c1e889997
Diffstat (limited to 'properties-node/provider/src/main')
-rw-r--r-- | properties-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/prop/PropertiesNode.java | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/properties-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/prop/PropertiesNode.java b/properties-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/prop/PropertiesNode.java index f0c7e0b4..b4bc8474 100644 --- a/properties-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/prop/PropertiesNode.java +++ b/properties-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/prop/PropertiesNode.java @@ -3,7 +3,7 @@ * openECOMP : SDN-C * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights - * reserved. + * reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -63,14 +63,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, value.trim()); + ctx.setAttribute(pfx + name, getObfuscatedVal(value.trim())); log.info("+++ " + pfx + name + ": [" + maskPassword(pfx + name, value) + "]"); } } } if (mm != null) { for (Map.Entry<String, String> entry : mm.entrySet()) { - ctx.setAttribute(pfx + entry.getKey(), entry.getValue()); + ctx.setAttribute(pfx + entry.getKey(), getObfuscatedVal(entry.getValue())); log.info("+++ " + pfx + entry.getKey() + ": [" + maskPassword(pfx + entry.getKey(), entry.getValue()) + "]"); } @@ -81,7 +81,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, value.trim()); + ctx.setAttribute(pfx + name, getObfuscatedVal(value.trim())); log.info("+++ " + pfx + name + ": [" + maskPassword(pfx + name, value) + "]"); } } @@ -92,6 +92,25 @@ public class PropertiesNode implements SvcLogicJavaPlugin { } } + /* Unobfuscate param value */ + private static String getObfuscatedVal(String paramValue) { + String resValue = paramValue; + if (paramValue != null && paramValue.startsWith("${") && paramValue.endsWith("}")) + { + String paramStr = paramValue.substring(2, paramValue.length()-1); + if (paramStr != null && paramStr.length() > 0) + { + String val = System.getenv(paramStr); + if (val != null && val.length() > 0) + { + resValue=val; + log.info("Obfuscated value RESET for param value:" + paramValue); + } + } + } + return resValue; + } + /* * Getting extension has to do the following "" --> "" "name" --> "" "name.txt" --> "txt" * ".htpasswd" --> "" "name.with.many.dots.myext" --> "myext" |