Class AbstractTLSSocketFactory

  • Direct Known Subclasses:
    TLSSocketFactory

    public abstract class AbstractTLSSocketFactory
    extends javax.net.ssl.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

      Fields 
      Modifier and Type Field Description
      protected java.lang.String[] cipherSuites
      Enabled cipher suites.
      static java.lang.String DEFAULT_PROTOCOL
      Default SSL protocol, value is "TLS".
      protected javax.net.ssl.SSLSocketFactory factory
      SSLSocketFactory used for creating SSL sockets.
      protected javax.net.ssl.HostnameVerifier hostnameVerifier
      Hostname verifier for this socket factory.
      protected java.lang.String[] protocols
      Enabled protocol versions.
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      java.net.Socket createSocket()
      This creates an unconnected socket.
      java.net.Socket createSocket​(java.lang.String host, int port)
      This creates a socket and connects it to the specified port number at the specified address.
      java.net.Socket createSocket​(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.Socket createSocket​(java.net.InetAddress host, int port)
      This creates a socket and connects it to the specified port number at the specified address.
      java.net.Socket createSocket​(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.Socket createSocket​(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.SSLSocketFactory getFactory()
      This returns the underlying SSLSocketFactory that this class uses for creating SSL Sockets.
      javax.net.ssl.HostnameVerifier getHostnameVerifier()
      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 void initialize()
      Prepares this socket factory for use.
      protected javax.net.ssl.SSLSocket initSSLSocket​(javax.net.ssl.SSLSocket s)
      Initializes the supplied socket for use.
      void setEnabledCipherSuites​(java.lang.String[] s)
      Sets the cipher suites enabled for use on sockets created by this factory.
      void setEnabledProtocols​(java.lang.String[] s)
      Sets the protocol versions enabled for use on sockets created by this factory.
      void setHostnameVerifier​(javax.net.ssl.HostnameVerifier verifier)
      Sets the hostname verifier to invoke when sockets are created.
      • Methods inherited from class javax.net.ssl.SSLSocketFactory

        createSocket, 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 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.
    • Constructor Detail

      • AbstractTLSSocketFactory

        public AbstractTLSSocketFactory()
    • Method Detail

      • initialize

        public abstract void initialize()
                                 throws java.security.GeneralSecurityException
        Prepares 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 underlying SSLSocketFactory that 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. See SSLSocket.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. See SSLSocket.setEnabledProtocols(String[]).
        Parameters:
        s - String[] of cipher suites
      • initSSLSocket

        protected javax.net.ssl.SSLSocket initSSLSocket​(javax.net.ssl.SSLSocket s)
                                                 throws java.io.IOException
        Initializes the supplied socket for use.
        Parameters:
        s - SSLSocket to 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.IOException
        This returns a socket layered over an existing socket connected to the named host, at the given port.
        Specified by:
        createSocket in class javax.net.ssl.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:
        java.io.IOException - if an I/O error occurs when creating the socket
      • createSocket

        public java.net.Socket createSocket()
                                     throws java.io.IOException
        This creates an unconnected socket.
        Overrides:
        createSocket in class javax.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.IOException
        This creates a socket and connects it to the specified port number at the specified address.
        Specified by:
        createSocket in class javax.net.SocketFactory
        Parameters:
        host - InetAddress server hostname
        port - int server 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.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 javax.net.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:
        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.IOException
        This creates a socket and connects it to the specified port number at the specified address.
        Specified by:
        createSocket in class javax.net.SocketFactory
        Parameters:
        host - String server hostname
        port - int server 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.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 javax.net.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:
        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:
        getDefaultCipherSuites in class javax.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:
        getSupportedCipherSuites in class javax.net.ssl.SSLSocketFactory
        Returns:
        String[] - array of the cipher suites