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


Java MySSLSocketFactory类代码示例

本文整理汇总了Java中com.loopj.android.http.MySSLSocketFactory的典型用法代码示例。如果您正苦于以下问题:Java MySSLSocketFactory类的具体用法?Java MySSLSocketFactory怎么用?Java MySSLSocketFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


MySSLSocketFactory类属于com.loopj.android.http包,在下文中一共展示了MySSLSocketFactory类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getUnsafeSyncHttpClient

import com.loopj.android.http.MySSLSocketFactory; //导入依赖的package包/类
@NonNull
private SyncHttpClient getUnsafeSyncHttpClient() throws KeyStoreException, IOException, NoSuchAlgorithmException, CertificateException, KeyManagementException, UnrecoverableKeyException {
    // We initialize a default Keystore
    KeyStore trustStore = KeyStore.getInstance(KeyStore.getDefaultType());
    // We load the KeyStore
    trustStore.load(null, null);
    // We initialize a new SSLSocketFactory
    MySSLSocketFactory socketFactory = new MySSLSocketFactory(trustStore);
    // We set that all host names are allowed in the socket factory
    socketFactory.setHostnameVerifier(MySSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
    // We initialize the Async Client
    SyncHttpClient client = new SyncHttpClient();
    // We set the timeout to 30 seconds
    client.setTimeout(TIMEOUT);
    // We set the SSL Factory
    client.setSSLSocketFactory(socketFactory);
    client.setEnableRedirects(true);
    client.setUserAgent("Mozilla/5.0 (Linux; Android 4.4; Nexus 5 Build/_BuildID_) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/30.0.0.0 Mobile Safari/537.36");
    return client;
}
 
开发者ID:hatak30,项目名称:Benefit_mvvm,代码行数:21,代码来源:Repository.java

示例2: getSchemeRegistry

import com.loopj.android.http.MySSLSocketFactory; //导入依赖的package包/类
public static SchemeRegistry getSchemeRegistry() {
    try {
        KeyStore trustStore = KeyStore.getInstance(KeyStore.getDefaultType());
        trustStore.load(null, null);
        SSLSocketFactory sf = new MySSLSocketFactory(trustStore);
        sf.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
        HttpParams params = new BasicHttpParams();
        HttpConnectionParams.setConnectionTimeout(params, 10000);
        HttpConnectionParams.setSoTimeout(params, 10000);
        HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
        HttpProtocolParams.setContentCharset(params, HTTP.UTF_8);
        SchemeRegistry registry = new SchemeRegistry();
        registry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
        registry.register(new Scheme("https", sf, 443));
        return registry;
    } catch (Exception e) {
        return null;
    }
}
 
开发者ID:Seeed-Studio,项目名称:Wio_Link_Android_App,代码行数:20,代码来源:OtherPlatformUtils.java

示例3: init

import com.loopj.android.http.MySSLSocketFactory; //导入依赖的package包/类
private void init() {
    asyncHttpClient = new SyncHttpClient();
    asyncHttpClient.setTimeout(60 * 1000);
    asyncHttpClient.setSSLSocketFactory(MySSLSocketFactory.getFixedSocketFactory());
    asyncHttpClient.setCookieStore(new BasicCookieStore());//new PersistentCookieStore(context);
    addHeader("Accept", "application/json;");
    addHeader("Connection", "keep-alive");
}
 
开发者ID:MrxMo,项目名称:MHttp,代码行数:9,代码来源:MHttpAsync.java


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