diff options
Diffstat (limited to 'cadi')
6 files changed, 51 insertions, 19 deletions
diff --git a/cadi/core/src/main/java/org/onap/aaf/cadi/Access.java b/cadi/core/src/main/java/org/onap/aaf/cadi/Access.java index 7a9e63be..83127238 100644 --- a/cadi/core/src/main/java/org/onap/aaf/cadi/Access.java +++ b/cadi/core/src/main/java/org/onap/aaf/cadi/Access.java @@ -37,7 +37,7 @@ import java.util.Properties; public interface Access { // levels to use public enum Level { - DEBUG(0x1), INFO(0x10), AUDIT(0x100), WARN(0x2000), ERROR(0x4000), INIT(0x8000),NONE(0XFFFF); + DEBUG(0x1), INFO(0x10), AUDIT(0x100), WARN(0x2000), ERROR(0x4000), INIT(0x8000),TRACE(0x10000),NONE(0XFFFF); private final int bit; Level(int ord) { 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 bd1ad72d..c827477f 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,12 +31,11 @@ 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 { // 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"); @@ -70,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) { @@ -93,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"; @@ -248,9 +252,13 @@ public class PropAccess implements Access { logIt.push(level,elements); } } - + protected StringBuilder buildMsg(Level level, Object[] elements) { - StringBuilder sb = new StringBuilder(iso8601.format(new Date())); + return buildMsg(name,iso8601,level,elements); + } + + public static StringBuilder buildMsg(final String name, final SimpleDateFormat sdf, Level level, Object[] elements) { + StringBuilder sb = new StringBuilder(sdf.format(new Date())); sb.append(' '); sb.append(level.name()); sb.append(" ["); diff --git a/cadi/core/src/main/java/org/onap/aaf/cadi/Symm.java b/cadi/core/src/main/java/org/onap/aaf/cadi/Symm.java index 65cb81a5..82645c31 100644 --- a/cadi/core/src/main/java/org/onap/aaf/cadi/Symm.java +++ b/cadi/core/src/main/java/org/onap/aaf/cadi/Symm.java @@ -452,7 +452,8 @@ public class Symm { switch(read) { case -1: case '=': - case '\n': + case '\n': + case '\r': return -1; } for(int i=0;i<range.length;++i) { diff --git a/cadi/core/src/main/java/org/onap/aaf/cadi/config/Config.java b/cadi/core/src/main/java/org/onap/aaf/cadi/config/Config.java index 0c011541..0de6f4ef 100644 --- a/cadi/core/src/main/java/org/onap/aaf/cadi/config/Config.java +++ b/cadi/core/src/main/java/org/onap/aaf/cadi/config/Config.java @@ -73,6 +73,7 @@ public class Config { public static final String HOSTNAME = "hostname"; public static final String CADI_PROP_FILES = "cadi_prop_files"; // Additional Properties files (separate with ;) public static final String CADI_LOGLEVEL = "cadi_loglevel"; + public static final String CADI_LOGDIR = "cadi_logdir"; public static final String CADI_LOGNAME = "cadi_logname"; public static final String CADI_KEYFILE = "cadi_keyfile"; public static final String CADI_KEYSTORE = "cadi_keystore"; @@ -82,6 +83,7 @@ public class Config { public static final String CADI_LATITUDE = "cadi_latitude"; public static final String CADI_LONGITUDE = "cadi_longitude"; + public static final String CADI_KEY_PASSWORD = "cadi_key_password"; public static final String CADI_TRUSTSTORE = "cadi_truststore"; public static final String CADI_TRUSTSTORE_PASSWORD = "cadi_truststore_password"; diff --git a/cadi/core/src/test/java/org/onap/aaf/cadi/test/JU_Access.java b/cadi/core/src/test/java/org/onap/aaf/cadi/test/JU_Access.java index d62144ce..98903567 100644 --- a/cadi/core/src/test/java/org/onap/aaf/cadi/test/JU_Access.java +++ b/cadi/core/src/test/java/org/onap/aaf/cadi/test/JU_Access.java @@ -44,7 +44,7 @@ public class JU_Access { assertThat(Level.DEBUG.delFromMask(0x1), is(0x0)); assertThat(Level.DEBUG.toggle(0x2), is(0x3)); assertThat(Level.DEBUG.toggle(0x1), is(0x0)); - assertThat(Level.DEBUG.maskOf(), is(57617)); + assertThat(Level.DEBUG.maskOf(), is(123153)); assertThat(Level.NONE.maskOf(), is(0)); } diff --git a/cadi/core/src/test/java/org/onap/aaf/cadi/test/JU_CmdLine.java b/cadi/core/src/test/java/org/onap/aaf/cadi/test/JU_CmdLine.java index 533fe91f..b2820db2 100644 --- a/cadi/core/src/test/java/org/onap/aaf/cadi/test/JU_CmdLine.java +++ b/cadi/core/src/test/java/org/onap/aaf/cadi/test/JU_CmdLine.java @@ -32,6 +32,7 @@ import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileInputStream; +import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStream; import java.io.PrintStream; @@ -42,6 +43,7 @@ import java.util.Properties; import org.onap.aaf.cadi.CmdLine; import org.onap.aaf.cadi.PropAccess; import org.onap.aaf.cadi.Symm; +import org.onap.aaf.cadi.util.Chmod; public class JU_CmdLine { @@ -67,11 +69,30 @@ public class JU_CmdLine { p.setProperty("force_exit", "false"); CmdLine.access = new PropAccess(p); - - password = "password"; + File test = new File("test"); + if(test.exists()) { + if(!test.isDirectory()) { + test.delete(); + test.mkdirs(); + } + } else { + test.mkdirs(); + } + + File keyF= new File(test,"keyfile"); + if(!keyF.exists()) { + FileOutputStream fos = new FileOutputStream(keyF); + try { + fos.write(Symm.keygen()); + fos.flush(); + } finally { + fos.close(); + } + } keyfile = "test/keyfile"; + password = "password"; - FileInputStream fis = new FileInputStream(keyfile); + FileInputStream fis = new FileInputStream(keyF); try { symm = Symm.obtain(fis); } finally { |