com.novell.nds.dirxml.driver.ssl
Class SSLFactory

java.lang.Object
  extended by com.novell.nds.dirxml.driver.ssl.SSLFactory
Direct Known Subclasses:
KeyStoreSSLFactory, KmoSSLFactory

public abstract class SSLFactory
extends Object

Abstract class describing a factory that will produce SSL-capable sockets. This typically must be extended to allow specification of authentication parameters.

The getInstance() method is used to get an implementation of this class.

This exists primarily to allow use to use various SSL providers that are accessed via introspection. This allows us to not require that a. the classes be present even when not used, and b. to use Java 2 classes without impacting the requirement that DirXML run under Java 1.1.7B on Netware 5.


Field Summary
protected static int DEFAULT
          Used with useClientMode and needClientAuth
protected static int FALSE
          Used with useClientMode and needClientAuth
protected  int needClientAuth
          Specifies if sockets performing server handshake need to authenticate the other side.
protected static int TRUE
          Used with useClientMode and needClientAuth
protected  int useClientMode
          Specifies handshake mode for sockets created by this factory.
 
Constructor Summary
SSLFactory()
           
 
Method Summary
abstract  ServerSocket createServerSocket(int port)
          Returns a server socket which uses all network interfaces on the host, and is bound to the specified port.
abstract  ServerSocket createServerSocket(int port, int backlog)
          Returns a server socket which uses all network interfaces on the host, is bound to a the specified port, and uses the specified connection backlog.
abstract  ServerSocket createServerSocket(int port, int backlog, InetAddress ifAddress)
          Returns a server socket which uses only the specified network interface on the local host, is bound to a the specified port, and uses the specified connection backlog.
abstract  Socket createSocket(InetAddress host, int port)
          Returns a socket connected to a ServerSocket at the specified network address and port.
abstract  Socket createSocket(InetAddress host, int port, InetAddress clientAddress, int clientPort)
          Returns a socket connected to a ServerSocket at the specified network address and port.
abstract  Socket createSocket(String host, int port)
          Returns a socket connected to a ServerSocket at the specified network address and port.
abstract  Socket createSocket(String host, int port, InetAddress clientAddress, int clientPort)
          Returns a socket connected to a ServerSocket at the specified network address and port.
static SSLFactory getInstance(String type)
          Return an instance of SSLFactory based on the passed type String.
abstract  String getSSLDescription(Socket socket)
          Returns a String describing basic SSL connections parameters where available.
abstract  String getSSLVerboseDescription(Socket socket)
          Returns a String describing verbose SSL connections parameters where available.
 void setNeedClientAuth(boolean needClientAuth)
          Specify if a socket performing the server mode handshake will require the client to authenticate.
 void setUseClientMode(boolean useClientMode)
          Specify whether to use client or server mode for the initial SSL handshake.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

useClientMode

protected int useClientMode
Specifies handshake mode for sockets created by this factory. Will be DEFAULT, TRUE, or FALSE.


needClientAuth

protected int needClientAuth
Specifies if sockets performing server handshake need to authenticate the other side. Will be DEFAULT, TRUE, or FALSE.


FALSE

protected static final int FALSE
Used with useClientMode and needClientAuth

See Also:
Constant Field Values

TRUE

protected static final int TRUE
Used with useClientMode and needClientAuth

See Also:
Constant Field Values

DEFAULT

protected static final int DEFAULT
Used with useClientMode and needClientAuth

See Also:
Constant Field Values
Constructor Detail

SSLFactory

public SSLFactory()
Method Detail

getInstance

public static SSLFactory getInstance(String type)
                              throws IllegalArgumentException,
                                     SSLInitializationException
Return an instance of SSLFactory based on the passed type String.

Valid values for type are:

"kmo" - returns a factory that implements KmoSSLFactory and returns sockets that use Novell's SAS SSL implementation. Certificates and keys are used from eDirectory Key Material Objects.

"keystore" - returns a factory that implements KeyStoreSSLFactory and returns sockets that use Sun's JSSE SSL implementation. Certificates and keys are used from a Java KeyStore object, stored as a file.

Parameters:
type - "kmo" or "keystore"
Throws:
IllegalArgumentException - if type value is invalid.
SSLInitializationException - thrown if an error occurs creating the factory

setUseClientMode

public void setUseClientMode(boolean useClientMode)
Specify whether to use client or server mode for the initial SSL handshake. By default, server sockets use server mode and client sockets use client mode, but this can be changed.

Parameters:
useClientMode - true if sockets from this factory should use client mode handshakes.

setNeedClientAuth

public void setNeedClientAuth(boolean needClientAuth)
Specify if a socket performing the server mode handshake will require the client to authenticate. By default, sockets performing the server handshake do not require the client to authenticate.

Parameters:
needClientAuth - true if client authentication is to be required.

createServerSocket

public abstract ServerSocket createServerSocket(int port)
                                         throws IOException
Returns a server socket which uses all network interfaces on the host, and is bound to the specified port.

Parameters:
port - the port to listen to
Returns:
created ServerSocket
Throws:
IOException - for networking errors

createServerSocket

public abstract ServerSocket createServerSocket(int port,
                                                int backlog)
                                         throws IOException
Returns a server socket which uses all network interfaces on the host, is bound to a the specified port, and uses the specified connection backlog.

Parameters:
port - the port to listen to
backlog - how many connections are queued
Returns:
created ServerSocket
Throws:
IOException - for networking errors

createServerSocket

public abstract ServerSocket createServerSocket(int port,
                                                int backlog,
                                                InetAddress ifAddress)
                                         throws IOException
Returns a server socket which uses only the specified network interface on the local host, is bound to a the specified port, and uses the specified connection backlog.

Parameters:
port - the port to listen to
backlog - how many connections are queued
ifAddress - the network interface address to use
Returns:
created ServerSocket
Throws:
IOException - for networking errors

createSocket

public abstract Socket createSocket(InetAddress host,
                                    int port)
                             throws IOException
Returns a socket connected to a ServerSocket at the specified network address and port.

Parameters:
host - the server host
port - the server port
Returns:
created Socket
Throws:
IOException - if the connection can't be established

createSocket

public abstract Socket createSocket(InetAddress host,
                                    int port,
                                    InetAddress clientAddress,
                                    int clientPort)
                             throws IOException
Returns a socket connected to a ServerSocket at the specified network address and port.

Parameters:
host - the server host
port - the server port
clientAddress - the client network interface address
clientPort - the client port
Returns:
created Socket
Throws:
IOException - if the connection can't be established

createSocket

public abstract Socket createSocket(String host,
                                    int port)
                             throws IOException,
                                    UnknownHostException
Returns a socket connected to a ServerSocket at the specified network address and port.

Parameters:
host - the server host
port - the server port
Returns:
created Socket
Throws:
IOException - if the connection can't be established
UnknownHostException - if the host name can't be resolved

createSocket

public abstract Socket createSocket(String host,
                                    int port,
                                    InetAddress clientAddress,
                                    int clientPort)
                             throws IOException,
                                    UnknownHostException
Returns a socket connected to a ServerSocket at the specified network address and port.

Parameters:
host - the server host
port - the server port
clientAddress - the client network interface address
clientPort - the client port
Returns:
created Socket
Throws:
IOException - if the connection can't be established
UnknownHostException - if the host name can't be resolved

getSSLDescription

public abstract String getSSLDescription(Socket socket)
                                  throws ClassCastException
Returns a String describing basic SSL connections parameters where available.

Parameters:
socket - a Socket returned by this SSLFactory instance's createSocket(), or by ServerSocket.accept() where the ServerSocket was returned by this SSLFactory instance's createServerSocket().
Returns:
String containing a description of the SSL connection
Throws:
ClassCastException - thrown if the passed Socket is not of a type supported by this SSLFactory.

getSSLVerboseDescription

public abstract String getSSLVerboseDescription(Socket socket)
                                         throws ClassCastException
Returns a String describing verbose SSL connections parameters where available.

Parameters:
socket - a Socket returned by this SSLFactory instance's createSocket(), or by ServerSocket.accept() where the ServerSocket was returned by this SSLFactory instance's createServerSocket().
Returns:
String containing a description of the SSL connection
Throws:
ClassCastException - thrown if the passed Socket is not of a type supported by this SSLFactory.