Package edu.vt.middleware.ldap.ssl
Class AbstractTLSSocketFactory
- java.lang.Object
-
- javax.net.SocketFactory
-
- javax.net.ssl.SSLSocketFactory
-
- edu.vt.middleware.ldap.ssl.AbstractTLSSocketFactory
-
- Direct Known Subclasses:
TLSSocketFactory
public abstract class AbstractTLSSocketFactory extends javax.net.ssl.SSLSocketFactoryProvides common implementation forTLSSocketFactory.- Version:
- $Revision: 1106 $ $Date: 2010-01-29 23:34:13 -0500 (Fri, 29 Jan 2010) $
- Author:
- Middleware Services
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.String[]cipherSuitesEnabled cipher suites.static java.lang.StringDEFAULT_PROTOCOLDefault SSL protocol, value is "TLS".protected javax.net.ssl.SSLSocketFactoryfactorySSLSocketFactory used for creating SSL sockets.protected javax.net.ssl.HostnameVerifierhostnameVerifierHostname verifier for this socket factory.protected java.lang.String[]protocolsEnabled protocol versions.
-
Constructor Summary
Constructors Constructor Description AbstractTLSSocketFactory()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description java.net.SocketcreateSocket()This creates an unconnected socket.java.net.SocketcreateSocket(java.lang.String host, int port)This creates a socket and connects it to the specified port number at the specified address.java.net.SocketcreateSocket(java.lang.String host, int port, java.net.InetAddress localHost, int localPort)This creates a socket and connect it to the specified port number at the specified address.java.net.SocketcreateSocket(java.net.InetAddress host, int port)This creates a socket and connects it to the specified port number at the specified address.java.net.SocketcreateSocket(java.net.InetAddress address, int port, java.net.InetAddress localAddress, int localPort)This creates a socket and connect it to the specified port number at the specified address.java.net.SocketcreateSocket(java.net.Socket s, java.lang.String host, int port, boolean autoClose)This returns a socket layered over an existing socket connected to the named host, at the given port.java.lang.String[]getDefaultCipherSuites()This returns the list of cipher suites which are enabled by default.java.lang.String[]getEnabledCipherSuites()This returns the names of the SSL cipher suites which are currently enabled for use on sockets created by this factory.java.lang.String[]getEnabledProtocols()This returns the names of the protocol versions which are currently enabled for use on sockets created by this factory.javax.net.ssl.SSLSocketFactorygetFactory()This returns the underlyingSSLSocketFactorythat this class uses for creating SSL Sockets.javax.net.ssl.HostnameVerifiergetHostnameVerifier()Returns the hostname verifier to invoke when sockets are created.java.lang.String[]getSupportedCipherSuites()This returns the names of the cipher suites which could be enabled for use on an SSL connection.abstract voidinitialize()Prepares this socket factory for use.protected javax.net.ssl.SSLSocketinitSSLSocket(javax.net.ssl.SSLSocket s)Initializes the supplied socket for use.voidsetEnabledCipherSuites(java.lang.String[] s)Sets the cipher suites enabled for use on sockets created by this factory.voidsetEnabledProtocols(java.lang.String[] s)Sets the protocol versions enabled for use on sockets created by this factory.voidsetHostnameVerifier(javax.net.ssl.HostnameVerifier verifier)Sets the hostname verifier to invoke when sockets are created.
-
-
-
Field Detail
-
DEFAULT_PROTOCOL
public static final java.lang.String DEFAULT_PROTOCOL
Default SSL protocol, value is "TLS".- See Also:
- Constant Field Values
-
factory
protected javax.net.ssl.SSLSocketFactory factory
SSLSocketFactory used for creating SSL sockets.
-
hostnameVerifier
protected javax.net.ssl.HostnameVerifier hostnameVerifier
Hostname verifier for this socket factory.
-
cipherSuites
protected java.lang.String[] cipherSuites
Enabled cipher suites.
-
protocols
protected java.lang.String[] protocols
Enabled protocol versions.
-
-
Method Detail
-
initialize
public abstract void initialize() throws java.security.GeneralSecurityExceptionPrepares this socket factory for use. Must be called before factory can be used.- Throws:
java.security.GeneralSecurityException- if the factory cannot be initialized
-
getFactory
public javax.net.ssl.SSLSocketFactory getFactory()
This returns the underlyingSSLSocketFactorythat this class uses for creating SSL Sockets.- Returns:
SSLSocketFactory
-
getHostnameVerifier
public javax.net.ssl.HostnameVerifier getHostnameVerifier()
Returns the hostname verifier to invoke when sockets are created.- Returns:
- hostname verifier
-
setHostnameVerifier
public void setHostnameVerifier(javax.net.ssl.HostnameVerifier verifier)
Sets the hostname verifier to invoke when sockets are created.- Parameters:
verifier- for SSL hostnames
-
getEnabledCipherSuites
public java.lang.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
-
setEnabledCipherSuites
public void setEnabledCipherSuites(java.lang.String[] s)
Sets the cipher suites enabled for use on sockets created by this factory. SeeSSLSocket.setEnabledCipherSuites(String[]).- Parameters:
s-String[]of cipher suites
-
getEnabledProtocols
public java.lang.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
-
setEnabledProtocols
public void setEnabledProtocols(java.lang.String[] s)
Sets the protocol versions enabled for use on sockets created by this factory. SeeSSLSocket.setEnabledProtocols(String[]).- Parameters:
s-String[]of cipher suites
-
initSSLSocket
protected javax.net.ssl.SSLSocket initSSLSocket(javax.net.ssl.SSLSocket s) throws java.io.IOExceptionInitializes the supplied socket for use.- Parameters:
s-SSLSocketto initialize- Returns:
SSLSocket- Throws:
java.io.IOException- if an I/O error occurs when initializing the socket
-
createSocket
public java.net.Socket createSocket(java.net.Socket s, java.lang.String host, int port, boolean autoClose) throws java.io.IOExceptionThis returns a socket layered over an existing socket connected to the named host, at the given port.- Specified by:
createSocketin classjavax.net.ssl.SSLSocketFactory- Parameters:
s-Socketexisting sockethost-Stringserver hostnameport-intserver portautoClose-booleanclose the underlying socket when this socket is closed- Returns:
Socket- connected to the specified host and port- Throws:
java.io.IOException- if an I/O error occurs when creating the socket
-
createSocket
public java.net.Socket createSocket() throws java.io.IOExceptionThis creates an unconnected socket.- Overrides:
createSocketin classjavax.net.SocketFactory- Returns:
Socket- unconnected socket- Throws:
java.io.IOException- if an I/O error occurs when creating the socket
-
createSocket
public java.net.Socket createSocket(java.net.InetAddress host, int port) throws java.io.IOExceptionThis creates a socket and connects it to the specified port number at the specified address.- Specified by:
createSocketin classjavax.net.SocketFactory- Parameters:
host-InetAddressserver hostnameport-intserver port- Returns:
Socket- connected to the specified host and port- Throws:
java.io.IOException- if an I/O error occurs when creating the socket
-
createSocket
public java.net.Socket createSocket(java.net.InetAddress address, int port, java.net.InetAddress localAddress, int localPort) throws java.io.IOExceptionThis 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:
createSocketin classjavax.net.SocketFactory- Parameters:
address-InetAddressserver hostnameport-intserver portlocalAddress-InetAddressclient hostnamelocalPort-intclient port- Returns:
Socket- connected to the specified host and port- Throws:
java.io.IOException- if an I/O error occurs when creating the socket
-
createSocket
public java.net.Socket createSocket(java.lang.String host, int port) throws java.io.IOExceptionThis creates a socket and connects it to the specified port number at the specified address.- Specified by:
createSocketin classjavax.net.SocketFactory- Parameters:
host-Stringserver hostnameport-intserver port- Returns:
Socket- connected to the specified host and port- Throws:
java.io.IOException- if an I/O error occurs when creating the socket
-
createSocket
public java.net.Socket createSocket(java.lang.String host, int port, java.net.InetAddress localHost, int localPort) throws java.io.IOExceptionThis 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:
createSocketin classjavax.net.SocketFactory- Parameters:
host-Stringserver hostnameport-intserver portlocalHost-InetAddressclient hostnamelocalPort-intclient port- Returns:
Socket- connected to the specified host and port- Throws:
java.io.IOException- if an I/O error occurs when creating the socket
-
getDefaultCipherSuites
public java.lang.String[] getDefaultCipherSuites()
This returns the list of cipher suites which are enabled by default.- Specified by:
getDefaultCipherSuitesin classjavax.net.ssl.SSLSocketFactory- Returns:
String[]- array of the cipher suites
-
getSupportedCipherSuites
public java.lang.String[] getSupportedCipherSuites()
This returns the names of the cipher suites which could be enabled for use on an SSL connection.- Specified by:
getSupportedCipherSuitesin classjavax.net.ssl.SSLSocketFactory- Returns:
String[]- array of the cipher suites
-
-