01: package org.bouncycastle.asn1.cmp;
02:
03: import org.bouncycastle.asn1.ASN1Encodable;
04: import org.bouncycastle.asn1.ASN1EncodableVector;
05: import org.bouncycastle.asn1.ASN1Sequence;
06: import org.bouncycastle.asn1.DERGeneralizedTime;
07: import org.bouncycastle.asn1.DERObject;
08: import org.bouncycastle.asn1.DERSequence;
09: import org.bouncycastle.asn1.crmf.CertId;
10: import org.bouncycastle.asn1.x509.X509Extensions;
11:
12: public class RevAnnContent extends ASN1Encodable {
13: private PKIStatus status;
14: private CertId certId;
15: private DERGeneralizedTime willBeRevokedAt;
16: private DERGeneralizedTime badSinceDate;
17: private X509Extensions crlDetails;
18:
19: private RevAnnContent(ASN1Sequence seq) {
20: status = PKIStatus.getInstance(seq.getObjectAt(0));
21: certId = CertId.getInstance(seq.getObjectAt(1));
22: willBeRevokedAt = DERGeneralizedTime.getInstance(seq
23: .getObjectAt(2));
24: badSinceDate = DERGeneralizedTime.getInstance(seq
25: .getObjectAt(3));
26:
27: if (seq.size() > 4) {
28: crlDetails = X509Extensions.getInstance(seq.getObjectAt(4));
29: }
30: }
31:
32: public static RevAnnContent getInstance(Object o) {
33: if (o instanceof RevAnnContent) {
34: return (RevAnnContent) o;
35: }
36:
37: if (o instanceof ASN1Sequence) {
38: return new RevAnnContent((ASN1Sequence) o);
39: }
40:
41: throw new IllegalArgumentException("Invalid object: "
42: + o.getClass().getName());
43: }
44:
45: public PKIStatus getStatus() {
46: return status;
47: }
48:
49: public CertId getCertId() {
50: return certId;
51: }
52:
53: public DERGeneralizedTime getWillBeRevokedAt() {
54: return willBeRevokedAt;
55: }
56:
57: public DERGeneralizedTime getBadSinceDate() {
58: return badSinceDate;
59: }
60:
61: public X509Extensions getCrlDetails() {
62: return crlDetails;
63: }
64:
65: /**
66: * <pre>
67: * RevAnnContent ::= SEQUENCE {
68: * status PKIStatus,
69: * certId CertId,
70: * willBeRevokedAt GeneralizedTime,
71: * badSinceDate GeneralizedTime,
72: * crlDetails Extensions OPTIONAL
73: * -- extra CRL details (e.g., crl number, reason, location, etc.)
74: * }
75: * </pre>
76: * @return a basic ASN.1 object representation.
77: */
78: public DERObject toASN1Object() {
79: ASN1EncodableVector v = new ASN1EncodableVector();
80:
81: v.add(status);
82: v.add(certId);
83: v.add(willBeRevokedAt);
84: v.add(badSinceDate);
85:
86: if (crlDetails != null) {
87: v.add(crlDetails);
88: }
89:
90: return new DERSequence(v);
91: }
92: }
|