diff options
author | Instrumental <jonathan.gathman@att.com> | 2018-05-24 10:03:19 -0500 |
---|---|---|
committer | Instrumental <jonathan.gathman@att.com> | 2018-05-24 14:11:08 -0500 |
commit | dcaa1072621c7e0f586e2965fd8bb952d4b01880 (patch) | |
tree | 61559dab5fb7287d85d93dc8ac93a488841aaf17 /cadi/core/src/main | |
parent | 2607c2b2cd427616a8f869c809aff19453212f14 (diff) |
Add Cert Cred for aafcli
Issue-ID: AAF-322
Change-Id: I507e43b56922d8c5771a3027deda173be00fa4af
Signed-off-by: Instrumental <jonathan.gathman@att.com>
Diffstat (limited to 'cadi/core/src/main')
-rw-r--r-- | cadi/core/src/main/java/org/onap/aaf/cadi/Symm.java | 33 |
1 files changed, 29 insertions, 4 deletions
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 82645c31..ea3891f9 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 @@ -117,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 * @@ -537,10 +538,10 @@ public class Symm { * @throws CadiException */ public static Symm obtain(Access access) throws CadiException { - Symm symm = Symm.baseCrypt(); - String keyfile = access.getProperty(Config.CADI_KEYFILE,null); if(keyfile!=null) { + Symm symm = Symm.baseCrypt(); + File file = new File(keyfile); try { access.log(Level.INIT, Config.CADI_KEYFILE,"points to",file.getCanonicalPath()); @@ -570,8 +571,14 @@ public class Symm { } throw new CadiException("ERROR: " + filename + " does not exist!"); } + return symm; + } else { + try { + return internalOnly(); + } catch (IOException e) { + throw new CadiException(e); + } } - return symm; } /** * Create a new random key @@ -855,4 +862,22 @@ public class Symm { return newSymm; } + + /** + * This Symm is generated for internal JVM use. It has no external keyfile, but can be used + * for securing Memory, as it remains the same ONLY of the current JVM + * @return + * @throws IOException + */ + public static synchronized Symm internalOnly() throws IOException { + if(internalOnly==null) { + ByteArrayInputStream baos = new ByteArrayInputStream(keygen()); + try { + internalOnly = Symm.obtain(baos); + } finally { + baos.close(); + } + } + return internalOnly; + } } |