TimeStampAndCrl
using Org.BouncyCastle.Asn1.X509;
using System;
namespace Org.BouncyCastle.Asn1.Cms
{
public class TimeStampAndCrl : Asn1Encodable
{
private readonly ContentInfo m_timeStamp;
private readonly CertificateList m_crl;
public virtual ContentInfo TimeStampToken => m_timeStamp;
public virtual CertificateList Crl => m_crl;
public static TimeStampAndCrl GetInstance(object obj)
{
if (obj == null)
return null;
TimeStampAndCrl timeStampAndCrl = obj as TimeStampAndCrl;
if (timeStampAndCrl != null)
return timeStampAndCrl;
return new TimeStampAndCrl(Asn1Sequence.GetInstance(obj));
}
public static TimeStampAndCrl GetInstance(Asn1TaggedObject taggedObject, bool declaredExplicit)
{
return new TimeStampAndCrl(Asn1Sequence.GetInstance(taggedObject, declaredExplicit));
}
public static TimeStampAndCrl GetTagged(Asn1TaggedObject taggedObject, bool declaredExplicit)
{
return new TimeStampAndCrl(Asn1Sequence.GetTagged(taggedObject, declaredExplicit));
}
public TimeStampAndCrl(ContentInfo timeStamp)
: this(timeStamp, null)
{
}
public TimeStampAndCrl(ContentInfo timeStamp, CertificateList crl)
{
if (timeStamp == null)
throw new ArgumentNullException("timeStamp");
m_timeStamp = timeStamp;
m_crl = crl;
}
private TimeStampAndCrl(Asn1Sequence seq)
{
int count = seq.Count;
int sequencePosition = 0;
if (count < 1 || count > 2)
throw new ArgumentException("Bad sequence size: " + count.ToString(), "seq");
m_timeStamp = ContentInfo.GetInstance(seq[sequencePosition++]);
m_crl = Asn1Utilities.ReadOptional(seq, ref sequencePosition, CertificateList.GetOptional);
if (sequencePosition != count)
throw new ArgumentException("Unexpected elements in sequence", "seq");
}
public override Asn1Object ToAsn1Object()
{
if (m_crl != null)
return new DerSequence(m_timeStamp, m_crl);
return new DerSequence(m_timeStamp);
}
}
}