mirrored from https://www.bouncycastle.org/repositories/bc-csharp
-
Notifications
You must be signed in to change notification settings - Fork 602
Expand file tree
/
Copy pathRevokedStatus.cs
More file actions
53 lines (42 loc) · 1.78 KB
/
Copy pathRevokedStatus.cs
File metadata and controls
53 lines (42 loc) · 1.78 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
using System;
using Org.BouncyCastle.Asn1;
using Org.BouncyCastle.Asn1.Ocsp;
using Org.BouncyCastle.Asn1.X509;
namespace Org.BouncyCastle.Ocsp
{
/// <summary>Wrapper for the RevokedInfo object</summary>
public class RevokedStatus
: CertificateStatus
{
private readonly RevokedInfo m_revokedInfo;
public RevokedStatus(RevokedInfo revokedInfo)
{
m_revokedInfo = revokedInfo;
}
public RevokedStatus(DateTime revocationDate)
{
var revocationTime = Rfc5280Asn1Utilities.CreateGeneralizedTime(revocationDate);
m_revokedInfo = new RevokedInfo(revocationTime);
}
public RevokedStatus(DateTime revocationDate, int reason)
{
var revocationTime = Rfc5280Asn1Utilities.CreateGeneralizedTime(revocationDate);
m_revokedInfo = new RevokedInfo(revocationTime, new CrlReason(reason));
}
public DateTime RevocationTime => m_revokedInfo.RevocationTime.ToDateTime();
public bool HasRevocationReason => m_revokedInfo.RevocationReason != null;
/// <summary>Return the revocation reason, if there is one.</summary>
/// <remarks>This field is optional; test for it with <see cref="HasRevocationReason"/> first.</remarks>
/// <returns>The revocation reason, if available.</returns>
/// <exception cref="InvalidOperationException">If no revocation reason is available.</exception>
public int RevocationReason
{
get
{
if (m_revokedInfo.RevocationReason == null)
throw new InvalidOperationException("attempt to get a reason where none is available");
return m_revokedInfo.RevocationReason.IntValueExact;
}
}
}
}