1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package com.novosec.pkix.asn1.crmf;
21
22 import org.bouncycastle.asn1.ASN1Encodable;
23 import org.bouncycastle.asn1.ASN1EncodableVector;
24 import org.bouncycastle.asn1.ASN1Integer;
25 import org.bouncycastle.asn1.ASN1Primitive;
26 import org.bouncycastle.asn1.ASN1Sequence;
27 import org.bouncycastle.asn1.ASN1TaggedObject;
28 import org.bouncycastle.asn1.DERSequence;
29 import org.bouncycastle.asn1.x509.GeneralName;
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45 public class SinglePubInfo implements ASN1Encodable
46 {
47 ASN1Integer pubMethod;
48 GeneralName pubLocation;
49
50 public static SinglePubInfo getInstance( ASN1TaggedObject obj, boolean explicit )
51 {
52 return getInstance(ASN1Sequence.getInstance(obj, explicit));
53 }
54
55 public static SinglePubInfo getInstance( Object obj )
56 {
57 if (obj instanceof SinglePubInfo)
58 {
59 return (SinglePubInfo)obj;
60 }
61 else if (obj instanceof ASN1Sequence)
62 {
63 return new SinglePubInfo((ASN1Sequence)obj);
64 }
65
66 throw new IllegalArgumentException("unknown object in factory");
67 }
68
69 public SinglePubInfo( ASN1Sequence seq )
70 {
71 this.pubMethod = ASN1Integer.getInstance(seq.getObjectAt(0));
72
73 if( seq.size()>1 ) {
74 this.pubLocation = GeneralName.getInstance((ASN1TaggedObject)seq.getObjectAt(1),true);
75 }
76 }
77
78 public SinglePubInfo( ASN1Integer pubMethod )
79 {
80 this.pubMethod = pubMethod;
81 }
82
83 public ASN1Integer getPubMethod()
84 {
85 return pubMethod;
86 }
87
88 public GeneralName getPubLocation()
89 {
90 return pubLocation;
91 }
92
93 public void setPubLocation(GeneralName pubLocation)
94 {
95 this.pubLocation = pubLocation;
96 }
97
98 public ASN1Primitive toASN1Primitive()
99 {
100 ASN1EncodableVector v = new ASN1EncodableVector();
101
102 v.add( pubMethod );
103
104 if( pubLocation != null ) {
105 v.add( pubLocation );
106 }
107
108 return new DERSequence(v);
109 }
110
111 public String toString()
112 {
113 String s = "SinglePubInfo: (pubMethod = " + this.getPubMethod() + ", ";
114
115 if( this.getPubLocation() != null ) {
116 s += "pubLocation = " + this.getPubLocation();
117 }
118
119 s += ")";
120
121 return s;
122 }
123 }