Package ch.astorm.smtp4j.secure
Class DefaultSSLContextProvider
java.lang.Object
ch.astorm.smtp4j.secure.DefaultSSLContextProvider
- All Implemented Interfaces:
SSLContextProvider
Simple implementation of a
SSLContextProvider.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic DefaultSSLContextProviderCreates a newSSLContextProviderwith the givenkeyStoreandpassword.Returns anSSLContext.static DefaultSSLContextProviderCreates a newSSLContextProviderthat uses and internal generated keystore.
-
Constructor Details
-
DefaultSSLContextProvider
-
-
Method Details
-
create
public static DefaultSSLContextProvider create(KeyStore keyStore, char[] password) throws NoSuchAlgorithmException, KeyStoreException, UnrecoverableKeyException Creates a newSSLContextProviderwith the givenkeyStoreandpassword.- Parameters:
keyStore- TheKeyStore.password- The password.- Returns:
- A new
DefaultSSLContextProviderinstance. - Throws:
NoSuchAlgorithmExceptionKeyStoreExceptionUnrecoverableKeyException
-
selfSigned
public static DefaultSSLContextProvider selfSigned() throws NoSuchAlgorithmException, KeyStoreException, UnrecoverableKeyException, IOException, CertificateExceptionCreates a newSSLContextProviderthat uses and internal generated keystore. This provides an easy-for-use tool for testing TLS communications. This implies that the Session propertiesmail.smtp.ssl.checkserveridentityandmail.smtp.ssl.trustmust be set tofalseand*respectively.- Returns:
- A new
DefaultSSLContextProviderinstance. - Throws:
NoSuchAlgorithmExceptionKeyStoreExceptionUnrecoverableKeyExceptionIOExceptionCertificateException
-
getSSLContext
Description copied from interface:SSLContextProviderReturns anSSLContext.- Specified by:
getSSLContextin interfaceSSLContextProvider- Throws:
Exception
-