List of usage examples for org.apache.http.conn.ssl SSLSocketFactory getSocketFactory
public static SSLSocketFactory getSocketFactory() throws SSLInitializationException
cacerts
file in the security properties directory). From source file:org.apache.tuscany.sca.host.http.client.HttpClientFactory.java
public HttpClient createHttpClient() { HttpParams defaultParameters = new BasicHttpParams(); //defaultParameters.setIntParameter(HttpConnectionManagerParams.MAX_TOTAL_CONNECTIONS, 10); ConnManagerParams.setMaxTotalConnections(defaultParameters, 1024); ConnPerRoute connPerRoute = new ConnPerRouteBean(256); ConnManagerParams.setMaxConnectionsPerRoute(defaultParameters, connPerRoute); HttpProtocolParams.setContentCharset(defaultParameters, HTTP.UTF_8); HttpConnectionParams.setConnectionTimeout(defaultParameters, 60000); HttpConnectionParams.setSoTimeout(defaultParameters, 60000); SchemeRegistry supportedSchemes = new SchemeRegistry(); supportedSchemes/* w w w . j ava 2s . c om*/ .register(new Scheme(HttpHost.DEFAULT_SCHEME_NAME, PlainSocketFactory.getSocketFactory(), 80)); supportedSchemes.register(new Scheme("https", SSLSocketFactory.getSocketFactory(), 443)); ClientConnectionManager connectionManager = new ThreadSafeClientConnManager(defaultParameters, supportedSchemes); return new DefaultHttpClient(connectionManager, defaultParameters); }
From source file:com.google.appengine.tck.teamcity.ReportsFeature.java
public void start() { SchemeRegistry registry = new SchemeRegistry(); registry.register(new Scheme("http", 80, new PlainSocketFactory())); registry.register(new Scheme("https", 443, SSLSocketFactory.getSocketFactory())); ClientConnectionManager ccm = new PoolingClientConnectionManager(registry); client = new DefaultHttpClient(ccm); }
From source file:com.mnxfst.testing.handler.exec.client.PTestPlanExecutorClientCallable.java
/** * Initializes the plan executor/* w ww . j av a2 s.c o m*/ * @param hostname * @param port * @param uri * @param testplan */ public PTestPlanExecutorClientCallable(String hostname, int port, String uri, byte[] testplan) { this.httpHost = new HttpHost(hostname, port); this.postMethod = new HttpPost(uri); try { String encodedTestplan = new String(testplan, "UTF-8"); postMethod.setEntity(new StringEntity(PTestPlanExecutorClient.REQUEST_PARAMETER_TESTPLAN + "=" + URLEncoder.encode(encodedTestplan, "UTF-8"), "UTF-8")); } catch (UnsupportedEncodingException e) { throw new RuntimeException("Unsupported encoding exception. Error: " + e.getMessage()); } // TODO setting? SchemeRegistry schemeRegistry = new SchemeRegistry(); schemeRegistry.register(new Scheme("http", 80, PlainSocketFactory.getSocketFactory())); schemeRegistry.register(new Scheme("https", 443, SSLSocketFactory.getSocketFactory())); ThreadSafeClientConnManager threadSafeClientConnectionManager = new ThreadSafeClientConnManager( schemeRegistry); threadSafeClientConnectionManager.setMaxTotal(20); threadSafeClientConnectionManager.setDefaultMaxPerRoute(20); this.httpClient = new DefaultHttpClient(threadSafeClientConnectionManager); }
From source file:org.iglootools.hchelpers.core.DefaultHttpClientFactory.java
public static SchemeRegistry defaultSchemeRegistry() { SchemeRegistry schemeRegistry = new SchemeRegistry(); schemeRegistry.register(new Scheme("http", 80, PlainSocketFactory.getSocketFactory())); schemeRegistry.register(new Scheme("https", 443, SSLSocketFactory.getSocketFactory())); return schemeRegistry; }
From source file:io.coldstart.android.API.java
public API() { HttpParams params = new BasicHttpParams(); this.client = new DefaultHttpClient(); SchemeRegistry registry = new SchemeRegistry(); registry.register(new Scheme("https", SSLSocketFactory.getSocketFactory(), 443)); this.mgr = new ThreadSafeClientConnManager(params, registry); this.httpclient = new DefaultHttpClient(mgr, client.getParams()); //Timeout ---------------------------------- HttpParams httpParameters = new BasicHttpParams(); int timeoutConnection = 20000; HttpConnectionParams.setConnectionTimeout(httpParameters, timeoutConnection); int timeoutSocket = 30000; HttpConnectionParams.setSoTimeout(httpParameters, timeoutSocket); httpclient.setParams(httpParameters); //Timeout ---------------------------------- }
From source file:com.DGSD.DGUtils.Http.BetterHttp.java
public static void setupHttpClient() { BasicHttpParams httpParams = new BasicHttpParams(); ConnManagerParams.setTimeout(httpParams, socketTimeout); ConnManagerParams.setMaxConnectionsPerRoute(httpParams, new ConnPerRouteBean(maxConnections)); ConnManagerParams.setMaxTotalConnections(httpParams, DEFAULT_MAX_CONNECTIONS); HttpConnectionParams.setSoTimeout(httpParams, socketTimeout); HttpConnectionParams.setTcpNoDelay(httpParams, true); HttpProtocolParams.setVersion(httpParams, HttpVersion.HTTP_1_1); HttpProtocolParams.setUserAgent(httpParams, httpUserAgent); SchemeRegistry schemeRegistry = new SchemeRegistry(); schemeRegistry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80)); if (DiagnosticUtils.ANDROID_API_LEVEL >= 7) { schemeRegistry.register(new Scheme("https", SSLSocketFactory.getSocketFactory(), 443)); } else {/*from w ww. j a v a2s .c o m*/ // used to work around a bug in Android 1.6: // http://code.google.com/p/android/issues/detail?id=1946 // TODO: is there a less rigorous workaround for this? schemeRegistry.register(new Scheme("https", new EasySSLSocketFactory(), 443)); } ThreadSafeClientConnManager cm = new ThreadSafeClientConnManager(httpParams, schemeRegistry); httpClient = new DefaultHttpClient(cm, httpParams); }
From source file:com.leanengine.Configuration.java
public SocketFactory getSslFactory() { if (sslFactory == null) return SSLSocketFactory.getSocketFactory(); return sslFactory; }
From source file:spring.test.web.HttpComponentsHttpInvokerRequestExecutor.java
/** * Create a new instance of the HttpComponentsHttpInvokerRequestExecutor with a default * {@link HttpClient} that uses a default {@link org.apache.http.impl.conn.PoolingClientConnectionManager}. *///from www . ja v a 2 s. co m public HttpComponentsHttpInvokerRequestExecutor() { SchemeRegistry schemeRegistry = new SchemeRegistry(); schemeRegistry.register(new Scheme("http", 80, PlainSocketFactory.getSocketFactory())); schemeRegistry.register(new Scheme("https", 443, SSLSocketFactory.getSocketFactory())); PoolingClientConnectionManager connectionManager = new PoolingClientConnectionManager(schemeRegistry); connectionManager.setMaxTotal(DEFAULT_MAX_TOTAL_CONNECTIONS); connectionManager.setDefaultMaxPerRoute(DEFAULT_MAX_CONNECTIONS_PER_ROUTE); this.httpClient = new DefaultHttpClient(connectionManager); setReadTimeout(DEFAULT_READ_TIMEOUT_MILLISECONDS); }
From source file:uk.ac.ebi.intact.task.mitab.index.OntologyEnricherItemProcessor.java
private HttpClient createHttpClient() { SchemeRegistry schemeRegistry = new SchemeRegistry(); schemeRegistry.register(new Scheme("http", 80, PlainSocketFactory.getSocketFactory())); schemeRegistry.register(new Scheme("https", 443, SSLSocketFactory.getSocketFactory())); PoolingClientConnectionManager cm = new PoolingClientConnectionManager(schemeRegistry); cm.setMaxTotal(maxTotalConnections); cm.setDefaultMaxPerRoute(defaultMaxConnectionsPerHost); HttpClient httpClient = new DefaultHttpClient(cm); return httpClient; }
From source file:com.jrodeo.queue.messageset.provider.TestHttpClient5.java
public TestHttpClient5() { super();//from w w w . j a v a 2 s. com HttpParams params = new SyncBasicHttpParams(); params.setParameter(HttpProtocolParams.PROTOCOL_VERSION, HttpVersion.HTTP_1_1); params.setBooleanParameter(HttpProtocolParams.USE_EXPECT_CONTINUE, false); params.setBooleanParameter(HttpConnectionParams.STALE_CONNECTION_CHECK, false); params.setIntParameter(HttpConnectionParams.SOCKET_BUFFER_SIZE, 8 * 1024); params.setIntParameter(HttpConnectionParams.SO_TIMEOUT, 15000); SchemeRegistry schemeRegistry = new SchemeRegistry(); schemeRegistry.register(new Scheme("http", 80, PlainSocketFactory.getSocketFactory())); schemeRegistry.register(new Scheme("https", 443, SSLSocketFactory.getSocketFactory())); this.mgr = new PoolingClientConnectionManager(schemeRegistry); this.httpclient = new DefaultHttpClient(this.mgr, params); this.httpclient.setHttpRequestRetryHandler(new HttpRequestRetryHandler() { public boolean retryRequest(final IOException exception, int executionCount, final HttpContext context) { return false; } }); }