Package ch.qos.logback.core.net.ssl
Class SSLContextFactoryBean
- java.lang.Object
-
- ch.qos.logback.core.net.ssl.SSLContextFactoryBean
-
- Direct Known Subclasses:
SSLConfiguration
public class SSLContextFactoryBean extends java.lang.Object
A factory bean for a JSSESSLContext
.This object holds the configurable properties for an SSL context and uses them to create an
SSLContext
instance.
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.String
JSSE_KEY_STORE_PROPERTY
private static java.lang.String
JSSE_TRUST_STORE_PROPERTY
private KeyManagerFactoryFactoryBean
keyManagerFactory
private KeyStoreFactoryBean
keyStore
private java.lang.String
protocol
private java.lang.String
provider
private SecureRandomFactoryBean
secureRandom
private TrustManagerFactoryFactoryBean
trustManagerFactory
private KeyStoreFactoryBean
trustStore
-
Constructor Summary
Constructors Constructor Description SSLContextFactoryBean()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description javax.net.ssl.SSLContext
createContext(ContextAware context)
Creates a newSSLContext
using the receiver's configuration.private javax.net.ssl.KeyManager[]
createKeyManagers(ContextAware context)
Creates key managers using the receiver's key store configuration.private java.security.SecureRandom
createSecureRandom(ContextAware context)
private javax.net.ssl.TrustManager[]
createTrustManagers(ContextAware context)
Creates trust managers using the receiver's trust store configuration.KeyManagerFactoryFactoryBean
getKeyManagerFactory()
Gets the key manager factory configuration.KeyStoreFactoryBean
getKeyStore()
Gets the key store configuration.java.lang.String
getProtocol()
Gets the secure transport protocol name.java.lang.String
getProvider()
Gets the JSSE provider name for the SSL context.SecureRandomFactoryBean
getSecureRandom()
Gets the secure random generator configuration.TrustManagerFactoryFactoryBean
getTrustManagerFactory()
Gets the trust manager factory configuration.KeyStoreFactoryBean
getTrustStore()
Gets the trust store configuration.private KeyStoreFactoryBean
keyStoreFromSystemProperties(java.lang.String property)
Constructs a key store factory bean using JSSE system properties.private java.lang.String
locationFromSystemProperty(java.lang.String name)
Constructs a resource location from a JSSE system property.void
setKeyManagerFactory(KeyManagerFactoryFactoryBean keyManagerFactory)
Sets the key manager factory configuration.void
setKeyStore(KeyStoreFactoryBean keyStore)
Sets the key store configuration.void
setProtocol(java.lang.String protocol)
Sets the secure transport protocol name.void
setProvider(java.lang.String provider)
Sets the JSSE provider name for the SSL context.void
setSecureRandom(SecureRandomFactoryBean secureRandom)
Sets the secure random generator configuration.void
setTrustManagerFactory(TrustManagerFactoryFactoryBean trustManagerFactory)
Sets the trust manager factory configuration.void
setTrustStore(KeyStoreFactoryBean trustStore)
Sets the trust store configuration.
-
-
-
Field Detail
-
JSSE_KEY_STORE_PROPERTY
private static final java.lang.String JSSE_KEY_STORE_PROPERTY
- See Also:
- Constant Field Values
-
JSSE_TRUST_STORE_PROPERTY
private static final java.lang.String JSSE_TRUST_STORE_PROPERTY
- See Also:
- Constant Field Values
-
keyStore
private KeyStoreFactoryBean keyStore
-
trustStore
private KeyStoreFactoryBean trustStore
-
secureRandom
private SecureRandomFactoryBean secureRandom
-
keyManagerFactory
private KeyManagerFactoryFactoryBean keyManagerFactory
-
trustManagerFactory
private TrustManagerFactoryFactoryBean trustManagerFactory
-
protocol
private java.lang.String protocol
-
provider
private java.lang.String provider
-
-
Method Detail
-
createContext
public javax.net.ssl.SSLContext createContext(ContextAware context) throws java.security.NoSuchProviderException, java.security.NoSuchAlgorithmException, java.security.KeyManagementException, java.security.UnrecoverableKeyException, java.security.KeyStoreException, java.security.cert.CertificateException
Creates a newSSLContext
using the receiver's configuration.- Parameters:
context
- context for status messages- Returns:
SSLContext
object- Throws:
java.security.NoSuchProviderException
- if a provider specified for one of the JCA or JSSE components utilized in creating the context is not known to the platformjava.security.NoSuchAlgorithmException
- if a JCA or JSSE algorithm, protocol, or type name specified for one of the context's components is not known to a given provider (or platform default provider for the component)java.security.KeyManagementException
- if an error occurs in creating aKeyManager
for the contextjava.security.UnrecoverableKeyException
- if a private key needed by aKeyManager
cannot be obtained from a key storejava.security.KeyStoreException
- if an error occurs in reading the contents of a key storejava.security.cert.CertificateException
- if an error occurs in reading the contents of a certificate
-
createKeyManagers
private javax.net.ssl.KeyManager[] createKeyManagers(ContextAware context) throws java.security.NoSuchProviderException, java.security.NoSuchAlgorithmException, java.security.UnrecoverableKeyException, java.security.KeyStoreException
Creates key managers using the receiver's key store configuration.- Parameters:
context
- context for status messages- Returns:
- an array of key managers or
null
if no key store configuration was provided - Throws:
java.security.NoSuchProviderException
- if a provider specified for one of the key manager components is not known to the platformjava.security.NoSuchAlgorithmException
- if an algorithm specified for one of the key manager components is not known to the relevant providerjava.security.KeyStoreException
- if an error occurs in reading a key storejava.security.UnrecoverableKeyException
-
createTrustManagers
private javax.net.ssl.TrustManager[] createTrustManagers(ContextAware context) throws java.security.NoSuchProviderException, java.security.NoSuchAlgorithmException, java.security.KeyStoreException
Creates trust managers using the receiver's trust store configuration.- Parameters:
context
- context for status messages- Returns:
- an array of trust managers or
null
if no trust store configuration was provided - Throws:
java.security.NoSuchProviderException
- if a provider specified for one of the trust manager components is not known to the platformjava.security.NoSuchAlgorithmException
- if an algorithm specified for one of the trust manager components is not known to the relevant providerjava.security.KeyStoreException
- if an error occurs in reading a key store containing trust anchors
-
createSecureRandom
private java.security.SecureRandom createSecureRandom(ContextAware context) throws java.security.NoSuchProviderException, java.security.NoSuchAlgorithmException
- Throws:
java.security.NoSuchProviderException
java.security.NoSuchAlgorithmException
-
getKeyStore
public KeyStoreFactoryBean getKeyStore()
Gets the key store configuration.- Returns:
- key store factory bean or
null
if no key store configuration was provided
-
setKeyStore
public void setKeyStore(KeyStoreFactoryBean keyStore)
Sets the key store configuration.- Parameters:
keyStore
- the key store factory bean to set
-
getTrustStore
public KeyStoreFactoryBean getTrustStore()
Gets the trust store configuration.- Returns:
- trust store factory bean or
null
if no trust store configuration was provided
-
setTrustStore
public void setTrustStore(KeyStoreFactoryBean trustStore)
Sets the trust store configuration.- Parameters:
trustStore
- the trust store factory bean to set
-
keyStoreFromSystemProperties
private KeyStoreFactoryBean keyStoreFromSystemProperties(java.lang.String property)
Constructs a key store factory bean using JSSE system properties.- Parameters:
property
- base property name (e.g.javax.net.ssl.keyStore
)- Returns:
- key store or
null
if no value is defined for the base system property name
-
locationFromSystemProperty
private java.lang.String locationFromSystemProperty(java.lang.String name)
Constructs a resource location from a JSSE system property.- Parameters:
name
- property name (e.g.javax.net.ssl.keyStore
)- Returns:
- URL for the location specified in the property or
null
if no value is defined for the property
-
getSecureRandom
public SecureRandomFactoryBean getSecureRandom()
Gets the secure random generator configuration.- Returns:
- secure random factory bean; if no secure random generator configuration has been set, a default factory bean is returned
-
setSecureRandom
public void setSecureRandom(SecureRandomFactoryBean secureRandom)
Sets the secure random generator configuration.- Parameters:
secureRandom
- the secure random factory bean to set
-
getKeyManagerFactory
public KeyManagerFactoryFactoryBean getKeyManagerFactory()
Gets the key manager factory configuration.- Returns:
- factory bean; if no key manager factory configuration has been set, a default factory bean is returned
-
setKeyManagerFactory
public void setKeyManagerFactory(KeyManagerFactoryFactoryBean keyManagerFactory)
Sets the key manager factory configuration.- Parameters:
keyManagerFactory
- the key manager factory factory bean to set
-
getTrustManagerFactory
public TrustManagerFactoryFactoryBean getTrustManagerFactory()
Gets the trust manager factory configuration.- Returns:
- factory bean; if no trust manager factory configuration has been set, a default factory bean is returned
-
setTrustManagerFactory
public void setTrustManagerFactory(TrustManagerFactoryFactoryBean trustManagerFactory)
Sets the trust manager factory configuration.- Parameters:
trustManagerFactory
- the factory bean to set
-
getProtocol
public java.lang.String getProtocol()
Gets the secure transport protocol name.- Returns:
- protocol name (e.g.
SSL
,TLS
); theSSL.DEFAULT_PROTOCOL
is returned if no protocol has been configured
-
setProtocol
public void setProtocol(java.lang.String protocol)
Sets the secure transport protocol name.- Parameters:
protocol
- a protocol name, which must be recognized by the provider specified bysetProvider(String)
or by the platform's default provider if no platform was specified.
-
getProvider
public java.lang.String getProvider()
Gets the JSSE provider name for the SSL context.- Returns:
- JSSE provider name
-
setProvider
public void setProvider(java.lang.String provider)
Sets the JSSE provider name for the SSL context.- Parameters:
provider
- name of the JSSE provider to use in creating the SSL context
-
-