+ // Sonar says cannot be static... it's ok. not too many PropAccesses created.
+ private final SimpleDateFormat iso8601 = newISO8601();
+
+ public static SimpleDateFormat newISO8601() {
+ return new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
+ }
+
+ public static final Level DEFAULT = Level.AUDIT;
+
+ private Symm symm;
+ private int level;
+ private Properties props;
+ private List<String> recursionProtection = null;
+ private LogIt logIt;
+ private String name;
+
+ public PropAccess() {
+ logIt = new StreamLogIt(System.out);
+ init(null);
+ }
+
+ /**
+ * This Constructor soly exists to instantiate Servlet Context Based Logging that will call "init" later.
+ * @param sc
+ */
+ protected PropAccess(Object o) {
+ logIt = new StreamLogIt(System.out);
+ props = new Properties();
+ }
+
+ public PropAccess(String ... args) {
+ this(System.out,args);
+ }
+
+ public PropAccess(PrintStream ps, String[] args) {
+ logIt = new StreamLogIt(ps==null?System.out:ps);
+ init(logIt,args);
+ }
+
+ public PropAccess(LogIt logit, String[] args) {
+ init(logit, args);
+ }
+
+ public PropAccess(Properties p) {
+ this(System.out,p);
+ }
+
+ public PropAccess(PrintStream ps, Properties p) {
+ logIt = new StreamLogIt(ps==null?System.out:ps);
+ 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 synchronized void init(Properties p) {
+ // Make sure these two are set before any changes in Logging
+ name = "cadi";
+ level=DEFAULT.maskOf();
+
+ props = new Properties();
+ // First, load related System Properties
+ for (Entry<Object,Object> es : System.getProperties().entrySet()) {
+ String key = es.getKey().toString();
+ for (String start : new String[] {"cadi_","aaf_","cm_"}) {
+ if (key.startsWith(start)) {
+ props.put(key, es.getValue());
+ }
+ }
+ }
+ // Second, overlay or fill in with Passed in Props
+ if (p!=null) {
+ props.putAll(p);
+ }
+
+ // Preset LogLevel
+ String sLevel = props.getProperty(Config.CADI_LOGLEVEL);
+ if (sLevel!=null) {
+ level=Level.valueOf(sLevel).maskOf();
+ }
+
+ // Third, load any Chained Property Files
+ load(props.getProperty(Config.CADI_PROP_FILES));
+
+ if(sLevel==null) { // if LogLev wasn't set before, check again after Chained Load
+ sLevel = props.getProperty(Config.CADI_LOGLEVEL);
+ if (sLevel!=null) {
+ level=Level.valueOf(sLevel).maskOf();
+ }
+ }
+ // Setup local Symmetrical key encryption
+ if (symm==null) {
+ try {
+ symm = Symm.obtain(this);
+ } catch (CadiException e) {
+ System.err.append("FATAL ERROR: Cannot obtain Key Information.");
+ e.printStackTrace(System.err);
+ System.exit(1);
+ }
+ }
+
+ name = props.getProperty(Config.CADI_LOGNAME, name);
+
+ SecurityInfo.setHTTPProtocols(this);
+
+ }
+
+
+ private void load(String cadi_prop_files) {
+ if (cadi_prop_files==null) {
+ return;
+ }
+ String prevKeyFile = props.getProperty(Config.CADI_KEYFILE);