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: import org.bouncycastle.asn1.x509.GeneralName;
10:
11: public class SinglePubInfo extends ASN1Encodable {
12: private DERInteger pubMethod;
13: private GeneralName pubLocation;
14:
15: private SinglePubInfo(ASN1Sequence seq) {
16: pubMethod = DERInteger.getInstance(seq.getObjectAt(0));
17:
18: if (seq.size() == 2) {
19: pubLocation = GeneralName.getInstance(seq.getObjectAt(1));
20: }
21: }
22:
23: public static SinglePubInfo getInstance(Object o) {
24: if (o instanceof SinglePubInfo) {
25: return (SinglePubInfo) o;
26: }
27:
28: if (o instanceof ASN1Sequence) {
29: return new SinglePubInfo((ASN1Sequence) o);
30: }
31:
32: throw new IllegalArgumentException("Invalid object: "
33: + o.getClass().getName());
34: }
35:
36: public GeneralName getPubLocation() {
37: return pubLocation;
38: }
39:
40: /**
41: * <pre>
42: * SinglePubInfo ::= SEQUENCE {
43: * pubMethod INTEGER {
44: * dontCare (0),
45: * x500 (1),
46: * web (2),
47: * ldap (3) },
48: * pubLocation GeneralName OPTIONAL }
49: * </pre>
50: * @return a basic ASN.1 object representation.
51: */
52: public DERObject toASN1Object() {
53: ASN1EncodableVector v = new ASN1EncodableVector();
54:
55: v.add(pubMethod);
56:
57: if (pubLocation != null) {
58: v.add(pubLocation);
59: }
60:
61: return new DERSequence(v);
62: }
63: }
|