X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=cadi%2Fcore%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Faaf%2Fcadi%2FPropAccess.java;h=3d15b09dbed3484e9874130f6bb91d4e56a8612e;hb=89c662c2a7c50eb533256497de0420ba1176fe13;hp=07e9b592df00ada88d83db523c5b0b5bc8e9cde4;hpb=a20accc73189d8e5454cd26049c0e6fae75da16f;p=aaf%2Fauthz.git diff --git a/cadi/core/src/main/java/org/onap/aaf/cadi/PropAccess.java b/cadi/core/src/main/java/org/onap/aaf/cadi/PropAccess.java index 07e9b592..3d15b09d 100644 --- a/cadi/core/src/main/java/org/onap/aaf/cadi/PropAccess.java +++ b/cadi/core/src/main/java/org/onap/aaf/cadi/PropAccess.java @@ -31,16 +31,16 @@ import java.util.ArrayList; import java.util.Date; import java.util.List; import java.util.Map.Entry; +import java.util.Properties; import org.onap.aaf.cadi.config.Config; import org.onap.aaf.cadi.config.SecurityInfo; -import java.util.Properties; - public class PropAccess implements Access { - private static final SimpleDateFormat iso8601 = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ"); + // Sonar says cannot be static... it's ok. not too many PropAccesses created. + private final SimpleDateFormat iso8601 = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ"); - public static Level DEFAULT = Level.AUDIT; + public static final Level DEFAULT = Level.AUDIT; private Symm symm; private int level; @@ -69,18 +69,11 @@ public class PropAccess implements Access { public PropAccess(PrintStream ps, String[] args) { logIt = new StreamLogIt(ps==null?System.out:ps); - Properties nprops=new Properties(); - int eq; - for(String arg : args) { - if((eq=arg.indexOf('='))>0) { - nprops.setProperty(arg.substring(0, eq),arg.substring(eq+1)); - } - } - init(nprops); + init(logIt,args); } public PropAccess(LogIt logit, String[] args) { - logIt = logit; + init(logit, args); } public PropAccess(Properties p) { @@ -92,6 +85,18 @@ public class PropAccess implements Access { init(p); } + protected void init(final LogIt logIt, final String[] args) { + this.logIt = logIt; + Properties nprops=new Properties(); + int eq; + for(String arg : args) { + if((eq=arg.indexOf('='))>0) { + nprops.setProperty(arg.substring(0, eq),arg.substring(eq+1)); + } + } + init(nprops); + } + protected void init(Properties p) { // Make sure these two are set before any changes in Logging name = "cadi"; @@ -179,7 +184,7 @@ public class PropAccess implements Access { String chainProp = props.getProperty(Config.CADI_PROP_FILES); if(chainProp!=null) { if(recursionProtection==null) { - recursionProtection = new ArrayList(); + recursionProtection = new ArrayList<>(); recursionProtection.add(cadi_prop_files); } if(!recursionProtection.contains(chainProp)) { @@ -204,6 +209,11 @@ public class PropAccess implements Access { Object value = es.getValue(); if(value instanceof String) { String trim = ((String)value).trim(); + // Remove Beginning/End Quotes, which might be there if mixed with Bash Props + int s = 0, e=trim.length()-1; + if(s