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.envirocar.app.network.HTTPClient.java
/** * setup a client instance with SSL/HTTPS capabilities. * /*from w w w. j a v a2s . c om*/ * @param client the client to set up */ public static void setupClient(HttpClient client) { SSLSocketFactory factory = SSLSocketFactory.getSocketFactory(); factory.setHostnameVerifier(SSLSocketFactory.STRICT_HOSTNAME_VERIFIER); client.getConnectionManager().getSchemeRegistry().register(new Scheme("https", factory, 443)); }
From source file:com.vk.sdk.api.httpClient.VKHttpClient.java
/** * Creates the http client (if need). Returns reusing client * * @return Prepared client used for API requests loading */// w ww .ja v a 2 s . com public static VKHttpClient getClient() { if (sInstance == null) { SchemeRegistry schemeRegistry = new SchemeRegistry(); schemeRegistry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80)); schemeRegistry.register(new Scheme("https", SSLSocketFactory.getSocketFactory(), 443)); HttpParams params = new BasicHttpParams(); Context ctx = VKUIHelper.getApplicationContext(); try { if (ctx != null) { PackageManager packageManager = ctx.getPackageManager(); if (packageManager != null) { PackageInfo info = packageManager.getPackageInfo(ctx.getPackageName(), 0); params.setParameter(CoreProtocolPNames.USER_AGENT, String.format(Locale.US, "%s/%s (%s; Android %d; Scale/%.2f; VK SDK %s; %s)", VKUtil.getApplicationName(ctx), info.versionName, Build.MODEL, Build.VERSION.SDK_INT, ctx.getResources().getDisplayMetrics().density, VKSdkVersion.SDK_VERSION, info.packageName)); } } } catch (Exception ignored) { } sInstance = new VKHttpClient(new ThreadSafeClientConnManager(params, schemeRegistry), params); } return sInstance; }
From source file:com.phonty.improved.Register.java
public Register(String url, Context _context) { context = _context;/*from w w w.ja v 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, 443)); ClientConnectionManager cm = new ThreadSafeClientConnManager(params, schemeRegistry); client = new PhontyHttpClient(cm, params, context); client.getParams().setParameter(CoreProtocolPNames.USER_AGENT, "Phonty-Android-Client"); }
From source file:org.spiffyui.server.AuthServlet.java
private static void setHostnameVerifier() { SSLSocketFactory.getSocketFactory().setHostnameVerifier(new HostVerifier()); }
From source file:com.phonty.improved.DirectionCost.java
public DirectionCost(String url, Context _context) { context = _context;/*from w w w. ja v a2s . co m*/ 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); CookieStore cookieStore = new BasicCookieStore(); cookieStore.addCookie(Login.SESSION_COOKIE); client.setCookieStore(cookieStore); APIURL = url; httppost = new HttpPost(APIURL); }
From source file:fedroot.dacs.http.DacsClientContext.java
public DacsClientContext(HttpParams httpParams) { SchemeRegistry schemeRegistry = new SchemeRegistry(); schemeRegistry.register(new Scheme("http", 80, PlainSocketFactory.getSocketFactory())); schemeRegistry.register(new Scheme("https", 443, SSLSocketFactory.getSocketFactory())); ClientConnectionManager cm = new ThreadSafeClientConnManager(schemeRegistry); if (httpParams.getParameter(ClientPNames.COOKIE_POLICY) == null) { httpParams.setParameter(ClientPNames.COOKIE_POLICY, CookiePolicy.BROWSER_COMPATIBILITY); }//from w ww . j a v a 2 s. c o m httpClient = new DefaultHttpClient(cm, httpParams); cookieStore = new BasicCookieStore(); httpContext = new BasicHttpContext(); // Bind custom cookie store to the local context httpContext.setAttribute(ClientContext.COOKIE_STORE, cookieStore); }
From source file:com.vk.sdkweb.api.httpClient.VKHttpClient.java
/** * Creates the http client (if need). Returns reusing client * * @return Prepared client used for API requests loading *//*www .j a va 2 s .c o m*/ public static VKHttpClient getClient() { if (sInstance == null) { SchemeRegistry schemeRegistry = new SchemeRegistry(); schemeRegistry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80)); schemeRegistry.register(new Scheme("https", SSLSocketFactory.getSocketFactory(), 443)); HttpParams params = new BasicHttpParams(); Context ctx = VKUIHelper.getTopActivity(); try { if (ctx != null) { PackageManager packageManager = ctx.getPackageManager(); if (packageManager != null) { PackageInfo info = packageManager.getPackageInfo(ctx.getPackageName(), 0); params.setParameter(CoreProtocolPNames.USER_AGENT, String.format(Locale.US, "%s/%s (%s; Android %d; Scale/%.2f; VK SDK %s; %s)", VKUtil.getApplicationName(ctx), info.versionName, Build.MODEL, Build.VERSION.SDK_INT, ctx.getResources().getDisplayMetrics().density, VKSdkVersion.SDK_VERSION, info.packageName)); } } } catch (Exception ignored) { } sInstance = new VKHttpClient(new ThreadSafeClientConnManager(params, schemeRegistry), params); } return sInstance; }
From source file:org.dthume.spring.http.client.httpcomponents.HttpComponentsClientRequestFactory.java
private static Scheme createHttpsScheme() { return new Scheme("https", 443, SSLSocketFactory.getSocketFactory()); }
From source file:com.makotosan.vimeodroid.ApplicationEx.java
private HttpClient createHttpClient() { // Log.d(TAG, "createHttpClient()..."); HttpParams params = new BasicHttpParams(); HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1); HttpProtocolParams.setContentCharset(params, HTTP.DEFAULT_CONTENT_CHARSET); HttpProtocolParams.setUseExpectContinue(params, true); HttpProtocolParams.setUserAgent(params, "Vimeo Droid"); SchemeRegistry schReg = new SchemeRegistry(); schReg.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80)); schReg.register(new Scheme("https", SSLSocketFactory.getSocketFactory(), 443)); ClientConnectionManager conMgr = new ThreadSafeClientConnManager(params, schReg); return new DefaultHttpClient(conMgr, params); }