org.spongycastle.asn1.cms.IssuerAndSerialNumber 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.cms;
import java.math.BigInteger;
import org.spongycastle.asn1.ASN1EncodableVector;
import org.spongycastle.asn1.ASN1Integer;
import org.spongycastle.asn1.ASN1Object;
import org.spongycastle.asn1.ASN1Primitive;
import org.spongycastle.asn1.ASN1Sequence;
import org.spongycastle.asn1.DERSequence;
import org.spongycastle.asn1.x500.X500Name;
import org.spongycastle.asn1.x509.Certificate;
import org.spongycastle.asn1.x509.X509CertificateStructure;
import org.spongycastle.asn1.x509.X509Name;
public class IssuerAndSerialNumber
extends ASN1Object
{
private X500Name name;
private ASN1Integer serialNumber;
public static IssuerAndSerialNumber getInstance(
Object obj)
{
if (obj instanceof IssuerAndSerialNumber)
{
return (IssuerAndSerialNumber)obj;
}
else if (obj != null)
{
return new IssuerAndSerialNumber(ASN1Sequence.getInstance(obj));
}
return null;
}
public IssuerAndSerialNumber(
ASN1Sequence seq)
{
this.name = X500Name.getInstance(seq.getObjectAt(0));
this.serialNumber = (ASN1Integer)seq.getObjectAt(1);
}
public IssuerAndSerialNumber(
Certificate certificate)
{
this.name = certificate.getIssuer();
this.serialNumber = certificate.getSerialNumber();
}
public IssuerAndSerialNumber(
X509CertificateStructure certificate)
{
this.name = certificate.getIssuer();
this.serialNumber = certificate.getSerialNumber();
}
public IssuerAndSerialNumber(
X500Name name,
BigInteger serialNumber)
{
this.name = name;
this.serialNumber = new ASN1Integer(serialNumber);
}
/**
* @deprecated use X500Name constructor
*/
public IssuerAndSerialNumber(
X509Name name,
BigInteger serialNumber)
{
this.name = X500Name.getInstance(name);
this.serialNumber = new ASN1Integer(serialNumber);
}
/**
* @deprecated use X500Name constructor
*/
public IssuerAndSerialNumber(
X509Name name,
ASN1Integer serialNumber)
{
this.name = X500Name.getInstance(name);
this.serialNumber = serialNumber;
}
public X500Name getName()
{
return name;
}
public ASN1Integer getSerialNumber()
{
return serialNumber;
}
public ASN1Primitive toASN1Primitive()
{
ASN1EncodableVector v = new ASN1EncodableVector();
v.add(name);
v.add(serialNumber);
return new DERSequence(v);
}
}