Package ch.qos.logback.core.net.ssl
Class SSLContextFactoryBean
java.lang.Object
ch.qos.logback.core.net.ssl.SSLContextFactoryBean
- Direct Known Subclasses:
SSLConfiguration
A factory bean for a JSSE
SSLContext.
This object holds the configurable properties for an SSL context and uses
them to create an SSLContext instance.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final Stringprivate static final Stringprivate KeyManagerFactoryFactoryBeanprivate KeyStoreFactoryBeanprivate Stringprivate Stringprivate SecureRandomFactoryBeanprivate TrustManagerFactoryFactoryBeanprivate KeyStoreFactoryBean -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncreateContext(ContextAware context) Creates a newSSLContextusing the receiver's configuration.private KeyManager[]createKeyManagers(ContextAware context) Creates key managers using the receiver's key store configuration.private SecureRandomcreateSecureRandom(ContextAware context) private TrustManager[]createTrustManagers(ContextAware context) Creates trust managers using the receiver's trust store configuration.Gets the key manager factory configuration.Gets the key store configuration.Gets the secure transport protocol name.Gets the JSSE provider name for the SSL context.Gets the secure random generator configuration.Gets the trust manager factory configuration.Gets the trust store configuration.private KeyStoreFactoryBeankeyStoreFromSystemProperties(String property) Constructs a key store factory bean using JSSE system properties.private StringConstructs a resource location from a JSSE system property.voidsetKeyManagerFactory(KeyManagerFactoryFactoryBean keyManagerFactory) Sets the key manager factory configuration.voidsetKeyStore(KeyStoreFactoryBean keyStore) Sets the key store configuration.voidsetProtocol(String protocol) Sets the secure transport protocol name.voidsetProvider(String provider) Sets the JSSE provider name for the SSL context.voidsetSecureRandom(SecureRandomFactoryBean secureRandom) Sets the secure random generator configuration.voidsetTrustManagerFactory(TrustManagerFactoryFactoryBean trustManagerFactory) Sets the trust manager factory configuration.voidsetTrustStore(KeyStoreFactoryBean trustStore) Sets the trust store configuration.
-
Field Details
-
JSSE_KEY_STORE_PROPERTY
- See Also:
-
JSSE_TRUST_STORE_PROPERTY
- See Also:
-
keyStore
-
trustStore
-
secureRandom
-
keyManagerFactory
-
trustManagerFactory
-
protocol
-
provider
-
-
Constructor Details
-
SSLContextFactoryBean
public SSLContextFactoryBean()
-
-
Method Details
-
createContext
public SSLContext createContext(ContextAware context) throws NoSuchProviderException, NoSuchAlgorithmException, KeyManagementException, UnrecoverableKeyException, KeyStoreException, CertificateException Creates a newSSLContextusing the receiver's configuration.- Parameters:
context- context for status messages- Returns:
SSLContextobject- Throws:
NoSuchProviderException- if a provider specified for one of the JCA or JSSE components utilized in creating the context is not known to the platformNoSuchAlgorithmException- 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)KeyManagementException- if an error occurs in creating aKeyManagerfor the contextUnrecoverableKeyException- if a private key needed by aKeyManagercannot be obtained from a key storeKeyStoreException- if an error occurs in reading the contents of a key storeCertificateException- if an error occurs in reading the contents of a certificate
-
createKeyManagers
private KeyManager[] createKeyManagers(ContextAware context) throws NoSuchProviderException, NoSuchAlgorithmException, UnrecoverableKeyException, KeyStoreException Creates key managers using the receiver's key store configuration.- Parameters:
context- context for status messages- Returns:
- an array of key managers or
nullif no key store configuration was provided - Throws:
NoSuchProviderException- if a provider specified for one of the key manager components is not known to the platformNoSuchAlgorithmException- if an algorithm specified for one of the key manager components is not known to the relevant providerKeyStoreException- if an error occurs in reading a key storeUnrecoverableKeyException
-
createTrustManagers
private TrustManager[] createTrustManagers(ContextAware context) throws NoSuchProviderException, NoSuchAlgorithmException, KeyStoreException Creates trust managers using the receiver's trust store configuration.- Parameters:
context- context for status messages- Returns:
- an array of trust managers or
nullif no trust store configuration was provided - Throws:
NoSuchProviderException- if a provider specified for one of the trust manager components is not known to the platformNoSuchAlgorithmException- if an algorithm specified for one of the trust manager components is not known to the relevant providerKeyStoreException- if an error occurs in reading a key store containing trust anchors
-
createSecureRandom
private SecureRandom createSecureRandom(ContextAware context) throws NoSuchProviderException, NoSuchAlgorithmException -
getKeyStore
Gets the key store configuration.- Returns:
- key store factory bean or
nullif no key store configuration was provided
-
setKeyStore
Sets the key store configuration.- Parameters:
keyStore- the key store factory bean to set
-
getTrustStore
Gets the trust store configuration.- Returns:
- trust store factory bean or
nullif no trust store configuration was provided
-
setTrustStore
Sets the trust store configuration.- Parameters:
trustStore- the trust store factory bean to set
-
keyStoreFromSystemProperties
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
nullif no value is defined for the base system property name
-
locationFromSystemProperty
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
nullif no value is defined for the property
-
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
Sets the secure random generator configuration.- Parameters:
secureRandom- the secure random factory bean to set
-
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
Sets the key manager factory configuration.- Parameters:
keyManagerFactory- the key manager factory factory bean to set
-
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
Sets the trust manager factory configuration.- Parameters:
trustManagerFactory- the factory bean to set
-
getProtocol
Gets the secure transport protocol name.- Returns:
- protocol name (e.g.
SSL,TLS); theSSL.DEFAULT_PROTOCOLis returned if no protocol has been configured
-
setProtocol
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
Gets the JSSE provider name for the SSL context.- Returns:
- JSSE provider name
-
setProvider
Sets the JSSE provider name for the SSL context.- Parameters:
provider- name of the JSSE provider to use in creating the SSL context
-