private void configureServerSocket ( SSLServerSocket serverSocket , SSLServerSocketFactory serverSocketFactory , String sslConfigName , OptionsKey options ) throws IOException { try { String [ ] cipherSuites = sslConfig . getCipherSuites ( sslConfigName , serverSocketFactory . getSupportedCipherSuites ( ) ) ; serverSocket . setEnabledCipherSuites ( cipherSuites ) ; // set the SSL protocol on the server socket String protocol = sslConfig . getSSLProtocol ( sslConfigName ) ; if ( protocol != null ) serverSocket . setEnabledProtocols ( new String [ ] { protocol } ) ; boolean clientAuthRequired = ( ( options . requires & EstablishTrustInClient . value ) == EstablishTrustInClient . value ) ; boolean clientAuthSupported = ( ( options . supports & EstablishTrustInClient . value ) == EstablishTrustInClient . value ) ; if ( clientAuthRequired ) { serverSocket . setNeedClientAuth ( true ) ; } else if ( clientAuthSupported ) { serverSocket . setWantClientAuth ( true ) ; } else { serverSocket . setNeedClientAuth ( false ) ; //could set want with the same effect } serverSocket . setSoTimeout ( 60 * 1000 ) ; if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isEventEnabled ( ) ) { Tr . debug ( tc , "Created SSL server socket on port " + serverSocket . getLocalPort ( ) ) ; Tr . debug ( tc , " client authentication " + ( clientAuthSupported ? "SUPPORTED" : "UNSUPPORTED" ) ) ; Tr . debug ( tc , " client authentication " + ( clientAuthRequired ? "REQUIRED" : "OPTIONAL" ) ) ; Tr . debug ( tc , " cipher suites:" ) ; for ( int i = 0 ; i < cipherSuites . length ; i ++ ) { Tr . debug ( tc , " " + cipherSuites [ i ] ) ; } } } catch ( SSLException e ) { throw new IOException ( "Could not configure server socket" , e ) ; } }
Set the server socket configuration to our required QOS values .