Package org.wildfly.security.x500.cert
Class X509CertificateBuilder
java.lang.Object
org.wildfly.security.x500.cert.X509CertificateBuilder
A builder for X.509 certificates.
- Author:
- David M. Lloyd
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddExtension(X509CertificateExtension extension) Add a certificate extension.addOrReplaceExtension(X509CertificateExtension extension) Add or replace a certificate extension.build()Attempt to construct and sign an X.509 certificate according to the information in this builder.Get the issuer DN.byte[]Get the issuer unique ID.Get the not-valid-after date.Get the not-valid-before date.Get the public key.Get the serial number of the certificate being built.Get the signature algorithm name.Get the signing key.Get the subject DN.byte[]Get the subject unique ID.intGet the certificate version.removeExtension(String oid) Remove the extension with the given OID, if it is registered.setIssuerDn(X500Principal issuerDn) Set the issuer DN.setIssuerUniqueId(byte[] issuerUniqueId) Set the issuer unique ID.setNotValidAfter(ZonedDateTime notValidAfter) Set the not-valid-after date.setNotValidBefore(ZonedDateTime notValidBefore) Set the not-valid-before date.setPublicKey(PublicKey publicKey) Set the public key.setSerialNumber(BigInteger serialNumber) Set the serial number of the certificate being built.setSignatureAlgorithmName(String signatureAlgorithmName) Set the signature algorithm name.setSigningKey(PrivateKey signingKey) Set the signing key.setSubjectDn(X500Principal subjectDn) Set the subject DN.setSubjectUniqueId(byte[] subjectUniqueId) Set the subject unique ID.setVersion(int version) Set the certificate version.
-
Constructor Details
-
X509CertificateBuilder
public X509CertificateBuilder()Construct a new uninitialized instance.
-
-
Method Details
-
addExtension
Add a certificate extension. If an extension with the same OID already exists, an exception is thrown.- Parameters:
extension- the extension to add (must not benull)- Returns:
- this builder instance
-
addOrReplaceExtension
Add or replace a certificate extension. If an extension with the same OID already exists, it is replaced and returned.- Parameters:
extension- the extension to add (must not benull)- Returns:
- the existing extension, or
nullif no other extension with the same OID was existent
-
removeExtension
Remove the extension with the given OID, if it is registered.- Parameters:
oid- the OID of the extension to remove- Returns:
- the extension, or
nullif no extension with the same OID was existent
-
getVersion
public int getVersion()Get the certificate version.- Returns:
- the certificate version
-
setVersion
Set the certificate version.- Parameters:
version- the certificate version (must be between 1 and 3, inclusive)- Returns:
- this builder instance
-
getSerialNumber
Get the serial number of the certificate being built.- Returns:
- the serial number of the certificate being built (must not be
null)
-
setSerialNumber
Set the serial number of the certificate being built. The serial number must be positive and no larger than 20 octets (or 2^160).- Parameters:
serialNumber- the serial number of the certificate being built- Returns:
- this builder instance
-
getSubjectDn
Get the subject DN.- Returns:
- the subject DN
-
setSubjectDn
Set the subject DN.- Parameters:
subjectDn- the subject DN (must not benull)- Returns:
- this builder instance
-
getSubjectUniqueId
public byte[] getSubjectUniqueId()Get the subject unique ID.- Returns:
- the subject unique ID
-
setSubjectUniqueId
Set the subject unique ID.- Parameters:
subjectUniqueId- the subject unique ID (must not benull)- Returns:
- this builder instance
-
getIssuerDn
Get the issuer DN.- Returns:
- the issuer DN
-
setIssuerDn
Set the issuer DN.- Parameters:
issuerDn- the issuer DN (must not benull)- Returns:
- this builder instance
-
getIssuerUniqueId
public byte[] getIssuerUniqueId()Get the issuer unique ID.- Returns:
- the issuer unique ID
-
setIssuerUniqueId
Set the issuer unique ID.- Parameters:
issuerUniqueId- the issuer unique ID (must not benull)- Returns:
- this builder instance
-
getNotValidBefore
Get the not-valid-before date. The default is the date when this builder was constructed.- Returns:
- the not-valid-before date
-
setNotValidBefore
Set the not-valid-before date.- Parameters:
notValidBefore- the not-valid-before date (must not benull)- Returns:
- this builder instance
-
getNotValidAfter
Get the not-valid-after date. The default is equal to99991231235959Zas specified inRFC 5280.- Returns:
- the not-valid-after date
-
setNotValidAfter
Set the not-valid-after date.- Parameters:
notValidAfter- the not-valid-after date (must not benull)- Returns:
- this builder instance
-
getPublicKey
Get the public key.- Returns:
- the public key
-
setPublicKey
Set the public key.- Parameters:
publicKey- the public key (must not benull)- Returns:
- this builder instance
-
getSigningKey
Get the signing key.- Returns:
- the signing key
-
setSigningKey
Set the signing key.- Parameters:
signingKey- the signing key (must not benull)- Returns:
- this builder instance
-
getSignatureAlgorithmName
Get the signature algorithm name.- Returns:
- the signature algorithm name
-
setSignatureAlgorithmName
Set the signature algorithm name.- Parameters:
signatureAlgorithmName- the signature algorithm name (must not benull)- Returns:
- this builder instance
-
build
Attempt to construct and sign an X.509 certificate according to the information in this builder.- Returns:
- the constructed certificate
- Throws:
IllegalArgumentException- if one or more of the builder parameters are invalid or missingCertificateException- if the certificate failed to be constructed
-