Class KeyStoreUtils
java.lang.Object
org.wildfly.test.security.common.other.KeyStoreUtils
Common methods for keystore generation.
- Author:
- Jan Stourac
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic classstatic enum -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic KeyStoregenerateKeystore(KeyStoreUtils.KeyEntry[] keys, KeyStoreUtils.CertEntry[] trustCerts, String keystorePassword) Generates keystore of JKS type with specified key and cert entries.static KeyStoregenerateKeystore(KeyStoreUtils.KeyStoreType keyStoreType, KeyStoreUtils.KeyEntry[] keys, KeyStoreUtils.CertEntry[] trustCerts, String keystorePassword) Generates keystore of given type with specified key and cert entries.static voidsaveKeystore(KeyStore keyStore, String keystorePassword, File keystoreFile) Saves given keystore on the filesystem.static voidsaveKeystore(KeyStore keyStore, String keystorePassword, String keystoreFile) Saves given keystore on the filesystem.
-
Constructor Details
-
KeyStoreUtils
public KeyStoreUtils()
-
-
Method Details
-
generateKeystore
public static KeyStore generateKeystore(KeyStoreUtils.KeyEntry[] keys, KeyStoreUtils.CertEntry[] trustCerts, String keystorePassword) throws KeyStoreException, CertificateException, NoSuchAlgorithmException, IOException Generates keystore of JKS type with specified key and cert entries. Thus using this method one can create both keystore and truststore.- Parameters:
keys- array of key-pair entriestrustCerts- array of trusted certificates entrieskeystorePassword- keystore password- Returns:
- generated keystore instance with given entries as a content
- Throws:
KeyStoreExceptionCertificateExceptionNoSuchAlgorithmExceptionIOException
-
generateKeystore
public static KeyStore generateKeystore(KeyStoreUtils.KeyStoreType keyStoreType, KeyStoreUtils.KeyEntry[] keys, KeyStoreUtils.CertEntry[] trustCerts, String keystorePassword) throws KeyStoreException, CertificateException, NoSuchAlgorithmException, IOException Generates keystore of given type with specified key and cert entries. Thus using this method one can create both keystore and truststore.- Parameters:
keyStoreType- type of keystore to be createdkeys- array of key-pair entriestrustCerts- array of trusted certificates entrieskeystorePassword- keystore password- Returns:
- generated keystore instance with given entries as a content
- Throws:
KeyStoreExceptionCertificateExceptionNoSuchAlgorithmExceptionIOException
-
saveKeystore
public static void saveKeystore(KeyStore keyStore, String keystorePassword, File keystoreFile) throws IOException, CertificateException, NoSuchAlgorithmException, KeyStoreException Saves given keystore on the filesystem.- Parameters:
keyStore- keystore to be savedkeystorePassword- password for keystorekeystoreFile- destination keystore file on the filesystem- Throws:
IOExceptionCertificateExceptionNoSuchAlgorithmExceptionKeyStoreException
-
saveKeystore
public static void saveKeystore(KeyStore keyStore, String keystorePassword, String keystoreFile) throws IOException, CertificateException, NoSuchAlgorithmException, KeyStoreException Saves given keystore on the filesystem.- Parameters:
keyStore- keystore to be savedkeystorePassword- password for keystorekeystoreFile- destination keystore file on the filesystem- Throws:
IOExceptionCertificateExceptionNoSuchAlgorithmExceptionKeyStoreException
-