Validity
using System;
namespace Org.BouncyCastle.Asn1.X509
{
public class Validity : Asn1Encodable
{
private readonly Time m_notBefore;
private readonly Time m_notAfter;
public Time NotBefore => m_notBefore;
public Time NotAfter => m_notAfter;
public static Validity GetInstance(object obj)
{
if (obj == null)
return null;
Validity validity = obj as Validity;
if (validity != null)
return validity;
return new Validity(Asn1Sequence.GetInstance(obj));
}
public static Validity GetInstance(Asn1TaggedObject taggedObject, bool declaredExplicit)
{
return new Validity(Asn1Sequence.GetInstance(taggedObject, declaredExplicit));
}
public static Validity GetTagged(Asn1TaggedObject taggedObject, bool declaredExplicit)
{
return new Validity(Asn1Sequence.GetTagged(taggedObject, declaredExplicit));
}
private Validity(Asn1Sequence seq)
{
int count = seq.Count;
if (count != 2)
throw new ArgumentException("Bad sequence size: " + count.ToString(), "seq");
m_notBefore = Time.GetInstance(seq[0]);
m_notAfter = Time.GetInstance(seq[1]);
}
public Validity(Time notBefore, Time notAfter)
{
if (notBefore == null)
throw new ArgumentNullException("notBefore");
m_notBefore = notBefore;
if (notAfter == null)
throw new ArgumentNullException("notAfter");
m_notAfter = notAfter;
}
public override Asn1Object ToAsn1Object()
{
return new DerSequence(m_notBefore, m_notAfter);
}
}
}