org.spongycastle.asn1.tsp.TimeStampResp 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.tsp;
import java.util.Enumeration;
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;
import org.spongycastle.asn1.cms.ContentInfo;
import org.spongycastle.asn1.cmp.PKIStatusInfo;
public class TimeStampResp
extends ASN1Encodable
{
PKIStatusInfo pkiStatusInfo;
ContentInfo timeStampToken;
public static TimeStampResp getInstance(Object o)
{
if (o == null || o instanceof TimeStampResp)
{
return (TimeStampResp) o;
}
else if (o instanceof ASN1Sequence)
{
return new TimeStampResp((ASN1Sequence) o);
}
throw new IllegalArgumentException(
"unknown object in 'TimeStampResp' factory : "
+ o.getClass().getName() + ".");
}
public TimeStampResp(ASN1Sequence seq)
{
Enumeration e = seq.getObjects();
// status
pkiStatusInfo = PKIStatusInfo.getInstance(e.nextElement());
if (e.hasMoreElements())
{
timeStampToken = ContentInfo.getInstance(e.nextElement());
}
}
public TimeStampResp(PKIStatusInfo pkiStatusInfo, ContentInfo timeStampToken)
{
this.pkiStatusInfo = pkiStatusInfo;
this.timeStampToken = timeStampToken;
}
public PKIStatusInfo getStatus()
{
return pkiStatusInfo;
}
public ContentInfo getTimeStampToken()
{
return timeStampToken;
}
/**
*
* TimeStampResp ::= SEQUENCE {
* status PKIStatusInfo,
* timeStampToken TimeStampToken OPTIONAL }
*
*/
public DERObject toASN1Object()
{
ASN1EncodableVector v = new ASN1EncodableVector();
v.add(pkiStatusInfo);
if (timeStampToken != null)
{
v.add(timeStampToken);
}
return new DERSequence(v);
}
}