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