private static ConnectionConfigurator getSSLConnectionConfiguration( final int connectTimeout, final int readTimeout, Configuration conf) { ConnectionConfigurator conn; try { conn = newSslConnConfigurator(connectTimeout, readTimeout, conf); } catch (Exception e) { LOG.warn( "Cannot load customized ssl related configuration. Fallback to" + " system-generic settings.", e); if (connectTimeout == DEFAULT_SOCKET_TIMEOUT && readTimeout == DEFAULT_SOCKET_TIMEOUT) { conn = DEFAULT_TIMEOUT_CONN_CONFIGURATOR; } else { conn = new ConnectionConfigurator() { @Override public HttpURLConnection configure(HttpURLConnection connection) throws IOException { URLConnectionFactory.setTimeouts(connection, connectTimeout, readTimeout); return connection; } }; } } return conn; }
/** * Construct a new URLConnectionFactory based on the configuration. It will * try to load SSL certificates when it is specified. */ public static URLConnectionFactory newDefaultURLConnectionFactory(Configuration conf) { ConnectionConfigurator conn = null; try { conn = newSslConnConfigurator(DEFAULT_SOCKET_TIMEOUT, conf); } catch (Exception e) { LOG.debug( "Cannot load customized ssl related configuration. Fallback to system-generic settings.", e); conn = DEFAULT_TIMEOUT_CONN_CONFIGURATOR; } return new URLConnectionFactory(conn); }
/** * Construct a new URLConnectionFactory that supports OAut-based connections. * It will also try to load the SSL configuration when they are specified. */ public static URLConnectionFactory newOAuth2URLConnectionFactory( int connectTimeout, int readTimeout, Configuration conf) throws IOException { ConnectionConfigurator conn; try { ConnectionConfigurator sslConnConfigurator = newSslConnConfigurator(connectTimeout, readTimeout, conf); conn = new OAuth2ConnectionConfigurator(conf, sslConnConfigurator); } catch (Exception e) { throw new IOException("Unable to load OAuth2 connection factory.", e); } return new URLConnectionFactory(conn); }
/** * Construct a new URLConnectionFactory based on the configuration. It will * try to load SSL certificates when it is specified. */ public static URLConnectionFactory newDefaultURLConnectionFactory(Configuration conf) { ConnectionConfigurator conn = null; try { conn = newSslConnConfigurator(DEFAULT_SOCKET_TIMEOUT, conf); } catch (Exception e) { LOG.debug( "Cannot load customized ssl related configuration. Fallback to system-generic settings.", e); conn = DEFAULT_TIMEOUT_CONN_CONFIGURATOR; } return new URLConnectionFactory(conn); }