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.DERObject;
07: import org.bouncycastle.asn1.DERSequence;
08: import org.bouncycastle.asn1.crmf.CertTemplate;
09: import org.bouncycastle.asn1.x509.X509Extensions;
10:
11: public class RevDetails extends ASN1Encodable {
12: private CertTemplate certDetails;
13: private X509Extensions crlEntryDetails;
14:
15: private RevDetails(ASN1Sequence seq) {
16: certDetails = CertTemplate.getInstance(seq.getObjectAt(0));
17: if (seq.size() > 1) {
18: crlEntryDetails = X509Extensions.getInstance(seq
19: .getObjectAt(1));
20: }
21: }
22:
23: public static RevDetails getInstance(Object o) {
24: if (o instanceof RevDetails) {
25: return (RevDetails) o;
26: }
27:
28: if (o instanceof ASN1Sequence) {
29: return new RevDetails((ASN1Sequence) o);
30: }
31:
32: throw new IllegalArgumentException("Invalid object: "
33: + o.getClass().getName());
34: }
35:
36: public CertTemplate getCertDetails() {
37: return certDetails;
38: }
39:
40: public X509Extensions getCrlEntryDetails() {
41: return crlEntryDetails;
42: }
43:
44: /**
45: * <pre>
46: * RevDetails ::= SEQUENCE {
47: * certDetails CertTemplate,
48: * -- allows requester to specify as much as they can about
49: * -- the cert. for which revocation is requested
50: * -- (e.g., for cases in which serialNumber is not available)
51: * crlEntryDetails Extensions OPTIONAL
52: * -- requested crlEntryExtensions
53: * }
54: * </pre>
55: * @return a basic ASN.1 object representation.
56: */
57: public DERObject toASN1Object() {
58: ASN1EncodableVector v = new ASN1EncodableVector();
59:
60: v.add(certDetails);
61:
62: if (crlEntryDetails != null) {
63: v.add(crlEntryDetails);
64: }
65:
66: return new DERSequence(v);
67: }
68: }
|