1b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallampackage org.bouncycastle.asn1.x509;
2b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam
36e736056d64d0e33b26cf9f7c4e351b496241fdeBrian Carlstromimport java.util.Enumeration;
46e736056d64d0e33b26cf9f7c4e351b496241fdeBrian Carlstrom
5b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallamimport org.bouncycastle.asn1.ASN1Encodable;
6b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallamimport org.bouncycastle.asn1.ASN1Sequence;
7b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallamimport org.bouncycastle.asn1.ASN1TaggedObject;
8b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallamimport org.bouncycastle.asn1.DERGeneralizedTime;
9b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallamimport org.bouncycastle.asn1.DERInteger;
10b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallamimport org.bouncycastle.asn1.DERObject;
11b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallamimport org.bouncycastle.asn1.DERTaggedObject;
12b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallamimport org.bouncycastle.asn1.DERUTCTime;
13b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam
14b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam/**
15b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam * PKIX RFC-2459 - TBSCertList object.
16b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam * <pre>
17b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam * TBSCertList  ::=  SEQUENCE  {
18b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam *      version                 Version OPTIONAL,
19b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam *                                   -- if present, shall be v2
20b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam *      signature               AlgorithmIdentifier,
21b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam *      issuer                  Name,
22b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam *      thisUpdate              Time,
23b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam *      nextUpdate              Time OPTIONAL,
24b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam *      revokedCertificates     SEQUENCE OF SEQUENCE  {
25b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam *           userCertificate         CertificateSerialNumber,
26b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam *           revocationDate          Time,
27b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam *           crlEntryExtensions      Extensions OPTIONAL
28b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam *                                         -- if present, shall be v2
29b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam *                                }  OPTIONAL,
30b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam *      crlExtensions           [0]  EXPLICIT Extensions OPTIONAL
31b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam *                                         -- if present, shall be v2
32b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam *                                }
33b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam * </pre>
34b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam */
35b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallampublic class TBSCertList
36b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam    extends ASN1Encodable
37b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam{
386e736056d64d0e33b26cf9f7c4e351b496241fdeBrian Carlstrom    public static class CRLEntry
39b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam        extends ASN1Encodable
40b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam    {
41b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam        ASN1Sequence  seq;
42b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam
43b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam        DERInteger          userCertificate;
44b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam        Time                revocationDate;
45b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam        X509Extensions      crlEntryExtensions;
46b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam
47b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam        public CRLEntry(
48b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam            ASN1Sequence  seq)
49b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam        {
50b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam            if (seq.size() < 2 || seq.size() > 3)
51b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam            {
52b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam                throw new IllegalArgumentException("Bad sequence size: " + seq.size());
53b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam            }
54b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam
55b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam            this.seq = seq;
56b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam
57b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam            userCertificate = DERInteger.getInstance(seq.getObjectAt(0));
58b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam            revocationDate = Time.getInstance(seq.getObjectAt(1));
59b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam        }
60b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam
61b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam        public DERInteger getUserCertificate()
62b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam        {
63b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam            return userCertificate;
64b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam        }
65b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam
66b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam        public Time getRevocationDate()
67b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam        {
68b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam            return revocationDate;
69b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam        }
70b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam
71b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam        public X509Extensions getExtensions()
72b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam        {
73c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom            if (crlEntryExtensions == null && seq.size() == 3)
74c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom            {
75c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom                crlEntryExtensions = X509Extensions.getInstance(seq.getObjectAt(2));
76c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom            }
77c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom
78b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam            return crlEntryExtensions;
79b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam        }
80b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam
81b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam        public DERObject toASN1Object()
82b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam        {
83b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam            return seq;
84b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam        }
85b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam    }
86b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam
87c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom    private class RevokedCertificatesEnumeration
88c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom        implements Enumeration
89c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom    {
90c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom        private final Enumeration en;
91c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom
92c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom        RevokedCertificatesEnumeration(Enumeration en)
93c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom        {
94c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom            this.en = en;
95c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom        }
96c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom
97c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom        public boolean hasMoreElements()
98c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom        {
99c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom            return en.hasMoreElements();
100c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom        }
101c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom
102c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom        public Object nextElement()
103c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom        {
104c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom            return new CRLEntry(ASN1Sequence.getInstance(en.nextElement()));
105c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom        }
106c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom    }
107c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom
108c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom    private class EmptyEnumeration
109c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom        implements Enumeration
110c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom    {
111c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom        public boolean hasMoreElements()
112c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom        {
113c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom            return false;
114c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom        }
115c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom
116c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom        public Object nextElement()
117c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom        {
118c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom            return null;   // TODO: check exception handling
119c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom        }
120c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom    }
121c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom
122b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam    ASN1Sequence     seq;
123b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam
124b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam    DERInteger              version;
125b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam    AlgorithmIdentifier     signature;
126b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam    X509Name                issuer;
127b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam    Time                    thisUpdate;
128b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam    Time                    nextUpdate;
129c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom    ASN1Sequence            revokedCertificates;
130b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam    X509Extensions          crlExtensions;
131b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam
132b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam    public static TBSCertList getInstance(
133b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam        ASN1TaggedObject obj,
134b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam        boolean          explicit)
135b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam    {
136b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam        return getInstance(ASN1Sequence.getInstance(obj, explicit));
137b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam    }
138b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam
139b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam    public static TBSCertList getInstance(
140b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam        Object  obj)
141b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam    {
142b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam        if (obj instanceof TBSCertList)
143b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam        {
144b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam            return (TBSCertList)obj;
145b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam        }
146b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam        else if (obj instanceof ASN1Sequence)
147b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam        {
148b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam            return new TBSCertList((ASN1Sequence)obj);
149b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam        }
150b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam
151c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom        throw new IllegalArgumentException("unknown object in factory: " + obj.getClass().getName());
152b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam    }
153b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam
154b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam    public TBSCertList(
155b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam        ASN1Sequence  seq)
156b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam    {
157b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam        if (seq.size() < 3 || seq.size() > 7)
158b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam        {
159b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam            throw new IllegalArgumentException("Bad sequence size: " + seq.size());
160b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam        }
161b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam
162b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam        int seqPos = 0;
163b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam
164b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam        this.seq = seq;
165b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam
166b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam        if (seq.getObjectAt(seqPos) instanceof DERInteger)
167b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam        {
168b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam            version = DERInteger.getInstance(seq.getObjectAt(seqPos++));
169b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam        }
170b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam        else
171b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam        {
172b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam            version = new DERInteger(0);
173b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam        }
174b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam
175b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam        signature = AlgorithmIdentifier.getInstance(seq.getObjectAt(seqPos++));
176b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam        issuer = X509Name.getInstance(seq.getObjectAt(seqPos++));
177b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam        thisUpdate = Time.getInstance(seq.getObjectAt(seqPos++));
178b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam
179b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam        if (seqPos < seq.size()
180b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam            && (seq.getObjectAt(seqPos) instanceof DERUTCTime
181b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam               || seq.getObjectAt(seqPos) instanceof DERGeneralizedTime
182b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam               || seq.getObjectAt(seqPos) instanceof Time))
183b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam        {
184b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam            nextUpdate = Time.getInstance(seq.getObjectAt(seqPos++));
185b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam        }
186b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam
187b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam        if (seqPos < seq.size()
188b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam            && !(seq.getObjectAt(seqPos) instanceof DERTaggedObject))
189b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam        {
190c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom            revokedCertificates = ASN1Sequence.getInstance(seq.getObjectAt(seqPos++));
191b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam        }
192b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam
193b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam        if (seqPos < seq.size()
194b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam            && seq.getObjectAt(seqPos) instanceof DERTaggedObject)
195b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam        {
196c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom            crlExtensions = X509Extensions.getInstance(seq.getObjectAt(seqPos));
197b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam        }
198b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam    }
199b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam
200b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam    public int getVersion()
201b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam    {
202b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam        return version.getValue().intValue() + 1;
203b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam    }
204b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam
205b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam    public DERInteger getVersionNumber()
206b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam    {
207b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam        return version;
208b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam    }
209b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam
210b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam    public AlgorithmIdentifier getSignature()
211b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam    {
212b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam        return signature;
213b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam    }
214b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam
215b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam    public X509Name getIssuer()
216b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam    {
217b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam        return issuer;
218b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam    }
219b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam
220b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam    public Time getThisUpdate()
221b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam    {
222b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam        return thisUpdate;
223b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam    }
224b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam
225b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam    public Time getNextUpdate()
226b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam    {
227b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam        return nextUpdate;
228b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam    }
229b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam
230b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam    public CRLEntry[] getRevokedCertificates()
231b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam    {
232c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom        if (revokedCertificates == null)
233c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom        {
234c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom            return new CRLEntry[0];
235c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom        }
236c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom
237c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom        CRLEntry[] entries = new CRLEntry[revokedCertificates.size()];
238c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom
239c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom        for (int i = 0; i < entries.length; i++)
240c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom        {
241c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom            entries[i] = new CRLEntry(ASN1Sequence.getInstance(revokedCertificates.getObjectAt(i)));
242c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom        }
243c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom
244c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom        return entries;
245c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom    }
246c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom
247c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom    public Enumeration getRevokedCertificateEnumeration()
248c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom    {
249c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom        if (revokedCertificates == null)
250c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom        {
251c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom            return new EmptyEnumeration();
252c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom        }
253c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom
254c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom        return new RevokedCertificatesEnumeration(revokedCertificates.getObjects());
255b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam    }
256b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam
257b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam    public X509Extensions getExtensions()
258b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam    {
259b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam        return crlExtensions;
260b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam    }
261b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam
262b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam    public DERObject toASN1Object()
263b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam    {
264b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam        return seq;
265b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam    }
266b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam}
267