Class SimpleSSLContextFactory


  • public class SimpleSSLContextFactory
    extends Object
    A "simple" factory class that makes it simpler to to create SSLContext instances.

    Construct using one of the public constructors or via the builder().

    This abstracts the much lower level KiwiSecurity class.

    See Also:
    KiwiSecurity
    • Constructor Detail

      • SimpleSSLContextFactory

        public SimpleSSLContextFactory​(String keyStorePath,
                                       String keyStorePassword,
                                       String trustStorePath,
                                       String trustStorePassword,
                                       String protocol)
        Create a new SimpleSSLContextFactory with verifyHostname set to true.
        Parameters:
        keyStorePath - path to the key store
        keyStorePassword - password of the key store
        trustStorePath - path to the trust store
        trustStorePassword - password of the trust store
        protocol - the protocol to use
      • SimpleSSLContextFactory

        public SimpleSSLContextFactory​(String keyStorePath,
                                       String keyStorePassword,
                                       String trustStorePath,
                                       String trustStorePassword,
                                       String protocol,
                                       boolean verifyHostname)
        Parameters:
        keyStorePath - path to the key store
        keyStorePassword - password of the key store
        trustStorePath - path to the trust store
        trustStorePassword - password of the trust store
        protocol - the protocol to use
        verifyHostname - whether to verify host names or not
    • Method Detail

      • getSslContext

        public SSLContext getSslContext()
        Create/get a SSLContext instance for the key and trust store properties and protocol that this SimpleSSLContextFactory instance was built with.
        Returns:
        a new SSLContext instance 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.