## mx4j.tools.adaptor.ssl
Class SSLAdaptorServerSocketFactory

    java.lang.Object
      mx4j.tools.adaptor.ssl.SSLAdaptorServerSocketFactory

All Implemented Interfaces:
  AdaptorServerSocketFactory, SSLAdaptorServerSocketFactoryMBean

public class SSLAdaptorServerSocketFactory
extends java.lang.Object
implements SSLAdaptorServerSocketFactoryMBean

TODO: Fix this class to avoid hardcoding Sun's provider, since it will not work with IBM's JDK. This MBean creates SSLServerSocket instances.

It can be configured to use a specific keystore and SSL protocol version to create SSLServerSockets that will use the keystore information to encrypt data.

A keystore can be created with this command:

     keytool -genkey -v -keystore store.key -storepass storepwd -keypass keypwd -dname "CN=Simone Bordet, OU=Project Administrator, O=MX4J, L=Torino, S=TO, C=IT" -validity 365

or with this minimal command (that will prompt you for further information):

     keytool -genkey -keystore store.key

A keystore may contains more than one entry, but only the first entry will be used for encryption, no matter which is the alias for that entry.

Following the first example of generation of the keystore, this MBean must be instantiated and then setup by invoking the following methods:

- `setKeyStoreName(java.lang.String)`("store.key");
- `setKeyStorePassword(java.lang.String)`("storepwd");
- `setKeyManagerPassword(java.lang.String)`("keypwd");

before `createServerSocket(int, int, java.lang.String)` is called.

Version:
  $Revision: 1.5 $

Constructor Summary
`SSLAdaptorServerSocketFactory()`

Method Summary
`static void` `addProvider(java.security.Provider provider)`
`java.net.ServerSocket` `createServerSocket(int port, int backlog, java.lang.String host)` Returns a SSLServerSocket on the given port.
`void` `setKeyManagerAlgorithm(java.lang.String algorithm)` Sets the key manager algorithm, by default is "SunX509".
`void` `setKeyManagerPassword(java.lang.String password)` Sets the password to access the key present in the keystore.
`void` `setKeyStoreName(java.lang.String name)` Sets the name of the keystore; if the keystore is of type JKS, then this is a file name, that will be resolved by the ClassLoader of this class, via getResourceAsStream.
`void` `setKeyStorePassword(java.lang.String password)` Sets the password to access the keystore specified by `setKeyStoreName(java.lang.String)`.
`void` `setKeyStoreType(java.lang.String keyStoreType)` Sets the type of the keystore, by default is "JKS".
`void` `setSSLProtocol(java.lang.String protocol)` Sets the SSL protocol version, by default is "TLS".
`void` `setTrustManagerAlgorithm(java.lang.String algorithm)` Sets the trust manager algorithm, by default is "SunX509".
`void` `setTrustStoreName(java.lang.String name)` Sets the name of the truststore; if the truststore is of type JKS, then this is a file name, that will be resolved by the ClassLoader of this class, via getResourceAsStream.
`void` `setTrustStorePassword(java.lang.String password)` Sets the password to access the truststore specified by `setTrustStoreName(java.lang.String)`.
`void` `setTrustStoreType(java.lang.String trustStoreType)` Sets the type of the truststore, by default is "JKS".

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### SSLAdaptorServerSocketFactory

    public SSLAdaptorServerSocketFactory()

Method Detail

### addProvider

    public static void addProvider(java.security.Provider provider)

### setKeyStoreType

    public void setKeyStoreType(java.lang.String keyStoreType)

  Description copied from interface: `SSLAdaptorServerSocketFactoryMBean`
  Sets the type of the keystore, by default is "JKS".

  Specified by:
    `setKeyStoreType` in interface `SSLAdaptorServerSocketFactoryMBean`

### setTrustStoreType

    public void setTrustStoreType(java.lang.String trustStoreType)

  Description copied from interface: `SSLAdaptorServerSocketFactoryMBean`
  Sets the type of the truststore, by default is "JKS".

  Specified by:
    `setTrustStoreType` in interface `SSLAdaptorServerSocketFactoryMBean`

### setKeyStoreName

    public void setKeyStoreName(java.lang.String name)

  Description copied from interface: `SSLAdaptorServerSocketFactoryMBean`
  Sets the name of the keystore; if the keystore is of type JKS, then this is a file name, that will be resolved by the ClassLoader of this class, via getResourceAsStream.

  Specified by:
    `setKeyStoreName` in interface `SSLAdaptorServerSocketFactoryMBean`

### setTrustStoreName

    public void setTrustStoreName(java.lang.String name)

  Description copied from interface: `SSLAdaptorServerSocketFactoryMBean`
  Sets the name of the truststore; if the truststore is of type JKS, then this is a file name, that will be resolved by the ClassLoader of this class, via getResourceAsStream.

  Specified by:
    `setTrustStoreName` in interface `SSLAdaptorServerSocketFactoryMBean`

### setKeyStorePassword

    public void setKeyStorePassword(java.lang.String password)

  Description copied from interface: `SSLAdaptorServerSocketFactoryMBean`
  Sets the password to access the keystore specified by `SSLAdaptorServerSocketFactoryMBean.setKeyStoreName(java.lang.String)`.

  It correspond to the value of the -storepass option of keytool.

  Specified by:
    `setKeyStorePassword` in interface `SSLAdaptorServerSocketFactoryMBean`

### setTrustStorePassword

    public void setTrustStorePassword(java.lang.String password)

  Description copied from interface: `SSLAdaptorServerSocketFactoryMBean`
  Sets the password to access the truststore specified by `SSLAdaptorServerSocketFactoryMBean.setTrustStoreName(java.lang.String)`.

  It correspond to the value of the -storepass option of keytool.

  Specified by:
    `setTrustStorePassword` in interface `SSLAdaptorServerSocketFactoryMBean`

### setKeyManagerAlgorithm

    public void setKeyManagerAlgorithm(java.lang.String algorithm)

  Description copied from interface: `SSLAdaptorServerSocketFactoryMBean`
  Sets the key manager algorithm, by default is "SunX509".

  Specified by:
    `setKeyManagerAlgorithm` in interface `SSLAdaptorServerSocketFactoryMBean`

### setTrustManagerAlgorithm

    public void setTrustManagerAlgorithm(java.lang.String algorithm)

  Description copied from interface: `SSLAdaptorServerSocketFactoryMBean`
  Sets the trust manager algorithm, by default is "SunX509".

  Specified by:
    `setTrustManagerAlgorithm` in interface `SSLAdaptorServerSocketFactoryMBean`

### setKeyManagerPassword

    public void setKeyManagerPassword(java.lang.String password)

  Description copied from interface: `SSLAdaptorServerSocketFactoryMBean`
  Sets the password to access the key present in the keystore.

  It correspond to the value of the -keypass option of keytool; if not specified, the KeyStore password is taken.

  Specified by:
    `setKeyManagerPassword` in interface `SSLAdaptorServerSocketFactoryMBean`

### setSSLProtocol

    public void setSSLProtocol(java.lang.String protocol)

  Description copied from interface: `SSLAdaptorServerSocketFactoryMBean`
  Sets the SSL protocol version, by default is "TLS".

  Specified by:
    `setSSLProtocol` in interface `SSLAdaptorServerSocketFactoryMBean`

### createServerSocket

    public java.net.ServerSocket createServerSocket(int port,
                                                    int backlog,
                                                    java.lang.String host)
                                             throws java.io.IOException

  Returns a SSLServerSocket on the given port.

  Specified by:
    `createServerSocket` in interface `AdaptorServerSocketFactory`
  Throws:
    `java.io.IOException`

Copyright © 2001-2005 The MX4J Contributors. All Rights Reserved.