本文整理汇总了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;未经允许,请勿转载。 |
请发表评论