当前位置: 首页>>代码示例>>Java>>正文


Java SSLSocketFactory.getSocketFactory方法代码示例

本文整理汇总了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;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:27,代码来源:AsyncHttpClient.java

示例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);
}
 
开发者ID:odoo-mobile-intern,项目名称:odoo-follow-up,代码行数:22,代码来源:OdooSafeClient.java

示例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;

}
 
开发者ID:mleoking,项目名称:PhET,代码行数:24,代码来源:ManagerConnectProxy.java

示例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);
}
 
开发者ID:murielK,项目名称:AndroidWPTemplate,代码行数:22,代码来源:CookieRestTemplate.java

示例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();
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:11,代码来源:MySSLSocketFactory.java

示例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;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:32,代码来源:b.java

示例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;
}
 
开发者ID:LanguidSheep,项目名称:sealtalk-android-master,代码行数:12,代码来源:MySSLSocketFactory.java

示例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;
}
 
开发者ID:LanguidSheep,项目名称:sealtalk-android-master,代码行数:38,代码来源:SyncHttpClient.java

示例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;
}
 
开发者ID:LanguidSheep,项目名称:sealtalk-android-master,代码行数:37,代码来源:AsyncHttpClient.java

示例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;
}
 
开发者ID:benniaobuguai,项目名称:android-project-gallery,代码行数:17,代码来源:MySSLSocketFactory.java

示例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;
}
 
开发者ID:yiwent,项目名称:Mobike,代码行数:17,代码来源:MySSLSocketFactory.java

示例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;
}
 
开发者ID:yiwent,项目名称:Mobike,代码行数:38,代码来源:AsyncHttpClient.java

示例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);
}
 
开发者ID:tiberiusteng,项目名称:financisto1-holo,代码行数:13,代码来源:FlowzrSyncTask.java

示例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;
}
 
开发者ID:zsavvas,项目名称:ReCRED_FIDO_UAF_OIDC,代码行数:15,代码来源:Curl.java

示例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;
}
 
开发者ID:13120241790,项目名称:RongChat,代码行数:41,代码来源:SyncHttpClient.java


注:本文中的org.apache.http.conn.ssl.SSLSocketFactory.getSocketFactory方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。