edu.vt.middleware.ldap.ssl
Class AbstractTLSSocketFactory

java.lang.Object
  extended by javax.net.SocketFactory
      extended by javax.net.ssl.SSLSocketFactory
          extended by edu.vt.middleware.ldap.ssl.AbstractTLSSocketFactory
Direct Known Subclasses:
TLSSocketFactory

public abstract class AbstractTLSSocketFactory
extends SSLSocketFactory

Provides common implementation for TLSSocketFactory.

Version:
$Revision: 1106 $ $Date: 2010-01-29 23:34:13 -0500 (Fri, 29 Jan 2010) $
Author:
Middleware Services

Field Summary
protected  String[] cipherSuites
          Enabled cipher suites.
static String DEFAULT_PROTOCOL
          Default SSL protocol, value is "TLS".
protected  SSLSocketFactory factory
          SSLSocketFactory used for creating SSL sockets.
protected  String[] protocols
          Enabled protocol versions.
 
Constructor Summary
AbstractTLSSocketFactory()
           
 
Method Summary
 Socket createSocket()
          This creates an unconnected socket.
 Socket createSocket(InetAddress host, int port)
          This creates a socket and connects it to the specified port number at the specified address.
 Socket createSocket(InetAddress address, int port, InetAddress localAddress, int localPort)
          This creates a socket and connect it to the specified port number at the specified address.
 Socket createSocket(Socket s, String host, int port, boolean autoClose)
          This returns a socket layered over an existing socket connected to the named host, at the given port.
 Socket createSocket(String host, int port)
          This creates a socket and connects it to the specified port number at the specified address.
 Socket createSocket(String host, int port, InetAddress localHost, int localPort)
          This creates a socket and connect it to the specified port number at the specified address.
 String[] getDefaultCipherSuites()
          This returns the list of cipher suites which are enabled by default.
 String[] getEnabledCipherSuites()
          This returns the names of the SSL cipher suites which are currently enabled for use on sockets created by this factory.
 String[] getEnabledProtocols()
          This returns the names of the protocol versions which are currently enabled for use on sockets created by this factory.
 SSLSocketFactory getFactory()
          This returns the underlying SSLSocketFactory that this class uses for creating SSL Sockets.
 String[] getSupportedCipherSuites()
          This returns the names of the cipher suites which could be enabled for use on an SSL connection.
abstract  void initialize()
          Prepares this socket factory for use.
protected  SSLSocket initSSLSocket(SSLSocket s)
          Initializes the supplied socket for use.
 void setEnabledCipherSuites(String[] s)
          Sets the cipher suites enabled for use on sockets created by this factory.
 void setEnabledProtocols(String[] s)
          Sets the protocol versions enabled for use on sockets created by this factory.
 
Methods inherited from class javax.net.ssl.SSLSocketFactory
getDefault
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_PROTOCOL

public static final String DEFAULT_PROTOCOL
Default SSL protocol, value is "TLS".

See Also:
Constant Field Values

factory

protected SSLSocketFactory factory
SSLSocketFactory used for creating SSL sockets.


cipherSuites

protected String[] cipherSuites
Enabled cipher suites.


protocols

protected String[] protocols
Enabled protocol versions.

Constructor Detail

AbstractTLSSocketFactory

public AbstractTLSSocketFactory()
Method Detail

initialize

public abstract void initialize()
                         throws GeneralSecurityException
Prepares this socket factory for use. Must be called before factory can be used.

Throws:
GeneralSecurityException - if the factory cannot be initialized

getFactory

public SSLSocketFactory getFactory()
This returns the underlying SSLSocketFactory that this class uses for creating SSL Sockets.

Returns:
SSLSocketFactory

getEnabledCipherSuites

public String[] getEnabledCipherSuites()
This returns the names of the SSL cipher suites which are currently enabled for use on sockets created by this factory. A null value indicates that no specific cipher suites have been enabled and that the default suites are in use.

Returns:
String[] of cipher suites

getEnabledProtocols

public String[] getEnabledProtocols()
This returns the names of the protocol versions which are currently enabled for use on sockets created by this factory. A null value indicates that no specific protocols have been enabled and that the default protocols are in use.

Returns:
String[] of protocols

setEnabledCipherSuites

public void setEnabledCipherSuites(String[] s)
Sets the cipher suites enabled for use on sockets created by this factory. See SSLSocket.setEnabledCipherSuites(String[]).

Parameters:
s - String[] of cipher suites

setEnabledProtocols

public void setEnabledProtocols(String[] s)
Sets the protocol versions enabled for use on sockets created by this factory. See SSLSocket.setEnabledProtocols(String[]).

Parameters:
s - String[] of cipher suites

initSSLSocket

protected SSLSocket initSSLSocket(SSLSocket s)
Initializes the supplied socket for use.

Parameters:
s - SSLSocket to initialize
Returns:
SSLSocket

createSocket

public Socket createSocket(Socket s,
                           String host,
                           int port,
                           boolean autoClose)
                    throws IOException
This returns a socket layered over an existing socket connected to the named host, at the given port.

Specified by:
createSocket in class SSLSocketFactory
Parameters:
s - Socket existing socket
host - String server hostname
port - int server port
autoClose - boolean close the underlying socket when this socket is closed
Returns:
Socket - connected to the specified host and port
Throws:
IOException - if an I/O error occurs when creating the socket

createSocket

public Socket createSocket()
                    throws IOException
This creates an unconnected socket.

Overrides:
createSocket in class SocketFactory
Returns:
Socket - unconnected socket
Throws:
IOException - if an I/O error occurs when creating the socket

createSocket

public Socket createSocket(InetAddress host,
                           int port)
                    throws IOException
This creates a socket and connects it to the specified port number at the specified address.

Specified by:
createSocket in class SocketFactory
Parameters:
host - InetAddress server hostname
port - int server port
Returns:
Socket - connected to the specified host and port
Throws:
IOException - if an I/O error occurs when creating the socket

createSocket

public Socket createSocket(InetAddress address,
                           int port,
                           InetAddress localAddress,
                           int localPort)
                    throws IOException
This creates a socket and connect it to the specified port number at the specified address. The socket will also be bound to the supplied local address and port.

Specified by:
createSocket in class SocketFactory
Parameters:
address - InetAddress server hostname
port - int server port
localAddress - InetAddress client hostname
localPort - int client port
Returns:
Socket - connected to the specified host and port
Throws:
IOException - if an I/O error occurs when creating the socket

createSocket

public Socket createSocket(String host,
                           int port)
                    throws IOException
This creates a socket and connects it to the specified port number at the specified address.

Specified by:
createSocket in class SocketFactory
Parameters:
host - String server hostname
port - int server port
Returns:
Socket - connected to the specified host and port
Throws:
IOException - if an I/O error occurs when creating the socket

createSocket

public Socket createSocket(String host,
                           int port,
                           InetAddress localHost,
                           int localPort)
                    throws IOException
This creates a socket and connect it to the specified port number at the specified address. The socket will also be bound to the supplied local address and port.

Specified by:
createSocket in class SocketFactory
Parameters:
host - String server hostname
port - int server port
localHost - InetAddress client hostname
localPort - int client port
Returns:
Socket - connected to the specified host and port
Throws:
IOException - if an I/O error occurs when creating the socket

getDefaultCipherSuites

public String[] getDefaultCipherSuites()
This returns the list of cipher suites which are enabled by default.

Specified by:
getDefaultCipherSuites in class SSLSocketFactory
Returns:
String[] - array of the cipher suites

getSupportedCipherSuites

public String[] getSupportedCipherSuites()
This returns the names of the cipher suites which could be enabled for use on an SSL connection.

Specified by:
getSupportedCipherSuites in class SSLSocketFactory
Returns:
String[] - array of the cipher suites


Copyright © 2003-2010 Virginia Tech. All Rights Reserved.