Class SSLSocketFactoryEx


  • public class SSLSocketFactoryEx
    extends javax.net.ssl.SSLSocketFactory
    TODO - is this class needed anymore as we do not support Java 6 and 7. This class is used to enable additional ciphers used by the SSL Socket. This is specifically because the NVD stopped supporting TLS 1.0 and Java 6 and 7 clients by default were unable to connect to download the NVD data feeds.

    The following code was copied from http://stackoverflow.com/questions/1037590/which-cipher-suites-to-enable-for-ssl-socket/23365536#23365536

    Version:
    $Id: $Id
    Author:
    jww
    • Constructor Summary

      Constructors 
      Constructor Description
      SSLSocketFactoryEx​(javax.net.ssl.KeyManager[] km, javax.net.ssl.TrustManager[] tm, java.security.SecureRandom random, Settings settings)
      Constructs a new SSLSocketFactory.
      SSLSocketFactoryEx​(javax.net.ssl.SSLContext ctx, Settings settings)
      Constructs a new SSLSocketFactory.
      SSLSocketFactoryEx​(Settings settings)
      Constructs a new SSLSocketFactory.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.net.Socket createSocket​(java.lang.String host, int port)
      java.net.Socket createSocket​(java.lang.String host, int port, java.net.InetAddress localHost, int localPort)
      java.net.Socket createSocket​(java.net.InetAddress host, int port)
      java.net.Socket createSocket​(java.net.InetAddress address, int port, java.net.InetAddress localAddress, int localPort)
      java.net.Socket createSocket​(java.net.Socket s, java.lang.String host, int port, boolean autoClose)
      java.lang.String[] getDefaultCipherSuites()
      java.lang.String[] getDefaultProtocols()
      Returns the default protocols.
      protected java.lang.String[] getProtocolList()
      Returns the protocol list.
      java.lang.String[] getSupportedCipherSuites()
      java.lang.String[] getSupportedProtocols()
      Returns the supported protocols.
      • Methods inherited from class javax.net.ssl.SSLSocketFactory

        createSocket, getDefault
      • Methods inherited from class javax.net.SocketFactory

        createSocket
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • SSLSocketFactoryEx

        public SSLSocketFactoryEx​(Settings settings)
                           throws java.security.NoSuchAlgorithmException,
                                  java.security.KeyManagementException
        Constructs a new SSLSocketFactory.
        Parameters:
        settings - reference to the configured settings
        Throws:
        java.security.NoSuchAlgorithmException - thrown when an algorithm is not supported
        java.security.KeyManagementException - thrown if initialization fails
      • SSLSocketFactoryEx

        public SSLSocketFactoryEx​(javax.net.ssl.KeyManager[] km,
                                  javax.net.ssl.TrustManager[] tm,
                                  java.security.SecureRandom random,
                                  Settings settings)
                           throws java.security.NoSuchAlgorithmException,
                                  java.security.KeyManagementException
        Constructs a new SSLSocketFactory.
        Parameters:
        km - the key manager
        tm - the trust manager
        random - secure random
        settings - reference to the configured settings
        Throws:
        java.security.NoSuchAlgorithmException - thrown when an algorithm is not supported
        java.security.KeyManagementException - thrown if initialization fails
      • SSLSocketFactoryEx

        public SSLSocketFactoryEx​(javax.net.ssl.SSLContext ctx,
                                  Settings settings)
                           throws java.security.NoSuchAlgorithmException,
                                  java.security.KeyManagementException
        Constructs a new SSLSocketFactory.
        Parameters:
        ctx - the SSL context
        settings - reference to the configured settings
        Throws:
        java.security.NoSuchAlgorithmException - thrown when an algorithm is not supported
        java.security.KeyManagementException - thrown if initialization fails
    • Method Detail

      • getDefaultCipherSuites

        public java.lang.String[] getDefaultCipherSuites()

        Returns the default cipher suites.

        Specified by:
        getDefaultCipherSuites in class javax.net.ssl.SSLSocketFactory
      • getSupportedCipherSuites

        public java.lang.String[] getSupportedCipherSuites()

        Returns the supported cipher suites.

        Specified by:
        getSupportedCipherSuites in class javax.net.ssl.SSLSocketFactory
      • getDefaultProtocols

        public java.lang.String[] getDefaultProtocols()
        Returns the default protocols.
        Returns:
        the default protocols
      • getSupportedProtocols

        public java.lang.String[] getSupportedProtocols()
        Returns the supported protocols.
        Returns:
        the supported protocols
      • createSocket

        public java.net.Socket createSocket​(java.net.Socket s,
                                            java.lang.String host,
                                            int port,
                                            boolean autoClose)
                                     throws java.io.IOException

        Creates an SSL Socket.

        Specified by:
        createSocket in class javax.net.ssl.SSLSocketFactory
        Throws:
        java.io.IOException
      • createSocket

        public java.net.Socket createSocket​(java.net.InetAddress address,
                                            int port,
                                            java.net.InetAddress localAddress,
                                            int localPort)
                                     throws java.io.IOException

        Creates a new SSL Socket.

        Specified by:
        createSocket in class javax.net.SocketFactory
        Throws:
        java.io.IOException
      • createSocket

        public java.net.Socket createSocket​(java.lang.String host,
                                            int port,
                                            java.net.InetAddress localHost,
                                            int localPort)
                                     throws java.io.IOException

        Creates a new SSL Socket.

        Specified by:
        createSocket in class javax.net.SocketFactory
        Throws:
        java.io.IOException
      • createSocket

        public java.net.Socket createSocket​(java.net.InetAddress host,
                                            int port)
                                     throws java.io.IOException

        Creates a new SSL Socket.

        Specified by:
        createSocket in class javax.net.SocketFactory
        Throws:
        java.io.IOException
      • createSocket

        public java.net.Socket createSocket​(java.lang.String host,
                                            int port)
                                     throws java.io.IOException

        Creates a new SSL Socket.

        Specified by:
        createSocket in class javax.net.SocketFactory
        Throws:
        java.io.IOException
      • getProtocolList

        protected java.lang.String[] getProtocolList()
        Returns the protocol list.
        Returns:
        the protocol list