01: package org.bouncycastle.asn1.x509;
02:
03: import org.bouncycastle.asn1.ASN1Encodable;
04: import org.bouncycastle.asn1.ASN1EncodableVector;
05: import org.bouncycastle.asn1.ASN1Sequence;
06: import org.bouncycastle.asn1.ASN1TaggedObject;
07: import org.bouncycastle.asn1.DERBitString;
08: import org.bouncycastle.asn1.DERObject;
09: import org.bouncycastle.asn1.DERSequence;
10:
11: /**
12: * PKIX RFC-2459
13: *
14: * The X.509 v2 CRL syntax is as follows. For signature calculation,
15: * the data that is to be signed is ASN.1 DER encoded.
16: *
17: * <pre>
18: * CertificateList ::= SEQUENCE {
19: * tbsCertList TBSCertList,
20: * signatureAlgorithm AlgorithmIdentifier,
21: * signatureValue BIT STRING }
22: * </pre>
23: */
24: public class CertificateList extends ASN1Encodable {
25: TBSCertList tbsCertList;
26: AlgorithmIdentifier sigAlgId;
27: DERBitString sig;
28:
29: public static CertificateList getInstance(ASN1TaggedObject obj,
30: boolean explicit) {
31: return getInstance(ASN1Sequence.getInstance(obj, explicit));
32: }
33:
34: public static CertificateList getInstance(Object obj) {
35: if (obj instanceof CertificateList) {
36: return (CertificateList) obj;
37: } else if (obj instanceof ASN1Sequence) {
38: return new CertificateList((ASN1Sequence) obj);
39: }
40:
41: throw new IllegalArgumentException("unknown object in factory");
42: }
43:
44: public CertificateList(ASN1Sequence seq) {
45: if (seq.size() == 3) {
46: tbsCertList = TBSCertList.getInstance(seq.getObjectAt(0));
47: sigAlgId = AlgorithmIdentifier.getInstance(seq
48: .getObjectAt(1));
49: sig = DERBitString.getInstance(seq.getObjectAt(2));
50: } else {
51: throw new IllegalArgumentException(
52: "sequence wrong size for CertificateList");
53: }
54: }
55:
56: public TBSCertList getTBSCertList() {
57: return tbsCertList;
58: }
59:
60: public TBSCertList.CRLEntry[] getRevokedCertificates() {
61: return tbsCertList.getRevokedCertificates();
62: }
63:
64: public AlgorithmIdentifier getSignatureAlgorithm() {
65: return sigAlgId;
66: }
67:
68: public DERBitString getSignature() {
69: return sig;
70: }
71:
72: public int getVersion() {
73: return tbsCertList.getVersion();
74: }
75:
76: public X509Name getIssuer() {
77: return tbsCertList.getIssuer();
78: }
79:
80: public Time getThisUpdate() {
81: return tbsCertList.getThisUpdate();
82: }
83:
84: public Time getNextUpdate() {
85: return tbsCertList.getNextUpdate();
86: }
87:
88: public DERObject toASN1Object() {
89: ASN1EncodableVector v = new ASN1EncodableVector();
90:
91: v.add(tbsCertList);
92: v.add(sigAlgId);
93: v.add(sig);
94:
95: return new DERSequence(v);
96: }
97: }
|