Search in sources :

Example 1 with SingleClientConnManager

use of org.apache.http.impl.conn.SingleClientConnManager in project platform_external_apache-http by android.

the class DefaultHttpClient method createClientConnectionManager.

@Override
protected ClientConnectionManager createClientConnectionManager() {
    SchemeRegistry registry = new SchemeRegistry();
    registry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
    registry.register(new Scheme("https", SSLSocketFactory.getSocketFactory(), 443));
    ClientConnectionManager connManager = null;
    HttpParams params = getParams();
    ClientConnectionManagerFactory factory = null;
    // Try first getting the factory directly as an object.
    factory = (ClientConnectionManagerFactory) params.getParameter(ClientPNames.CONNECTION_MANAGER_FACTORY);
    if (factory == null) {
        // then try getting its class name.
        String className = (String) params.getParameter(ClientPNames.CONNECTION_MANAGER_FACTORY_CLASS_NAME);
        if (className != null) {
            try {
                Class<?> clazz = Class.forName(className);
                factory = (ClientConnectionManagerFactory) clazz.newInstance();
            } catch (ClassNotFoundException ex) {
                throw new IllegalStateException("Invalid class name: " + className);
            } catch (IllegalAccessException ex) {
                throw new IllegalAccessError(ex.getMessage());
            } catch (InstantiationException ex) {
                throw new InstantiationError(ex.getMessage());
            }
        }
    }
    if (factory != null) {
        connManager = factory.newInstance(params, registry);
    } else {
        connManager = new SingleClientConnManager(getParams(), registry);
    }
    return connManager;
}
Also used : Scheme(org.apache.http.conn.scheme.Scheme) ClientConnectionManager(org.apache.http.conn.ClientConnectionManager) BasicHttpParams(org.apache.http.params.BasicHttpParams) HttpParams(org.apache.http.params.HttpParams) ClientConnectionManagerFactory(org.apache.http.conn.ClientConnectionManagerFactory) SingleClientConnManager(org.apache.http.impl.conn.SingleClientConnManager) AuthSchemeRegistry(org.apache.http.auth.AuthSchemeRegistry) SchemeRegistry(org.apache.http.conn.scheme.SchemeRegistry)

Example 2 with SingleClientConnManager

use of org.apache.http.impl.conn.SingleClientConnManager in project oxAuth by GluuFederation.

the class BaseTest method createHttpClient.

public static DefaultHttpClient createHttpClient(HostnameVerifierType p_verifierType) {
    if (p_verifierType != null && p_verifierType != HostnameVerifierType.DEFAULT) {
        switch(p_verifierType) {
            case ALLOW_ALL:
                HostnameVerifier hostnameVerifier = org.apache.http.conn.ssl.SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER;
                DefaultHttpClient client = new DefaultHttpClient();
                SchemeRegistry registry = new SchemeRegistry();
                SSLSocketFactory socketFactory = SSLSocketFactory.getSocketFactory();
                socketFactory.setHostnameVerifier((X509HostnameVerifier) hostnameVerifier);
                registry.register(new Scheme("https", socketFactory, 443));
                SingleClientConnManager mgr = new SingleClientConnManager(client.getParams(), registry);
                // Set verifier
                HttpsURLConnection.setDefaultHostnameVerifier(hostnameVerifier);
                return new DefaultHttpClient(mgr, client.getParams());
            case DEFAULT:
                return new DefaultHttpClient();
        }
    }
    return new DefaultHttpClient();
}
Also used : Scheme(org.apache.http.conn.scheme.Scheme) SingleClientConnManager(org.apache.http.impl.conn.SingleClientConnManager) SchemeRegistry(org.apache.http.conn.scheme.SchemeRegistry) SSLSocketFactory(org.apache.http.conn.ssl.SSLSocketFactory) DefaultHttpClient(org.apache.http.impl.client.DefaultHttpClient) X509HostnameVerifier(org.apache.http.conn.ssl.X509HostnameVerifier) HostnameVerifier(javax.net.ssl.HostnameVerifier) AllowAllHostnameVerifier(org.apache.http.conn.ssl.AllowAllHostnameVerifier)

Example 3 with SingleClientConnManager

use of org.apache.http.impl.conn.SingleClientConnManager in project robovm by robovm.

the class DefaultHttpClient method createClientConnectionManager.

@Override
protected ClientConnectionManager createClientConnectionManager() {
    SchemeRegistry registry = new SchemeRegistry();
    registry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
    registry.register(new Scheme("https", SSLSocketFactory.getSocketFactory(), 443));
    ClientConnectionManager connManager = null;
    HttpParams params = getParams();
    ClientConnectionManagerFactory factory = null;
    // Try first getting the factory directly as an object.
    factory = (ClientConnectionManagerFactory) params.getParameter(ClientPNames.CONNECTION_MANAGER_FACTORY);
    if (factory == null) {
        // then try getting its class name.
        String className = (String) params.getParameter(ClientPNames.CONNECTION_MANAGER_FACTORY_CLASS_NAME);
        if (className != null) {
            try {
                Class<?> clazz = Class.forName(className);
                factory = (ClientConnectionManagerFactory) clazz.newInstance();
            } catch (ClassNotFoundException ex) {
                throw new IllegalStateException("Invalid class name: " + className);
            } catch (IllegalAccessException ex) {
                throw new IllegalAccessError(ex.getMessage());
            } catch (InstantiationException ex) {
                throw new InstantiationError(ex.getMessage());
            }
        }
    }
    if (factory != null) {
        connManager = factory.newInstance(params, registry);
    } else {
        connManager = new SingleClientConnManager(getParams(), registry);
    }
    return connManager;
}
Also used : Scheme(org.apache.http.conn.scheme.Scheme) ClientConnectionManager(org.apache.http.conn.ClientConnectionManager) BasicHttpParams(org.apache.http.params.BasicHttpParams) HttpParams(org.apache.http.params.HttpParams) ClientConnectionManagerFactory(org.apache.http.conn.ClientConnectionManagerFactory) SingleClientConnManager(org.apache.http.impl.conn.SingleClientConnManager) AuthSchemeRegistry(org.apache.http.auth.AuthSchemeRegistry) SchemeRegistry(org.apache.http.conn.scheme.SchemeRegistry)

Example 4 with SingleClientConnManager

use of org.apache.http.impl.conn.SingleClientConnManager in project XobotOS by xamarin.

the class DefaultHttpClient method createClientConnectionManager.

@Override
protected ClientConnectionManager createClientConnectionManager() {
    SchemeRegistry registry = new SchemeRegistry();
    registry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
    registry.register(new Scheme("https", SSLSocketFactory.getSocketFactory(), 443));
    ClientConnectionManager connManager = null;
    HttpParams params = getParams();
    ClientConnectionManagerFactory factory = null;
    // Try first getting the factory directly as an object.
    factory = (ClientConnectionManagerFactory) params.getParameter(ClientPNames.CONNECTION_MANAGER_FACTORY);
    if (factory == null) {
        // then try getting its class name.
        String className = (String) params.getParameter(ClientPNames.CONNECTION_MANAGER_FACTORY_CLASS_NAME);
        if (className != null) {
            try {
                Class<?> clazz = Class.forName(className);
                factory = (ClientConnectionManagerFactory) clazz.newInstance();
            } catch (ClassNotFoundException ex) {
                throw new IllegalStateException("Invalid class name: " + className);
            } catch (IllegalAccessException ex) {
                throw new IllegalAccessError(ex.getMessage());
            } catch (InstantiationException ex) {
                throw new InstantiationError(ex.getMessage());
            }
        }
    }
    if (factory != null) {
        connManager = factory.newInstance(params, registry);
    } else {
        connManager = new SingleClientConnManager(getParams(), registry);
    }
    return connManager;
}
Also used : Scheme(org.apache.http.conn.scheme.Scheme) ClientConnectionManager(org.apache.http.conn.ClientConnectionManager) BasicHttpParams(org.apache.http.params.BasicHttpParams) HttpParams(org.apache.http.params.HttpParams) ClientConnectionManagerFactory(org.apache.http.conn.ClientConnectionManagerFactory) SingleClientConnManager(org.apache.http.impl.conn.SingleClientConnManager) AuthSchemeRegistry(org.apache.http.auth.AuthSchemeRegistry) SchemeRegistry(org.apache.http.conn.scheme.SchemeRegistry)

Aggregations

Scheme (org.apache.http.conn.scheme.Scheme)4 SchemeRegistry (org.apache.http.conn.scheme.SchemeRegistry)4 SingleClientConnManager (org.apache.http.impl.conn.SingleClientConnManager)4 AuthSchemeRegistry (org.apache.http.auth.AuthSchemeRegistry)3 ClientConnectionManager (org.apache.http.conn.ClientConnectionManager)3 ClientConnectionManagerFactory (org.apache.http.conn.ClientConnectionManagerFactory)3 BasicHttpParams (org.apache.http.params.BasicHttpParams)3 HttpParams (org.apache.http.params.HttpParams)3 HostnameVerifier (javax.net.ssl.HostnameVerifier)1 AllowAllHostnameVerifier (org.apache.http.conn.ssl.AllowAllHostnameVerifier)1 SSLSocketFactory (org.apache.http.conn.ssl.SSLSocketFactory)1 X509HostnameVerifier (org.apache.http.conn.ssl.X509HostnameVerifier)1 DefaultHttpClient (org.apache.http.impl.client.DefaultHttpClient)1