From 57bfbb05e485fb11b620b1bf12e70aa063aaa3c8 Mon Sep 17 00:00:00 2001 From: "Agarwal, Ruchira (ra1926)" Date: Mon, 22 Jul 2019 20:26:50 +0000 Subject: configurable param resolution support config parameter resolution to k8s secret value Issue-ID: CCSDK-1502 Signed-off-by: Agarwal, Ruchira (ra1926) Change-Id: I8acc98fa3fdd9ba46c617b4d0113086c1e889997 --- .../ccsdk/sli/plugins/prop/PropertiesNode.java | 27 ++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) (limited to 'properties-node/provider/src/main') 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 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" -- cgit 1.2.3-korg