本文整理汇总了Java中org.apache.http.conn.scheme.SocketFactory.setHostnameVerifier方法的典型用法代码示例。如果您正苦于以下问题:Java SocketFactory.setHostnameVerifier方法的具体用法?Java SocketFactory.setHostnameVerifier怎么用?Java SocketFactory.setHostnameVerifier使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.http.conn.scheme.SocketFactory
的用法示例。
在下文中一共展示了SocketFactory.setHostnameVerifier方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getSSLHttpClient
import org.apache.http.conn.scheme.SocketFactory; //导入方法依赖的package包/类
private HttpClient getSSLHttpClient() throws Throwable {
KeyStore instance = KeyStore.getInstance(KeyStore.getDefaultType());
instance.load(null, null);
SocketFactory sSLSocketFactoryEx = new SSLSocketFactoryEx(instance);
sSLSocketFactoryEx.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
HttpParams basicHttpParams = new BasicHttpParams();
HttpProtocolParams.setVersion(basicHttpParams, HttpVersion.HTTP_1_1);
HttpProtocolParams.setContentCharset(basicHttpParams, "UTF-8");
SchemeRegistry schemeRegistry = new SchemeRegistry();
schemeRegistry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
schemeRegistry.register(new Scheme(b.a, sSLSocketFactoryEx, WebSocket.DEFAULT_WSS_PORT));
return new DefaultHttpClient(new ThreadSafeClientConnManager(basicHttpParams,
schemeRegistry), basicHttpParams);
}
示例2: a
import org.apache.http.conn.scheme.SocketFactory; //导入方法依赖的package包/类
public static b a() {
if (b == null) {
HttpParams basicHttpParams = new BasicHttpParams();
HttpProtocolParams.setVersion(basicHttpParams, HttpVersion.HTTP_1_1);
HttpConnectionParams.setStaleCheckingEnabled(basicHttpParams, true);
basicHttpParams.setBooleanParameter("http.protocol.expect-continue", false);
ConnManagerParams.setMaxTotalConnections(basicHttpParams, 50);
ConnManagerParams.setMaxConnectionsPerRoute(basicHttpParams, new ConnPerRouteBean(30));
ConnManagerParams.setTimeout(basicHttpParams, 1000);
HttpConnectionParams.setConnectionTimeout(basicHttpParams, 20000);
HttpConnectionParams.setSoTimeout(basicHttpParams, 30000);
HttpConnectionParams.setSocketBufferSize(basicHttpParams, 16384);
HttpProtocolParams.setUseExpectContinue(basicHttpParams, false);
HttpClientParams.setRedirecting(basicHttpParams, true);
HttpClientParams.setAuthenticating(basicHttpParams, false);
HttpProtocolParams.setUserAgent(basicHttpParams, a);
try {
SocketFactory socketFactory = SSLSocketFactory.getSocketFactory();
socketFactory.setHostnameVerifier(SSLSocketFactory.STRICT_HOSTNAME_VERIFIER);
Scheme scheme = new Scheme(com.alipay.sdk.cons.b.a, socketFactory, WebSocket.DEFAULT_WSS_PORT);
Scheme scheme2 = new Scheme("http", PlainSocketFactory.getSocketFactory(), 80);
SchemeRegistry schemeRegistry = new SchemeRegistry();
schemeRegistry.register(scheme);
schemeRegistry.register(scheme2);
b = new b(new ThreadSafeClientConnManager(basicHttpParams, schemeRegistry), basicHttpParams);
} catch (Exception e) {
b = new b(basicHttpParams);
}
}
return b;
}
示例3: getHttpClient
import org.apache.http.conn.scheme.SocketFactory; //导入方法依赖的package包/类
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;
}
示例4: getHttpClient
import org.apache.http.conn.scheme.SocketFactory; //导入方法依赖的package包/类
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("http", 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(b.a, customSSLSocketFactory, WebSocket
.DEFAULT_WSS_PORT));
} catch (Exception e) {
schemeRegistry.register(new Scheme(b.a, SSLSocketFactory.getSocketFactory(),
WebSocket.DEFAULT_WSS_PORT));
}
} else {
schemeRegistry.register(new Scheme(b.a, SSLSocketFactory.getSocketFactory(),
WebSocket.DEFAULT_WSS_PORT));
}
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 = 15000;
}
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 + "_" +
Build.DEVICE + "_" + 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;
}