blob: 6100bd307bbcc77de2eb521e0ce4cf049a1aa65d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
|
package org.spongycastle.asn1.dvcs;
import java.io.IOException;
import org.spongycastle.asn1.ASN1Choice;
import org.spongycastle.asn1.ASN1Object;
import org.spongycastle.asn1.ASN1Primitive;
import org.spongycastle.asn1.ASN1Sequence;
import org.spongycastle.asn1.ASN1TaggedObject;
import org.spongycastle.asn1.DERTaggedObject;
/**
* <pre>
* DVCSResponse ::= CHOICE
* {
* dvCertInfo DVCSCertInfo ,
* dvErrorNote [0] DVCSErrorNotice
* }
* </pre>
*/
public class DVCSResponse
extends ASN1Object
implements ASN1Choice
{
private DVCSCertInfo dvCertInfo;
private DVCSErrorNotice dvErrorNote;
public DVCSResponse(DVCSCertInfo dvCertInfo)
{
this.dvCertInfo = dvCertInfo;
}
public DVCSResponse(DVCSErrorNotice dvErrorNote)
{
this.dvErrorNote = dvErrorNote;
}
public static DVCSResponse getInstance(Object obj)
{
if (obj == null || obj instanceof DVCSResponse)
{
return (DVCSResponse)obj;
}
else
{
if (obj instanceof byte[])
{
try
{
return getInstance(ASN1Primitive.fromByteArray((byte[])obj));
}
catch (IOException e)
{
throw new IllegalArgumentException("failed to construct sequence from byte[]: " + e.getMessage());
}
}
if (obj instanceof ASN1Sequence)
{
DVCSCertInfo dvCertInfo = DVCSCertInfo.getInstance(obj);
return new DVCSResponse(dvCertInfo);
}
if (obj instanceof ASN1TaggedObject)
{
ASN1TaggedObject t = ASN1TaggedObject.getInstance(obj);
DVCSErrorNotice dvErrorNote = DVCSErrorNotice.getInstance(t, false);
return new DVCSResponse(dvErrorNote);
}
}
throw new IllegalArgumentException("Couldn't convert from object to DVCSResponse: " + obj.getClass().getName());
}
public static DVCSResponse getInstance(
ASN1TaggedObject obj,
boolean explicit)
{
return getInstance(ASN1Sequence.getInstance(obj, explicit));
}
public DVCSCertInfo getCertInfo()
{
return dvCertInfo;
}
public DVCSErrorNotice getErrorNotice()
{
return dvErrorNote;
}
public ASN1Primitive toASN1Primitive()
{
if (dvCertInfo != null)
{
return dvCertInfo.toASN1Primitive();
}
else
{
return new DERTaggedObject(0, dvErrorNote);
}
}
public String toString()
{
if (dvCertInfo != null)
{
return "DVCSResponse {\ndvCertInfo: " + dvCertInfo.toString() + "}\n";
}
if (dvErrorNote != null)
{
return "DVCSResponse {\ndvErrorNote: " + dvErrorNote.toString() + "}\n";
}
return null;
}
}
|