org.apache.mina.filter.ssl

## Class SslContextFactory

- java.lang.Object
- - org.apache.mina.filter.ssl.SslContextFactory

-     public class SslContextFactory
      extends Object

  A factory that creates and configures a new `SSLContext`.

  If no properties are set the returned `SSLContext` will be equivalent to what the following creates:

            SSLContext c = SSLContext.getInstance( "TLS" );
            c.init(null, null, null);

  Use the properties prefixed with `keyManagerFactory` to control the creation of the `KeyManager` to be used.

  Use the properties prefixed with `trustManagerFactory` to control the creation of the `TrustManagerFactory` to be used.

  Author:
    Apache MINA Project

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `SslContextFactory()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `SSLContext` | `newInstance()`
    `void` | `setClientSessionCacheSize(int size)` Sets the SSLSession cache size for the `SSLSessionContext` for use in client mode.
    `void` | `setClientSessionTimeout(int seconds)` Set the SSLSession timeout limit for the `SSLSessionContext` for use in client mode.
    `void` | `setKeyManagerFactory(KeyManagerFactory factory)` Sets the `KeyManagerFactory` to use.
    `void` | `setKeyManagerFactoryAlgorithm(String algorithm)` Sets the algorithm to use when creating the `KeyManagerFactory` using `KeyManagerFactory.getInstance(java.lang.String)` or `KeyManagerFactory.getInstance(java.lang.String, java.lang.String)`.
    `void` | `setKeyManagerFactoryAlgorithmUseDefault(boolean useDefault)` If this is set to `true` while no `KeyManagerFactory` has been set using `setKeyManagerFactory(KeyManagerFactory)` and no algorithm has been set using `setKeyManagerFactoryAlgorithm(String)` the default algorithm return by `KeyManagerFactory.getDefaultAlgorithm()` will be used.
    `void` | `setKeyManagerFactoryKeyStore(KeyStore keyStore)` Sets the `KeyStore` which will be used in the call to `KeyManagerFactory.init(java.security.KeyStore, char[])` when the `SSLContext` is created.
    `void` | `setKeyManagerFactoryKeyStorePassword(String password)` Sets the password which will be used in the call to `KeyManagerFactory.init(java.security.KeyStore, char[])` when the `SSLContext` is created.
    `void` | `setKeyManagerFactoryProvider(String provider)` Sets the provider to use when creating the `KeyManagerFactory` using `KeyManagerFactory.getInstance(java.lang.String, java.lang.String)`.
    `void` | `setProtocol(String protocol)` Sets the protocol to use when creating the `SSLContext`.
    `void` | `setProvider(String provider)` Sets the provider of the new `SSLContext`.
    `void` | `setSecureRandom(SecureRandom secureRandom)` Sets the `SecureRandom` to use when initializing the `SSLContext`.
    `void` | `setServerSessionCacheSize(int serverSessionCacheSize)` Sets the SSLSession cache size for the `SSLSessionContext` for use in server mode.
    `void` | `setServerSessionTimeout(int serverSessionTimeout)` Set the SSLSession timeout limit for the `SSLSessionContext` for use in server mode.
    `void` | `setTrustManagerFactory(TrustManagerFactory factory)` Sets the `TrustManagerFactory` to use.
    `void` | `setTrustManagerFactoryAlgorithm(String algorithm)` Sets the algorithm to use when creating the `TrustManagerFactory` using `TrustManagerFactory.getInstance(java.lang.String)` or `TrustManagerFactory.getInstance(java.lang.String, java.lang.String)`.
    `void` | `setTrustManagerFactoryAlgorithmUseDefault(boolean useDefault)` If this is set to `true` while no `TrustManagerFactory` has been set using `setTrustManagerFactory(TrustManagerFactory)` and no algorithm has been set using `setTrustManagerFactoryAlgorithm(String)` the default algorithm return by `TrustManagerFactory.getDefaultAlgorithm()` will be used.
    `void` | `setTrustManagerFactoryKeyStore(KeyStore keyStore)` Sets the `KeyStore` which will be used in the call to `TrustManagerFactory.init(java.security.KeyStore)` when the `SSLContext` is created.
    `void` | `setTrustManagerFactoryParameters(ManagerFactoryParameters parameters)` Sets the `ManagerFactoryParameters` which will be used in the call to `TrustManagerFactory.init(javax.net.ssl.ManagerFactoryParameters)` when the `SSLContext` is created.
    `void` | `setTrustManagerFactoryProvider(String provider)` Sets the provider to use when creating the `TrustManagerFactory` using `TrustManagerFactory.getInstance(java.lang.String, java.lang.String)`.

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

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

- - ### Constructor Detail

    - #### SslContextFactory

          public SslContextFactory()

  - ### Method Detail

    - #### newInstance

          public SSLContext newInstance()
                                 throws Exception

      Throws:
        `Exception`

    - #### setProvider

          public void setProvider(String provider)

      Sets the provider of the new `SSLContext`. The default value is `null`, which means the default provider will be used.
      Parameters:
        `provider` - the name of the `SSLContext` provider

    - #### setProtocol

          public void setProtocol(String protocol)

      Sets the protocol to use when creating the `SSLContext`. The default is `TLS`.
      Parameters:
        `protocol` - the name of the protocol.

    - #### setKeyManagerFactoryAlgorithmUseDefault

          public void setKeyManagerFactoryAlgorithmUseDefault(boolean useDefault)

      If this is set to `true` while no `KeyManagerFactory` has been set using `setKeyManagerFactory(KeyManagerFactory)` and no algorithm has been set using `setKeyManagerFactoryAlgorithm(String)` the default algorithm return by `KeyManagerFactory.getDefaultAlgorithm()` will be used. The default value of this property is `true``.`
      Parameters:
        `useDefault` - `true` or `false`.

    - #### setTrustManagerFactoryAlgorithmUseDefault

          public void setTrustManagerFactoryAlgorithmUseDefault(boolean useDefault)

      If this is set to `true` while no `TrustManagerFactory` has been set using `setTrustManagerFactory(TrustManagerFactory)` and no algorithm has been set using `setTrustManagerFactoryAlgorithm(String)` the default algorithm return by `TrustManagerFactory.getDefaultAlgorithm()` will be used. The default value of this property is `true``.`
      Parameters:
        `useDefault` - `true` or `false`.

    - #### setKeyManagerFactory

          public void setKeyManagerFactory(KeyManagerFactory factory)

      Sets the `KeyManagerFactory` to use. If this is set the properties which are used by this factory bean to create a `KeyManagerFactory` will all be ignored.
      Parameters:
        `factory` - the factory.

    - #### setKeyManagerFactoryAlgorithm

          public void setKeyManagerFactoryAlgorithm(String algorithm)

      Sets the algorithm to use when creating the `KeyManagerFactory` using `KeyManagerFactory.getInstance(java.lang.String)` or `KeyManagerFactory.getInstance(java.lang.String, java.lang.String)`.

      This property will be ignored if a `KeyManagerFactory` has been set directly using `setKeyManagerFactory(KeyManagerFactory)`.

      If this property isn't set while no `KeyManagerFactory` has been set using `setKeyManagerFactory(KeyManagerFactory)` and `setKeyManagerFactoryAlgorithmUseDefault(boolean)` has been set to `true` the value returned by `KeyManagerFactory.getDefaultAlgorithm()` will be used instead.

      Parameters:
        `algorithm` - the algorithm to use.

    - #### setKeyManagerFactoryProvider

          public void setKeyManagerFactoryProvider(String provider)

      Sets the provider to use when creating the `KeyManagerFactory` using `KeyManagerFactory.getInstance(java.lang.String, java.lang.String)`.

      This property will be ignored if a `KeyManagerFactory` has been set directly using `setKeyManagerFactory(KeyManagerFactory)`.

      If this property isn't set and no `KeyManagerFactory` has been set using `setKeyManagerFactory(KeyManagerFactory)` `KeyManagerFactory.getInstance(java.lang.String)` will be used to create the `KeyManagerFactory`.

      Parameters:
        `provider` - the name of the provider.

    - #### setKeyManagerFactoryKeyStore

          public void setKeyManagerFactoryKeyStore(KeyStore keyStore)

      Sets the `KeyStore` which will be used in the call to `KeyManagerFactory.init(java.security.KeyStore, char[])` when the `SSLContext` is created.
      Parameters:
        `keyStore` - the key store.

    - #### setKeyManagerFactoryKeyStorePassword

          public void setKeyManagerFactoryKeyStorePassword(String password)

      Sets the password which will be used in the call to `KeyManagerFactory.init(java.security.KeyStore, char[])` when the `SSLContext` is created.
      Parameters:
        `password` - the password. Use `null` to disable password.

    - #### setTrustManagerFactory

          public void setTrustManagerFactory(TrustManagerFactory factory)

      Sets the `TrustManagerFactory` to use. If this is set the properties which are used by this factory bean to create a `TrustManagerFactory` will all be ignored.
      Parameters:
        `factory` - the factory.

    - #### setTrustManagerFactoryAlgorithm

          public void setTrustManagerFactoryAlgorithm(String algorithm)

      Sets the algorithm to use when creating the `TrustManagerFactory` using `TrustManagerFactory.getInstance(java.lang.String)` or `TrustManagerFactory.getInstance(java.lang.String, java.lang.String)`.

      This property will be ignored if a `TrustManagerFactory` has been set directly using `setTrustManagerFactory(TrustManagerFactory)`.

      If this property isn't set while no `TrustManagerFactory` has been set using `setTrustManagerFactory(TrustManagerFactory)` and `setTrustManagerFactoryAlgorithmUseDefault(boolean)` has been set to `true` the value returned by `TrustManagerFactory.getDefaultAlgorithm()` will be used instead.

      Parameters:
        `algorithm` - the algorithm to use.

    - #### setTrustManagerFactoryKeyStore

          public void setTrustManagerFactoryKeyStore(KeyStore keyStore)

      Sets the `KeyStore` which will be used in the call to `TrustManagerFactory.init(java.security.KeyStore)` when the `SSLContext` is created.

      This property will be ignored if `ManagerFactoryParameters` has been set directly using `setTrustManagerFactoryParameters(ManagerFactoryParameters)`.

      Parameters:
        `keyStore` - the key store.

    - #### setTrustManagerFactoryParameters

          public void setTrustManagerFactoryParameters(ManagerFactoryParameters parameters)

      Sets the `ManagerFactoryParameters` which will be used in the call to `TrustManagerFactory.init(javax.net.ssl.ManagerFactoryParameters)` when the `SSLContext` is created.
      Parameters:
        `parameters` - describing provider-specific trust material.

    - #### setTrustManagerFactoryProvider

          public void setTrustManagerFactoryProvider(String provider)

      Sets the provider to use when creating the `TrustManagerFactory` using `TrustManagerFactory.getInstance(java.lang.String, java.lang.String)`.

      This property will be ignored if a `TrustManagerFactory` has been set directly using `setTrustManagerFactory(TrustManagerFactory)`.

      If this property isn't set and no `TrustManagerFactory` has been set using `setTrustManagerFactory(TrustManagerFactory)` `TrustManagerFactory.getInstance(java.lang.String)` will be used to create the `TrustManagerFactory`.

      Parameters:
        `provider` - the name of the provider.

    - #### setSecureRandom

          public void setSecureRandom(SecureRandom secureRandom)

      Sets the `SecureRandom` to use when initializing the `SSLContext`. The JVM's default will be used if this isn't set.
      Parameters:
        `secureRandom` - the `SecureRandom` or `null` if the JVM's default should be used.
      See Also:
        `SSLContext.init(javax.net.ssl.KeyManager[], javax.net.ssl.TrustManager[], java.security.SecureRandom)`

    - #### setClientSessionCacheSize

          public void setClientSessionCacheSize(int size)

      Sets the SSLSession cache size for the `SSLSessionContext` for use in client mode.
      Parameters:
        `size` - the new session cache size limit; zero means there is no limit.
      See Also:
        `SSLSessionContext.setSessionCacheSize(int size)`

    - #### setClientSessionTimeout

          public void setClientSessionTimeout(int seconds)

      Set the SSLSession timeout limit for the `SSLSessionContext` for use in client mode.
      Parameters:
        `seconds` - the new session timeout limit in seconds; zero means there is no limit.
      See Also:
        `SSLSessionContext.setSessionTimeout(int seconds)`

    - #### setServerSessionCacheSize

          public void setServerSessionCacheSize(int serverSessionCacheSize)

      Sets the SSLSession cache size for the `SSLSessionContext` for use in server mode.
      Parameters:
        `serverSessionCacheSize` - the new session cache size limit; zero means there is no limit.
      See Also:
        `SSLSessionContext.setSessionCacheSize(int)`

    - #### setServerSessionTimeout

          public void setServerSessionTimeout(int serverSessionTimeout)

      Set the SSLSession timeout limit for the `SSLSessionContext` for use in server mode.
      Parameters:
        `serverSessionTimeout` - the new session timeout limit in seconds; zero means there is no limit.
      See Also:
        `SSLSessionContext.setSessionTimeout(int)`

Copyright © 2004-2012 Apache MINA Project. All Rights Reserved.