summary refs log tree commit diff
path: root/crypto/src/asn1/cms/TimeStampTokenEvidence.cs
blob: 6ac1eb11d529bce673fa929e0d1f798d837d3a22 (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
namespace Org.BouncyCastle.Asn1.Cms
{
    public class TimeStampTokenEvidence
		: Asn1Encodable
	{
        public static TimeStampTokenEvidence GetInstance(object obj)
        {
			if (obj == null)
				return null;
			if (obj is TimeStampTokenEvidence timeStampTokenEvidence)
				return timeStampTokenEvidence;
            return new TimeStampTokenEvidence(Asn1Sequence.GetInstance(obj));
        }

        public static TimeStampTokenEvidence GetInstance(Asn1TaggedObject tagged, bool isExplicit)
        {
            return new TimeStampTokenEvidence(Asn1Sequence.GetInstance(tagged, isExplicit));
        }

        private TimeStampAndCrl[] timeStampAndCrls;

		public TimeStampTokenEvidence(TimeStampAndCrl[] timeStampAndCrls)
		{
			this.timeStampAndCrls = timeStampAndCrls;
		}

		public TimeStampTokenEvidence(TimeStampAndCrl timeStampAndCrl)
		{
			this.timeStampAndCrls = new TimeStampAndCrl[]{ timeStampAndCrl };
		}

		private TimeStampTokenEvidence(Asn1Sequence seq)
		{
			this.timeStampAndCrls = new TimeStampAndCrl[seq.Count];

			int count = 0;

			foreach (Asn1Encodable ae in seq)
			{
				this.timeStampAndCrls[count++] = TimeStampAndCrl.GetInstance(ae.ToAsn1Object());
			}
		}

        public virtual TimeStampAndCrl[] ToTimeStampAndCrlArray()
		{
			return (TimeStampAndCrl[])timeStampAndCrls.Clone();
		}

		/**
		 * <pre>
		 * TimeStampTokenEvidence ::=
		 *    SEQUENCE SIZE(1..MAX) OF TimeStampAndCrl
		 * </pre>
		 * @return
		 */
		public override Asn1Object ToAsn1Object()
		{
			return new DerSequence(timeStampAndCrls);
		}
	}
}