• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java HttpsUtils类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: initialize

import com.zhy.http.okhttp.https.HttpsUtils; //导入依赖的package包/类
private static void initialize(boolean isHttps, InputStream[] online, InputStream loc, String password) {
    OkHttpClient.Builder httpClientBuilder = new OkHttpClient.Builder();
    CookieJarImpl cookieJar = new CookieJarImpl(new PersistentCookieStore(context));
    HttpsUtils.SSLParams sslParams = null;
    if (isHttps) {
        sslParams = HttpsUtils.getSslSocketFactory(online, loc, password);
    }
    if (sslParams != null) {
        httpClientBuilder.sslSocketFactory(sslParams.sSLSocketFactory, sslParams.trustManager);
    }
    httpClientBuilder.connectTimeout(MAX_CONNECT_TIMEOUT, TimeUnit.MILLISECONDS)
            .readTimeout(MAX_READ_TIMEOUT, TimeUnit.MILLISECONDS);
    OkHttpUtils.initClient(httpClientBuilder.build());
    isInitialized = true;
    LogUtil.e("OkHttpClient初始化:支持Https = " + isHttps);
}
 
开发者ID:wzc25151,项目名称:lrs_android,代码行数:17,代码来源:HttpManager.java


示例2: getClient

import com.zhy.http.okhttp.https.HttpsUtils; //导入依赖的package包/类
private OkHttpClient getClient() {
    HttpsUtils.SSLParams sslParams = HttpsUtils.getSslSocketFactory(null, null, null);
    return new OkHttpClient.Builder()
            .readTimeout(TIME_OUT, TimeUnit.MILLISECONDS)
            .connectTimeout(TIME_OUT, TimeUnit.MILLISECONDS)
            .addInterceptor(new ReceiveCookieInterceptor())
            .addInterceptor(new AddCookieInterceptor())
            .sslSocketFactory(sslParams.sSLSocketFactory, sslParams.trustManager)
            .build();
}
 
开发者ID:Akari10032,项目名称:12306_Android,代码行数:11,代码来源:RetrofitManager.java


示例3: onCreate

import com.zhy.http.okhttp.https.HttpsUtils; //导入依赖的package包/类
@Override
    public void onCreate()
    {
        super.onCreate();

        ClearableCookieJar cookieJar1 = new PersistentCookieJar(new SetCookieCache(), new SharedPrefsCookiePersistor(getApplicationContext()));

        HttpsUtils.SSLParams sslParams = HttpsUtils.getSslSocketFactory(null, null, null);

//        CookieJarImpl cookieJar1 = new CookieJarImpl(new MemoryCookieStore());
        OkHttpClient okHttpClient = new OkHttpClient.Builder()
                .connectTimeout(10000L, TimeUnit.MILLISECONDS)
                .readTimeout(10000L, TimeUnit.MILLISECONDS)
                .addInterceptor(new LoggerInterceptor("TAG"))
                .cookieJar(cookieJar1)
                .hostnameVerifier(new HostnameVerifier()
                {
                    @Override
                    public boolean verify(String hostname, SSLSession session)
                    {
                        return true;
                    }
                })
                .sslSocketFactory(sslParams.sSLSocketFactory, sslParams.trustManager)
                .build();
        OkHttpUtils.initClient(okHttpClient);

    }
 
开发者ID:laotanggit,项目名称:okhttputils-masterlaotang,代码行数:29,代码来源:MyApplication.java


示例4: onCreate

import com.zhy.http.okhttp.https.HttpsUtils; //导入依赖的package包/类
@Override
    public void onCreate() {
        super.onCreate();
        INSTANCE = this;
        final Context mContext = this;
        DBUtils.getInstance().initDB(getApplicationContext());
        Stetho.initialize(Stetho.newInitializerBuilder(mContext)
                .enableDumpapp(new DumperPluginsProvider() {
                    @Override
                    public Iterable<DumperPlugin> get() {
                        return new Stetho.DefaultDumperPluginsBuilder(mContext)
                                .provide(new HprofDumperPlugin(mContext))
                                .finish();
                    }
                })
                .enableWebKitInspector(Stetho.defaultInspectorModulesProvider(mContext))
                .build());
        Stetho.initializeWithDefaults(mContext);




        HttpsUtils.SSLParams sslParams = HttpsUtils.getSslSocketFactory(null, null, null);
        OkHttpClient okHttpClient = new OkHttpClient.Builder()
//                .addInterceptor(new LoggerInterceptor("TAG"))
                .connectTimeout(10000L, TimeUnit.MILLISECONDS)
                .sslSocketFactory(sslParams.sSLSocketFactory, sslParams.trustManager)
                .readTimeout(10000L, TimeUnit.MILLISECONDS)
                //其他配置
                .build();

        OkHttpUtils.initClient(okHttpClient);
    }
 
开发者ID:ZhuoKeTeam,项目名称:AndroidJsoup,代码行数:34,代码来源:IApplication.java


示例5: initOkHttpUtils

import com.zhy.http.okhttp.https.HttpsUtils; //导入依赖的package包/类
/**
 * 初始化网络请求
 */
private void initOkHttpUtils() {
    // Cookie
    CookieJarImpl cookieJar = new CookieJarImpl(new PersistentCookieStore(getApplicationContext()));
    // Https
    HttpsUtils.SSLParams sslParams = HttpsUtils.getSslSocketFactory(null, null, null);

    OkHttpClient okHttpClient = new OkHttpClient.Builder()
            .connectTimeout(10000L, TimeUnit.MILLISECONDS)
            .readTimeout(10000L, TimeUnit.MILLISECONDS)
            .sslSocketFactory(sslParams.sSLSocketFactory, sslParams.trustManager)
            .cookieJar(cookieJar)
            //其他配置
            .build();
    OkHttpUtils.initClient(okHttpClient);
    /**
     *  网络配置
     */
    NetWorkConfiguration configuration=new NetWorkConfiguration(this)
                                                        .baseUrl(NetWorkApi.baseUrl)
                                                        .isCache(true)
                                                        .isDiskCache(true)
                                                        .isMemoryCache(false);
    HttpUtils.setConFiguration(configuration);


}
 
开发者ID:ZhuoKeTeam,项目名称:MasterHelper,代码行数:30,代码来源:ZhuoKeApplication.java


示例6: setCertificates

import com.zhy.http.okhttp.https.HttpsUtils; //导入依赖的package包/类
/**
 * for https-way authentication
 *
 * @param certificates
 */
public void setCertificates(InputStream... certificates)
{
    SSLSocketFactory sslSocketFactory = HttpsUtils.getSslSocketFactory(certificates, null, null);

    OkHttpClient.Builder builder = getOkHttpClient().newBuilder();
    builder = builder.sslSocketFactory(sslSocketFactory);
    mOkHttpClient = builder.build();


}
 
开发者ID:cowthan,项目名称:AyoSunny,代码行数:16,代码来源:OkHttpUtils.java


示例7: inti

import com.zhy.http.okhttp.https.HttpsUtils; //导入依赖的package包/类
public void inti(){

		//设置Thread Exception Handler
		//Thread.setDefaultUncaughtExceptionHandler(this);

		//初始化全局上下文
		context = getApplicationContext();


		//初始化请求管理器
		//RequestManager.init(this);

		//初始化OkHttp
		HttpsUtils.SSLParams sslParams = HttpsUtils.getSslSocketFactory(null, null, null);

		OkHttpClient okHttpClient = new OkHttpClient.Builder()
				.connectTimeout(10000L, TimeUnit.MILLISECONDS)
				.readTimeout(10000L, TimeUnit.MILLISECONDS)
				.addInterceptor(new LoggerInterceptor("TAG"))
				//.cookieJar(cookieJar1)
				.hostnameVerifier(new HostnameVerifier()
				{
					@Override
					public boolean verify(String hostname, SSLSession session)
					{
						return true;
					}
				})
				.sslSocketFactory(sslParams.sSLSocketFactory, sslParams.trustManager)
				.build();
		OkHttpUtils.initClient(okHttpClient);

		Log.v("initEnvir","OkHttp初始化成功");

		//初始化ShareSDK
		ShareSDK.initSDK(this);
		Log.v("initEnvir","ShareSDK初始化成功");


		//初始化GreenDao
		GreenDaoManager.getInstance();
		Log.v("initEnvir","GreenDao初始化成功");

		// 初始化环信SDK
		initEasemob();
		Log.v("initEnvir","环信SDK初始化成功");

		//初始化sharesdk
		ShareSDK.initSDK(this);

		UiModeManager mUiModeManager = (UiModeManager) this.getSystemService(Context.UI_MODE_SERVICE);
		mUiModeManager.setNightMode(UiModeManager.MODE_NIGHT_NO);
        SPutils.put(MyApplication.getContext(),"NigthMode",false);
	}
 
开发者ID:starmelon,项目名称:lovelife,代码行数:55,代码来源:MyApplication.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ThemeUtil类代码示例发布时间:2022-05-22
下一篇:
Java RelOptTable类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap