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.DERInteger;
07: import org.bouncycastle.asn1.DERObject;
08: import org.bouncycastle.asn1.DERSequence;
09:
10: public class PollRepContent extends ASN1Encodable {
11: private DERInteger certReqId;
12: private DERInteger checkAfter;
13: private PKIFreeText reason;
14:
15: private PollRepContent(ASN1Sequence seq) {
16: certReqId = DERInteger.getInstance(seq.getObjectAt(0));
17: checkAfter = DERInteger.getInstance(seq.getObjectAt(1));
18:
19: if (seq.size() > 2) {
20: reason = PKIFreeText.getInstance(seq.getObjectAt(2));
21: }
22: }
23:
24: public static PollRepContent getInstance(Object o) {
25: if (o instanceof PollRepContent) {
26: return (PollRepContent) o;
27: }
28:
29: if (o instanceof ASN1Sequence) {
30: return new PollRepContent((ASN1Sequence) o);
31: }
32:
33: throw new IllegalArgumentException("Invalid object: "
34: + o.getClass().getName());
35: }
36:
37: public DERInteger getCertReqId() {
38: return certReqId;
39: }
40:
41: public DERInteger getCheckAfter() {
42: return checkAfter;
43: }
44:
45: public PKIFreeText getReason() {
46: return reason;
47: }
48:
49: /**
50: * <pre>
51: * PollRepContent ::= SEQUENCE OF SEQUENCE {
52: * certReqId INTEGER,
53: * checkAfter INTEGER, -- time in seconds
54: * reason PKIFreeText OPTIONAL
55: * }
56: * </pre>
57: * @return a basic ASN.1 object representation.
58: */
59: public DERObject toASN1Object() {
60: ASN1EncodableVector v = new ASN1EncodableVector();
61:
62: v.add(certReqId);
63: v.add(checkAfter);
64:
65: if (reason != null) {
66: v.add(reason);
67: }
68:
69: return new DERSequence(v);
70: }
71: }
|