當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。