summary refs log tree commit diff
path: root/crypto/src/ocsp/RevokedStatus.cs
blob: f21222b8d88d91ca59b8c537a30cfd40aa5ca49d (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;
using Org.BouncyCastle.Asn1.Ocsp;
using Org.BouncyCastle.Asn1.X509;

namespace Org.BouncyCastle.Ocsp
{
	/**
	 * wrapper for the RevokedInfo object
	 */
	public class RevokedStatus
		: CertificateStatus
	{
		internal readonly RevokedInfo info;

		public RevokedStatus(
			RevokedInfo info)
		{
			this.info = info;
		}

		public RevokedStatus(
			DateTime	revocationDate,
			int			reason)
		{
			this.info = new RevokedInfo(new DerGeneralizedTime(revocationDate), new CrlReason(reason));
		}

		public RevokedStatus(
			DateTime revocationDate)
		{
			this.info = new RevokedInfo(new DerGeneralizedTime(revocationDate));
		}

		public DateTime RevocationTime
		{
			get { return info.RevocationTime.ToDateTime(); }
		}

		public bool HasRevocationReason
		{
			get { return (info.RevocationReason != null); }
		}

		/**
		 * return the revocation reason. Note: this field is optional, test for it
		 * with hasRevocationReason() first.
		 * @exception InvalidOperationException if a reason is asked for and none is avaliable
		 */
		public int RevocationReason
		{
			get
			{
				if (info.RevocationReason == null)
				{
					throw new InvalidOperationException("attempt to get a reason where none is available");
				}

                return info.RevocationReason.IntValueExact;
			}
		}
	}
}