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
|
using System;
using Org.BouncyCastle.Utilities;
namespace Org.BouncyCastle.Asn1.Cms
{
public class Evidence
: Asn1Encodable, IAsn1Choice
{
private TimeStampTokenEvidence tstEvidence;
private Asn1Sequence otherEvidence;
public Evidence(TimeStampTokenEvidence tstEvidence)
{
this.tstEvidence = tstEvidence;
}
private Evidence(Asn1TaggedObject tagged)
{
if (tagged.TagNo == 0)
{
this.tstEvidence = TimeStampTokenEvidence.GetInstance(tagged, false);
}
//else if (tagged.TagNo == 1)
//{
// this.ersEvidence = EvidenceRecord.GetInstance(tagged, false);
//}
else if (tagged.TagNo == 2)
{
this.otherEvidence = Asn1Sequence.GetInstance(tagged, false);
}
else
{
throw new ArgumentException("unknown tag in Evidence", "tagged");
}
}
public static Evidence GetInstance(object obj)
{
if (obj is Evidence evidence)
return evidence;
if (obj is Asn1TaggedObject taggedObject)
return new Evidence(taggedObject);
throw new ArgumentException("Unknown object in GetInstance: " + Platform.GetTypeName(obj), "obj");
}
public static Evidence GetInstance(Asn1TaggedObject obj, bool isExplicit)
{
return GetInstance(obj.GetObject()); // must be explicitly tagged
}
public virtual TimeStampTokenEvidence TstEvidence
{
get { return tstEvidence; }
}
//public EvidenceRecord ErsEvidence
//{
// get { return ersEvidence; }
//}
public override Asn1Object ToAsn1Object()
{
if (tstEvidence != null)
return new DerTaggedObject(false, 0, tstEvidence);
//if (ersEvidence != null)
// return new DerTaggedObject(false, 1, ersEvidence);
return new DerTaggedObject(false, 2, otherEvidence);
}
}
}
|