TimeStampedData.cs
2.1 KB
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
using System;
namespace Org.BouncyCastle.Asn1.Cms
{
public class TimeStampedData
: Asn1Encodable
{
private DerInteger version;
private DerIA5String dataUri;
private MetaData metaData;
private Asn1OctetString content;
private Evidence temporalEvidence;
public TimeStampedData(DerIA5String dataUri, MetaData metaData, Asn1OctetString content,
Evidence temporalEvidence)
{
this.version = new DerInteger(1);
this.dataUri = dataUri;
this.metaData = metaData;
this.content = content;
this.temporalEvidence = temporalEvidence;
}
private TimeStampedData(Asn1Sequence seq)
{
this.version = DerInteger.GetInstance(seq[0]);
int index = 1;
if (seq[index] is DerIA5String)
{
this.dataUri = DerIA5String.GetInstance(seq[index++]);
}
if (seq[index] is MetaData || seq[index] is Asn1Sequence)
{
this.metaData = MetaData.GetInstance(seq[index++]);
}
if (seq[index] is Asn1OctetString)
{
this.content = Asn1OctetString.GetInstance(seq[index++]);
}
this.temporalEvidence = Evidence.GetInstance(seq[index]);
}
public static TimeStampedData GetInstance(object obj)
{
if (obj is TimeStampedData)
return (TimeStampedData)obj;
if (obj != null)
return new TimeStampedData(Asn1Sequence.GetInstance(obj));
return null;
}
public virtual DerIA5String DataUri
{
get { return dataUri; }
}
public MetaData MetaData
{
get { return metaData; }
}
public Asn1OctetString Content
{
get { return content; }
}
public Evidence TemporalEvidence
{
get { return temporalEvidence; }
}
/**
* <pre>
* TimeStampedData ::= SEQUENCE {
* version INTEGER { v1(1) },
* dataUri IA5String OPTIONAL,
* metaData MetaData OPTIONAL,
* content OCTET STRING OPTIONAL,
* temporalEvidence Evidence
* }
* </pre>
* @return
*/
public override Asn1Object ToAsn1Object()
{
Asn1EncodableVector v = new Asn1EncodableVector(version);
v.AddOptional(dataUri, metaData, content);
v.Add(temporalEvidence);
return new BerSequence(v);
}
}
}