01: package org.bouncycastle.asn1.cmp;
02:
03: import org.bouncycastle.asn1.ASN1Encodable;
04: import org.bouncycastle.asn1.ASN1Sequence;
05: import org.bouncycastle.asn1.DERInteger;
06: import org.bouncycastle.asn1.DERObject;
07:
08: public class PollReqContent extends ASN1Encodable {
09: private ASN1Sequence content;
10:
11: private PollReqContent(ASN1Sequence seq) {
12: content = seq;
13: }
14:
15: public static PollReqContent getInstance(Object o) {
16: if (o instanceof PollReqContent) {
17: return (PollReqContent) o;
18: }
19:
20: if (o instanceof ASN1Sequence) {
21: return new PollReqContent((ASN1Sequence) o);
22: }
23:
24: throw new IllegalArgumentException("Invalid object: "
25: + o.getClass().getName());
26: }
27:
28: public DERInteger[][] getCertReqIds() {
29: DERInteger[][] result = new DERInteger[content.size()][];
30:
31: for (int i = 0; i != result.length; i++) {
32: result[i] = seqenceToDERIntegerArray((ASN1Sequence) content
33: .getObjectAt(i));
34: }
35:
36: return result;
37: }
38:
39: private DERInteger[] seqenceToDERIntegerArray(ASN1Sequence seq) {
40: DERInteger[] result = new DERInteger[seq.size()];
41:
42: for (int i = 0; i != result.length; i++) {
43: result[i] = DERInteger.getInstance(seq.getObjectAt(i));
44: }
45:
46: return result;
47: }
48:
49: /**
50: * <pre>
51: * PollReqContent ::= SEQUENCE OF SEQUENCE {
52: * certReqId INTEGER
53: * }
54: * </pre>
55: * @return a basic ASN.1 object representation.
56: */
57: public DERObject toASN1Object() {
58: return content;
59: }
60: }
|