Package org.kiwiproject.security
Class SimpleSSLContextFactory
- java.lang.Object
-
- org.kiwiproject.security.SimpleSSLContextFactory
-
public class SimpleSSLContextFactory extends Object
A "simple" factory class that makes it simpler to to createSSLContextinstances.Construct using one of the public constructors or via the
builder().This abstracts the much lower level
KiwiSecurityclass.- See Also:
KiwiSecurity
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classSimpleSSLContextFactory.BuilderA builder class forSimpleSSLContextFactory.
-
Constructor Summary
Constructors Constructor Description SimpleSSLContextFactory(String keyStorePath, String keyStorePassword, String trustStorePath, String trustStorePassword, String protocol)SimpleSSLContextFactory(String keyStorePath, String keyStorePassword, String trustStorePath, String trustStorePassword, String protocol, boolean verifyHostname)Create a newSimpleSSLContextFactory.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static SimpleSSLContextFactory.Builderbuilder()Return a new builder instance.SSLContextgetSslContext()Create/get aSSLContextinstance for the key and trust store properties and protocol that thisSimpleSSLContextFactoryinstance was built with.
-
-
-
Constructor Detail
-
SimpleSSLContextFactory
public SimpleSSLContextFactory(String keyStorePath, String keyStorePassword, String trustStorePath, String trustStorePassword, String protocol)
- Parameters:
keyStorePath- path to the key storekeyStorePassword- password of the key storetrustStorePath- path to the trust storetrustStorePassword- password of the trust storeprotocol- the protocol to use
-
SimpleSSLContextFactory
public SimpleSSLContextFactory(String keyStorePath, String keyStorePassword, String trustStorePath, String trustStorePassword, String protocol, boolean verifyHostname)
Create a newSimpleSSLContextFactory.- Parameters:
keyStorePath- path to the key storekeyStorePassword- password of the key storetrustStorePath- path to the trust storetrustStorePassword- password of the trust storeprotocol- the protocol to useverifyHostname- whether to verify host names or not
-
-
Method Detail
-
builder
public static SimpleSSLContextFactory.Builder builder()
Return a new builder instance.- Returns:
- new Builder
-
getSslContext
public SSLContext getSslContext()
Create/get aSSLContextinstance for the key and trust store properties and protocol that thisSimpleSSLContextFactoryinstance was built with.- Returns:
- a new
SSLContextinstance when first called; all subsequent calls return the same cached instance - Implementation Note:
- This is intended to be called infrequently, e.g. once when a service/app starts. Thus, making it synchronized was the easiest way to ensure thread-safety.
-
-