Search in sources :

Example 1 with PoolingClientConnectionManager

use of org.apache.http.impl.conn.PoolingClientConnectionManager in project tdi-studio-se by Talend.

the class RestClient method getConnectionManager.

private static PoolingClientConnectionManager getConnectionManager() {
    PoolingClientConnectionManager conMan = new PoolingClientConnectionManager(SchemeRegistryFactory.createDefault());
    conMan.setMaxTotal(200);
    conMan.setDefaultMaxPerRoute(200);
    return conMan;
}
Also used : PoolingClientConnectionManager(org.apache.http.impl.conn.PoolingClientConnectionManager)

Example 2 with PoolingClientConnectionManager

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

the class UmaMultithreadTest method before.

@BeforeClass
public void before() {
    ClientConnectionManager connectoinManager = new PoolingClientConnectionManager();
    final DefaultHttpClient defaultHttpClient = new DefaultHttpClient(connectoinManager);
    final ApacheHttpClient4Executor clientExecutor = new ApacheHttpClient4Executor(defaultHttpClient);
    String url = serverUri + "/oxauth/seam/resource/restv1/oxauth/uma-configuration";
    service = UmaClientFactory.instance().createMetaDataConfigurationService(url, clientExecutor);
}
Also used : PoolingClientConnectionManager(org.apache.http.impl.conn.PoolingClientConnectionManager) ApacheHttpClient4Executor(org.jboss.resteasy.client.core.executors.ApacheHttpClient4Executor) ClientConnectionManager(org.apache.http.conn.ClientConnectionManager) PoolingClientConnectionManager(org.apache.http.impl.conn.PoolingClientConnectionManager) DefaultHttpClient(org.apache.http.impl.client.DefaultHttpClient) BeforeClass(org.testng.annotations.BeforeClass)

Example 3 with PoolingClientConnectionManager

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

the class HttpService method getHttpsClientTrustAll.

public HttpClient getHttpsClientTrustAll() {
    try {
        SSLSocketFactory sf = new SSLSocketFactory(new TrustStrategy() {

            @Override
            public boolean isTrusted(X509Certificate[] chain, String authType) throws CertificateException {
                return true;
            }
        }, new AllowAllHostnameVerifier());
        PlainSocketFactory psf = PlainSocketFactory.getSocketFactory();
        SchemeRegistry registry = new SchemeRegistry();
        registry.register(new Scheme("http", 80, psf));
        registry.register(new Scheme("https", 443, sf));
        ClientConnectionManager ccm = new PoolingClientConnectionManager(registry);
        return new DefaultHttpClient(ccm);
    } catch (Exception ex) {
        log.error("Failed to create TrustAll https client", ex);
        return new DefaultHttpClient();
    }
}
Also used : TrustStrategy(org.apache.http.conn.ssl.TrustStrategy) PoolingClientConnectionManager(org.apache.http.impl.conn.PoolingClientConnectionManager) Scheme(org.apache.http.conn.scheme.Scheme) AllowAllHostnameVerifier(org.apache.http.conn.ssl.AllowAllHostnameVerifier) CertificateException(java.security.cert.CertificateException) PlainSocketFactory(org.apache.http.conn.scheme.PlainSocketFactory) PoolingClientConnectionManager(org.apache.http.impl.conn.PoolingClientConnectionManager) ClientConnectionManager(org.apache.http.conn.ClientConnectionManager) X509Certificate(java.security.cert.X509Certificate) DefaultHttpClient(org.apache.http.impl.client.DefaultHttpClient) SslDefaultHttpClient(org.xdi.net.SslDefaultHttpClient) ClientProtocolException(org.apache.http.client.ClientProtocolException) IOException(java.io.IOException) CertificateException(java.security.cert.CertificateException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) SchemeRegistry(org.apache.http.conn.scheme.SchemeRegistry) SSLSocketFactory(org.apache.http.conn.ssl.SSLSocketFactory)

Example 4 with PoolingClientConnectionManager

use of org.apache.http.impl.conn.PoolingClientConnectionManager in project coprhd-controller by CoprHD.

the class RenderProxy method createClientConnectionManager.

private static ClientConnectionManager createClientConnectionManager() {
    SchemeRegistry schemeRegistry = SchemeRegistryFactory.createDefault();
    SSLSocketFactory sf;
    if (StorageOsPlugin.isEnabled()) {
        try {
            // initialize an SSLContext with the vipr keystore and trustmanager.
            // This is basically a dup of most of the ViPRSSLSocketFactory constructor,
            // and could be extracted
            X509TrustManager[] trustManagers = { BourneUtil.getTrustManager() };
            KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
            kmf.init(BourneUtil.getKeyStore(), "".toCharArray());
            SSLContext context = SSLContext.getInstance("TLS");
            context.init(kmf.getKeyManagers(), trustManagers, new SecureRandom());
            sf = new SSLSocketFactory(context, SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
        } catch (Exception e) {
            throw new RuntimeException("Unable to initialize the ViPRX509TrustManager for RenderProxy", e);
        }
    } else {
        sf = new SSLSocketFactory(SSLUtil.getTrustAllContext(), SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
    }
    Scheme httpsScheme = new Scheme("https", 443, sf);
    schemeRegistry.register(httpsScheme);
    ClientConnectionManager connectionManager = new PoolingClientConnectionManager(schemeRegistry);
    return connectionManager;
}
Also used : PoolingClientConnectionManager(org.apache.http.impl.conn.PoolingClientConnectionManager) Scheme(org.apache.http.conn.scheme.Scheme) X509TrustManager(javax.net.ssl.X509TrustManager) SchemeRegistry(org.apache.http.conn.scheme.SchemeRegistry) SecureRandom(java.security.SecureRandom) SSLContext(javax.net.ssl.SSLContext) SSLSocketFactory(org.apache.http.conn.ssl.SSLSocketFactory) PoolingClientConnectionManager(org.apache.http.impl.conn.PoolingClientConnectionManager) ClientConnectionManager(org.apache.http.conn.ClientConnectionManager) IOException(java.io.IOException) UnexpectedException(play.exceptions.UnexpectedException) KeyManagerFactory(javax.net.ssl.KeyManagerFactory)

Example 5 with PoolingClientConnectionManager

use of org.apache.http.impl.conn.PoolingClientConnectionManager in project iaf by ibissource.

the class WebServiceNtlmSender method open.

public void open() {
    connectionManager = new PoolingClientConnectionManager();
    connectionManager.setMaxTotal(getMaxConnections());
}
Also used : PoolingClientConnectionManager(org.apache.http.impl.conn.PoolingClientConnectionManager)

Aggregations

PoolingClientConnectionManager (org.apache.http.impl.conn.PoolingClientConnectionManager)30 DefaultHttpClient (org.apache.http.impl.client.DefaultHttpClient)24 Scheme (org.apache.http.conn.scheme.Scheme)12 SchemeRegistry (org.apache.http.conn.scheme.SchemeRegistry)11 HttpResponse (org.apache.http.HttpResponse)10 HttpGet (org.apache.http.client.methods.HttpGet)10 Test (org.junit.Test)10 ClientConnectionManager (org.apache.http.conn.ClientConnectionManager)9 SSLSocketFactory (org.apache.http.conn.ssl.SSLSocketFactory)9 IOException (java.io.IOException)7 CertificateException (java.security.cert.CertificateException)5 UsernamePasswordCredentials (org.apache.http.auth.UsernamePasswordCredentials)5 TrustStrategy (org.apache.http.conn.ssl.TrustStrategy)5 X509Certificate (java.security.cert.X509Certificate)4 UnsupportedEncodingException (java.io.UnsupportedEncodingException)3 URI (java.net.URI)3 URISyntaxException (java.net.URISyntaxException)3 SSLContext (javax.net.ssl.SSLContext)3 HttpHost (org.apache.http.HttpHost)3 Credentials (org.apache.http.auth.Credentials)3