Package org.kiwiproject.config
Class SSLContextConfiguration
- java.lang.Object
-
- org.kiwiproject.config.SSLContextConfiguration
-
- All Implemented Interfaces:
KeyAndTrustStoreConfigProvider,TrustStoreConfigProvider
- Direct Known Subclasses:
SecureEndpointsConfiguration
public class SSLContextConfiguration extends Object implements KeyAndTrustStoreConfigProvider
Configuration for standard/common properties required for secure (i.e. SSL/TLS) connections.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classSSLContextConfiguration.BuilderA builder class forSSLContextConfiguration.
-
Constructor Summary
Constructors Constructor Description SSLContextConfiguration()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static SSLContextConfiguration.Builderbuilder()Return a new builder instance.StringgetTrustStoreType()Overrides and defines trust store type to be the same askeyStoreType, since this is the most common case.SimpleSSLContextFactorytoSimpleSSLContextFactory()Convert this configuration to aSimpleSSLContextFactory.SSLContexttoSSLContext()Convert this instance to a newSSLContext.TlsContextConfigurationtoTlsContextConfiguration()Convert thisSSLContextConfigurationto aTlsContextConfiguration, using thekeyStoreTypefor both the key and trust store type in the returned object.TlsContextConfigurationtoTlsContextConfiguration(String trustStoreType)Convert thisSSLContextConfigurationto aTlsContextConfiguration, using thekeyStoreTypefor the key and the specifiedtrustStoreTypeas the trust store type in the returned object.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.kiwiproject.security.KeyAndTrustStoreConfigProvider
getKeyStorePassword, getKeyStorePath, getKeyStoreType
-
Methods inherited from interface org.kiwiproject.security.TrustStoreConfigProvider
getProtocol, getTrustStorePassword, getTrustStorePath, isVerifyHostname, toSslSocketFactory
-
-
-
-
Method Detail
-
builder
public static SSLContextConfiguration.Builder builder()
Return a new builder instance.- Returns:
- builder instance
-
getTrustStoreType
public String getTrustStoreType()
Overrides and defines trust store type to be the same askeyStoreType, since this is the most common case.This may be changed in the future by adding an explicit trust store type property, though we would keep the same default value.
- Specified by:
getTrustStoreTypein interfaceTrustStoreConfigProvider- Returns:
- trust store type
- See Also:
KeyStoreType.JKS
-
toSSLContext
public SSLContext toSSLContext()
Convert this instance to a newSSLContext.If you would rather not create a new instance every time, use
toSimpleSSLContextFactory()to obtain a factory that will always return the sameSSLContextinstance.- Specified by:
toSSLContextin interfaceKeyAndTrustStoreConfigProvider- Specified by:
toSSLContextin interfaceTrustStoreConfigProvider- Returns:
- a new
SSLContextinstance - See Also:
KiwiSecurity.createSslContext(String, String, String, String, String, String, String)- Implementation Note:
- This will always create a new instance, first creating a new
SimpleSSLContextFactoryand then using that to create theSSLContext.
-
toSimpleSSLContextFactory
public SimpleSSLContextFactory toSimpleSSLContextFactory()
Convert this configuration to aSimpleSSLContextFactory.- Returns:
- a new instance
-
toTlsContextConfiguration
public TlsContextConfiguration toTlsContextConfiguration()
Convert thisSSLContextConfigurationto aTlsContextConfiguration, using thekeyStoreTypefor both the key and trust store type in the returned object.Use
toTlsContextConfiguration(String)if you need to specify a different trust store type.- Returns:
- a new
TlsContextConfigurationinstance - See Also:
toTlsContextConfiguration(String)
-
toTlsContextConfiguration
public TlsContextConfiguration toTlsContextConfiguration(String trustStoreType)
Convert thisSSLContextConfigurationto aTlsContextConfiguration, using thekeyStoreTypefor the key and the specifiedtrustStoreTypeas the trust store type in the returned object.- Parameters:
trustStoreType- the type of trust store to use- Returns:
- a new
TlsContextConfigurationinstance
-
-