X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=auth%2Fauth-cass%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Faaf%2Fauth%2Fdao%2Fcached%2FFileGetter.java;h=10136272e1e6608b4fb9116e6340189d1062ce0f;hb=0d982409d8931d92e62c88414ece2c48ab5e4b52;hp=702f989a85e30a226ed825e8999b5b432c0540c6;hpb=1296352d8eafee57f982a4342ad79ada4aa56d28;p=aaf%2Fauthz.git diff --git a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cached/FileGetter.java b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cached/FileGetter.java index 702f989a..10136272 100644 --- a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cached/FileGetter.java +++ b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cached/FileGetter.java @@ -43,9 +43,9 @@ import org.onap.aaf.cadi.util.CSV; public class FileGetter { private static final String AAF_FILEGETTER = "aaf_filegetter"; - public static boolean isLoaded = false; + private static boolean isLoaded = false; private static FileGetter singleton; - + private static List EMPTY = new ArrayList<>(); private Map> data; private SimpleDateFormat sdf; private FileGetter(Access access) { @@ -71,12 +71,19 @@ public class FileGetter { if(CredDAO.CERT_SHA256_RSA == type) { return; } + byte ba[]; CredDAO.Data cdd = new CredDAO.Data(); cdd.id=row.get(0); cdd.type = type; try { cdd.expires = sdf.parse(row.get(2)); - cdd.cred = ByteBuffer.wrap(Hash.fromHex(row.get(3))); + // Note: Note sure this can be null, but throwing was + // part of original "fromHex" method. Remove if you can + // prove ba will never be null J - May 19,2020 + if((ba=Hash.fromHex(row.get(3)))==null) { + throw new CadiException("Invalid Cred"); + } + cdd.cred = ByteBuffer.wrap(ba); cdd.notes= row.get(4); cdd.ns = row.get(5); cdd.other = Integer.parseInt(row.get(6)); @@ -110,12 +117,12 @@ public class FileGetter { singleton = new FileGetter(access); } return singleton; - } + public Getter getter(String id) { return new FGetter(id); } - private static List EMPTY = new ArrayList<>(); + public class FGetter implements Getter { private final List lcdd; public FGetter(final String id) { @@ -129,7 +136,7 @@ public class FileGetter { public static void main(String[] args) { PropAccess access = new PropAccess(args); - access.setProperty(AAF_FILEGETTER,"/Users/jg1555/cred.dat"); + access.setProperty(AAF_FILEGETTER,"/opt/app/aaf/data/cred.dat"); FileGetter fg = FileGetter.singleton(access); for(String id : new String[] {"m01891@aaf.att.com","bogus"}) { @@ -142,5 +149,9 @@ public class FileGetter { } } } + + public static boolean isLoaded() { + return isLoaded; + } }