01: package org.bouncycastle.asn1.ocsp;
02:
03: import java.util.Enumeration;
04:
05: import org.bouncycastle.asn1.*;
06:
07: public class CrlID extends ASN1Encodable {
08: DERIA5String crlUrl;
09: DERInteger crlNum;
10: DERGeneralizedTime crlTime;
11:
12: public CrlID(ASN1Sequence seq) {
13: Enumeration e = seq.getObjects();
14:
15: while (e.hasMoreElements()) {
16: ASN1TaggedObject o = (ASN1TaggedObject) e.nextElement();
17:
18: switch (o.getTagNo()) {
19: case 0:
20: crlUrl = DERIA5String.getInstance(o, true);
21: break;
22: case 1:
23: crlNum = DERInteger.getInstance(o, true);
24: break;
25: case 2:
26: crlTime = DERGeneralizedTime.getInstance(o, true);
27: break;
28: default:
29: throw new IllegalArgumentException(
30: "unknown tag number: " + o.getTagNo());
31: }
32: }
33: }
34:
35: public DERIA5String getCrlUrl() {
36: return crlUrl;
37: }
38:
39: public DERInteger getCrlNum() {
40: return crlNum;
41: }
42:
43: public DERGeneralizedTime getCrlTime() {
44: return crlTime;
45: }
46:
47: /**
48: * Produce an object suitable for an ASN1OutputStream.
49: * <pre>
50: * CrlID ::= SEQUENCE {
51: * crlUrl [0] EXPLICIT IA5String OPTIONAL,
52: * crlNum [1] EXPLICIT INTEGER OPTIONAL,
53: * crlTime [2] EXPLICIT GeneralizedTime OPTIONAL }
54: * </pre>
55: */
56: public DERObject toASN1Object() {
57: ASN1EncodableVector v = new ASN1EncodableVector();
58:
59: if (crlUrl != null) {
60: v.add(new DERTaggedObject(true, 0, crlUrl));
61: }
62:
63: if (crlNum != null) {
64: v.add(new DERTaggedObject(true, 1, crlNum));
65: }
66:
67: if (crlTime != null) {
68: v.add(new DERTaggedObject(true, 2, crlTime));
69: }
70:
71: return new DERSequence(v);
72: }
73: }
|