org.apache.http.conn.scheme.SocketFactory Java Examples
The following examples show how to use
org.apache.http.conn.scheme.SocketFactory.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HttpLoadTestClient.java From carbon-apimgt with Apache License 2.0 | 6 votes |
@Override public void run() { SchemeRegistry supportedSchemes = new SchemeRegistry(); SocketFactory sf = PlainSocketFactory.getSocketFactory(); supportedSchemes.register(new Scheme("http", sf, 80)); ThreadSafeClientConnManager connManager = new ThreadSafeClientConnManager(supportedSchemes); connManager.setDefaultMaxPerRoute(1000); DefaultHttpClient client = new DefaultHttpClient(connManager); HttpParams params = client.getParams(); HttpConnectionParams.setConnectionTimeout(params, 30000); HttpConnectionParams.setSoTimeout(params, 30000); client.setHttpRequestRetryHandler(new HttpRequestRetryHandler() { public boolean retryRequest(IOException e, int i, HttpContext httpContext) { return false; } }); //test API call long t1 = System.currentTimeMillis(); testEndpoint(client,apiEndpoint); long t2 = System.currentTimeMillis(); timeElapsedForAPICall = t2 - t1; }
Example #2
Source File: TrustAllSSLSocketFactory.java From GOpenSource_AppKit_Android_AS with MIT License | 5 votes |
public static SocketFactory getDefault() { if (instance == null) { try { instance = new TrustAllSSLSocketFactory(); } catch (Exception e) { e.printStackTrace(); } } return instance; }
Example #3
Source File: TrustAllSSLSocketFactory.java From Gizwits-SmartBuld_Android with MIT License | 5 votes |
public static SocketFactory getDefault() { if (instance == null) { try { instance = new TrustAllSSLSocketFactory(); } catch (Exception e) { e.printStackTrace(); } } return instance; }
Example #4
Source File: KakaduaUtil.java From Popeens-DSub with GNU General Public License v3.0 | 5 votes |
private static SocketFactory createSSLSocketFactory() { try { return new SSLSocketFactory(new TrustSelfSignedStrategy(), SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER); } catch (Throwable x) { Log.e("TAG", "Failed to create custom SSL socket factory, using default.", x); return org.apache.http.conn.ssl.SSLSocketFactory.getSocketFactory(); } }
Example #5
Source File: TrustAllSSLSocketFactory.java From gokit-android with MIT License | 5 votes |
public static SocketFactory getDefault() { if (instance == null) { try { instance = new TrustAllSSLSocketFactory(); } catch (Exception e) { e.printStackTrace(); } } return instance; }
Example #6
Source File: HttpClientFactory.java From Onosendai with Apache License 2.0 | 5 votes |
private static void addHttpsSchemaForTrustStore (final ClientConnectionManager connMan, final String tsPath, final char[] password) throws IOException, GeneralSecurityException { final KeyStore truststore = loadKeyStore(tsPath, password); final TrustManagerFactory tmfactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); tmfactory.init(truststore); final SocketFactory sf = new TlsSniSocketFactory(tmfactory.getTrustManagers()); final Scheme scheme = new Scheme("https", sf, 443); // NOSONAR 443 is not a magic number. Its HTTPS specification. connMan.getSchemeRegistry().register(scheme); }
Example #7
Source File: BuddycloudHTTPHelper.java From buddycloud-android with Apache License 2.0 | 5 votes |
public static HttpClient createHttpClient(Context context) { try { SchemeRegistry registry = new SchemeRegistry(); SocketFactory socketFactory = createSecureSocketFactory(); registry.register(new Scheme("http", PlainSocketFactory .getSocketFactory(), 80)); registry.register(new Scheme("https", socketFactory, 443)); HttpParams connManagerParams = new BasicHttpParams(); ConnManagerParams.setMaxTotalConnections(connManagerParams, 20); ConnManagerParams.setMaxConnectionsPerRoute(connManagerParams, new ConnPerRouteBean(20)); ClientConnectionManager ccm = new ThreadSafeClientConnManager( connManagerParams, registry); DefaultHttpClient client = new DefaultHttpClient(ccm, null); client.setHttpRequestRetryHandler(new DefaultHttpRequestRetryHandler( 0, true)); return client; } catch (Exception e) { throw new RuntimeException(e); } }
Example #8
Source File: HttpUtils.java From letv with Apache License 2.0 | 4 votes |
public static HttpClient getHttpClient(Context context, String str, String str2) { OpenConfig instance; int i; int i2 = 0; SchemeRegistry schemeRegistry = new SchemeRegistry(); schemeRegistry.register(new Scheme(IDataSource.SCHEME_HTTP_TAG, PlainSocketFactory.getSocketFactory(), 80)); if (VERSION.SDK_INT < 16) { try { KeyStore instance2 = KeyStore.getInstance(KeyStore.getDefaultType()); instance2.load(null, null); SocketFactory customSSLSocketFactory = new CustomSSLSocketFactory(instance2); customSSLSocketFactory.setHostnameVerifier(SSLSocketFactory.STRICT_HOSTNAME_VERIFIER); schemeRegistry.register(new Scheme(IDataSource.SCHEME_HTTPS_TAG, customSSLSocketFactory, 443)); } catch (Exception e) { schemeRegistry.register(new Scheme(IDataSource.SCHEME_HTTPS_TAG, SSLSocketFactory.getSocketFactory(), 443)); } } else { schemeRegistry.register(new Scheme(IDataSource.SCHEME_HTTPS_TAG, SSLSocketFactory.getSocketFactory(), 443)); } HttpParams basicHttpParams = new BasicHttpParams(); if (context != null) { instance = OpenConfig.getInstance(context, str); } else { instance = null; } if (instance != null) { i = instance.getInt("Common_HttpConnectionTimeout"); i2 = instance.getInt("Common_SocketConnectionTimeout"); } else { i = 0; } if (i == 0) { i = LetvConstant.WIDGET_UPDATE_UI_TIME; } if (i2 == 0) { i2 = 30000; } HttpConnectionParams.setConnectionTimeout(basicHttpParams, i); HttpConnectionParams.setSoTimeout(basicHttpParams, i2); HttpProtocolParams.setVersion(basicHttpParams, HttpVersion.HTTP_1_1); HttpProtocolParams.setContentCharset(basicHttpParams, "UTF-8"); HttpProtocolParams.setUserAgent(basicHttpParams, "AndroidSDK_" + VERSION.SDK + EventsFilesManager.ROLL_OVER_FILE_NAME_SEPARATOR + Build.DEVICE + EventsFilesManager.ROLL_OVER_FILE_NAME_SEPARATOR + VERSION.RELEASE); HttpClient defaultHttpClient = new DefaultHttpClient(new ThreadSafeClientConnManager(basicHttpParams, schemeRegistry), basicHttpParams); NetworkProxy proxy = getProxy(context); if (proxy != null) { defaultHttpClient.getParams().setParameter("http.route.default-proxy", new HttpHost(proxy.host, proxy.port)); } return defaultHttpClient; }
Example #9
Source File: RetrofitApacheClientBuilder.java From hello-pinnedcerts with MIT License | 4 votes |
public RetrofitApacheClientBuilder registerScheme(String name, SocketFactory factory, int port) { httpClientBuilder.registerScheme(name, factory, port); return this; }
Example #10
Source File: HttpClientBuilder.java From hello-pinnedcerts with MIT License | 4 votes |
public HttpClientBuilder registerScheme(String name, SocketFactory factory, int port) { schemeRegistry.register(new Scheme(name, factory, port)); return this; }
Example #11
Source File: HttpClientFactory.java From Onosendai with Apache License 2.0 | 4 votes |
private static void addHttpsSchema (final ClientConnectionManager connMan) { final SocketFactory sf = SSLSocketFactory.getSocketFactory(); final Scheme scheme = new Scheme("https", sf, 443); // NOSONAR 443 is not a magic number. Its HTTPS specification. connMan.getSchemeRegistry().register(scheme); }
Example #12
Source File: BuddycloudHTTPHelper.java From buddycloud-android with Apache License 2.0 | 4 votes |
protected static SocketFactory createSecureSocketFactory() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { return new TLSSNISocketFactory(); } return SSLSocketFactory.getSocketFactory(); }