org.bouncycastle.asn1.cmc.PendInfo Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of bcutil-fips Show documentation
Show all versions of bcutil-fips Show documentation
The Bouncy Castle Java APIs for ASN.1 extension and utility APIs used to support bcpkix and bctls 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 and used appropriately.
package org.bouncycastle.asn1.cmc;
import org.bouncycastle.asn1.ASN1EncodableVector;
import org.bouncycastle.asn1.ASN1GeneralizedTime;
import org.bouncycastle.asn1.ASN1Object;
import org.bouncycastle.asn1.ASN1OctetString;
import org.bouncycastle.asn1.ASN1Primitive;
import org.bouncycastle.asn1.ASN1Sequence;
import org.bouncycastle.asn1.DEROctetString;
import org.bouncycastle.asn1.DERSequence;
import org.bouncycastle.util.Arrays;
/**
*
* PendInfo ::= SEQUENCE {
* pendToken OCTET STRING,
* pendTime GeneralizedTime
* }
*
*/
public class PendInfo
extends ASN1Object
{
private final byte[] pendToken;
private final ASN1GeneralizedTime pendTime;
public PendInfo(byte[] pendToken, ASN1GeneralizedTime pendTime)
{
this.pendToken = Arrays.clone(pendToken);
this.pendTime = pendTime;
}
private PendInfo(ASN1Sequence seq)
{
if (seq.size() != 2)
{
throw new IllegalArgumentException("incorrect sequence size");
}
this.pendToken = Arrays.clone(ASN1OctetString.getInstance(seq.getObjectAt(0)).getOctets());
this.pendTime = ASN1GeneralizedTime.getInstance(seq.getObjectAt(1));
}
public static PendInfo getInstance(Object o)
{
if (o instanceof PendInfo)
{
return (PendInfo)o;
}
if (o != null)
{
return new PendInfo(ASN1Sequence.getInstance(o));
}
return null;
}
public ASN1Primitive toASN1Primitive()
{
ASN1EncodableVector v = new ASN1EncodableVector(2);
v.add(new DEROctetString(pendToken));
v.add(pendTime);
return new DERSequence(v);
}
public byte[] getPendToken()
{
return Arrays.clone(pendToken);
}
public ASN1GeneralizedTime getPendTime()
{
return pendTime;
}
}