org.spongycastle.asn1.esf.OcspResponsesID 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.esf;
import org.spongycastle.asn1.ASN1Encodable;
import org.spongycastle.asn1.ASN1EncodableVector;
import org.spongycastle.asn1.ASN1Sequence;
import org.spongycastle.asn1.DERObject;
import org.spongycastle.asn1.DERSequence;
/**
*
* OcspResponsesID ::= SEQUENCE {
* ocspIdentifier OcspIdentifier,
* ocspRepHash OtherHash OPTIONAL
* }
*
*/
public class OcspResponsesID
extends ASN1Encodable
{
private OcspIdentifier ocspIdentifier;
private OtherHash ocspRepHash;
public static OcspResponsesID getInstance(Object obj)
{
if (obj instanceof OcspResponsesID)
{
return (OcspResponsesID)obj;
}
else if (obj != null)
{
return new OcspResponsesID(ASN1Sequence.getInstance(obj));
}
throw new IllegalArgumentException("null value in getInstance");
}
private OcspResponsesID(ASN1Sequence seq)
{
if (seq.size() < 1 || seq.size() > 2)
{
throw new IllegalArgumentException("Bad sequence size: "
+ seq.size());
}
this.ocspIdentifier = OcspIdentifier.getInstance(seq.getObjectAt(0));
if (seq.size() > 1)
{
this.ocspRepHash = OtherHash.getInstance(seq.getObjectAt(1));
}
}
public OcspResponsesID(OcspIdentifier ocspIdentifier)
{
this(ocspIdentifier, null);
}
public OcspResponsesID(OcspIdentifier ocspIdentifier, OtherHash ocspRepHash)
{
this.ocspIdentifier = ocspIdentifier;
this.ocspRepHash = ocspRepHash;
}
public OcspIdentifier getOcspIdentifier()
{
return this.ocspIdentifier;
}
public OtherHash getOcspRepHash()
{
return this.ocspRepHash;
}
public DERObject toASN1Object()
{
ASN1EncodableVector v = new ASN1EncodableVector();
v.add(this.ocspIdentifier);
if (null != this.ocspRepHash)
{
v.add(this.ocspRepHash);
}
return new DERSequence(v);
}
}