Package net.solarnetwork.service.support
Class ConfigurableSSLService
java.lang.Object
net.solarnetwork.service.support.ConfigurableSSLService
- All Implemented Interfaces:
SSLService
Basic implementation of
SSLService that allows configuring a keystore
and truststore to use for the SSLSocketFactory returned by
getSSLSocketFactory().- Version:
- 2.0
- Author:
- matt
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe default value for thekeyStorePathproperty.static final StringThe default password used for all configurable password properties.static final StringThe default value for thetrustStorePathproperty.protected final org.slf4j.LoggerA class-level logger to use. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected StringGet the JRE truststore password.Get a key manager factory, configured appropriately for the application.protected StringGet the keystore password.Get the path to the keystore.Get a SSL socket factory, configured appropriately for the application.Get a trust manager factory, configured appropriately for the application.protected StringGet the truststore password.Get the path to the truststore.protected KeyStorestatic final KeyStoreloadKeyStore(String type, InputStream in, String password) Load a keystore from anInputStream.protected KeyStoreprotected voidClear any cachedSSLSocketFactoryso that a subsequent call togetSSLSocketFactory()returns a new instance.static final voidsaveKeyStore(KeyStore keyStore, String password, OutputStream out) Serialize aKeyStoreto an output stream.voidsetJreTrustStorePassword(String jreTrustStorePassword) Set the JRE truststore password.voidsetKeyStorePassword(String keyStorePassword) Set the keystore password.voidsetKeyStorePath(String keyStorePath) Set the path to the keystore.voidsetTrustStorePassword(String trustStorePassword) Set the truststore password.voidsetTrustStorePath(String trustStorePath) Set the path to the truststore.
-
Field Details
-
DEFAULT_KEY_STORE_PATH
The default value for thekeyStorePathproperty.- See Also:
-
DEFAULT_TRUST_STORE_PATH
The default value for thetrustStorePathproperty.- See Also:
-
DEFAULT_PASSWORD
The default password used for all configurable password properties.- See Also:
-
log
protected final org.slf4j.Logger logA class-level logger to use.
-
-
Constructor Details
-
ConfigurableSSLService
public ConfigurableSSLService()
-
-
Method Details
-
loadKeyStore
Load a keystore from anInputStream.- Parameters:
type- The keystore type, e.g.KeyStore.getDefaultType().in- The stream to load from.password- The keystore password to use.- Returns:
- The keystore.
- Throws:
CertificateException- if any error occurs
-
saveKeyStore
Serialize aKeyStoreto an output stream.- Parameters:
keyStore- The keystore to serialize.password- The password to use.out- The stream to write to.- Throws:
CertificateException- if any error occurs
-
loadKeyStore
-
loadTrustStore
-
resetSocketFactory
protected void resetSocketFactory()Clear any cachedSSLSocketFactoryso that a subsequent call togetSSLSocketFactory()returns a new instance. -
getTrustManagerFactory
Description copied from interface:SSLServiceGet a trust manager factory, configured appropriately for the application.This method may return a singleton object.
- Specified by:
getTrustManagerFactoryin interfaceSSLService- Returns:
- the factory
-
getKeyManagerFactory
Description copied from interface:SSLServiceGet a key manager factory, configured appropriately for the application.This method may return a singleton object.
- Specified by:
getKeyManagerFactoryin interfaceSSLService- Returns:
- the factory
-
getSSLSocketFactory
Description copied from interface:SSLServiceGet a SSL socket factory, configured appropriately for the application.This method may return a singleton object.
- Specified by:
getSSLSocketFactoryin interfaceSSLService- Returns:
- the factory
-
getKeyStorePath
Get the path to the keystore.- Returns:
- the keyStorePath
-
setKeyStorePath
Set the path to the keystore.- Parameters:
keyStorePath- the keyStorePath to set
-
getTrustStorePath
Get the path to the truststore.- Returns:
- the trustStorePath
-
setTrustStorePath
Set the path to the truststore.- Parameters:
trustStorePath- the trustStorePath to set
-
getTrustStorePassword
Get the truststore password.- Returns:
- the trustStorePassword
-
setTrustStorePassword
Set the truststore password.- Parameters:
trustStorePassword- the trustStorePassword to set
-
getJreTrustStorePassword
Get the JRE truststore password.- Returns:
- the jreTrustStorePassword
-
setJreTrustStorePassword
Set the JRE truststore password.- Parameters:
jreTrustStorePassword- the jreTrustStorePassword to set
-
getKeyStorePassword
Get the keystore password.- Returns:
- The keystore password.
-
setKeyStorePassword
Set the keystore password.- Parameters:
keyStorePassword- the keyStorePassword to set
-