blob: 31320416ed3aa083efd66e836ca10228c4864fcb (
plain) (
blame)
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
|
using Org.BouncyCastle.Math;
namespace Org.BouncyCastle.Asn1.Cmp
{
public class PollReqContent
: Asn1Encodable
{
public static PollReqContent GetInstance(object obj)
{
if (obj == null)
return null;
if (obj is PollReqContent pollReqContent)
return pollReqContent;
return new PollReqContent(Asn1Sequence.GetInstance(obj));
}
public static PollReqContent GetInstance(Asn1TaggedObject taggedObject, bool declaredExplicit)
{
return GetInstance(Asn1Sequence.GetInstance(taggedObject, declaredExplicit));
}
private readonly Asn1Sequence m_content;
private PollReqContent(Asn1Sequence seq)
{
m_content = seq;
}
/**
* Create a pollReqContent for a single certReqId.
*
* @param certReqId the certificate request ID.
*/
public PollReqContent(DerInteger certReqId)
: this(new DerSequence(new DerSequence(certReqId)))
{
}
/**
* Create a pollReqContent for a multiple certReqIds.
*
* @param certReqIds the certificate request IDs.
*/
public PollReqContent(DerInteger[] certReqIds)
: this(new DerSequence(IntsToSequence(certReqIds)))
{
}
/**
* Create a pollReqContent for a single certReqId.
*
* @param certReqId the certificate request ID.
*/
public PollReqContent(BigInteger certReqId)
: this(new DerInteger(certReqId))
{
}
/**
* Create a pollReqContent for a multiple certReqIds.
*
* @param certReqIds the certificate request IDs.
*/
public PollReqContent(BigInteger[] certReqIds)
: this(IntsToAsn1(certReqIds))
{
}
public virtual DerInteger[][] GetCertReqIDs()
{
return m_content.MapElements(
element => Asn1Sequence.GetInstance(element).MapElements(DerInteger.GetInstance));
}
public virtual BigInteger[] GetCertReqIDValues()
{
return m_content.MapElements(element => DerInteger.GetInstance(Asn1Sequence.GetInstance(element)[0]).Value);
}
/**
* <pre>
* PollReqContent ::= SEQUENCE OF SEQUENCE {
* certReqId INTEGER
* }
* </pre>
* @return a basic ASN.1 object representation.
*/
public override Asn1Object ToAsn1Object()
{
return m_content;
}
private static DerSequence[] IntsToSequence(DerInteger[] ids)
{
DerSequence[] result = new DerSequence[ids.Length];
for (int i = 0; i != result.Length; i++)
{
result[i] = new DerSequence(ids[i]);
}
return result;
}
private static DerInteger[] IntsToAsn1(BigInteger[] ids)
{
DerInteger[] result = new DerInteger[ids.Length];
for (int i = 0; i != result.Length; i++)
{
result[i] = new DerInteger(ids[i]);
}
return result;
}
}
}
|