private SSLSocketFactory getSocketFactory ( String id ) throws IOException { // first use? SSLSocketFactory socketFactory = socketFactoryMap . get ( id ) ; if ( socketFactory == null ) { // the SSLConfig is optional, so if it's not there, use the default SSLSocketFactory. if ( id == null ) { socketFactory = ( SSLSocketFactory ) SSLSocketFactory . getDefault ( ) ; } else { // ask the SSLConfig bean to create a factory for us. try { socketFactory = sslConfig . createSSLFactory ( id ) ; } catch ( Exception e ) { Tr . error ( tc , "Unable to create client SSL socket factory" , e ) ; throw ( IOException ) new IOException ( "Unable to create client SSL socket factory: " + e . getMessage ( ) ) . initCause ( e ) ; } } socketFactoryMap . put ( id , socketFactory ) ; } return socketFactory ; }
On - demand creation of an SSL socket factory for the ssl alias provided