X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=auth%2Fauth-certman%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Faaf%2Fauth%2Fcm%2Fca%2FCA.java;h=f1f70a7ec5678fe4ff3cc7dba4bdfbe3d94aa8d2;hb=32cdd553a8668e6d03a9cf5b11b360d35a63c87f;hp=ea7264802fedd56da513a2f3e9be399246da7f9c;hpb=1be676f478440ad014c4b6ba762a95cff4fbd19d;p=aaf%2Fauthz.git diff --git a/auth/auth-certman/src/main/java/org/onap/aaf/auth/cm/ca/CA.java b/auth/auth-certman/src/main/java/org/onap/aaf/auth/cm/ca/CA.java index ea726480..f1f70a7e 100644 --- a/auth/auth-certman/src/main/java/org/onap/aaf/auth/cm/ca/CA.java +++ b/auth/auth-certman/src/main/java/org/onap/aaf/auth/cm/ca/CA.java @@ -36,7 +36,8 @@ import org.onap.aaf.auth.cm.cert.CSRMeta; import org.onap.aaf.auth.cm.cert.RDN; import org.onap.aaf.cadi.Access; import org.onap.aaf.cadi.Access.Level; -import org.onap.aaf.cadi.cm.CertException; +import org.onap.aaf.cadi.config.Config; +import org.onap.aaf.cadi.configure.CertException; import org.onap.aaf.misc.env.Trans; import org.onap.aaf.misc.env.util.Split; @@ -50,28 +51,30 @@ public abstract class CA { private static final String CM_TRUST_CAS = "cm_trust_cas"; protected static final String CM_BACKUP_CAS = "cm_backup_cas"; - public static final Set EMPTY = Collections.unmodifiableSet(new HashSet()); + public static final Set EMPTY = Collections.unmodifiableSet(new HashSet<>()); private final String name; private final String env; private MessageDigest messageDigest; + private final String permNS; private final String permType; - private Set caIssuerDNs; private final ArrayList idDomains; private String[] trustedCAs; - private List rdns; + private String[] caIssuerDNs; + private List rdns; protected CA(Access access, String caName, String env) throws IOException, CertException { trustedCAs = new String[4]; // starting array this.name = caName; this.env = env; - permType = access.getProperty(CM_CA_PREFIX + name + ".perm_type",null); + permNS = CM_CA_PREFIX + name; + permType = access.getProperty(permNS + ".perm_type",null); if(permType==null) { - throw new CertException(CM_CA_PREFIX + name + ".perm_type" + MUST_EXIST_TO_CREATE_CSRS_FOR + caName); + throw new CertException(permNS + ".perm_type" + MUST_EXIST_TO_CREATE_CSRS_FOR + caName); } - caIssuerDNs = new HashSet<>(); + caIssuerDNs = Split.splitTrim(':', access.getProperty(Config.CADI_X509_ISSUERS, null)); String tag = CA.CM_CA_PREFIX+caName+CA.CM_CA_BASE_SUBJECT; @@ -112,7 +115,12 @@ public abstract class CA { String trustCas = access.getProperty(CM_TRUST_CAS,null); if(trustCas!=null) { for(String fname : Split.splitTrim(',', trustCas)) { - File crt = new File(data,fname); + File crt; + if(fname.contains("/")) { + crt = new File(fname); + } else { + crt = new File(data,fname); + } if(crt.exists()) { access.printf(Level.INIT, "Loading CA Cert from %s", crt.getAbsolutePath()); bytes = new byte[(int)crt.length()]; @@ -139,7 +147,19 @@ public abstract class CA { } protected void addCaIssuerDN(String issuerDN) { - caIssuerDNs.add(issuerDN); + boolean changed = true; + for(String id : caIssuerDNs) { + if(id.equals(issuerDN)) { + changed = false; + break; + } + } + if(changed) { + String[] newsa = new String[caIssuerDNs.length+1]; + newsa[0]=issuerDN; + System.arraycopy(caIssuerDNs, 0, newsa, 1, caIssuerDNs.length); + caIssuerDNs = newsa; + } } protected synchronized void addTrustedCA(final String crtString) { @@ -161,7 +181,7 @@ public abstract class CA { trustedCAs = temp; } - public Set getCaIssuerDNs() { + public String[] getCaIssuerDNs() { return caIssuerDNs; } @@ -186,6 +206,10 @@ public abstract class CA { } + public String getPermNS() { + return permNS; + } + public String getPermType() { return permType; } @@ -211,4 +235,5 @@ public abstract class CA { public CSRMeta newCSRMeta() { return new CSRMeta(rdns); } + }