use of org.apache.http.conn.ClientConnectionManager in project oxAuth by GluuFederation.
the class HttpService method getHttpsClientDefaulTrustStore.
@Deprecated
public HttpClient getHttpsClientDefaulTrustStore() {
try {
PlainSocketFactory psf = PlainSocketFactory.getSocketFactory();
SSLContext ctx = SSLContext.getInstance("TLS");
SSLSocketFactory ssf = new SSLSocketFactory(ctx, SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
SchemeRegistry registry = new SchemeRegistry();
registry.register(new Scheme("http", 80, psf));
registry.register(new Scheme("https", 443, ssf));
ClientConnectionManager ccm = new PoolingClientConnectionManager(registry);
return new DefaultHttpClient(ccm);
} catch (Exception ex) {
log.error("Failed to create https client", ex);
return new DefaultHttpClient();
}
}
use of org.apache.http.conn.ClientConnectionManager in project oxAuth by GluuFederation.
the class BaseTest method createHttpClientTrustAll.
public static HttpClient createHttpClientTrustAll() throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException, UnrecoverableKeyException {
SSLSocketFactory sf = new SSLSocketFactory(new TrustStrategy() {
@Override
public boolean isTrusted(X509Certificate[] chain, String authType) throws CertificateException {
return true;
}
}, new AllowAllHostnameVerifier());
SchemeRegistry registry = new SchemeRegistry();
registry.register(new Scheme("http", 80, PlainSocketFactory.getSocketFactory()));
registry.register(new Scheme("https", 443, sf));
ClientConnectionManager ccm = new PoolingClientConnectionManager(registry);
return new DefaultHttpClient(ccm);
}
use of org.apache.http.conn.ClientConnectionManager in project java-chassis by ServiceComb.
the class HttpsClient method getHttpsClient.
public static HttpClient getHttpsClient(HttpsConfigInfoBean configBean) {
try {
SSLContext sslContext = createSSLContext(configBean);
SSLSocketFactory sf = new SSLSocketFactory(sslContext);
sf.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
HttpParams params = new BasicHttpParams();
HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
HttpProtocolParams.setContentCharset(params, HTTP.UTF_8);
HttpConnectionParams.setConnectionTimeout(params, CONNECTION_TIMEOUT);
HttpConnectionParams.setSoTimeout(params, SO_TIMEOUT);
SchemeRegistry registry = new SchemeRegistry();
registry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), PORT_80));
registry.register(new Scheme("https", sf, PORT_443));
ClientConnectionManager ccm = new ThreadSafeClientConnManager(params, registry);
return new DefaultHttpClient(ccm, params);
} catch (RuntimeException e) {
LOGGER.error("Get https client runtime exception: {}", FortifyUtils.getErrorInfo(e));
return new DefaultHttpClient();
} catch (GeneralSecurityException | IOException e) {
LOGGER.error("Get https client exception: {}", FortifyUtils.getErrorInfo(e));
return new DefaultHttpClient();
}
}
use of org.apache.http.conn.ClientConnectionManager in project cdap by caskdata.
the class NettyRouterHttpsTest method getHTTPClient.
@Override
protected DefaultHttpClient getHTTPClient() throws Exception {
SSLContext sslContext = SSLContext.getInstance("SSL");
// set up a TrustManager that trusts everything
sslContext.init(null, new TrustManager[] { new X509TrustManager() {
@Override
public java.security.cert.X509Certificate[] getAcceptedIssuers() {
return null;
}
@Override
public void checkClientTrusted(java.security.cert.X509Certificate[] x509Certificates, String s) throws CertificateException {
//
}
@Override
public void checkServerTrusted(java.security.cert.X509Certificate[] x509Certificates, String s) throws CertificateException {
//
}
} }, new SecureRandom());
SSLSocketFactory sf = new SSLSocketFactory(sslContext);
Scheme httpsScheme = new Scheme("https", 10101, sf);
SchemeRegistry schemeRegistry = new SchemeRegistry();
schemeRegistry.register(httpsScheme);
// apache HttpClient version >4.2 should use BasicClientConnectionManager
ClientConnectionManager cm = new BasicClientConnectionManager(schemeRegistry);
return new DefaultHttpClient(cm);
}
use of org.apache.http.conn.ClientConnectionManager in project cdap by caskdata.
the class ExternalMTLSAuthenticationServerTestBase method getHTTPClient.
private HttpClient getHTTPClient(KeyManager[] kms, TrustManager[] tms) throws Exception {
SSLContext sslContext = SSLContext.getInstance("SSL");
sslContext.init(kms, tms, new SecureRandom());
// only for test purposes ignoring check of certificate hostname matching host on which server runs
SSLSocketFactory sf = new SSLSocketFactory(sslContext, SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
Scheme httpsScheme = new Scheme("https", getAuthServerPort(), sf);
SchemeRegistry schemeRegistry = new SchemeRegistry();
schemeRegistry.register(httpsScheme);
// Apache HttpClient version >4.2 should use BasicClientConnectionManager
ClientConnectionManager cm = new BasicClientConnectionManager(schemeRegistry);
return new DefaultHttpClient(cm);
}
Aggregations