org.apache.solr.util

## Class SSLTestConfig

- java.lang.Object
- - org.apache.solr.client.solrj.embedded.SSLConfig
  - - org.apache.solr.util.SSLTestConfig

-     public class SSLTestConfig
      extends org.apache.solr.client.solrj.embedded.SSLConfig

  An `SSLConfig` that supports reading key/trust store information directly from resource files provided with the Solr test-framework classes

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static File` | `TEST_KEYSTORE` Deprecated. No longer used except by `setSSLSystemProperties()`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `SSLTestConfig()` Creates an SSLTestConfig that does not use SSL or client authentication
    `SSLTestConfig(boolean useSSL, boolean clientAuth)` Create an SSLTestConfig based on a few caller specified options.
    `SSLTestConfig(boolean useSSL, boolean clientAuth, String keyStore, String keyStorePassword, String trustStore, String trustStorePassword)` Deprecated. - use `SSLConfig` directly

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods
    Modifier and Type | Method and Description
    --- | ---
    `org.apache.http.conn.ssl.SSLConnectionSocketFactory` | `buildClientSSLConnectionSocketFactory()` Constructs a new SSLConnectionSocketFactory for HTTP clients to use when communicating with servers which have been configured based on the settings of this object.
    `SSLContext` | `buildClientSSLContext()` Builds a new SSLContext for HTTP clients to use when communicating with servers which have been configured based on the settings of this object.
    `protected static KeyStore` | `buildKeyStore(org.eclipse.jetty.util.resource.Resource resource, String password)` Constructs a KeyStore using the specified filename and password
    `SSLContext` | `buildServerSSLContext()` Builds a new SSLContext for jetty servers which have been configured based on the settings of this object.
    `static void` | `clearSSLSystemProperties()` Deprecated. this method has very little practical use, in most cases you'll want to use `SSLContext.setDefault(javax.net.ssl.SSLContext)` with `buildClientSSLContext()` instead.
    `org.eclipse.jetty.util.ssl.SslContextFactory` | `createContextFactory()` Returns an SslContextFactory using `buildServerSSLContext()` if SSL should be used, else returns null.
    `org.apache.solr.client.solrj.impl.HttpClientConfigurer` | `getHttpClientConfigurer()` Creates a `HttpClientConfigurer` for HTTP clients to use when communicating with servers which have been configured based on the settings of this object.
    `String` | `getKeyStore()` NOTE: This method is meaningless unless you explicitly provide paths when constructing this instance
    `String` | `getTrustStore()` NOTE: This method is meaningless unless you explicitly provide paths when constructing this instance
    `static void` | `setSSLSystemProperties()` Deprecated. this method has very little practical use, in most cases you'll want to use `SSLContext.setDefault(javax.net.ssl.SSLContext)` with `buildClientSSLContext()` instead.
    `static boolean` | `toBooleanDefaultIfNull(Boolean bool, boolean valueIfNull)`
    `static Boolean` | `toBooleanObject(String str)`

    - ### Methods inherited from class org.apache.solr.client.solrj.embedded.SSLConfig

      `createContextFactory, getKeyStorePassword, getTrustStorePassword, isClientAuthMode, isSSLMode, setClientAuth, setUseSSL`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### TEST_KEYSTORE

          public static File TEST_KEYSTORE

      Deprecated. No longer used except by `setSSLSystemProperties()`

  - ### Constructor Detail

    - #### SSLTestConfig

          public SSLTestConfig()

      Creates an SSLTestConfig that does not use SSL or client authentication

    - #### SSLTestConfig

          public SSLTestConfig(boolean useSSL,
                               boolean clientAuth)

      Create an SSLTestConfig based on a few caller specified options. As needed, keystore/truststore information will be pulled from a hardocded resource file provided by the solr test-framework.
      Parameters:
        `useSSL` - - wether SSL should be required.
        `clientAuth` - - whether client authentication should be required.

    - #### SSLTestConfig

          @Deprecated
          public SSLTestConfig(boolean useSSL,
                                           boolean clientAuth,
                                           String keyStore,
                                           String keyStorePassword,
                                           String trustStore,
                                           String trustStorePassword)

      Deprecated. - use `SSLConfig` directly
      Create an SSLTestConfig using explicit paths for files

  - ### Method Detail

    - #### getKeyStore

          public String getKeyStore()

      NOTE: This method is meaningless unless you explicitly provide paths when constructing this instance
      Overrides:
        `getKeyStore` in class `org.apache.solr.client.solrj.embedded.SSLConfig`
      See Also:
        `SSLTestConfig(boolean,boolean,String,String,String,String)`

    - #### getTrustStore

          public String getTrustStore()

      NOTE: This method is meaningless unless you explicitly provide paths when constructing this instance
      Overrides:
        `getTrustStore` in class `org.apache.solr.client.solrj.embedded.SSLConfig`
      See Also:
        `SSLTestConfig(boolean,boolean,String,String,String,String)`

    - #### getHttpClientConfigurer

          public org.apache.solr.client.solrj.impl.HttpClientConfigurer getHttpClientConfigurer()

      Creates a `HttpClientConfigurer` for HTTP clients to use when communicating with servers which have been configured based on the settings of this object. When `SSLConfig.isSSLMode()` is true, this `HttpClientConfigurer` will only support HTTPS (no HTTP scheme) using the appropriate certs. When `SSLConfig.isSSLMode()` is false, only HTTP (no HTTPS scheme) will be supported.

    - #### buildClientSSLContext

          public SSLContext buildClientSSLContext()
                                           throws KeyManagementException,
                                                  UnrecoverableKeyException,
                                                  NoSuchAlgorithmException,
                                                  KeyStoreException

      Builds a new SSLContext for HTTP clients to use when communicating with servers which have been configured based on the settings of this object. NOTE: Uses a completely insecure `SecureRandom` instance to prevent tests from blocking due to lack of entropy, also explicitly allows the use of self-signed certificates (since that's what is almost always used during testing).
      Throws:
        `KeyManagementException`
        `UnrecoverableKeyException`
        `NoSuchAlgorithmException`
        `KeyStoreException`

    - #### buildServerSSLContext

          public SSLContext buildServerSSLContext()
                                           throws KeyManagementException,
                                                  UnrecoverableKeyException,
                                                  NoSuchAlgorithmException,
                                                  KeyStoreException

      Builds a new SSLContext for jetty servers which have been configured based on the settings of this object. NOTE: Uses a completely insecure `SecureRandom` instance to prevent tests from blocking due to lack of entropy, also explicitly allows the use of self-signed certificates (since that's what is almost always used during testing). almost always used during testing).
      Throws:
        `KeyManagementException`
        `UnrecoverableKeyException`
        `NoSuchAlgorithmException`
        `KeyStoreException`

    - #### createContextFactory

          public org.eclipse.jetty.util.ssl.SslContextFactory createContextFactory()

      Returns an SslContextFactory using `buildServerSSLContext()` if SSL should be used, else returns null.
      Overrides:
        `createContextFactory` in class `org.apache.solr.client.solrj.embedded.SSLConfig`

    - #### buildKeyStore

          protected static KeyStore buildKeyStore(org.eclipse.jetty.util.resource.Resource resource,
                                                  String password)

      Constructs a KeyStore using the specified filename and password

    - #### buildClientSSLConnectionSocketFactory

          public org.apache.http.conn.ssl.SSLConnectionSocketFactory buildClientSSLConnectionSocketFactory()

      Constructs a new SSLConnectionSocketFactory for HTTP clients to use when communicating with servers which have been configured based on the settings of this object. Will return null unless `SSLConfig.isSSLMode()` is true.

    - #### toBooleanDefaultIfNull

          public static boolean toBooleanDefaultIfNull(Boolean bool,
                                                       boolean valueIfNull)

    - #### toBooleanObject

          public static Boolean toBooleanObject(String str)

    - #### setSSLSystemProperties

          @Deprecated
          public static void setSSLSystemProperties()

      Deprecated. this method has very little practical use, in most cases you'll want to use `SSLContext.setDefault(javax.net.ssl.SSLContext)` with `buildClientSSLContext()` instead.

    - #### clearSSLSystemProperties

          @Deprecated
          public static void clearSSLSystemProperties()

      Deprecated. this method has very little practical use, in most cases you'll want to use `SSLContext.setDefault(javax.net.ssl.SSLContext)` with `buildClientSSLContext()` instead.

Copyright © 2000-2016 Apache Software Foundation. All Rights Reserved.