Class SSLContextBuilder


  • public class SSLContextBuilder
    extends java.lang.Object
    Builder for SSLContext instances.

    Please note: the default Oracle JSSE implementation of SSLContext.init(KeyManager[], TrustManager[], SecureRandom) accepts multiple key and trust managers, however only only first matching type is ever used. See for example: SSLContext.html#init

    TODO Specify which Oracle JSSE versions the above has been verified.

    Since:
    4.4
    • Constructor Detail

      • SSLContextBuilder

        public SSLContextBuilder()
    • Method Detail

      • setSecureRandom

        public SSLContextBuilder setSecureRandom​(java.security.SecureRandom secureRandom)
      • setProvider

        public SSLContextBuilder setProvider​(java.security.Provider provider)
      • loadTrustMaterial

        public SSLContextBuilder loadTrustMaterial​(java.security.KeyStore truststore,
                                                   TrustStrategy trustStrategy)
                                            throws java.security.NoSuchAlgorithmException,
                                                   java.security.KeyStoreException
        Throws:
        java.security.NoSuchAlgorithmException
        java.security.KeyStoreException
      • loadTrustMaterial

        public SSLContextBuilder loadTrustMaterial​(TrustStrategy trustStrategy)
                                            throws java.security.NoSuchAlgorithmException,
                                                   java.security.KeyStoreException
        Throws:
        java.security.NoSuchAlgorithmException
        java.security.KeyStoreException
      • loadTrustMaterial

        public SSLContextBuilder loadTrustMaterial​(java.io.File file,
                                                   char[] storePassword,
                                                   TrustStrategy trustStrategy)
                                            throws java.security.NoSuchAlgorithmException,
                                                   java.security.KeyStoreException,
                                                   java.security.cert.CertificateException,
                                                   java.io.IOException
        Throws:
        java.security.NoSuchAlgorithmException
        java.security.KeyStoreException
        java.security.cert.CertificateException
        java.io.IOException
      • loadTrustMaterial

        public SSLContextBuilder loadTrustMaterial​(java.io.File file,
                                                   char[] storePassword)
                                            throws java.security.NoSuchAlgorithmException,
                                                   java.security.KeyStoreException,
                                                   java.security.cert.CertificateException,
                                                   java.io.IOException
        Throws:
        java.security.NoSuchAlgorithmException
        java.security.KeyStoreException
        java.security.cert.CertificateException
        java.io.IOException
      • loadTrustMaterial

        public SSLContextBuilder loadTrustMaterial​(java.io.File file)
                                            throws java.security.NoSuchAlgorithmException,
                                                   java.security.KeyStoreException,
                                                   java.security.cert.CertificateException,
                                                   java.io.IOException
        Throws:
        java.security.NoSuchAlgorithmException
        java.security.KeyStoreException
        java.security.cert.CertificateException
        java.io.IOException
      • loadTrustMaterial

        public SSLContextBuilder loadTrustMaterial​(java.net.URL url,
                                                   char[] storePassword,
                                                   TrustStrategy trustStrategy)
                                            throws java.security.NoSuchAlgorithmException,
                                                   java.security.KeyStoreException,
                                                   java.security.cert.CertificateException,
                                                   java.io.IOException
        Throws:
        java.security.NoSuchAlgorithmException
        java.security.KeyStoreException
        java.security.cert.CertificateException
        java.io.IOException
      • loadTrustMaterial

        public SSLContextBuilder loadTrustMaterial​(java.net.URL url,
                                                   char[] storePassword)
                                            throws java.security.NoSuchAlgorithmException,
                                                   java.security.KeyStoreException,
                                                   java.security.cert.CertificateException,
                                                   java.io.IOException
        Throws:
        java.security.NoSuchAlgorithmException
        java.security.KeyStoreException
        java.security.cert.CertificateException
        java.io.IOException
      • loadKeyMaterial

        public SSLContextBuilder loadKeyMaterial​(java.security.KeyStore keystore,
                                                 char[] keyPassword,
                                                 PrivateKeyStrategy aliasStrategy)
                                          throws java.security.NoSuchAlgorithmException,
                                                 java.security.KeyStoreException,
                                                 java.security.UnrecoverableKeyException
        Throws:
        java.security.NoSuchAlgorithmException
        java.security.KeyStoreException
        java.security.UnrecoverableKeyException
      • loadKeyMaterial

        public SSLContextBuilder loadKeyMaterial​(java.security.KeyStore keystore,
                                                 char[] keyPassword)
                                          throws java.security.NoSuchAlgorithmException,
                                                 java.security.KeyStoreException,
                                                 java.security.UnrecoverableKeyException
        Throws:
        java.security.NoSuchAlgorithmException
        java.security.KeyStoreException
        java.security.UnrecoverableKeyException
      • loadKeyMaterial

        public SSLContextBuilder loadKeyMaterial​(java.io.File file,
                                                 char[] storePassword,
                                                 char[] keyPassword,
                                                 PrivateKeyStrategy aliasStrategy)
                                          throws java.security.NoSuchAlgorithmException,
                                                 java.security.KeyStoreException,
                                                 java.security.UnrecoverableKeyException,
                                                 java.security.cert.CertificateException,
                                                 java.io.IOException
        Throws:
        java.security.NoSuchAlgorithmException
        java.security.KeyStoreException
        java.security.UnrecoverableKeyException
        java.security.cert.CertificateException
        java.io.IOException
      • loadKeyMaterial

        public SSLContextBuilder loadKeyMaterial​(java.io.File file,
                                                 char[] storePassword,
                                                 char[] keyPassword)
                                          throws java.security.NoSuchAlgorithmException,
                                                 java.security.KeyStoreException,
                                                 java.security.UnrecoverableKeyException,
                                                 java.security.cert.CertificateException,
                                                 java.io.IOException
        Throws:
        java.security.NoSuchAlgorithmException
        java.security.KeyStoreException
        java.security.UnrecoverableKeyException
        java.security.cert.CertificateException
        java.io.IOException
      • loadKeyMaterial

        public SSLContextBuilder loadKeyMaterial​(java.net.URL url,
                                                 char[] storePassword,
                                                 char[] keyPassword,
                                                 PrivateKeyStrategy aliasStrategy)
                                          throws java.security.NoSuchAlgorithmException,
                                                 java.security.KeyStoreException,
                                                 java.security.UnrecoverableKeyException,
                                                 java.security.cert.CertificateException,
                                                 java.io.IOException
        Throws:
        java.security.NoSuchAlgorithmException
        java.security.KeyStoreException
        java.security.UnrecoverableKeyException
        java.security.cert.CertificateException
        java.io.IOException
      • loadKeyMaterial

        public SSLContextBuilder loadKeyMaterial​(java.net.URL url,
                                                 char[] storePassword,
                                                 char[] keyPassword)
                                          throws java.security.NoSuchAlgorithmException,
                                                 java.security.KeyStoreException,
                                                 java.security.UnrecoverableKeyException,
                                                 java.security.cert.CertificateException,
                                                 java.io.IOException
        Throws:
        java.security.NoSuchAlgorithmException
        java.security.KeyStoreException
        java.security.UnrecoverableKeyException
        java.security.cert.CertificateException
        java.io.IOException
      • build

        public javax.net.ssl.SSLContext build()
                                       throws java.security.NoSuchAlgorithmException,
                                              java.security.KeyManagementException
        Throws:
        java.security.NoSuchAlgorithmException
        java.security.KeyManagementException
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object