
org.bouncycastle.pkcs.Validity Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of bcpkix-fips Show documentation
Show all versions of bcpkix-fips Show documentation
The Bouncy Castle Java APIs for CMS, PKCS, EAC, TSP, CMP, CRMF, OCSP, and certificate generation. The APIs are designed primarily to be used in conjunction with the BC FIPS provider. The APIs may also be used with other providers although if being used in a FIPS context it is the responsibility of the user to ensure that any other providers used are FIPS certified.
The newest version!
package org.bouncycastle.pkcs;
import org.bouncycastle.asn1.ASN1Encodable;
import org.bouncycastle.asn1.ASN1Object;
import org.bouncycastle.asn1.ASN1Primitive;
import org.bouncycastle.asn1.ASN1Sequence;
import org.bouncycastle.asn1.ASN1TaggedObject;
import org.bouncycastle.asn1.DERSequence;
import org.bouncycastle.asn1.x509.Time;
class Validity
extends ASN1Object
{
public static Validity getInstance(Object obj)
{
if (obj instanceof Validity)
{
return (Validity)obj;
}
else if (obj != null)
{
return new Validity(ASN1Sequence.getInstance(obj));
}
return null;
}
public static Validity getInstance(ASN1TaggedObject taggedObject, boolean declaredExplicit)
{
return new Validity(ASN1Sequence.getInstance(taggedObject, declaredExplicit));
}
private final Time notBefore;
private final Time notAfter;
private Validity(ASN1Sequence seq)
{
int count = seq.size();
if (count != 2)
{
throw new IllegalArgumentException("Bad sequence size: " + count);
}
this.notBefore = Time.getInstance(seq.getObjectAt(0));
this.notAfter = Time.getInstance(seq.getObjectAt(1));
}
public Validity(Time notBefore, Time notAfter)
{
if (notBefore == null)
{
throw new NullPointerException("'notBefore' cannot be null");
}
if (notAfter == null)
{
throw new NullPointerException("'notAfter' cannot be null");
}
this.notBefore = notBefore;
this.notAfter = notAfter;
}
public Time getNotBefore()
{
return notBefore;
}
public Time getNotAfter()
{
return notAfter;
}
/**
*
* Validity ::= SEQUENCE {
* notBefore Time,
* notAfter Time }
*
*/
public ASN1Primitive toASN1Primitive()
{
return new DERSequence(new ASN1Encodable[] {notBefore, notAfter} );
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy