Top Description Fields Constructors Methods
org.bouncycastle.x509

public Class X509V3CertificateGenerator

extends Object
Class Inheritance
Imports
java.io.ByteArrayInputStream, .IOException, java.math.BigInteger, java.security.GeneralSecurityException, .InvalidKeyException, .NoSuchAlgorithmException, .NoSuchProviderException, .PrivateKey, .PublicKey, .SecureRandom, .SignatureException, java.security.cert.CertificateEncodingException, .CertificateParsingException, .X509Certificate, java.util.Date, .Iterator, javax.security.auth.x500.X500Principal, org.bouncycastle.asn1.ASN1Encodable, .ASN1EncodableVector, .ASN1Encoding, .ASN1InputStream, .ASN1Integer, .ASN1ObjectIdentifier, .DERBitString, .DERSequence, org.bouncycastle.asn1.x509.AlgorithmIdentifier, .SubjectPublicKeyInfo, .TBSCertificate, .Time, .V3TBSCertificateGenerator, .X509ExtensionsGenerator, .X509Name, org.bouncycastle.jcajce.provider.asymmetric.x509.CertificateFactory, org.bouncycastle.jcajce.util.BCJcaJceHelper, .JcaJceHelper, org.bouncycastle.jce.X509Principal, org.bouncycastle.x509.extension.X509ExtensionUtil

Deprecated

use org.bouncycastle.cert.X509v3CertificateBuilder.

class to produce an X.509 Version 3 certificate.

Field Summary

Modifier and TypeField and Description
private final JcaJceHelper
private final CertificateFactory
private X509ExtensionsGenerator
extGenerator

Deprecated as a consequence of X509ExtensionsGenerator being deprecated.
private AlgorithmIdentifier
private String
private ASN1ObjectIdentifier
private V3TBSCertificateGenerator

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
addExtension(String oid, boolean critical, ASN1Encodable value)

add a given extension field for the standard extensions tag (tag 3)

public void
addExtension(ASN1ObjectIdentifier oid, boolean critical, ASN1Encodable value)

add a given extension field for the standard extensions tag (tag 3)

public void
addExtension(String oid, boolean critical, byte[] value)

add a given extension field for the standard extensions tag (tag 3) The value parameter becomes the contents of the octet string associated with the extension.

public void
addExtension(ASN1ObjectIdentifier oid, boolean critical, byte[] value)

add a given extension field for the standard extensions tag (tag 3)

private DERBitString
booleanToBitString(boolean[] id)

public void
copyAndAddExtension(String oid, boolean critical, X509Certificate cert)

add a given extension field for the standard extensions tag (tag 3) copying the extension value from another certificate.

public void
copyAndAddExtension(ASN1ObjectIdentifier oid, boolean critical, X509Certificate cert)

add a given extension field for the standard extensions tag (tag 3) copying the extension value from another certificate.

public X509Certificate
generate(PrivateKey key)

generate an X509 certificate, based on the current issuer and subject using the default provider.

public X509Certificate
generate(PrivateKey key, SecureRandom random)

generate an X509 certificate, based on the current issuer and subject using the default provider, and the passed in source of randomness (if required).

public X509Certificate
generate(PrivateKey key, String provider)

generate an X509 certificate, based on the current issuer and subject, using the passed in provider for the signing.

public X509Certificate
generate(PrivateKey key, String provider, SecureRandom random)

generate an X509 certificate, based on the current issuer and subject, using the passed in provider for the signing and the supplied source of randomness, if required.

private X509Certificate
generateJcaObject(TBSCertificate tbsCert, byte[] signature)

private TBSCertificate
public X509Certificate
generateX509Certificate(PrivateKey key)

Deprecated use generate(key, "BC")
generate an X509 certificate, based on the current issuer and subject using the default provider "BC".
public X509Certificate
generateX509Certificate(PrivateKey key, SecureRandom random)

Deprecated use generate(key, random, "BC")
generate an X509 certificate, based on the current issuer and subject using the default provider "BC", and the passed in source of randomness (if required).
public X509Certificate
generateX509Certificate(PrivateKey key, String provider)

Deprecated use generate()
generate an X509 certificate, based on the current issuer and subject, using the passed in provider for the signing.
public X509Certificate
generateX509Certificate(PrivateKey key, String provider, SecureRandom random)

Deprecated use generate()
generate an X509 certificate, based on the current issuer and subject, using the passed in provider for the signing and the supplied source of randomness, if required.
public Iterator<E>

Returns:

an iterator containing recognised names.
getSignatureAlgNames
()

Return an iterator of the signature names supported by the generator.

public void
reset()

reset the generator

public void
setIssuerDN(X500Principal issuer)

Set the issuer distinguished name - the issuer is the entity whose private key is used to sign the certificate.

public void
setIssuerDN(X509Name issuer)

Deprecated as a consequence of X509Name being deprecated.
Set the issuer distinguished name - the issuer is the entity whose private key is used to sign the certificate.
public void
setIssuerUniqueID(boolean[] uniqueID)

Set the issuer unique ID - note: it is very rare that it is correct to do this.

public void
public void
public void
public void
setSerialNumber(BigInteger serialNumber)

set the serial number for the certificate.

public void
setSignatureAlgorithm(String
string representation of the algorithm name.
signatureAlgorithm
)

Set the signature algorithm.

public void
setSubjectDN(X500Principal subject)

Set the subject distinguished name.

public void
setSubjectDN(X509Name subject)

Deprecated as a consequence of X509Name being deprecated.
Set the subject distinguished name.
public void
setSubjectUniqueID(boolean[] uniqueID)

Set the subject unique ID - note: it is very rare that it is correct to do this.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

bcHelperback to summary
private final JcaJceHelper bcHelper
certificateFactoryback to summary
private final CertificateFactory certificateFactory
extGeneratorback to summary
private X509ExtensionsGenerator extGenerator

Deprecated

as a consequence of X509ExtensionsGenerator being deprecated. See corresponding docs for further information.

sigAlgIdback to summary
private AlgorithmIdentifier sigAlgId
signatureAlgorithmback to summary
private String signatureAlgorithm
sigOIDback to summary
private ASN1ObjectIdentifier sigOID
tbsGenback to summary
private V3TBSCertificateGenerator tbsGen

Constructor Detail

X509V3CertificateGeneratorback to summary
public X509V3CertificateGenerator()

Method Detail

addExtensionback to summary
public void addExtension(String oid, boolean critical, ASN1Encodable value)

add a given extension field for the standard extensions tag (tag 3)

addExtensionback to summary
public void addExtension(ASN1ObjectIdentifier oid, boolean critical, ASN1Encodable value)

add a given extension field for the standard extensions tag (tag 3)

addExtensionback to summary
public void addExtension(String oid, boolean critical, byte[] value)

add a given extension field for the standard extensions tag (tag 3) The value parameter becomes the contents of the octet string associated with the extension.

addExtensionback to summary
public void addExtension(ASN1ObjectIdentifier oid, boolean critical, byte[] value)

add a given extension field for the standard extensions tag (tag 3)

booleanToBitStringback to summary
private DERBitString booleanToBitString(boolean[] id)
copyAndAddExtensionback to summary
public void copyAndAddExtension(String oid, boolean critical, X509Certificate cert) throws CertificateParsingException

add a given extension field for the standard extensions tag (tag 3) copying the extension value from another certificate.

Exceptions
CertificateParsingException:
if the extension cannot be extracted.
copyAndAddExtensionback to summary
public void copyAndAddExtension(ASN1ObjectIdentifier oid, boolean critical, X509Certificate cert) throws CertificateParsingException

add a given extension field for the standard extensions tag (tag 3) copying the extension value from another certificate.

Exceptions
CertificateParsingException:
if the extension cannot be extracted.
generateback to summary
public X509Certificate generate(PrivateKey key) throws CertificateEncodingException, IllegalStateException, NoSuchAlgorithmException, SignatureException, InvalidKeyException

generate an X509 certificate, based on the current issuer and subject using the default provider.

Note

this differs from the deprecated method in that the default provider is used - not "BC".

generateback to summary
public X509Certificate generate(PrivateKey key, SecureRandom random) throws CertificateEncodingException, IllegalStateException, NoSuchAlgorithmException, SignatureException, InvalidKeyException

generate an X509 certificate, based on the current issuer and subject using the default provider, and the passed in source of randomness (if required).

Note

this differs from the deprecated method in that the default provider is used - not "BC".

generateback to summary
public X509Certificate generate(PrivateKey key, String provider) throws CertificateEncodingException, IllegalStateException, NoSuchProviderException, NoSuchAlgorithmException, SignatureException, InvalidKeyException

generate an X509 certificate, based on the current issuer and subject, using the passed in provider for the signing.

generateback to summary
public X509Certificate generate(PrivateKey key, String provider, SecureRandom random) throws CertificateEncodingException, IllegalStateException, NoSuchProviderException, NoSuchAlgorithmException, SignatureException, InvalidKeyException

generate an X509 certificate, based on the current issuer and subject, using the passed in provider for the signing and the supplied source of randomness, if required.

generateJcaObjectback to summary
private X509Certificate generateJcaObject(TBSCertificate tbsCert, byte[] signature) throws Exception
generateTbsCertback to summary
private TBSCertificate generateTbsCert()
generateX509Certificateback to summary
public X509Certificate generateX509Certificate(PrivateKey key) throws SecurityException, SignatureException, InvalidKeyException

Deprecated

use generate(key, "BC")

generate an X509 certificate, based on the current issuer and subject using the default provider "BC".

generateX509Certificateback to summary
public X509Certificate generateX509Certificate(PrivateKey key, SecureRandom random) throws SecurityException, SignatureException, InvalidKeyException

Deprecated

use generate(key, random, "BC")

generate an X509 certificate, based on the current issuer and subject using the default provider "BC", and the passed in source of randomness (if required).

generateX509Certificateback to summary
public X509Certificate generateX509Certificate(PrivateKey key, String provider) throws NoSuchProviderException, SecurityException, SignatureException, InvalidKeyException

Deprecated

use generate()

generate an X509 certificate, based on the current issuer and subject, using the passed in provider for the signing.

generateX509Certificateback to summary
public X509Certificate generateX509Certificate(PrivateKey key, String provider, SecureRandom random) throws NoSuchProviderException, SecurityException, SignatureException, InvalidKeyException

Deprecated

use generate()

generate an X509 certificate, based on the current issuer and subject, using the passed in provider for the signing and the supplied source of randomness, if required.

getSignatureAlgNamesback to summary
public Iterator<E> getSignatureAlgNames()

Return an iterator of the signature names supported by the generator.

Returns:Iterator<E>

an iterator containing recognised names.

resetback to summary
public void reset()

reset the generator

setIssuerDNback to summary
public void setIssuerDN(X500Principal issuer)

Set the issuer distinguished name - the issuer is the entity whose private key is used to sign the certificate.

setIssuerDNback to summary
public void setIssuerDN(X509Name issuer)

Deprecated

as a consequence of X509Name being deprecated. See corresponding docs for further information.

Set the issuer distinguished name - the issuer is the entity whose private key is used to sign the certificate.

setIssuerUniqueIDback to summary
public void setIssuerUniqueID(boolean[] uniqueID)

Set the issuer unique ID - note: it is very rare that it is correct to do this.

setNotAfterback to summary
public void setNotAfter(Date date)
setNotBeforeback to summary
public void setNotBefore(Date date)
setPublicKeyback to summary
public void setPublicKey(PublicKey key) throws IllegalArgumentException
setSerialNumberback to summary
public void setSerialNumber(BigInteger serialNumber)

set the serial number for the certificate.

setSignatureAlgorithmback to summary
public void setSignatureAlgorithm(String signatureAlgorithm)

Set the signature algorithm. This can be either a name or an OID, names are treated as case insensitive.

Parameters
signatureAlgorithm:String

string representation of the algorithm name.

setSubjectDNback to summary
public void setSubjectDN(X500Principal subject)

Set the subject distinguished name. The subject describes the entity associated with the public key.

setSubjectDNback to summary
public void setSubjectDN(X509Name subject)

Deprecated

as a consequence of X509Name being deprecated. See corresponding docs for further information.

Set the subject distinguished name. The subject describes the entity associated with the public key.

setSubjectUniqueIDback to summary
public void setSubjectUniqueID(boolean[] uniqueID)

Set the subject unique ID - note: it is very rare that it is correct to do this.