Package ratpack.ssl

Class SSLContexts


  • public class SSLContexts
    extends java.lang.Object
    Factory methods for initializing an SSLContext.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static javax.net.ssl.SSLContext sslContext​(java.io.File keyStoreFile, java.lang.String password)
      Creates an SSL context using a password-protected keystore file.
      static javax.net.ssl.SSLContext sslContext​(java.io.File keyStoreFile, java.lang.String keyStorePassword, java.io.File trustStoreFile, java.lang.String trustStorePassword)
      Creates an SSL context using password protected keystore as well as password protected truststore file.
      static javax.net.ssl.SSLContext sslContext​(java.io.InputStream keyStoreStream, java.lang.String password)
      Creates an SSL context using a password-protected keystore file.
      static javax.net.ssl.SSLContext sslContext​(java.io.InputStream keyStoreStream, java.lang.String keyStorePassword, java.io.InputStream trustStoreStream, java.lang.String trustStorePassword)
      Creates an SSL context using password protected keystore as well as password protected truststore file.
      static javax.net.ssl.SSLContext sslContext​(java.net.URL keyStoreFile, java.lang.String password)
      Creates an SSL context using a password-protected keystore file.
      static javax.net.ssl.SSLContext sslContext​(java.net.URL keyStoreFile, java.lang.String keyStorePassword, java.net.URL trustStoreFile, java.lang.String trustStorePassword)
      Creates an SSL context using password protected keystore as well as password protected truststore file.
      static javax.net.ssl.SSLContext sslContext​(java.nio.file.Path keyStoreFile, java.lang.String password)
      Creates an SSL context using a password-protected keystore file.
      static javax.net.ssl.SSLContext sslContext​(java.nio.file.Path keyStoreFile, java.lang.String keyStorePassword, java.nio.file.Path trustStoreFile, java.lang.String trustStorePassword)
      Creates an SSL context using password protected keystore as well as password protected truststore file.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • sslContext

        public static javax.net.ssl.SSLContext sslContext​(java.net.URL keyStoreFile,
                                                          java.lang.String password)
                                                   throws java.security.GeneralSecurityException,
                                                          java.io.IOException
        Creates an SSL context using a password-protected keystore file.
        Parameters:
        keyStoreFile - a file:// URL referencing a keystore file
        password - the password for the keystore file
        Returns:
        A newly created ssl context
        Throws:
        java.security.GeneralSecurityException - if the keystore is invalid, or the password is incorrect
        java.io.IOException - if the url cannot be read
      • sslContext

        public static javax.net.ssl.SSLContext sslContext​(java.net.URL keyStoreFile,
                                                          java.lang.String keyStorePassword,
                                                          java.net.URL trustStoreFile,
                                                          java.lang.String trustStorePassword)
                                                   throws java.security.GeneralSecurityException,
                                                          java.io.IOException
        Creates an SSL context using password protected keystore as well as password protected truststore file.
        Parameters:
        keyStoreFile - a file:// URL referencing a keystore file
        keyStorePassword - the password for the keystore file
        trustStoreFile - a file:// URL referencing a truststore file
        trustStorePassword - the password for the truststore file
        Returns:
        A newly created ssl context
        Throws:
        java.security.GeneralSecurityException - if either the keystore or truststore is invalid, or the password is incorrect
        java.io.IOException - if any of the urls cannot be read
      • sslContext

        public static javax.net.ssl.SSLContext sslContext​(java.io.File keyStoreFile,
                                                          java.lang.String password)
                                                   throws java.security.GeneralSecurityException,
                                                          java.io.IOException
        Creates an SSL context using a password-protected keystore file.
        Parameters:
        keyStoreFile - a keystore file
        password - the password for the keystore file
        Returns:
        A newly created ssl context
        Throws:
        java.security.GeneralSecurityException - if the keystore is invalid, or the password is incorrect
        java.io.IOException - if the url cannot be read
      • sslContext

        public static javax.net.ssl.SSLContext sslContext​(java.io.File keyStoreFile,
                                                          java.lang.String keyStorePassword,
                                                          java.io.File trustStoreFile,
                                                          java.lang.String trustStorePassword)
                                                   throws java.security.GeneralSecurityException,
                                                          java.io.IOException
        Creates an SSL context using password protected keystore as well as password protected truststore file.
        Parameters:
        keyStoreFile - a keystore file
        keyStorePassword - the pasword for the keystore file
        trustStoreFile - a truststore file
        trustStorePassword - the password for the truststore file
        Returns:
        A newly created ssl context
        Throws:
        java.security.GeneralSecurityException - if either the keystore or truststore is invalid, or the password is incorrect
        java.io.IOException - if any of the urls cannot be read
      • sslContext

        public static javax.net.ssl.SSLContext sslContext​(java.nio.file.Path keyStoreFile,
                                                          java.lang.String password)
                                                   throws java.security.GeneralSecurityException,
                                                          java.io.IOException
        Creates an SSL context using a password-protected keystore file.
        Parameters:
        keyStoreFile - a keystore file
        password - the password for the keystore file
        Returns:
        A newly created ssl context
        Throws:
        java.security.GeneralSecurityException - if the keystore is invalid, or the password is incorrect
        java.io.IOException - if the url cannot be read
      • sslContext

        public static javax.net.ssl.SSLContext sslContext​(java.nio.file.Path keyStoreFile,
                                                          java.lang.String keyStorePassword,
                                                          java.nio.file.Path trustStoreFile,
                                                          java.lang.String trustStorePassword)
                                                   throws java.security.GeneralSecurityException,
                                                          java.io.IOException
        Creates an SSL context using password protected keystore as well as password protected truststore file.
        Parameters:
        keyStoreFile - a keystore file
        keyStorePassword - the password for the keystore file
        trustStoreFile - a truststore file
        trustStorePassword - the password for the truststore file
        Returns:
        A newly created ssl context
        Throws:
        java.security.GeneralSecurityException - if either the keystore or the truststore is invalid, or the password is incorrect
        java.io.IOException - if any of the urls cannot be read
      • sslContext

        public static javax.net.ssl.SSLContext sslContext​(java.io.InputStream keyStoreStream,
                                                          java.lang.String password)
                                                   throws java.security.GeneralSecurityException,
                                                          java.io.IOException
        Creates an SSL context using a password-protected keystore file.
        Parameters:
        keyStoreStream - an input stream reading a keystore file
        password - the password for the keystore file
        Returns:
        A newly created ssl context
        Throws:
        java.security.GeneralSecurityException - if the keystore is invalid, or the password is incorrect
        java.io.IOException - if the url cannot be read
      • sslContext

        public static javax.net.ssl.SSLContext sslContext​(java.io.InputStream keyStoreStream,
                                                          java.lang.String keyStorePassword,
                                                          java.io.InputStream trustStoreStream,
                                                          java.lang.String trustStorePassword)
                                                   throws java.security.GeneralSecurityException,
                                                          java.io.IOException
        Creates an SSL context using password protected keystore as well as password protected truststore file.

        In SSL handshake the purpose of of keystore is to provide credentials, while the purpose of truststore is to verify credentials.

        Trustore stores certificates from thrid parties that application trusts or certificates signed by CA that can be used to identify third party. Keystore stores private key and public key that are used to generate certificates exposed to clients or used in client SSL authentication.

        Parameters:
        keyStoreStream - an input stream reading keystore file
        keyStorePassword - the password for the keystore file
        trustStoreStream - an input stream reading truststore file
        trustStorePassword - the password for the truststore file
        Returns:
        A newly created ssl context
        Throws:
        java.security.GeneralSecurityException - if either the keystore or the truststore is invalid, or the password is incorrect
        java.io.IOException - if any of the urls cannot be read