X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=cadi%2Fcore%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Faaf%2Fcadi%2FSymm.java;h=4067f16090c3e4ecfce7c0a67d25f6aab0b832b5;hb=f85f0889b3b0e5e9694afab4dd01a4a97a155188;hp=095f6e97c5ed58005abd0969bf8712c5f90986c5;hpb=a20accc73189d8e5454cd26049c0e6fae75da16f;p=aaf%2Fauthz.git 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 095f6e97..4067f160 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 @@ -71,6 +71,7 @@ import org.onap.aaf.cadi.config.Config; public class Symm { private static final byte[] DOUBLE_EQ = new byte[] {'=','='}; public static final String ENC = "enc:"; + private static final Object LOCK = new Object(); private static final SecureRandom random = new SecureRandom(); public final char[] codeset; @@ -116,7 +117,8 @@ public class Symm { private static char passChars[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+!@#$%^&*(){}[]?:;,.".toCharArray(); - + private static Symm internalOnly = null; + /** * Use this to create special case Case Sets and/or Line breaks * @@ -136,7 +138,7 @@ public class Symm { // There can be time efficiencies gained when the underlying keyset consists mainly of ordered // data (i.e. abcde...). Therefore, we'll quickly analyze the keyset. If it proves to have // too much entropy, the "Unordered" algorithm, which is faster in such cases is used. - ArrayList la = new ArrayList(); + ArrayList la = new ArrayList<>(); for(int i=0;i T exec(SyncExec exec) throws Exception { - synchronized(ENC) { + synchronized(LOCK) { if(keyBytes == null) { keyBytes = new byte[AES.AES_KEY_SIZE/8]; int offset = (Math.abs(codeset[0])+47)%(codeset.length-keyBytes.length); @@ -388,7 +390,9 @@ public class Symm { } public void decode(InputStream is, OutputStream os, int skip) throws IOException { - is.skip(skip); + if(is.skip(skip)!=skip) { + throw new IOException("Error skipping on IOStream in Symm"); + } decode(is,os); } @@ -446,10 +450,13 @@ public class Symm { this.range = range; } public int convert(int read) throws IOException { + // System.out.print((char)read); switch(read) { case -1: case '=': - case '\n': + case ' ': + case '\n': + case '\r': return -1; } for(int i=0;i