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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
|
using System;
using Org.BouncyCastle.Asn1.X509;
using Org.BouncyCastle.Utilities;
namespace Org.BouncyCastle.Asn1.Ocsp
{
public class ResponseData
: Asn1Encodable
{
private static readonly DerInteger V1 = new DerInteger(0);
private readonly bool versionPresent;
private readonly DerInteger version;
private readonly ResponderID responderID;
private readonly Asn1GeneralizedTime producedAt;
private readonly Asn1Sequence responses;
private readonly X509Extensions responseExtensions;
public static ResponseData GetInstance(
Asn1TaggedObject obj,
bool explicitly)
{
return GetInstance(Asn1Sequence.GetInstance(obj, explicitly));
}
public static ResponseData GetInstance(
object obj)
{
if (obj == null || obj is ResponseData)
{
return (ResponseData)obj;
}
if (obj is Asn1Sequence)
{
return new ResponseData((Asn1Sequence)obj);
}
throw new ArgumentException("unknown object in factory: " + Platform.GetTypeName(obj), "obj");
}
public ResponseData(
DerInteger version,
ResponderID responderID,
Asn1GeneralizedTime producedAt,
Asn1Sequence responses,
X509Extensions responseExtensions)
{
this.version = version;
this.responderID = responderID;
this.producedAt = producedAt;
this.responses = responses;
this.responseExtensions = responseExtensions;
}
public ResponseData(
ResponderID responderID,
Asn1GeneralizedTime producedAt,
Asn1Sequence responses,
X509Extensions responseExtensions)
: this(V1, responderID, producedAt, responses, responseExtensions)
{
}
private ResponseData(
Asn1Sequence seq)
{
int index = 0;
Asn1Encodable enc = seq[0];
if (enc is Asn1TaggedObject)
{
Asn1TaggedObject o = (Asn1TaggedObject)enc;
if (o.TagNo == 0)
{
this.versionPresent = true;
this.version = DerInteger.GetInstance(o, true);
index++;
}
else
{
this.version = V1;
}
}
else
{
this.version = V1;
}
this.responderID = ResponderID.GetInstance(seq[index++]);
this.producedAt = (Asn1GeneralizedTime)seq[index++];
this.responses = (Asn1Sequence)seq[index++];
if (seq.Count > index)
{
this.responseExtensions = X509Extensions.GetInstance(
(Asn1TaggedObject)seq[index], true);
}
}
public DerInteger Version
{
get { return version; }
}
public ResponderID ResponderID
{
get { return responderID; }
}
public Asn1GeneralizedTime ProducedAt
{
get { return producedAt; }
}
public Asn1Sequence Responses
{
get { return responses; }
}
public X509Extensions ResponseExtensions
{
get { return responseExtensions; }
}
/**
* Produce an object suitable for an Asn1OutputStream.
* <pre>
* ResponseData ::= Sequence {
* version [0] EXPLICIT Version DEFAULT v1,
* responderID ResponderID,
* producedAt GeneralizedTime,
* responses Sequence OF SingleResponse,
* responseExtensions [1] EXPLICIT Extensions OPTIONAL }
* </pre>
*/
public override Asn1Object ToAsn1Object()
{
Asn1EncodableVector v = new Asn1EncodableVector();
if (versionPresent || !version.Equals(V1))
{
v.Add(new DerTaggedObject(true, 0, version));
}
v.Add(responderID, producedAt, responses);
v.AddOptionalTagged(true, 1, responseExtensions);
return new DerSequence(v);
}
}
}
|