SPT Core API

com.sptci
Class SSLSocketFactory

java.lang.Object
  extended by javax.net.SocketFactory
      extended by javax.net.ssl.SSLSocketFactory
          extended by com.sptci.SSLSocketFactory

public class SSLSocketFactory
extends SSLSocketFactory

A wrapper around the standard SSLSocketFactory to return a custom TrustManager that unconditionally accepts certificates presented by a SSL server. *

Copyright 2006 Sans Pareil Technologies, Inc.

Version:
$Id: SSLSocketFactory.java 4553 2008-12-24 10:34:16Z rakesh $
Author:
Rakesh Vidyadharan 2006-02-17

Constructor Summary
SSLSocketFactory()
          Initialise an new instance of the wrapper factory.
 
Method Summary
 Socket createSocket()
          Create an unconnected socket.
 Socket createSocket(InetAddress host, int port)
          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)
          Creates a socket and connect it to the specified remote address on the specified remote port.
 Socket createSocket(Socket socket, String host, int port, boolean autoClose)
          Returns a socket layered over an existing socket connected to the named host, at the given port.
 Socket createSocket(String host, int port)
          Creates a socket and connects it to the specified remote host at the specified remote port.
 Socket createSocket(String host, int port, InetAddress localHost, int localPort)
          Creates a socket and connects it to the specified remote host on the specified remote port.
static SocketFactory getDefault()
          Returns a copy of the environment's default socket factory.
 String[] getDefaultCipherSuites()
          Returns the list of cipher suites which are enabled by default.
 String[] getSupportedCipherSuites()
          Returns the names of the cipher suites which could be enabled for use on an SSL connection.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SSLSocketFactory

public SSLSocketFactory()
Initialise an new instance of the wrapper factory.

Throws:
RuntimeException - If errors are encountered while initialising the factory.
Method Detail

getDefault

public static SocketFactory getDefault()
Returns a copy of the environment's default socket factory. Over-ridden to return a new instance of this wrapper factory.

Returns:
SocketFactory A new instance of this class.

createSocket

public Socket createSocket()
                    throws IOException
Create an unconnected socket.

Overrides:
createSocket in class SocketFactory
Returns:
The unconnected socket.
Throws:
IOException - If the socket cannot be created.

createSocket

public Socket createSocket(Socket socket,
                           String host,
                           int port,
                           boolean autoClose)
                    throws IOException
Returns a socket layered over an existing socket connected to the named host, at the given port. This constructor can be used when tunneling SSL through a proxy or when negotiating the use of SSL over an existing socket. The host and port refer to the logical peer destination. This socket is configured using the socket options established for this factory. Delegates the creation to factory.

Specified by:
createSocket in class SSLSocketFactory
Parameters:
socket - The existing socket.
host - The server host.
port - The server port.
autoClose - Close the underlying socket when this socket is closed.
Returns:
Socket The properly initialised socket.
Throws:
IOException - If errors are encountered while creating the layered socket.
UnknownHostException - If the server host specified is unknown.

createSocket

public Socket createSocket(InetAddress host,
                           int port)
                    throws IOException
Creates a socket and connects it to the specified port number at the specified address. This socket is configured using the socket options established for this factory. Delegates the creation to [@link #factory}.

Specified by:
createSocket in class SocketFactory
Parameters:
host - The server host.
port - The server port.
Returns:
Socket The properly initialised socket.
Throws:
IOException - If errors are encountered while creating the layered socket.

createSocket

public Socket createSocket(InetAddress address,
                           int port,
                           InetAddress localAddress,
                           int localPort)
                    throws IOException
Creates a socket and connect it to the specified remote address on the specified remote port. The socket will also be bound to the local address and port suplied. The socket is configured using the socket options established for this factory. Delegates the creation to [@link #factory}.

Specified by:
createSocket in class SocketFactory
Parameters:
address - The server network address.
port - The server port.
localAddress - The client network address.
localPort - The client port.
Returns:
The socket instance.
Throws:
IOException - If errors are encountered while creating the layered socket.

createSocket

public Socket createSocket(String host,
                           int port)
                    throws IOException
Creates a socket and connects it to the specified remote host at the specified remote port. This socket is configured using the socket options established for this factory. Delegates the creation to factory.

Specified by:
createSocket in class SocketFactory
Parameters:
host - The server host.
port - The server port.
Returns:
The socket connection to the host and port.
Throws:
IOException - If errors are encountered while creating the layered socket.
UnknownHostException - If the server host specified is unknown.

createSocket

public Socket createSocket(String host,
                           int port,
                           InetAddress localHost,
                           int localPort)
                    throws IOException
Creates a socket and connects it to the specified remote host on the specified remote port. The socket will also be bound to the local address and port supplied. This socket is configured using the socket options established for this factory. Delegates the creation to [@link #factory}.

Specified by:
createSocket in class SocketFactory
Parameters:
host - The server host.
port - The server port.
localHost - The local address the socket is bound to.
localPort - The local port the socket is bound to.
Returns:
The socket connection to the host and port.
Throws:
IOException - If errors are encountered while creating the layered socket.
UnknownHostException - If the server host specified is unknown.

getDefaultCipherSuites

public String[] getDefaultCipherSuites()
Returns the list of cipher suites which are enabled by default. Unless a different list is enabled, handshaking on an SSL connection will use one of these cipher suites. The minimum quality of service for these defaults requires confidentiality protection and server authentication (that is, no anonymous cipher suites). Delegates the creation to factory.

Specified by:
getDefaultCipherSuites in class SSLSocketFactory
Returns:
String[] Array of the cipher suites enabled by default.

getSupportedCipherSuites

public String[] getSupportedCipherSuites()
Returns the names of the cipher suites which could be enabled for use on an SSL connection. Normally, only a subset of these will actually be enabled by default, since this list may include cipher suites which do not meet quality of service requirements for those defaults. Such cipher suites are useful in specialised applications. Delegates the creation to factory.

Specified by:
getSupportedCipherSuites in class SSLSocketFactory
Returns:
String[] An array of cipher suite names

SPT Core API