diff options
Diffstat (limited to 'auth/auth-certman/src')
3 files changed, 21 insertions, 12 deletions
diff --git a/auth/auth-certman/src/main/java/org/onap/aaf/auth/cm/AAF_CM.java b/auth/auth-certman/src/main/java/org/onap/aaf/auth/cm/AAF_CM.java index bfdb977d..3727e34d 100644 --- a/auth/auth-certman/src/main/java/org/onap/aaf/auth/cm/AAF_CM.java +++ b/auth/auth-certman/src/main/java/org/onap/aaf/auth/cm/AAF_CM.java @@ -23,6 +23,7 @@ package org.onap.aaf.auth.cm; import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; import java.util.Map; import java.util.Map.Entry; import java.util.TreeMap; @@ -139,8 +140,12 @@ public class AAF_CM extends AbsService<AuthzEnv, AuthzTrans> { pinst[1]= key.substring(idx+1); pinst[2]= aafEnv; pinst[3] = multiParams; - CA ca = cons.newInstance(pinst); - certAuths.put(ca.getName(),ca); + try { + CA ca = cons.newInstance(pinst); + certAuths.put(ca.getName(),ca); + } catch (InvocationTargetException e) { + access.log(e, "Loading", segs[0]); + } } } } @@ -225,7 +230,7 @@ public class AAF_CM extends AbsService<AuthzEnv, AuthzTrans> { @Override public Registrant<AuthzEnv>[] registrants(final int port) throws CadiException, LocatorException { return new Registrant[] { - new DirectRegistrar(access,locateDAO,app_name,app_version,port) + new DirectRegistrar(access,locateDAO,port) }; } @@ -236,16 +241,19 @@ public class AAF_CM extends AbsService<AuthzEnv, AuthzTrans> { } public static void main(final String[] args) { - try { Log4JLogIt logIt = new Log4JLogIt(args, "cm"); PropAccess propAccess = new PropAccess(logIt,args); - AAF_CM service = new AAF_CM(new AuthzEnv(propAccess)); - JettyServiceStarter<AuthzEnv,AuthzTrans> jss = new JettyServiceStarter<AuthzEnv,AuthzTrans>(service); - jss.start(); - } catch (Exception e) { - envLog.error().log(e); + try { + AAF_CM service = new AAF_CM(new AuthzEnv(propAccess)); + JettyServiceStarter<AuthzEnv,AuthzTrans> jss = new JettyServiceStarter<AuthzEnv,AuthzTrans>(service); + jss.start(); + } catch (Exception e) { + propAccess.log(e); + } + } catch (APIException e) { + e.printStackTrace(System.err); } } } diff --git a/auth/auth-certman/src/main/java/org/onap/aaf/auth/cm/ca/LocalCA.java b/auth/auth-certman/src/main/java/org/onap/aaf/auth/cm/ca/LocalCA.java index da634868..08c96853 100644 --- a/auth/auth-certman/src/main/java/org/onap/aaf/auth/cm/ca/LocalCA.java +++ b/auth/auth-certman/src/main/java/org/onap/aaf/auth/cm/ca/LocalCA.java @@ -150,7 +150,7 @@ public class LocalCA extends CA { try { String pass = access.decrypt(params[0][2]/*encrypted passcode*/, true); - if (pass==null) { + if (pass==null || pass.isEmpty()) { throw new CertException("Passcode for " + fileName + " cannot be decrypted."); } char[] ksPass = pass.toCharArray(); @@ -159,8 +159,9 @@ public class LocalCA extends CA { keyStore.load(fis,ksPass); } finally { - if (fis != null) + if (fis != null) { fis.close(); + } } Entry entry; if (fileName.endsWith(".pkcs11")) { diff --git a/auth/auth-certman/src/test/java/org/onap/aaf/auth/cm/JU_AAF_CM.java b/auth/auth-certman/src/test/java/org/onap/aaf/auth/cm/JU_AAF_CM.java index e770fec7..58efa2a0 100644 --- a/auth/auth-certman/src/test/java/org/onap/aaf/auth/cm/JU_AAF_CM.java +++ b/auth/auth-certman/src/test/java/org/onap/aaf/auth/cm/JU_AAF_CM.java @@ -86,7 +86,7 @@ public class JU_AAF_CM { Properties props=new Properties(); Mockito.doReturn(props).when(access).getProperties(); props.setProperty("cm_ca.props", "test"); - Mockito.doReturn("test:2.1").when(access).getProperty(Config.AAF_COMPONENT, null); + Mockito.doReturn("test:2.1").when(access).getProperty(Config.AAF_LOCATOR_NAMES, null); Mockito.doReturn("test").when(access).getProperty("https.protocols","TLSv1.1,TLSv1.2"); Mockito.doReturn("test").when(env).getProperty("cm_ca.props.perm_type",null); Mockito.doReturn("test").when(env).getProperty("cm_ca.props.baseSubject",null); |