本文整理汇总了Java中com.zhy.http.okhttp.https.HttpsUtils.SSLParams方法的典型用法代码示例。如果您正苦于以下问题:Java HttpsUtils.SSLParams方法的具体用法?Java HttpsUtils.SSLParams怎么用?Java HttpsUtils.SSLParams使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.zhy.http.okhttp.https.HttpsUtils
的用法示例。
在下文中一共展示了HttpsUtils.SSLParams方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例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();
}
示例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);
}
示例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);
}
示例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);
}
示例6: 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);
}