2002/03/21 01:19:32
[org.ibex.core.git] / src / org / bouncycastle / asn1 / x509 / CertificateList.java
1
2 package org.bouncycastle.asn1.x509;
3
4 import org.bouncycastle.asn1.*;
5 import org.bouncycastle.asn1.pkcs.*;
6
7 /**
8  * PKIX RFC-2459
9  *
10  * The X.509 v2 CRL syntax is as follows.  For signature calculation,
11  * the data that is to be signed is ASN.1 DER encoded.
12  *
13  * <pre>
14  * CertificateList  ::=  SEQUENCE  {
15  *      tbsCertList          TBSCertList,
16  *      signatureAlgorithm   AlgorithmIdentifier,
17  *      signatureValue       BIT STRING  }
18  * </pre>
19  */
20
21 public class CertificateList
22         implements DEREncodable
23 {
24         DERConstructedSequence seq;
25
26         TBSCertList                     tbsCertList;
27         AlgorithmIdentifier     sigAlgId;
28         DERBitString            sig;
29
30     public CertificateList(
31         DERConstructedSequence seq)
32     {
33                 this.seq = seq;
34
35                 if ( seq.getObjectAt(0) instanceof TBSCertList )
36                 {
37                         tbsCertList = (TBSCertList)seq.getObjectAt(0);
38                 }
39                 else
40                 {
41                         tbsCertList = new TBSCertList((DERConstructedSequence)seq.getObjectAt(0));
42                 }
43
44                 if ( seq.getObjectAt(1) instanceof AlgorithmIdentifier )
45                 {
46                         sigAlgId = (AlgorithmIdentifier)seq.getObjectAt(1);
47                 }
48                 else
49                 {
50                         sigAlgId = new AlgorithmIdentifier((DERConstructedSequence)seq.getObjectAt(1));
51                 }
52
53                 sig = (DERBitString)seq.getObjectAt(2);
54         }
55
56         public TBSCertList getTBSCertList()
57         {
58                 return tbsCertList;
59         }
60
61         public TBSCertList.CRLEntry[] getRevokedCertificates()
62         {
63                 return tbsCertList.getRevokedCertificates();
64         }
65
66         public AlgorithmIdentifier getSignatureAlgorithm()
67         {
68                 return sigAlgId;
69         }
70
71         public DERBitString getSignature()
72         {
73                 return sig;
74         }
75
76         public int getVersion()
77         {
78                 return tbsCertList.getVersion();
79         }
80
81         public X509Name getIssuer()
82         {
83                 return tbsCertList.getIssuer();
84         }
85
86         public DERUTCTime getThisUpdate()
87         {
88                 return tbsCertList.getThisUpdate();
89         }
90
91         public DERUTCTime getNextUpdate()
92         {
93                 return tbsCertList.getNextUpdate();
94         }
95
96         public DERObject getDERObject()
97         {
98                 return seq;
99         }
100 }
101