Class TestCertificates
java.lang.Object
com.irurueta.authserver.testsupport.TestCertificates
Generates self-signed client certificates at run time for the tests of the sign-in with a client certificate, so no
certificate, key or key store is ever kept in the repository. It drives the
keytool of the JDK that runs the
tests: the JDK has no public API to issue a certificate, and a key store file only exists in a temporary directory
for the time it takes to read the certificate back.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordA generated certificate. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final StringAlias of the generated key.private static final StringStart of the validity of an expired certificate: five days ago, so that its two days are long gone.private static final StringType of the key store the certificate is read from.private static final intNumber of random bytes of the password of the temporary key store.private static final intCharacters of a line of a PEM certificate.private static final SecureRandomSource of the password of the temporary key store. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGenerates a self-signed certificate.private static TestCertificates.GeneratedCertificateGenerates a self-signed certificate.generateExpired(String commonName) Generates a self-signed certificate that expired days ago.of(X509Certificate certificate) Describes a certificate.
-
Field Details
-
ALIAS
Alias of the generated key.- See Also:
-
KEY_STORE_TYPE
Type of the key store the certificate is read from.- See Also:
-
EXPIRED_START
Start of the validity of an expired certificate: five days ago, so that its two days are long gone.- See Also:
-
PASSWORD_BYTES
private static final int PASSWORD_BYTESNumber of random bytes of the password of the temporary key store.- See Also:
-
PEM_LINE_LENGTH
private static final int PEM_LINE_LENGTHCharacters of a line of a PEM certificate.- See Also:
-
RANDOM
Source of the password of the temporary key store.
-
-
Constructor Details
-
TestCertificates
private TestCertificates()Not instantiable.
-
-
Method Details
-
generate
Generates a self-signed certificate.- Parameters:
commonName- common name of the subject.- Returns:
- the certificate, with its PEM text and its SHA-256 fingerprint.
-
generateExpired
Generates a self-signed certificate that expired days ago.- Parameters:
commonName- common name of the subject.- Returns:
- the certificate, with its PEM text and its SHA-256 fingerprint.
-
generate
private static TestCertificates.GeneratedCertificate generate(String commonName, List<String> extra) Generates a self-signed certificate.- Parameters:
commonName- common name of the subject.extra- additionalkeytoolarguments.- Returns:
- the certificate, with its PEM text and its SHA-256 fingerprint.
-
of
Describes a certificate.- Parameters:
certificate- the certificate.- Returns:
- the certificate with its PEM text and its SHA-256 fingerprint.
-