List of usage examples for org.apache.http.impl.conn.tsccm ThreadSafeClientConnManager ThreadSafeClientConnManager
@Deprecated public ThreadSafeClientConnManager(final HttpParams params, final SchemeRegistry schreg)
From source file:com.openmeap.util.SSLUtils.java
static public HttpClient getRelaxedSSLVerificationHttpClient() { try {/* w w w. j av a2 s . c om*/ KeyStore trustStore = KeyStore.getInstance(KeyStore.getDefaultType()); trustStore.load(null, null); SSLSocketFactory sf = new MySSLSocketFactory(trustStore); sf.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER); HttpParams params = new BasicHttpParams(); HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1); HttpProtocolParams.setContentCharset(params, FormConstants.CHAR_ENC_DEFAULT); SchemeRegistry registry = new SchemeRegistry(); registry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80)); registry.register(new Scheme("https", sf, 443)); ClientConnectionManager ccm = new ThreadSafeClientConnManager(params, registry); return new DefaultHttpClient(ccm, params); } catch (Exception e) { return new DefaultHttpClient(); } }
From source file:com.cttapp.bby.mytlc.layer8apps.ConnectionManager.java
/************ * PURPOSE: Creates a new instance of client * ARGUMENTS: null/*from w ww . ja va2 s.c om*/ * RETURNS: ConnectionManager * AUTHOR: Devin Collins <agent14709@gmail.com> *************/ private ConnectionManager() { try { SSLSocketFactory factory = new SimpleSSLSocketFactory(null); factory.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER); HttpParams params = new BasicHttpParams(); HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1); HttpProtocolParams.setContentCharset(params, HTTP.UTF_8); HttpProtocolParams.setUserAgent(params, "MyTLC-Sync"); SchemeRegistry registry = new SchemeRegistry(); registry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80)); registry.register(new Scheme("https", factory, 443)); ClientConnectionManager ccm = new ThreadSafeClientConnManager(params, registry); // Create a new connection for our client client = new DefaultHttpClient(ccm, params); } catch (Exception ex) { client = new DefaultHttpClient(); } }
From source file:com.todoroo.andlib.service.HttpRestClient.java
@SuppressWarnings("nls") public HttpRestClient() { DependencyInjectionService.getInstance().inject(this); SchemeRegistry schemeRegistry = new SchemeRegistry(); schemeRegistry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80)); schemeRegistry.register(new Scheme("https", SSLSocketFactory.getSocketFactory(), 443)); params = new BasicHttpParams(); HttpConnectionParams.setConnectionTimeout(params, timeout); HttpConnectionParams.setSoTimeout(params, timeout); params.setParameter(ConnManagerPNames.MAX_TOTAL_CONNECTIONS, 30); params.setParameter(ConnManagerPNames.MAX_CONNECTIONS_PER_ROUTE, new ConnPerRouteBean(30)); params.setParameter(HttpProtocolParams.USE_EXPECT_CONTINUE, false); HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1); cm = new ThreadSafeClientConnManager(params, schemeRegistry); }
From source file:com.flowzr.budget.holo.export.flowzr.FlowzrSyncTask.java
public FlowzrSyncTask(Context context) { this.context = context; BasicHttpParams params = new BasicHttpParams(); SchemeRegistry schemeRegistry = new SchemeRegistry(); schemeRegistry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80)); final SSLSocketFactory sslSocketFactory = SSLSocketFactory.getSocketFactory(); schemeRegistry.register(new Scheme("https", (SocketFactory) sslSocketFactory, 443)); ClientConnectionManager cm = new ThreadSafeClientConnManager(params, schemeRegistry); this.http_client = new DefaultHttpClient(cm, params); this.dba = new DatabaseAdapter(context); }
From source file:com.phonty.improved.Balance.java
public Balance(String url, Context _context) { context = _context;/*from w w w . j av a 2 s .com*/ APIURL = url; httppost = new HttpPost(APIURL); BasicHttpParams params = new BasicHttpParams(); SchemeRegistry schemeRegistry = new SchemeRegistry(); schemeRegistry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80)); final SSLSocketFactory sslSocketFactory = SSLSocketFactory.getSocketFactory(); schemeRegistry.register(new Scheme("https", sslSocketFactory, 4711)); ClientConnectionManager cm = new ThreadSafeClientConnManager(params, schemeRegistry); client = new PhontyHttpClient(cm, params, context); client.getParams().setParameter(CoreProtocolPNames.USER_AGENT, "Phonty-Android-Client"); }
From source file:com.phonty.improved.Calls.java
public Calls(String url, Context _context) { context = _context;/*from w ww .j a v a2s.c om*/ APIURL = url; httppost = new HttpPost(APIURL); httppost.addHeader("Content-Type", "application/json; charset=\"utf-8\""); BasicHttpParams params = new BasicHttpParams(); SchemeRegistry schemeRegistry = new SchemeRegistry(); schemeRegistry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80)); final SSLSocketFactory sslSocketFactory = SSLSocketFactory.getSocketFactory(); schemeRegistry.register(new Scheme("https", sslSocketFactory, 4711)); ClientConnectionManager cm = new ThreadSafeClientConnManager(params, schemeRegistry); client = new PhontyHttpClient(cm, params, context); client.getParams().setParameter(CoreProtocolPNames.USER_AGENT, "Phonty-Android-Client"); CookieStore cookieStore = new BasicCookieStore(); cookieStore.addCookie(Login.SESSION_COOKIE); client.setCookieStore(cookieStore); VALUES = new ArrayList<CallItem>(); type = "Calls:"; }
From source file:com.phonty.improved.Rates.java
public Rates(String url, Context _context) { context = _context;//from www . j av a2 s . c o m APIURL = url; httppost = new HttpPost(APIURL); httppost.addHeader("Content-Type", "application/json; charset=\"utf-8\""); BasicHttpParams params = new BasicHttpParams(); SchemeRegistry schemeRegistry = new SchemeRegistry(); schemeRegistry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80)); final SSLSocketFactory sslSocketFactory = SSLSocketFactory.getSocketFactory(); schemeRegistry.register(new Scheme("https", sslSocketFactory, 4711)); ClientConnectionManager cm = new ThreadSafeClientConnManager(params, schemeRegistry); client = new PhontyHttpClient(cm, params, context); client.getParams().setParameter(CoreProtocolPNames.USER_AGENT, "Phonty-Android-Client"); CookieStore cookieStore = new BasicCookieStore(); cookieStore.addCookie(Login.SESSION_COOKIE); client.setCookieStore(cookieStore); VALUES = new ArrayList<PriceItem>(); type = "Calls:"; }
From source file:org.wso2.emm.agent.proxy.clients.OAuthSSLClient.java
@Override public HttpClient getHttpClient() throws IDPTokenManagerException { HttpClient client = null;/*from www . j ava2 s. com*/ InputStream inStream = null; try { if (Constants.SERVER_PROTOCOL.equalsIgnoreCase("https://")) { KeyStore localTrustStore = KeyStore.getInstance("BKS"); inStream = IdentityProxy.getInstance().getContext().getResources().openRawResource(R.raw.trust); localTrustStore.load(inStream, Constants.TRUSTSTORE_PASSWORD.toCharArray()); SchemeRegistry schemeRegistry = new SchemeRegistry(); schemeRegistry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), Constants.HTTP)); SSLSocketFactory sslSocketFactory = new SSLSocketFactory(localTrustStore); sslSocketFactory.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER); schemeRegistry.register(new Scheme("https", sslSocketFactory, Constants.HTTPS)); HttpParams params = new BasicHttpParams(); ClientConnectionManager connectionManager = new ThreadSafeClientConnManager(params, schemeRegistry); client = new DefaultHttpClient(connectionManager, params); } else { client = new DefaultHttpClient(); } } catch (KeyStoreException e) { String errorMsg = "Error occurred while accessing keystore."; Log.e(TAG, errorMsg); throw new IDPTokenManagerException(errorMsg, e); } catch (CertificateException e) { String errorMsg = "Error occurred while loading certificate."; Log.e(TAG, errorMsg); throw new IDPTokenManagerException(errorMsg, e); } catch (NoSuchAlgorithmException e) { String errorMsg = "Error occurred while due to mismatch of defined algorithm."; Log.e(TAG, errorMsg); throw new IDPTokenManagerException(errorMsg, e); } catch (UnrecoverableKeyException e) { String errorMsg = "Error occurred while accessing keystore."; Log.e(TAG, errorMsg); throw new IDPTokenManagerException(errorMsg, e); } catch (KeyManagementException e) { String errorMsg = "Error occurred while accessing keystore."; Log.e(TAG, errorMsg); throw new IDPTokenManagerException(errorMsg, e); } catch (IOException e) { String errorMsg = "Error occurred while loading trust store. "; Log.e(TAG, errorMsg); throw new IDPTokenManagerException(errorMsg, e); } finally { StreamHandlerUtil.closeInputStream(inStream, TAG); } return client; }
From source file:org.silvertunnel_ng.demo.download_tool.HttpServiceImpl.java
/** * @see HttpService#initHttpClient()//from www . j ava 2s . c o m */ public void initHttpClient() { try { // prepare parameters HttpParams params = new BasicHttpParams(); HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1); HttpProtocolParams.setContentCharset(params, "UTF-8"); // create http client ClientConnectionManager ccm = new ThreadSafeClientConnManager(params, schemeRegistry); httpClient = new DefaultHttpClient(ccm, params); // user agent settings if (USER_AGENT != null) { HttpProtocolParams.setUserAgent(httpClient.getParams(), USER_AGENT); } } catch (Throwable t) { logger.log(Level.WARNING, "initHttpClient()", t); } }
From source file:edu.washington.iam.tools.IamConnectionManager.java
public IamConnectionManager(String caFile, String certFile, String keyFile) { log.debug("create connection manager"); caFilename = caFile;//from w w w . j a v a 2 s . com certFilename = certFile; keyFilename = keyFile; String protocol = "https"; int port = 443; initManagers(); try { SSLContext ctx = SSLContext.getInstance("TLS"); ctx.init(keyManagers, trustManagers, null); socketFactory = new SSLSocketFactory(ctx); Scheme scheme = new Scheme(protocol, socketFactory, port); schemeRegistry = new SchemeRegistry(); schemeRegistry.register(scheme); log.debug("create conn mgr"); connectionManager = new ThreadSafeClientConnManager(new BasicHttpParams(), schemeRegistry); } catch (Exception e) { log.error("sf error: " + e); } }