summary refs log tree commit diff
path: root/crypto/src/asn1/tsp/TimeStampResp.cs
blob: cc9c2ed4d7e3fb2cf13a44f64be02f940daeb918 (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
using System;

using Org.BouncyCastle.Asn1.Cmp;
using Org.BouncyCastle.Asn1.Cms;
using Org.BouncyCastle.Utilities;

namespace Org.BouncyCastle.Asn1.Tsp
{
	public class TimeStampResp
		: Asn1Encodable
	{
        public static TimeStampResp GetInstance(object obj)
        {
            if (obj == null)
                return null;
            if (obj is TimeStampResp timeStampResp)
                return timeStampResp;
            return new TimeStampResp(Asn1Sequence.GetInstance(obj));
        }

		public static TimeStampResp GetInstance(Asn1TaggedObject taggedObject, bool declaredExplicit)
		{
            return new TimeStampResp(Asn1Sequence.GetInstance(taggedObject, declaredExplicit));
        }

        private readonly PkiStatusInfo m_pkiStatusInfo;
        private readonly ContentInfo m_timeStampToken;

        private TimeStampResp(Asn1Sequence seq)
		{
			m_pkiStatusInfo = PkiStatusInfo.GetInstance(seq[0]);

			if (seq.Count > 1)
			{
				m_timeStampToken = ContentInfo.GetInstance(seq[1]);
			}
		}

		public TimeStampResp(PkiStatusInfo pkiStatusInfo, ContentInfo timeStampToken)
		{
			m_pkiStatusInfo = pkiStatusInfo;
			m_timeStampToken = timeStampToken;
		}

		public PkiStatusInfo Status => m_pkiStatusInfo;

		public ContentInfo TimeStampToken => m_timeStampToken;

		/**
		 * <pre>
		 * TimeStampResp ::= SEQUENCE  {
		 *   status                  PkiStatusInfo,
		 *   timeStampToken          TimeStampToken     OPTIONAL  }
		 * </pre>
		 */
        public override Asn1Object ToAsn1Object()
        {
            Asn1EncodableVector v = new Asn1EncodableVector(2);
			v.Add(m_pkiStatusInfo);
            v.AddOptional(m_timeStampToken);
            return new DerSequence(v);
        }
	}
}