org.spongycastle.asn1.x509.PrivateKeyUsagePeriod Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of scprov-jdk15on Show documentation
Show all versions of scprov-jdk15on Show documentation
The Bouncy Castle Crypto package is a Java implementation of cryptographic algorithms.
This jar contains JCE provider for the Bouncy Castle Cryptography APIs for JDK 1.5 to JDK 1.7.
package org.spongycastle.asn1.x509;
import java.util.Enumeration;
import org.spongycastle.asn1.ASN1EncodableVector;
import org.spongycastle.asn1.ASN1Object;
import org.spongycastle.asn1.ASN1Primitive;
import org.spongycastle.asn1.ASN1Sequence;
import org.spongycastle.asn1.ASN1TaggedObject;
import org.spongycastle.asn1.DERGeneralizedTime;
import org.spongycastle.asn1.DERSequence;
import org.spongycastle.asn1.DERTaggedObject;
/**
*
* PrivateKeyUsagePeriod ::= SEQUENCE {
* notBefore [0] GeneralizedTime OPTIONAL,
* notAfter [1] GeneralizedTime OPTIONAL }
*
*/
public class PrivateKeyUsagePeriod
extends ASN1Object
{
public static PrivateKeyUsagePeriod getInstance(Object obj)
{
if (obj instanceof PrivateKeyUsagePeriod)
{
return (PrivateKeyUsagePeriod)obj;
}
if (obj != null)
{
return new PrivateKeyUsagePeriod(ASN1Sequence.getInstance(obj));
}
return null;
}
private DERGeneralizedTime _notBefore, _notAfter;
private PrivateKeyUsagePeriod(ASN1Sequence seq)
{
Enumeration en = seq.getObjects();
while (en.hasMoreElements())
{
ASN1TaggedObject tObj = (ASN1TaggedObject)en.nextElement();
if (tObj.getTagNo() == 0)
{
_notBefore = DERGeneralizedTime.getInstance(tObj, false);
}
else if (tObj.getTagNo() == 1)
{
_notAfter = DERGeneralizedTime.getInstance(tObj, false);
}
}
}
public DERGeneralizedTime getNotBefore()
{
return _notBefore;
}
public DERGeneralizedTime getNotAfter()
{
return _notAfter;
}
public ASN1Primitive toASN1Primitive()
{
ASN1EncodableVector v = new ASN1EncodableVector();
if (_notBefore != null)
{
v.add(new DERTaggedObject(false, 0, _notBefore));
}
if (_notAfter != null)
{
v.add(new DERTaggedObject(false, 1, _notAfter));
}
return new DERSequence(v);
}
}