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
|
using System;
using Org.BouncyCastle.Utilities;
namespace Org.BouncyCastle.Asn1.Esf
{
/// <remarks>
/// RFC 3126: 4.2.2 Complete Revocation Refs Attribute Definition
/// <code>
/// CrlOcspRef ::= SEQUENCE {
/// crlids [0] CRLListID OPTIONAL,
/// ocspids [1] OcspListID OPTIONAL,
/// otherRev [2] OtherRevRefs OPTIONAL
/// }
/// </code>
/// </remarks>
public class CrlOcspRef
: Asn1Encodable
{
private readonly CrlListID crlids;
private readonly OcspListID ocspids;
private readonly OtherRevRefs otherRev;
public static CrlOcspRef GetInstance(
object obj)
{
if (obj == null || obj is CrlOcspRef)
return (CrlOcspRef) obj;
if (obj is Asn1Sequence)
return new CrlOcspRef((Asn1Sequence) obj);
throw new ArgumentException(
"Unknown object in 'CrlOcspRef' factory: "
+ Platform.GetTypeName(obj),
"obj");
}
private CrlOcspRef(Asn1Sequence seq)
{
if (seq == null)
throw new ArgumentNullException("seq");
foreach (var element in seq)
{
var o = Asn1TaggedObject.GetInstance(element, Asn1Tags.ContextSpecific);
switch (o.TagNo)
{
case 0:
this.crlids = CrlListID.GetInstance(o.GetExplicitBaseObject());
break;
case 1:
this.ocspids = OcspListID.GetInstance(o.GetExplicitBaseObject());
break;
case 2:
this.otherRev = OtherRevRefs.GetInstance(o.GetExplicitBaseObject());
break;
default:
throw new ArgumentException("Illegal tag in CrlOcspRef", "seq");
}
}
}
public CrlOcspRef(
CrlListID crlids,
OcspListID ocspids,
OtherRevRefs otherRev)
{
this.crlids = crlids;
this.ocspids = ocspids;
this.otherRev = otherRev;
}
public CrlListID CrlIDs
{
get { return crlids; }
}
public OcspListID OcspIDs
{
get { return ocspids; }
}
public OtherRevRefs OtherRev
{
get { return otherRev; }
}
public override Asn1Object ToAsn1Object()
{
Asn1EncodableVector v = new Asn1EncodableVector(3);
if (crlids != null)
{
v.Add(new DerTaggedObject(true, 0, crlids.ToAsn1Object()));
}
if (ocspids != null)
{
v.Add(new DerTaggedObject(true, 1, ocspids.ToAsn1Object()));
}
if (otherRev != null)
{
v.Add(new DerTaggedObject(true, 2, otherRev.ToAsn1Object()));
}
return new DerSequence(v);
}
}
}
|