org.bouncycastle.asn1.cms.IssuerAndSerialNumber 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.
The newest version!
/***************************************************************/
/****** DO NOT EDIT THIS CLASS bc-java SOURCE FILE ******/
/***************************************************************/
package org.bouncycastle.asn1.cms;
import java.math.BigInteger;
import org.bouncycastle.asn1.ASN1EncodableVector;
import org.bouncycastle.asn1.ASN1Integer;
import org.bouncycastle.asn1.ASN1Object;
import org.bouncycastle.asn1.ASN1Primitive;
import org.bouncycastle.asn1.ASN1Sequence;
import org.bouncycastle.asn1.DERSequence;
import org.bouncycastle.asn1.x500.X500Name;
import org.bouncycastle.asn1.x509.Certificate;
/**
* RFC 5652: IssuerAndSerialNumber object.
*
*
* IssuerAndSerialNumber ::= SEQUENCE {
* issuer Name,
* serialNumber CertificateSerialNumber
* }
*
* CertificateSerialNumber ::= INTEGER -- See RFC 5280
*
*/
public class IssuerAndSerialNumber
extends ASN1Object
{
private X500Name name;
private ASN1Integer serialNumber;
/**
* Return an IssuerAndSerialNumber object from the given object.
*
* Accepted inputs:
*
* - null → null
*
- {@link IssuerAndSerialNumber} object
*
- {@link org.bouncycastle.asn1.ASN1Sequence#getInstance(java.lang.Object) ASN1Sequence} input formats with IssuerAndSerialNumber structure inside
*
*
* @param obj the object we want converted.
* @exception IllegalArgumentException if the object cannot be converted.
*/
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;
}
private 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(
X500Name name,
BigInteger serialNumber)
{
this.name = name;
this.serialNumber = new ASN1Integer(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);
}
}