X-Git-Url: http://git.megacz.com/?p=org.ibex.core.git;a=blobdiff_plain;f=src%2Forg%2Fbouncycastle%2Fasn1%2Fx509%2FCertificateList.java;h=b658a1a73002833d216bda105faeb41ff2f62758;hp=48703d1cedea2d1c79aa8964ea2a110deecc6816;hb=da1f843588c8bd2b2c7cc74a5b4ffff8d57ab712;hpb=e5e9355b4f4e0e2c8de9068a71c1e3cc26fa9905 diff --git a/src/org/bouncycastle/asn1/x509/CertificateList.java b/src/org/bouncycastle/asn1/x509/CertificateList.java index 48703d1..b658a1a 100644 --- a/src/org/bouncycastle/asn1/x509/CertificateList.java +++ b/src/org/bouncycastle/asn1/x509/CertificateList.java @@ -2,7 +2,6 @@ package org.bouncycastle.asn1.x509; import org.bouncycastle.asn1.*; -import org.bouncycastle.asn1.pkcs.*; /** * PKIX RFC-2459 @@ -17,85 +16,89 @@ import org.bouncycastle.asn1.pkcs.*; * signatureValue BIT STRING } * */ - public class CertificateList - implements DEREncodable + implements DEREncodable { - DERConstructedSequence seq; + TBSCertList tbsCertList; + AlgorithmIdentifier sigAlgId; + DERBitString sig; + + public static CertificateList getInstance( + ASN1TaggedObject obj, + boolean explicit) + { + return getInstance(ASN1Sequence.getInstance(obj, explicit)); + } - TBSCertList tbsCertList; - AlgorithmIdentifier sigAlgId; - DERBitString sig; + public static CertificateList getInstance( + Object obj) + { + if (obj instanceof CertificateList) + { + return (CertificateList)obj; + } + else if (obj instanceof ASN1Sequence) + { + return new CertificateList((ASN1Sequence)obj); + } + + throw new IllegalArgumentException("unknown object in factory"); + } public CertificateList( - DERConstructedSequence seq) + ASN1Sequence seq) { - this.seq = seq; - - if ( seq.getObjectAt(0) instanceof TBSCertList ) - { - tbsCertList = (TBSCertList)seq.getObjectAt(0); - } - else - { - tbsCertList = new TBSCertList((DERConstructedSequence)seq.getObjectAt(0)); - } - - if ( seq.getObjectAt(1) instanceof AlgorithmIdentifier ) - { - sigAlgId = (AlgorithmIdentifier)seq.getObjectAt(1); - } - else - { - sigAlgId = new AlgorithmIdentifier((DERConstructedSequence)seq.getObjectAt(1)); - } - - sig = (DERBitString)seq.getObjectAt(2); - } - - public TBSCertList getTBSCertList() - { - return tbsCertList; - } - - public TBSCertList.CRLEntry[] getRevokedCertificates() - { - return tbsCertList.getRevokedCertificates(); - } - - public AlgorithmIdentifier getSignatureAlgorithm() - { - return sigAlgId; - } - - public DERBitString getSignature() - { - return sig; - } - - public int getVersion() - { - return tbsCertList.getVersion(); - } - - public X509Name getIssuer() - { - return tbsCertList.getIssuer(); - } - - public DERUTCTime getThisUpdate() - { - return tbsCertList.getThisUpdate(); - } - - public DERUTCTime getNextUpdate() - { - return tbsCertList.getNextUpdate(); - } - - public DERObject getDERObject() - { - return seq; - } -} + tbsCertList = TBSCertList.getInstance(seq.getObjectAt(0)); + sigAlgId = AlgorithmIdentifier.getInstance(seq.getObjectAt(1)); + sig = (DERBitString)seq.getObjectAt(2); + } + + public TBSCertList getTBSCertList() + { + return tbsCertList; + } + + public TBSCertList.CRLEntry[] getRevokedCertificates() + { + return tbsCertList.getRevokedCertificates(); + } + public AlgorithmIdentifier getSignatureAlgorithm() + { + return sigAlgId; + } + + public DERBitString getSignature() + { + return sig; + } + + public int getVersion() + { + return tbsCertList.getVersion(); + } + + public X509Name getIssuer() + { + return tbsCertList.getIssuer(); + } + + public Time getThisUpdate() + { + return tbsCertList.getThisUpdate(); + } + + public Time getNextUpdate() + { + return tbsCertList.getNextUpdate(); + } + + public DERObject getDERObject() + { + DERConstructedSequence seq = new DERConstructedSequence(); + seq.addObject(tbsCertList); + seq.addObject(sigAlgId); + seq.addObject(sig); + return seq; + } +}