Example usage for org.apache.http.client.fluent Executor unregisterScheme

List of usage examples for org.apache.http.client.fluent Executor unregisterScheme

Introduction

In this page you can find the example usage for org.apache.http.client.fluent Executor unregisterScheme.

Prototype

@Deprecated
public static void unregisterScheme(final String name) 

Source Link

Usage

From source file:org.talend.core.utils.StudioSSLContextProvider.java

public static boolean setSSLSystemProperty(boolean isPreference) {
    try {/*from   ww w .  j av  a 2s. c o  m*/
        buildContext();
        if (!isPreference && context == null) {
            return false;
        }
        changeProperty();
        Executor.unregisterScheme("https");
        SSLSocketFactory factory = new SSLSocketFactory(context,
                SSLSocketFactory.BROWSER_COMPATIBLE_HOSTNAME_VERIFIER);
        Executor.registerScheme(new Scheme("https", 443, factory));
    } catch (Exception e) {
        if (isPreference) {
            changeProperty();
            Executor.unregisterScheme("https");
        }
        ExceptionHandler.process(new Exception("Please check the SSL settings in Preference>Talend>SSL", e));
        return false;
    }
    return true;
}

From source file:net.bluemix.newsaggregator.api.AuthenticationServlet.java

static public void configureSSL() {
    // note that it's not adviced to use this in a production application
    // you should overwrite the X509TrustManager to use a cacerts file (list of trusted signers) 
    try {/*from  w  ww  .j  av a  2s  . c  o  m*/
        SSLContext sslContext = SSLContext.getInstance("SSL_TLSv2");

        sslContext.init(null, new TrustManager[] { new X509TrustManager() {
            public X509Certificate[] getAcceptedIssuers() {
                return null;
            }

            public void checkClientTrusted(X509Certificate[] certs, String authType) {
            }

            public void checkServerTrusted(X509Certificate[] certs, String authType) {
            }
        } }, new SecureRandom());

        Executor.unregisterScheme("https");
        SSLSocketFactory sslSocketFactory = new SSLSocketFactory(sslContext,
                SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
        Executor.registerScheme(new Scheme("https", 443, sslSocketFactory));

        HttpsURLConnection.setDefaultSSLSocketFactory(sslContext.getSocketFactory());

    } catch (KeyManagementException | NoSuchAlgorithmException e) {
        e.printStackTrace();
    }
}