Class SSLContextFactoryBean
- java.lang.Object
-
- org.springframework.beans.factory.config.AbstractFactoryBean
-
- org.apache.mina.integration.spring.ssl.SSLContextFactoryBean
-
- All Implemented Interfaces:
org.springframework.beans.factory.Aware,org.springframework.beans.factory.BeanClassLoaderAware,org.springframework.beans.factory.BeanFactoryAware,org.springframework.beans.factory.DisposableBean,org.springframework.beans.factory.FactoryBean,org.springframework.beans.factory.InitializingBean
public class SSLContextFactoryBean extends org.springframework.beans.factory.config.AbstractFactoryBeanSpringFactoryBeanimplementation which makes it possible to configureSSLContextinstances using Spring.If no properties are set the returned
SSLContextwill be equivalent to what the following creates:SSLContext c = SSLContext.getInstance( "TLS" ); c.init( null, null, null );Use the properties prefixed with
keyManagerFactoryto control the creation of theKeyManagerto be used.Use the properties prefixed with
trustManagerFactoryto control the creation of theTrustManagerFactoryto be used.
-
-
Constructor Summary
Constructors Constructor Description SSLContextFactoryBean()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.lang.ObjectcreateInstance()java.lang.ClassgetObjectType()voidsetKeyManagerFactory(javax.net.ssl.KeyManagerFactory factory)Sets theKeyManagerFactoryto use.voidsetKeyManagerFactoryAlgorithm(java.lang.String algorithm)Sets the algorithm to use when creating theKeyManagerFactoryusingKeyManagerFactory.getInstance(java.lang.String)orKeyManagerFactory.getInstance(java.lang.String, java.lang.String).voidsetKeyManagerFactoryAlgorithmUseDefault(boolean useDefault)If this is set totruewhile noKeyManagerFactoryhas been set usingsetKeyManagerFactory(KeyManagerFactory)and no algorithm has been set usingsetKeyManagerFactoryAlgorithm(String)the default algorithm return byKeyManagerFactory.getDefaultAlgorithm()will be used.voidsetKeyManagerFactoryKeyStore(java.security.KeyStore keyStore)Sets theKeyStorewhich will be used in the call toKeyManagerFactory.init(java.security.KeyStore, char[])when theSSLContextis created.voidsetKeyManagerFactoryKeyStorePassword(java.lang.String password)Sets the password which will be used in the call toKeyManagerFactory.init(java.security.KeyStore, char[])when theSSLContextis created.voidsetKeyManagerFactoryProvider(java.lang.String provider)Sets the provider to use when creating theKeyManagerFactoryusingKeyManagerFactory.getInstance(java.lang.String, java.lang.String).voidsetProtocol(java.lang.String protocol)Sets the protocol to use when creating theSSLContext.voidsetSecureRandom(java.security.SecureRandom secureRandom)Sets theSecureRandomto use when initializing theSSLContext.voidsetTrustManagerFactory(javax.net.ssl.TrustManagerFactory factory)Sets theTrustManagerFactoryto use.voidsetTrustManagerFactoryAlgorithm(java.lang.String algorithm)Sets the algorithm to use when creating theTrustManagerFactoryusingTrustManagerFactory.getInstance(java.lang.String)orTrustManagerFactory.getInstance(java.lang.String, java.lang.String).voidsetTrustManagerFactoryAlgorithmUseDefault(boolean useDefault)If this is set totruewhile noTrustManagerFactoryhas been set usingsetTrustManagerFactory(TrustManagerFactory)and no algorithm has been set usingsetTrustManagerFactoryAlgorithm(String)the default algorithm return byTrustManagerFactory.getDefaultAlgorithm()will be used.voidsetTrustManagerFactoryKeyStore(java.security.KeyStore keyStore)Sets theKeyStorewhich will be used in the call toTrustManagerFactory.init(java.security.KeyStore)when theSSLContextis created.voidsetTrustManagerFactoryParameters(javax.net.ssl.ManagerFactoryParameters parameters)Sets theManagerFactoryParameterswhich will be used in the call toTrustManagerFactory.init(javax.net.ssl.ManagerFactoryParameters)when theSSLContextis created.voidsetTrustManagerFactoryProvider(java.lang.String provider)Sets the provider to use when creating theTrustManagerFactoryusingTrustManagerFactory.getInstance(java.lang.String, java.lang.String).
-
-
-
Method Detail
-
createInstance
protected java.lang.Object createInstance() throws java.lang.Exception- Specified by:
createInstancein classorg.springframework.beans.factory.config.AbstractFactoryBean- Throws:
java.lang.Exception
-
getObjectType
public java.lang.Class getObjectType()
- Specified by:
getObjectTypein interfaceorg.springframework.beans.factory.FactoryBean- Specified by:
getObjectTypein classorg.springframework.beans.factory.config.AbstractFactoryBean
-
setProtocol
public void setProtocol(java.lang.String protocol)
Sets the protocol to use when creating theSSLContext. The default isTLS.- Parameters:
protocol- the name of the protocol.- Throws:
java.lang.IllegalArgumentException- if the specified value isnull.
-
setKeyManagerFactoryAlgorithmUseDefault
public void setKeyManagerFactoryAlgorithmUseDefault(boolean useDefault)
If this is set totruewhile noKeyManagerFactoryhas been set usingsetKeyManagerFactory(KeyManagerFactory)and no algorithm has been set usingsetKeyManagerFactoryAlgorithm(String)the default algorithm return byKeyManagerFactory.getDefaultAlgorithm()will be used.- Parameters:
useDefault-trueorfalse.
-
setTrustManagerFactoryAlgorithmUseDefault
public void setTrustManagerFactoryAlgorithmUseDefault(boolean useDefault)
If this is set totruewhile noTrustManagerFactoryhas been set usingsetTrustManagerFactory(TrustManagerFactory)and no algorithm has been set usingsetTrustManagerFactoryAlgorithm(String)the default algorithm return byTrustManagerFactory.getDefaultAlgorithm()will be used.- Parameters:
useDefault-trueorfalse.
-
setKeyManagerFactory
public void setKeyManagerFactory(javax.net.ssl.KeyManagerFactory factory)
Sets theKeyManagerFactoryto use. If this is set the properties which are used by this factory bean to create aKeyManagerFactorywill all be ignored.- Parameters:
factory- the factory.
-
setKeyManagerFactoryAlgorithm
public void setKeyManagerFactoryAlgorithm(java.lang.String algorithm)
Sets the algorithm to use when creating theKeyManagerFactoryusingKeyManagerFactory.getInstance(java.lang.String)orKeyManagerFactory.getInstance(java.lang.String, java.lang.String).This property will be ignored if a
KeyManagerFactoryhas been set directly usingsetKeyManagerFactory(KeyManagerFactory).If this property isn't set while no
KeyManagerFactoryhas been set usingsetKeyManagerFactory(KeyManagerFactory)andsetKeyManagerFactoryAlgorithmUseDefault(boolean)has been set totruethe value returned byKeyManagerFactory.getDefaultAlgorithm()will be used instead.- Parameters:
algorithm- the algorithm to use.
-
setKeyManagerFactoryProvider
public void setKeyManagerFactoryProvider(java.lang.String provider)
Sets the provider to use when creating theKeyManagerFactoryusingKeyManagerFactory.getInstance(java.lang.String, java.lang.String).This property will be ignored if a
KeyManagerFactoryhas been set directly usingsetKeyManagerFactory(KeyManagerFactory).If this property isn't set and no
KeyManagerFactoryhas been set usingsetKeyManagerFactory(KeyManagerFactory)KeyManagerFactory.getInstance(java.lang.String)will be used to create theKeyManagerFactory.- Parameters:
provider- the name of the provider.
-
setKeyManagerFactoryKeyStore
public void setKeyManagerFactoryKeyStore(java.security.KeyStore keyStore)
Sets theKeyStorewhich will be used in the call toKeyManagerFactory.init(java.security.KeyStore, char[])when theSSLContextis created.- Parameters:
keyStore- the key store.
-
setKeyManagerFactoryKeyStorePassword
public void setKeyManagerFactoryKeyStorePassword(java.lang.String password)
Sets the password which will be used in the call toKeyManagerFactory.init(java.security.KeyStore, char[])when theSSLContextis created.- Parameters:
password- the password. Usenullto disable password.
-
setTrustManagerFactory
public void setTrustManagerFactory(javax.net.ssl.TrustManagerFactory factory)
Sets theTrustManagerFactoryto use. If this is set the properties which are used by this factory bean to create aTrustManagerFactorywill all be ignored.- Parameters:
factory- the factory.
-
setTrustManagerFactoryAlgorithm
public void setTrustManagerFactoryAlgorithm(java.lang.String algorithm)
Sets the algorithm to use when creating theTrustManagerFactoryusingTrustManagerFactory.getInstance(java.lang.String)orTrustManagerFactory.getInstance(java.lang.String, java.lang.String).This property will be ignored if a
TrustManagerFactoryhas been set directly usingsetTrustManagerFactory(TrustManagerFactory).If this property isn't set while no
TrustManagerFactoryhas been set usingsetTrustManagerFactory(TrustManagerFactory)andsetTrustManagerFactoryAlgorithmUseDefault(boolean)has been set totruethe value returned byTrustManagerFactory.getDefaultAlgorithm()will be used instead.- Parameters:
algorithm- the algorithm to use.
-
setTrustManagerFactoryKeyStore
public void setTrustManagerFactoryKeyStore(java.security.KeyStore keyStore)
Sets theKeyStorewhich will be used in the call toTrustManagerFactory.init(java.security.KeyStore)when theSSLContextis created.This property will be ignored if
ManagerFactoryParametershas been set directly usingsetTrustManagerFactoryParameters(ManagerFactoryParameters).- Parameters:
keyStore- the key store.
-
setTrustManagerFactoryParameters
public void setTrustManagerFactoryParameters(javax.net.ssl.ManagerFactoryParameters parameters)
Sets theManagerFactoryParameterswhich will be used in the call toTrustManagerFactory.init(javax.net.ssl.ManagerFactoryParameters)when theSSLContextis created.- Parameters:
parameters- describing provider-specific trust material.
-
setTrustManagerFactoryProvider
public void setTrustManagerFactoryProvider(java.lang.String provider)
Sets the provider to use when creating theTrustManagerFactoryusingTrustManagerFactory.getInstance(java.lang.String, java.lang.String).This property will be ignored if a
TrustManagerFactoryhas been set directly usingsetTrustManagerFactory(TrustManagerFactory).If this property isn't set and no
TrustManagerFactoryhas been set usingsetTrustManagerFactory(TrustManagerFactory)TrustManagerFactory.getInstance(java.lang.String)will be used to create theTrustManagerFactory.- Parameters:
provider- the name of the provider.
-
setSecureRandom
public void setSecureRandom(java.security.SecureRandom secureRandom)
Sets theSecureRandomto use when initializing theSSLContext. The JVM's default will be used if this isn't set.- Parameters:
secureRandom- theSecureRandomornullif the JVM's default should be used.- See Also:
SSLContext.init(javax.net.ssl.KeyManager[], javax.net.ssl.TrustManager[], java.security.SecureRandom)
-
-