01: package org.bouncycastle.asn1.ocsp;
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.DEREnumerated;
08: import org.bouncycastle.asn1.DERGeneralizedTime;
09: import org.bouncycastle.asn1.DERObject;
10: import org.bouncycastle.asn1.DERSequence;
11: import org.bouncycastle.asn1.DERTaggedObject;
12: import org.bouncycastle.asn1.x509.CRLReason;
13:
14: public class RevokedInfo extends ASN1Encodable {
15: private DERGeneralizedTime revocationTime;
16: private CRLReason revocationReason;
17:
18: public RevokedInfo(DERGeneralizedTime revocationTime,
19: CRLReason revocationReason) {
20: this .revocationTime = revocationTime;
21: this .revocationReason = revocationReason;
22: }
23:
24: public RevokedInfo(ASN1Sequence seq) {
25: this .revocationTime = (DERGeneralizedTime) seq.getObjectAt(0);
26:
27: if (seq.size() > 1) {
28: this .revocationReason = new CRLReason(DEREnumerated
29: .getInstance((ASN1TaggedObject) seq.getObjectAt(1),
30: true));
31: }
32: }
33:
34: public static RevokedInfo getInstance(ASN1TaggedObject obj,
35: boolean explicit) {
36: return getInstance(ASN1Sequence.getInstance(obj, explicit));
37: }
38:
39: public static RevokedInfo getInstance(Object obj) {
40: if (obj == null || obj instanceof RevokedInfo) {
41: return (RevokedInfo) obj;
42: } else if (obj instanceof ASN1Sequence) {
43: return new RevokedInfo((ASN1Sequence) obj);
44: }
45:
46: throw new IllegalArgumentException("unknown object in factory");
47: }
48:
49: public DERGeneralizedTime getRevocationTime() {
50: return revocationTime;
51: }
52:
53: public CRLReason getRevocationReason() {
54: return revocationReason;
55: }
56:
57: /**
58: * Produce an object suitable for an ASN1OutputStream.
59: * <pre>
60: * RevokedInfo ::= SEQUENCE {
61: * revocationTime GeneralizedTime,
62: * revocationReason [0] EXPLICIT CRLReason OPTIONAL }
63: * </pre>
64: */
65: public DERObject toASN1Object() {
66: ASN1EncodableVector v = new ASN1EncodableVector();
67:
68: v.add(revocationTime);
69: if (revocationReason != null) {
70: v.add(new DERTaggedObject(true, 0, revocationReason));
71: }
72:
73: return new DERSequence(v);
74: }
75: }
|