org.ldaptive.ssl
Class AbstractTLSSocketFactory

java.lang.Object
  extended by javax.net.SocketFactory
      extended by javax.net.ssl.SSLSocketFactory
          extended by org.ldaptive.ssl.AbstractTLSSocketFactory
Direct Known Subclasses:
TLSSocketFactory

public abstract class AbstractTLSSocketFactory
extends SSLSocketFactory

Provides common implementation for TLSSocketFactory.

Version:
$Revision: 3120 $ $Date: 2015-10-01 11:50:02 -0400 (Thu, 01 Oct 2015) $
Author:
Middleware Services

Field Summary
static String DEFAULT_PROTOCOL
          Default SSL protocol, value is "TLS".
protected  SSLSocketFactory factory
          SSLSocketFactory used for creating SSL sockets.
protected  org.slf4j.Logger logger
          Logger for this class.
 
Constructor Summary
AbstractTLSSocketFactory()
           
 
Method Summary
 Socket createSocket()
          Creates 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 port number at the specified address.
 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 port number at the specified address.
 Socket createSocket(String host, int port, InetAddress localHost, int localPort)
          Creates a socket and connect it to the specified port number at the specified address.
 String[] getDefaultCipherSuites()
          Returns the list of cipher suites which are enabled by default.
 SSLSocketFactory getFactory()
          Returns the underlying SSL socket factory that this class uses for creating SSL Sockets.
 HostnameVerifier getHostnameVerifier()
          Returns the hostname verifier.
 SocketConfig getSocketConfig()
          Returns the socket configuration used by this socket factory.
 SslConfig getSslConfig()
          Returns the SSL configuration used by this socket factory.
 String[] getSupportedCipherSuites()
          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 socket)
          Initializes the supplied socket for use.
 void setHostnameVerifier(HostnameVerifier verifier)
          Sets the hostname verifier.
 void setSocketConfig(SocketConfig config)
          Sets the socket configuration used by this socket factory.
 void setSslConfig(SslConfig config)
          Sets the SSL configuration used by this socket 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

logger

protected final org.slf4j.Logger logger
Logger for this class.


factory

protected SSLSocketFactory factory
SSLSocketFactory used for creating SSL sockets.

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()
Returns the underlying SSL socket factory that this class uses for creating SSL Sockets.

Returns:
SSL socket factory

getSslConfig

public SslConfig getSslConfig()
Returns the SSL configuration used by this socket factory.

Returns:
ssl config

setSslConfig

public void setSslConfig(SslConfig config)
Sets the SSL configuration used by this socket factory.

Parameters:
config - ssl config

getHostnameVerifier

public HostnameVerifier getHostnameVerifier()
Returns the hostname verifier.

Returns:
trust managers

setHostnameVerifier

public void setHostnameVerifier(HostnameVerifier verifier)
Sets the hostname verifier.

Parameters:
verifier - hostname verifier

getSocketConfig

public SocketConfig getSocketConfig()
Returns the socket configuration used by this socket factory.

Returns:
socket config

setSocketConfig

public void setSocketConfig(SocketConfig config)
Sets the socket configuration used by this socket factory.

Parameters:
config - socket config

initSSLSocket

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

Parameters:
socket - SSL socket to initialize
Returns:
SSL socket
Throws:
IOException - if an I/O error occurs when initializing the socket

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.

Specified by:
createSocket in class SSLSocketFactory
Parameters:
socket - existing socket
host - server hostname
port - server port
autoClose - 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
Creates an unconnected socket.

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

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.

Specified by:
createSocket in class SocketFactory
Parameters:
host - server hostname
port - 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
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 - server hostname
port - server port
localAddress - client hostname
localPort - 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
Creates a socket and connects it to the specified port number at the specified address.

Specified by:
createSocket in class SocketFactory
Parameters:
host - server hostname
port - 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
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 - server hostname
port - server port
localHost - client hostname
localPort - 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()
Returns the list of cipher suites which are enabled by default.

Specified by:
getDefaultCipherSuites in class SSLSocketFactory
Returns:
cipher suites

getSupportedCipherSuites

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

Specified by:
getSupportedCipherSuites in class SSLSocketFactory
Returns:
cipher suites


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