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%2FX509ChainWithIssuer.java;h=fde94b429f6bc21fa7cc17f9dfb369cd30d9c81f;hb=1296352d8eafee57f982a4342ad79ada4aa56d28;hp=e31b99889108aab0ea5b84c3cf6ba0981a64ac10;hpb=6261a19e61138e861f5c7eaf37835205f19f1fe0;p=aaf%2Fauthz.git diff --git a/auth/auth-certman/src/main/java/org/onap/aaf/auth/cm/ca/X509ChainWithIssuer.java b/auth/auth-certman/src/main/java/org/onap/aaf/auth/cm/ca/X509ChainWithIssuer.java index e31b9988..fde94b42 100644 --- a/auth/auth-certman/src/main/java/org/onap/aaf/auth/cm/ca/X509ChainWithIssuer.java +++ b/auth/auth-certman/src/main/java/org/onap/aaf/auth/cm/ca/X509ChainWithIssuer.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -33,61 +33,61 @@ import org.onap.aaf.cadi.configure.CertException; import org.onap.aaf.cadi.configure.Factory; public class X509ChainWithIssuer extends X509andChain { - private String issuerDN; - public X509Certificate caX509; + private String issuerDN; + public X509Certificate caX509; + + public X509ChainWithIssuer(X509ChainWithIssuer orig, X509Certificate x509) { + super(x509,orig.trustChain); + issuerDN=orig.issuerDN; + } + + public X509ChainWithIssuer(final List rdrs) throws IOException, CertException { + // Trust Chain. Last one should be the CA + Collection certs; + X509Certificate x509; + for (Reader rdr : rdrs) { + if (rdr==null) { // cover for badly formed array + continue; + } + + byte[] bytes = Factory.decode(rdr,null); + try { + certs = Factory.toX509Certificate(bytes); + } catch (CertificateException e) { + throw new CertException(e); + } + for (Certificate c : certs) { + x509=(X509Certificate)c; + Principal subject = x509.getSubjectDN(); + if (subject==null) { + continue; + } + if (cert==null) { // first in Trust Chain + issuerDN = subject.toString(); + cert=x509; // adding each time makes sure last one is signer. + } + addTrustChainEntry(x509); + } + } + } - public X509ChainWithIssuer(X509ChainWithIssuer orig, X509Certificate x509) throws IOException, CertException { - super(x509,orig.trustChain); - issuerDN=orig.issuerDN; - } - - public X509ChainWithIssuer(final List rdrs) throws IOException, CertException { - // Trust Chain. Last one should be the CA - Collection certs; - X509Certificate x509; - for(Reader rdr : rdrs) { - if(rdr==null) { // cover for badly formed array - continue; - } - - byte[] bytes = Factory.decode(rdr,null); - try { - certs = Factory.toX509Certificate(bytes); - } catch (CertificateException e) { - throw new CertException(e); - } - for(Certificate c : certs) { - x509=(X509Certificate)c; - Principal subject = x509.getSubjectDN(); - if(subject==null) { - continue; - } - if(cert==null) { // first in Trust Chain - issuerDN = subject.toString(); - cert=x509; // adding each time makes sure last one is signer. - } - addTrustChainEntry(x509); - } - } - } - - public X509ChainWithIssuer(Certificate[] certs) throws IOException, CertException { - X509Certificate x509; - for(int i=certs.length-1; i>=0; --i) { - x509=(X509Certificate)certs[i]; - Principal subject = x509.getSubjectDN(); - if(subject!=null) { - addTrustChainEntry(x509); - if(i==0) { // last one is signer - cert=x509; - issuerDN= subject.toString(); - } - } - } - } + public X509ChainWithIssuer(Certificate[] certs) throws IOException, CertException { + X509Certificate x509; + for (int i=certs.length-1; i>=0; --i) { + x509=(X509Certificate)certs[i]; + Principal subject = x509.getSubjectDN(); + if (subject!=null) { + addTrustChainEntry(x509); + if (i==0) { // last one is signer + cert=x509; + issuerDN= subject.toString(); + } + } + } + } - public String getIssuerDN() { - return issuerDN; - } + public String getIssuerDN() { + return issuerDN; + } } \ No newline at end of file