01: package org.bouncycastle.asn1.crmf;
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 PKIPublicationInfo extends ASN1Encodable {
11: private DERInteger action;
12: private ASN1Sequence pubInfos;
13:
14: private PKIPublicationInfo(ASN1Sequence seq) {
15: action = DERInteger.getInstance(seq.getObjectAt(0));
16: pubInfos = ASN1Sequence.getInstance(seq.getObjectAt(1));
17: }
18:
19: public static PKIPublicationInfo getInstance(Object o) {
20: if (o instanceof PKIPublicationInfo) {
21: return (PKIPublicationInfo) o;
22: }
23:
24: if (o instanceof ASN1Sequence) {
25: return new PKIPublicationInfo((ASN1Sequence) o);
26: }
27:
28: throw new IllegalArgumentException("Invalid object: "
29: + o.getClass().getName());
30: }
31:
32: public DERInteger getAction() {
33: return action;
34: }
35:
36: public SinglePubInfo[] getPubInfos() {
37: if (pubInfos == null) {
38: return null;
39: }
40:
41: SinglePubInfo[] results = new SinglePubInfo[pubInfos.size()];
42:
43: for (int i = 0; i != results.length; i++) {
44: results[i] = SinglePubInfo.getInstance(pubInfos
45: .getObjectAt(i));
46: }
47:
48: return results;
49: }
50:
51: /**
52: * <pre>
53: * PKIPublicationInfo ::= SEQUENCE {
54: * action INTEGER {
55: * dontPublish (0),
56: * pleasePublish (1) },
57: * pubInfos SEQUENCE SIZE (1..MAX) OF SinglePubInfo OPTIONAL }
58: * -- pubInfos MUST NOT be present if action is "dontPublish"
59: * -- (if action is "pleasePublish" and pubInfos is omitted,
60: * -- "dontCare" is assumed)
61: * </pre>
62: * @return a basic ASN.1 object representation.
63: */
64: public DERObject toASN1Object() {
65: ASN1EncodableVector v = new ASN1EncodableVector();
66:
67: v.add(action);
68: v.add(pubInfos);
69:
70: return new DERSequence(v);
71: }
72: }
|