org.spongycastle.asn1.ocsp.CrlID Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of scprov-jdk15 Show documentation
Show all versions of scprov-jdk15 Show documentation
Spongy Castle is a package-rename (org.bouncycastle.* to org.spongycastle.*) of Bouncy Castle intended for Android.
Android ships with a stripped-down version of Bouncy Castle - this causes classloader collisions if you try to add
an alternative (updated/complete) Bouncy Castle jar.
This jar contains JCE provider and lightweight API for the Bouncy Castle Cryptography APIs for JDK 1.5.
package org.spongycastle.asn1.ocsp;
import java.util.Enumeration;
import org.spongycastle.asn1.*;
public class CrlID
extends ASN1Encodable
{
DERIA5String crlUrl;
DERInteger crlNum;
DERGeneralizedTime crlTime;
public CrlID(
ASN1Sequence seq)
{
Enumeration e = seq.getObjects();
while (e.hasMoreElements())
{
ASN1TaggedObject o = (ASN1TaggedObject)e.nextElement();
switch (o.getTagNo())
{
case 0:
crlUrl = DERIA5String.getInstance(o, true);
break;
case 1:
crlNum = DERInteger.getInstance(o, true);
break;
case 2:
crlTime = DERGeneralizedTime.getInstance(o, true);
break;
default:
throw new IllegalArgumentException(
"unknown tag number: " + o.getTagNo());
}
}
}
public DERIA5String getCrlUrl()
{
return crlUrl;
}
public DERInteger getCrlNum()
{
return crlNum;
}
public DERGeneralizedTime getCrlTime()
{
return crlTime;
}
/**
* Produce an object suitable for an ASN1OutputStream.
*
* CrlID ::= SEQUENCE {
* crlUrl [0] EXPLICIT IA5String OPTIONAL,
* crlNum [1] EXPLICIT INTEGER OPTIONAL,
* crlTime [2] EXPLICIT GeneralizedTime OPTIONAL }
*
*/
public DERObject toASN1Object()
{
ASN1EncodableVector v = new ASN1EncodableVector();
if (crlUrl != null)
{
v.add(new DERTaggedObject(true, 0, crlUrl));
}
if (crlNum != null)
{
v.add(new DERTaggedObject(true, 1, crlNum));
}
if (crlTime != null)
{
v.add(new DERTaggedObject(true, 2, crlTime));
}
return new DERSequence(v);
}
}