CertStatus
using System;
namespace Org.BouncyCastle.Asn1.Ocsp
{
public class CertStatus : Asn1Encodable, IAsn1Choice
{
private readonly int m_tagNo;
private readonly Asn1Encodable m_value;
public int TagNo => m_tagNo;
public Asn1Encodable Status => m_value;
public static CertStatus GetInstance(object obj)
{
if (obj == null)
return null;
CertStatus certStatus = obj as CertStatus;
if (certStatus != null)
return certStatus;
return new CertStatus(Asn1TaggedObject.GetInstance(obj));
}
public static CertStatus GetInstance(Asn1TaggedObject taggedObject, bool declaredExplicit)
{
return Asn1Utilities.GetInstanceFromChoice(taggedObject, declaredExplicit, GetInstance);
}
private static Asn1Encodable GetValue(Asn1TaggedObject choice)
{
if (choice.HasContextTag()) {
switch (choice.TagNo) {
case 0:
return Asn1Null.GetInstance(choice, false);
case 1:
return RevokedInfo.GetInstance(choice, false);
case 2:
return Asn1Null.GetInstance(choice, false);
}
}
throw new ArgumentException("unknown tag: " + Asn1Utilities.GetTagText(choice), "choice");
}
public CertStatus()
{
m_tagNo = 0;
m_value = DerNull.Instance;
}
public CertStatus(RevokedInfo info)
{
m_tagNo = 1;
if (info == null)
throw new ArgumentNullException("info");
m_value = info;
}
public CertStatus(int tagNo, Asn1Encodable value)
{
m_tagNo = tagNo;
if (value == null)
throw new ArgumentNullException("value");
m_value = value;
}
public CertStatus(Asn1TaggedObject choice)
{
m_tagNo = choice.TagNo;
m_value = GetValue(choice);
}
public override Asn1Object ToAsn1Object()
{
return new DerTaggedObject(false, m_tagNo, m_value);
}
}
}