CrlSource
using Org.BouncyCastle.Asn1.X509;
using System;
namespace Org.BouncyCastle.Asn1.Cmp
{
public class CrlSource : Asn1Encodable, IAsn1Choice
{
private readonly DistributionPointName m_dpn;
private readonly GeneralNames m_issuer;
public virtual DistributionPointName Dpn => m_dpn;
public virtual GeneralNames Issuer => m_issuer;
public static CrlSource GetInstance(object obj)
{
return Asn1Utilities.GetInstanceChoice(obj, GetOptional);
}
public static CrlSource GetInstance(Asn1TaggedObject taggedObject, bool declaredExplicit)
{
return Asn1Utilities.GetInstanceChoice(taggedObject, declaredExplicit, GetInstance);
}
public static CrlSource GetOptional(Asn1Encodable element)
{
if (element == null)
throw new ArgumentNullException("element");
CrlSource crlSource = element as CrlSource;
if (crlSource != null)
return crlSource;
Asn1TaggedObject optional = Asn1TaggedObject.GetOptional(element);
if (optional != null) {
if (optional.HasContextTag(0))
return new CrlSource(DistributionPointName.GetTagged(optional, true), null);
if (optional.HasContextTag(1))
return new CrlSource(null, GeneralNames.GetTagged(optional, true));
}
return null;
}
public static CrlSource GetTagged(Asn1TaggedObject taggedObject, bool declaredExplicit)
{
return Asn1Utilities.GetTaggedChoice(taggedObject, declaredExplicit, GetInstance);
}
public CrlSource(DistributionPointName dpn, GeneralNames issuer)
{
if (dpn == null == (issuer == null))
throw new ArgumentException("either dpn or issuer must be set");
m_dpn = dpn;
m_issuer = issuer;
}
public override Asn1Object ToAsn1Object()
{
if (m_dpn != null)
return new DerTaggedObject(true, 0, m_dpn);
if (m_issuer != null)
return new DerTaggedObject(true, 1, m_issuer);
throw new InvalidOperationException();
}
}
}