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