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 GenRepContent extends ASN1Encodable {
08: private ASN1Sequence content;
09:
10: private GenRepContent(ASN1Sequence seq) {
11: content = seq;
12: }
13:
14: public static GenRepContent getInstance(Object o) {
15: if (o instanceof GenRepContent) {
16: return (GenRepContent) o;
17: }
18:
19: if (o instanceof ASN1Sequence) {
20: return new GenRepContent((ASN1Sequence) o);
21: }
22:
23: throw new IllegalArgumentException("Invalid object: "
24: + o.getClass().getName());
25: }
26:
27: public InfoTypeAndValue[] toInfoTypeAndValueArray() {
28: InfoTypeAndValue[] result = new InfoTypeAndValue[content.size()];
29:
30: for (int i = 0; i != result.length; i++) {
31: result[i] = InfoTypeAndValue.getInstance(content
32: .getObjectAt(i));
33: }
34:
35: return result;
36: }
37:
38: /**
39: * <pre>
40: * GenRepContent ::= SEQUENCE OF InfoTypeAndValue
41: * </pre>
42: * @return a basic ASN.1 object representation.
43: */
44: public DERObject toASN1Object() {
45: return content;
46: }
47: }
|