Class CMKeyStores
java.lang.Object
com.io7m.canonmill.core.CMKeyStores
Convenience methods for keystores.
-
Method Summary
Modifier and TypeMethodDescriptionstatic KeyStoreCreate a new keystore using thecanonmillprovider.static KeyStorecreateKeyStore(CMKeyStoreProvider provider) Create a new keystore using thecanonmill provider.static SSLContextcreateSSLContext(KeyStore keyStore, KeyStore trustStore, String protocol) Create an SSL context using the given keystore and truststore.static SSLContextcreateSSLContext(KeyStore keyStore, KeyStore trustStore, String protocol, SecureRandom random) Create an SSL context using the given keystore and truststore.static KeyStoreopenKeyStore(Path file) Open acanonmillkeystore from the given file.static KeyStoreopenKeyStore(Path file, CMKeyStoreProvider provider) Open acanonmillkeystore from the given file.static voidreloadKeystoreFromFile(KeyStore keyStore, Path file) Reload the given keystore from the given file.static voidreloadSSLContext(KeyStore keyStore, KeyStore trustStore, SSLContext context) Reload the given SSL context's key manager and trust manager.static voidreloadSSLContext(KeyStore keyStore, KeyStore trustStore, SSLContext context, SecureRandom random) Reload the given SSL context's key manager and trust manager.
-
Method Details
-
createKeyStore
Create a new keystore using thecanonmillprovider.- Returns:
- A new keystore
- Throws:
KeyStoreException- On errorsNoSuchProviderException- If thecanonmillprovider is not loaded.
-
createKeyStore
Create a new keystore using thecanonmill provider.- Parameters:
provider- A specific provider instance- Returns:
- A new keystore
- Throws:
KeyStoreException- On errors
-
reloadKeystoreFromFile
public static void reloadKeystoreFromFile(KeyStore keyStore, Path file) throws CertificateException, IOException, NoSuchAlgorithmException Reload the given keystore from the given file.- Parameters:
keyStore- The keystorefile- The file- Throws:
CertificateException- On certificate errorsIOException- On I/O errorsNoSuchAlgorithmException- On unsupported algorithms
-
createSSLContext
public static SSLContext createSSLContext(KeyStore keyStore, KeyStore trustStore, String protocol) throws NoSuchAlgorithmException, KeyStoreException, UnrecoverableKeyException, KeyManagementException Create an SSL context using the given keystore and truststore.- Parameters:
keyStore- The keystoretrustStore- The truststoreprotocol- The protocol (such as "TLSv1.3")- Returns:
- A new SSL context
- Throws:
NoSuchAlgorithmException- On missing algorithmsKeyStoreException- On keystore exceptionsUnrecoverableKeyException- On unrecoverable keysKeyManagementException- On key management errors
-
createSSLContext
public static SSLContext createSSLContext(KeyStore keyStore, KeyStore trustStore, String protocol, SecureRandom random) throws NoSuchAlgorithmException, KeyStoreException, UnrecoverableKeyException, KeyManagementException Create an SSL context using the given keystore and truststore.- Parameters:
keyStore- The keystoretrustStore- The truststoreprotocol- The protocol (such as "TLSv1.3")random- A secure random instance- Returns:
- A new SSL context
- Throws:
NoSuchAlgorithmException- On missing algorithmsKeyStoreException- On keystore exceptionsUnrecoverableKeyException- On unrecoverable keysKeyManagementException- On key management errors
-
reloadSSLContext
public static void reloadSSLContext(KeyStore keyStore, KeyStore trustStore, SSLContext context, SecureRandom random) throws NoSuchAlgorithmException, UnrecoverableKeyException, KeyStoreException, KeyManagementException Reload the given SSL context's key manager and trust manager. This, effectively, reloads the keys and certificates in the context.- Parameters:
keyStore- The keystoretrustStore- The truststorecontext- The SSL contextrandom- A secure random instance- Throws:
NoSuchAlgorithmException- On missing algorithmsKeyStoreException- On keystore exceptionsUnrecoverableKeyException- On unrecoverable keysKeyManagementException- On key management errors
-
reloadSSLContext
public static void reloadSSLContext(KeyStore keyStore, KeyStore trustStore, SSLContext context) throws NoSuchAlgorithmException, UnrecoverableKeyException, KeyStoreException, KeyManagementException Reload the given SSL context's key manager and trust manager. This, effectively, reloads the keys and certificates in the context.- Parameters:
keyStore- The keystoretrustStore- The truststorecontext- The SSL context- Throws:
NoSuchAlgorithmException- On missing algorithmsKeyStoreException- On keystore exceptionsUnrecoverableKeyException- On unrecoverable keysKeyManagementException- On key management errors
-
openKeyStore
public static KeyStore openKeyStore(Path file, CMKeyStoreProvider provider) throws KeyStoreException, CertificateException, IOException, NoSuchAlgorithmException Open acanonmillkeystore from the given file.- Parameters:
file- The fileprovider- The specific provider- Returns:
- A keystore
- Throws:
NoSuchAlgorithmException- On missing algorithmsKeyStoreException- On keystore exceptionsCertificateException- On certificate exceptionsIOException- On I/O errors
-
openKeyStore
public static KeyStore openKeyStore(Path file) throws KeyStoreException, CertificateException, IOException, NoSuchAlgorithmException, NoSuchProviderException Open acanonmillkeystore from the given file.- Parameters:
file- The file- Returns:
- A keystore
- Throws:
NoSuchAlgorithmException- On missing algorithmsKeyStoreException- On keystore exceptionsCertificateException- On certificate exceptionsIOException- On I/O errorsNoSuchProviderException- If thecanonmillprovider is not loaded
-