use of org.apache.http.conn.scheme.SchemeRegistry in project product-apim by wso2.
the class PetstoreApiClient method createClient.
public static HttpClient createClient() {
HttpClient client = null;
try {
SSLContext sslContext = SSLContext.getInstance("SSL");
sslContext.init(null, new TrustManager[] { new X509TrustManager() {
public X509Certificate[] getAcceptedIssuers() {
return new X509Certificate[0];
}
public void checkClientTrusted(X509Certificate[] certs, String authType) {
}
public void checkServerTrusted(X509Certificate[] certs, String authType) {
}
} }, new SecureRandom());
SSLSocketFactory sf = new SSLSocketFactory(sslContext);
Scheme httpsScheme = new Scheme("https", 443, sf);
SchemeRegistry schemeRegistry = new SchemeRegistry();
schemeRegistry.register(httpsScheme);
BasicClientConnectionManager cm = new BasicClientConnectionManager(schemeRegistry);
client = new DefaultHttpClient(cm);
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
} catch (UnsupportedOperationException e) {
e.printStackTrace();
} catch (KeyManagementException e) {
e.printStackTrace();
}
return client;
}
use of org.apache.http.conn.scheme.SchemeRegistry in project oxCore by GluuFederation.
the class SslDefaultHttpClient method createClientConnectionManager.
@Override
protected ClientConnectionManager createClientConnectionManager() {
SchemeRegistry registry = new SchemeRegistry();
registry.register(new Scheme("http", 80, PlainSocketFactory.getSocketFactory()));
// Register for port 443 our SSLSocketFactory with our keystore to the
// ConnectionManager
registry.register(new Scheme("https", 443, newSslSocketFactory()));
return new PoolingClientConnectionManager(registry);
}
use of org.apache.http.conn.scheme.SchemeRegistry in project cdap by caskdata.
the class NettyRouterHttpsTest method getHTTPClient.
@Override
protected DefaultHttpClient getHTTPClient() throws Exception {
SSLContext sslContext = SSLContext.getInstance("TLS");
// set up a TrustManager that trusts everything
sslContext.init(null, InsecureTrustManagerFactory.INSTANCE.getTrustManagers(), new SecureRandom());
SSLSocketFactory sf = new SSLSocketFactory(sslContext, new AllowAllHostnameVerifier());
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.scheme.SchemeRegistry 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);
}
use of org.apache.http.conn.scheme.SchemeRegistry in project summer-mis by cn-cerc.
the class HttpClientConnectionManager method getSSLInstance.
// 获取SSL验证的HttpClient
public static HttpClient getSSLInstance(HttpClient httpClient) {
ClientConnectionManager ccm = httpClient.getConnectionManager();
SchemeRegistry sr = ccm.getSchemeRegistry();
sr.register(new Scheme("https", MySSLSocketFactory.getInstance(), 443));
httpClient = new DefaultHttpClient(ccm, httpClient.getParams());
return httpClient;
}
Aggregations