summary refs log tree commit diff
path: root/crypto/src/asn1/cmp/RevAnnContent.cs
blob: d5d42625cfc3385f34f77cc08e945f7c01fdb057 (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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
using System;

using Org.BouncyCastle.Asn1.Crmf;
using Org.BouncyCastle.Asn1.X509;
using Org.BouncyCastle.Utilities;

namespace Org.BouncyCastle.Asn1.Cmp
{
	public class RevAnnContent
		: Asn1Encodable
	{
		private readonly PkiStatusEncodable status;
		private readonly CertId certId;
		private readonly DerGeneralizedTime willBeRevokedAt;
		private readonly DerGeneralizedTime badSinceDate;
		private readonly X509Extensions crlDetails;

		private RevAnnContent(Asn1Sequence seq)
		{
			status = PkiStatusEncodable.GetInstance(seq[0]);
			certId = CertId.GetInstance(seq[1]);
			willBeRevokedAt = DerGeneralizedTime.GetInstance(seq[2]);
			badSinceDate = DerGeneralizedTime.GetInstance(seq[3]);

			if (seq.Count > 4)
			{
				crlDetails = X509Extensions.GetInstance(seq[4]);
			}
		}

		public static RevAnnContent GetInstance(object obj)
		{
			if (obj is RevAnnContent)
				return (RevAnnContent)obj;

			if (obj is Asn1Sequence)
				return new RevAnnContent((Asn1Sequence)obj);

            throw new ArgumentException("Invalid object: " + Platform.GetTypeName(obj), "obj");
		}

		public virtual PkiStatusEncodable Status
		{
			get { return status; }
		}

		public virtual CertId CertID
		{
			get { return certId; }
		}

		public virtual DerGeneralizedTime WillBeRevokedAt
		{
			get { return willBeRevokedAt; }
		}

		public virtual DerGeneralizedTime BadSinceDate
		{
			get { return badSinceDate; }
		}

		public virtual X509Extensions CrlDetails
		{
			get { return crlDetails; }
		}

		/**
		 * <pre>
		 * RevAnnContent ::= SEQUENCE {
		 *       status              PKIStatus,
		 *       certId              CertId,
		 *       willBeRevokedAt     GeneralizedTime,
		 *       badSinceDate        GeneralizedTime,
		 *       crlDetails          Extensions  OPTIONAL
		 *        -- extra CRL details (e.g., crl number, reason, location, etc.)
		 * }
		 * </pre>
		 * @return a basic ASN.1 object representation.
		 */
		public override Asn1Object ToAsn1Object()
		{
			Asn1EncodableVector v = new Asn1EncodableVector(status, certId, willBeRevokedAt, badSinceDate);
			v.AddOptional(crlDetails);
			return new DerSequence(v);
		}
	}
}