本文整理汇总了Java中org.apache.http.conn.ssl.SSLSocketFactory.getSocketFactory方法的典型用法代码示例。如果您正苦于以下问题:Java SSLSocketFactory.getSocketFactory方法的具体用法?Java SSLSocketFactory.getSocketFactory怎么用?Java SSLSocketFactory.getSocketFactory使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.http.conn.ssl.SSLSocketFactory
的用法示例。
在下文中一共展示了SSLSocketFactory.getSocketFactory方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getDefaultSchemeRegistry
import org.apache.http.conn.ssl.SSLSocketFactory; //导入方法依赖的package包/类
private static SchemeRegistry getDefaultSchemeRegistry(boolean fixNoHttpResponseException,
int httpPort, int httpsPort) {
SSLSocketFactory sslSocketFactory;
if (fixNoHttpResponseException) {
Log.d(LOG_TAG, "Beware! Using the fix is insecure, as it doesn't verify SSL " +
"certificates.");
}
if (httpPort < 1) {
httpPort = 80;
Log.d(LOG_TAG, "Invalid HTTP port number specified, defaulting to 80");
}
if (httpsPort < 1) {
httpsPort = WebSocket.DEFAULT_WSS_PORT;
Log.d(LOG_TAG, "Invalid HTTPS port number specified, defaulting to 443");
}
if (fixNoHttpResponseException) {
sslSocketFactory = MySSLSocketFactory.getFixedSocketFactory();
} else {
sslSocketFactory = SSLSocketFactory.getSocketFactory();
}
SchemeRegistry schemeRegistry = new SchemeRegistry();
schemeRegistry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(),
httpPort));
schemeRegistry.register(new Scheme(b.a, sslSocketFactory, httpsPort));
return schemeRegistry;
}
示例2: createThreadSafeClient
import org.apache.http.conn.ssl.SSLSocketFactory; //导入方法依赖的package包/类
private static void createThreadSafeClient(boolean forceSecure) {
httpClient = new DefaultHttpClient();
ClientConnectionManager mgr = httpClient.getConnectionManager();
HttpParams params = httpClient.getParams();
SchemeRegistry schemeRegistry = mgr.getSchemeRegistry();
if (forceSecure) {
schemeRegistry.register(new Scheme("https",
getSecureConnectionSetting(), 443));
} else {
HostnameVerifier hostnameVerifier = SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER;
SSLSocketFactory socketFactory = SSLSocketFactory
.getSocketFactory();
socketFactory
.setHostnameVerifier((X509HostnameVerifier) hostnameVerifier);
schemeRegistry.register(new Scheme("https", socketFactory, 443));
}
httpClient = new DefaultHttpClient(new ThreadSafeClientConnManager(params,
schemeRegistry), params);
}
示例3: setup
import org.apache.http.conn.ssl.SSLSocketFactory; //导入方法依赖的package包/类
/**
* Performs general setup.
* This should be called only once.
*/
private final static void setup() {
// Register the "http" and "https" protocol schemes, they are
// required by the default operator to look up socket factories.
supportedSchemes = new SchemeRegistry();
SocketFactory sf = PlainSocketFactory.getSocketFactory();
supportedSchemes.register(new Scheme("http", sf, 80));
sf = SSLSocketFactory.getSocketFactory();
supportedSchemes.register(new Scheme("https", sf, 80));
// Prepare parameters.
// Since this example doesn't use the full core framework,
// only few parameters are actually required.
HttpParams params = new BasicHttpParams();
HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
HttpProtocolParams.setUseExpectContinue(params, false);
defaultParameters = params;
}
示例4: CookieRestTemplate
import org.apache.http.conn.ssl.SSLSocketFactory; //导入方法依赖的package包/类
public CookieRestTemplate() {
httpContext = new BasicHttpContext();
cookieStore = new BasicCookieStore();
httpContext.setAttribute(ClientContext.COOKIE_STORE, cookieStore);
HttpParams params = new BasicHttpParams();
HttpClientParams.setRedirecting(params, false);
//REGISTERS SCHEMES FOR BOTH HTTP AND HTTPS
SchemeRegistry registry = new SchemeRegistry();
registry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
final SSLSocketFactory sslSocketFactory = SSLSocketFactory.getSocketFactory();
sslSocketFactory.setHostnameVerifier(SSLSocketFactory.BROWSER_COMPATIBLE_HOSTNAME_VERIFIER);
registry.register(new Scheme("https", sslSocketFactory, 443));
ClientConnectionManager conman = new ThreadSafeClientConnManager(params, registry);
httpClient = new DefaultHttpClient(conman, params);
HttpComponentsClientHttpRequestFactory hcchrf = new StatefulHttpComponentsClientHttpRequestFactory(httpClient, httpContext);
hcchrf.setConnectTimeout(30 * 1000);
setRequestFactory(hcchrf);
}
示例5: getFixedSocketFactory
import org.apache.http.conn.ssl.SSLSocketFactory; //导入方法依赖的package包/类
public static SSLSocketFactory getFixedSocketFactory() {
try {
SSLSocketFactory socketFactory = new MySSLSocketFactory(getKeystore());
socketFactory.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
return socketFactory;
} catch (Throwable t) {
t.printStackTrace();
return SSLSocketFactory.getSocketFactory();
}
}
示例6: a
import org.apache.http.conn.ssl.SSLSocketFactory; //导入方法依赖的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;
}
示例7: getFixedSocketFactory
import org.apache.http.conn.ssl.SSLSocketFactory; //导入方法依赖的package包/类
public static SSLSocketFactory getFixedSocketFactory() {
SSLSocketFactory socketFactory;
try {
socketFactory = new MySSLSocketFactory(getKeystore());
socketFactory.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
} catch (Throwable t) {
t.printStackTrace();
socketFactory = SSLSocketFactory.getSocketFactory();
}
return socketFactory;
}
示例8: getDefaultSchemeRegistry
import org.apache.http.conn.ssl.SSLSocketFactory; //导入方法依赖的package包/类
/**
* Returns default instance of SchemeRegistry
*
* @param fixNoHttpResponseException Whether to fix or not issue, by ommiting SSL verification
* @param httpPort HTTP port to be used, must be greater than 0
* @param httpsPort HTTPS port to be used, must be greater than 0
*/
private static SchemeRegistry getDefaultSchemeRegistry(
boolean fixNoHttpResponseException, int httpPort, int httpsPort) {
if (fixNoHttpResponseException) {
Log.d(LOG_TAG, "Beware! Using the fix is insecure, as it doesn't verify SSL certificates.");
}
if (httpPort < 1) {
httpPort = 80;
Log.d(LOG_TAG, "Invalid HTTP port number specified, defaulting to 80");
}
if (httpsPort < 1) {
httpsPort = 443;
Log.d(LOG_TAG, "Invalid HTTPS port number specified, defaulting to 443");
}
// Fix to SSL flaw in API < ICS
// See https://code.google.com/p/android/issues/detail?id=13117
SSLSocketFactory sslSocketFactory;
if (fixNoHttpResponseException)
sslSocketFactory = MySSLSocketFactory.getFixedSocketFactory();
else
sslSocketFactory = SSLSocketFactory.getSocketFactory();
SchemeRegistry schemeRegistry = new SchemeRegistry();
schemeRegistry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), httpPort));
schemeRegistry.register(new Scheme("https", sslSocketFactory, httpsPort));
return schemeRegistry;
}
示例9: getDefaultSchemeRegistry
import org.apache.http.conn.ssl.SSLSocketFactory; //导入方法依赖的package包/类
/**
* Returns default instance of SchemeRegistry
*
* @param fixNoHttpResponseException Whether to fix or not issue, by ommiting SSL verification
* @param httpPort HTTP port to be used, must be greater than 0
* @param httpsPort HTTPS port to be used, must be greater than 0
*/
private static SchemeRegistry getDefaultSchemeRegistry(boolean fixNoHttpResponseException, int httpPort, int httpsPort) {
if (fixNoHttpResponseException) {
Log.d(LOG_TAG, "Beware! Using the fix is insecure, as it doesn't verify SSL certificates.");
}
if (httpPort < 1) {
httpPort = 80;
Log.d(LOG_TAG, "Invalid HTTP port number specified, defaulting to 80");
}
if (httpsPort < 1) {
httpsPort = 443;
Log.d(LOG_TAG, "Invalid HTTPS port number specified, defaulting to 443");
}
// Fix to SSL flaw in API < ICS
// See https://code.google.com/p/android/issues/detail?id=13117
SSLSocketFactory sslSocketFactory;
if (fixNoHttpResponseException)
sslSocketFactory = MySSLSocketFactory.getFixedSocketFactory();
else
sslSocketFactory = SSLSocketFactory.getSocketFactory();
SchemeRegistry schemeRegistry = new SchemeRegistry();
schemeRegistry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), httpPort));
schemeRegistry.register(new Scheme("https", sslSocketFactory, httpsPort));
return schemeRegistry;
}
示例10: getFixedSocketFactory
import org.apache.http.conn.ssl.SSLSocketFactory; //导入方法依赖的package包/类
/**
* Returns a SSlSocketFactory which trusts all certificates
*
* @return SSLSocketFactory
*/
public static SSLSocketFactory getFixedSocketFactory() {
SSLSocketFactory socketFactory;
try {
socketFactory = new MySSLSocketFactory(getKeystore());
socketFactory.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
} catch (Throwable t) {
t.printStackTrace();
socketFactory = SSLSocketFactory.getSocketFactory();
}
return socketFactory;
}
示例11: getFixedSocketFactory
import org.apache.http.conn.ssl.SSLSocketFactory; //导入方法依赖的package包/类
/**
* Returns getUrl SSlSocketFactory which trusts all certificates
*
* @return SSLSocketFactory
*/
public static SSLSocketFactory getFixedSocketFactory() {
SSLSocketFactory socketFactory;
try {
socketFactory = new MySSLSocketFactory(getKeystore());
socketFactory.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
} catch (Throwable t) {
t.printStackTrace();
socketFactory = SSLSocketFactory.getSocketFactory();
}
return socketFactory;
}
示例12: getDefaultSchemeRegistry
import org.apache.http.conn.ssl.SSLSocketFactory; //导入方法依赖的package包/类
/**
* Returns default instance of SchemeRegistry
*
* @param fixNoHttpResponseException Whether to fix issue or not, by omitting SSL verification
* @param httpPort HTTP port to be used, must be greater than 0
* @param httpsPort HTTPS port to be used, must be greater than 0
*/
private static SchemeRegistry getDefaultSchemeRegistry(boolean fixNoHttpResponseException, int httpPort, int httpsPort) {
if (fixNoHttpResponseException) {
Log.d(LOG_TAG, "Beware! Using the fix is insecure, as it doesn't verify SSL certificates.");
}
if (httpPort < 1) {
httpPort = 80;
Log.d(LOG_TAG, "Invalid HTTP port number specified, defaulting to 80");
}
if (httpsPort < 1) {
httpsPort = 443;
Log.d(LOG_TAG, "Invalid HTTPS port number specified, defaulting to 443");
}
// Fix to SSL flaw in API < ICS
// See https://code.google.com/p/android/issues/detail?id=13117
SSLSocketFactory sslSocketFactory;
if (fixNoHttpResponseException) {
sslSocketFactory = MySSLSocketFactory.getFixedSocketFactory();
} else {
sslSocketFactory = SSLSocketFactory.getSocketFactory();
}
SchemeRegistry schemeRegistry = new SchemeRegistry();
schemeRegistry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), httpPort));
schemeRegistry.register(new Scheme("https", sslSocketFactory, httpsPort));
return schemeRegistry;
}
示例13: FlowzrSyncTask
import org.apache.http.conn.ssl.SSLSocketFactory; //导入方法依赖的package包/类
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);
}
示例14: createHttpsClient
import org.apache.http.conn.ssl.SSLSocketFactory; //导入方法依赖的package包/类
private static HttpClient createHttpsClient() {
HostnameVerifier hostnameVerifier = org.apache.http.conn.ssl.SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER;
SchemeRegistry registry = new SchemeRegistry();
SSLSocketFactory socketFactory = SSLSocketFactory.getSocketFactory();
socketFactory
.setHostnameVerifier((X509HostnameVerifier) hostnameVerifier);
registry.register(new Scheme("https", socketFactory, 443));
HttpClient client = new DefaultHttpClient();
SingleClientConnManager mgr = new SingleClientConnManager(
client.getParams(), registry);
DefaultHttpClient httpClient = new DefaultHttpClient(mgr,
client.getParams());
return httpClient;
}
示例15: getDefaultSchemeRegistry
import org.apache.http.conn.ssl.SSLSocketFactory; //导入方法依赖的package包/类
/**
* Returns default instance of SchemeRegistry
*
* @param fixNoHttpResponseException
* Whether to fix or not issue, by ommiting SSL verification
* @param httpPort
* HTTP port to be used, must be greater than 0
* @param httpsPort
* HTTPS port to be used, must be greater than 0
*/
private static SchemeRegistry getDefaultSchemeRegistry(
boolean fixNoHttpResponseException, int httpPort, int httpsPort) {
if (fixNoHttpResponseException) {
Log.d(LOG_TAG, "Beware! Using the fix is insecure, as it doesn't verify SSL certificates.");
}
if (httpPort < 1) {
httpPort = 80;
Log.d(LOG_TAG, "Invalid HTTP port number specified, defaulting to 80");
}
if (httpsPort < 1) {
httpsPort = 443;
Log.d(LOG_TAG, "Invalid HTTPS port number specified, defaulting to 443");
}
// Fix to SSL flaw in API < ICS
// See https://code.google.com/p/android/issues/detail?id=13117
SSLSocketFactory sslSocketFactory;
if (fixNoHttpResponseException)
sslSocketFactory = MySSLSocketFactory.getFixedSocketFactory();
else
sslSocketFactory = SSLSocketFactory.getSocketFactory();
SchemeRegistry schemeRegistry = new SchemeRegistry();
schemeRegistry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), httpPort));
schemeRegistry.register(new Scheme("https", sslSocketFactory, httpsPort));
return schemeRegistry;
}