public class SelfSignedCertificateGenerator extends Object
| Modifier and Type | Class and Description |
|---|---|
private static class |
SelfSignedCertificateGenerator.CommandLineArgs
Manages command line parsing for application and the bean properties used by the generator.
|
static class |
SelfSignedCertificateGenerator.FileConverter
Command line option conversion from String to File.
|
| Modifier and Type | Field and Description |
|---|---|
private SelfSignedCertificateGenerator.CommandLineArgs |
args
Container for options that can be parsed from a command line.
|
private Logger |
log
Class logger.
|
| Constructor and Description |
|---|
SelfSignedCertificateGenerator()
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
protected org.bouncycastle.asn1.ASN1Encodable[] |
buildSubjectAltNames()
Builds the subject alt names for the certificate.
|
void |
generate()
The main routine.
|
protected X509Certificate |
generateCertificate(KeyPair keypair)
Generates the self-signed certificate.
|
protected KeyPair |
generateKeyPair()
Generates the key pair for the certificate.
|
static void |
main(String[] args)
Command line entry point.
|
void |
setCertificateAlg(String alg)
Set the certificate algorithm that will be used.
|
void |
setCertificateFile(File file)
Set the file to which the certificate will be written.
|
void |
setCertificateLifetime(int lifetime)
Set the number of years for which the certificate will be valid.
|
void |
setDNSSubjectAltNames(Collection<String> altNames)
Set the optional DNS subject alt names.
|
void |
setHostName(String name)
Set the hostname that will appear in the certificate's DN.
|
void |
setKeySize(int size)
Set the size of the generated key.
|
void |
setKeystoreFile(File file)
Set the file to which the keystore will be written.
|
void |
setKeystorePassword(String password)
Set the password for the generated keystore.
|
void |
setKeystoreType(String type)
Set the type of keystore to create.
|
void |
setKeyType(String type)
Set the type of key that will be generated.
|
void |
setPrivateKeyFile(File file)
Set the file to which the private key will be written.
|
void |
setURISubjectAltNames(Collection<String> altNames)
Set the optional URI subject alt names.
|
protected void |
validate()
Validates the settings.
|
@Nonnull private final SelfSignedCertificateGenerator.CommandLineArgs args
public SelfSignedCertificateGenerator()
public void setKeyType(@Nonnull@NotEmpty String type)
type - type of key that will be generatedpublic void setKeySize(@Positive int size)
size - size of the generated keypublic void setCertificateLifetime(@Positive int lifetime)
lifetime - number of years for which the certificate will be validpublic void setCertificateAlg(@Nonnull@NotEmpty String alg)
alg - certificate algorithmpublic void setHostName(@Nonnull@NotEmpty String name)
name - hostname that will appear in the certificate's DNpublic void setPrivateKeyFile(@Nullable File file)
file - file to which the private key will be writtenpublic void setCertificateFile(@Nullable File file)
file - file to which the certificate will be writtenpublic void setKeystoreType(@Nonnull@NotEmpty String type)
type - keystore typepublic void setKeystoreFile(@Nullable File file)
file - file to which the keystore will be writtenpublic void setKeystorePassword(@Nullable String password)
password - password for the generated keystorepublic void setDNSSubjectAltNames(@Nonnull@NonnullElements Collection<String> altNames)
altNames - collection of subject alt names.public void setURISubjectAltNames(@Nonnull@NonnullElements Collection<String> altNames)
altNames - collection of subject alt names.public void generate()
throws Exception
Exception - if an error occursprotected void validate()
@Nonnull protected KeyPair generateKeyPair() throws NoSuchAlgorithmException
NoSuchAlgorithmException - if there is a problem generating the keys@Nonnull protected X509Certificate generateCertificate(@Nonnull KeyPair keypair) throws Exception
keypair - keypair associated with the certificateException - if an error occurs@Nonnull @NonnullElements protected org.bouncycastle.asn1.ASN1Encodable[] buildSubjectAltNames()
Copyright © 1999–2020 Shibboleth Consortium. All rights reserved.