GQ_Communicate/GQ_VR/Assets/Best HTTP/Source/SecureProtocol/ocsp/RevokedStatus.cs

60 lines
1.7 KiB
C#

#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
#pragma warning disable
using System;
using BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1;
using BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1.Ocsp;
using BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1.X509;
namespace BestHTTP.SecureProtocol.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)
{
m_revokedInfo = new RevokedInfo(new Asn1GeneralizedTime(revocationDate));
}
public RevokedStatus(DateTime revocationDate, int reason)
{
m_revokedInfo = new RevokedInfo(new Asn1GeneralizedTime(revocationDate), new CrlReason(reason));
}
public DateTime RevocationTime
{
get { return m_revokedInfo.RevocationTime.ToDateTime(); }
}
public bool HasRevocationReason
{
get { return 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;
}
}
}
}
#pragma warning restore
#endif