本文整理汇总了Java中com.squareup.okhttp.CertificatePinner类的典型用法代码示例。如果您正苦于以下问题:Java CertificatePinner类的具体用法?Java CertificatePinner怎么用?Java CertificatePinner使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CertificatePinner类属于com.squareup.okhttp包,在下文中一共展示了CertificatePinner类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: bindOkHttpClient
import com.squareup.okhttp.CertificatePinner; //导入依赖的package包/类
private void bindOkHttpClient() {
mOkHttpClient.setSslSocketFactory(mSSLSocketFactory);
mOkHttpClient.setHostnameVerifier(mHostnameVerifier);
mOkHttpClient.setProxy(mProxy);
mOkHttpClient.setConnectTimeout(mConnectTimeout, TimeUnit.MILLISECONDS);
mOkHttpClient.setReadTimeout(mReadTimeout, TimeUnit.MILLISECONDS);
mOkHttpClient.setWriteTimeout(mWriteTimeout, TimeUnit.MILLISECONDS);
if (!mPinners.isEmpty()) {
Set<Map.Entry<String, String>> sets = mPinners.entrySet();
CertificatePinner.Builder cBuilder = new CertificatePinner.Builder();
for (Map.Entry<String, String> entry : sets) {
cBuilder.add(entry.getKey(), entry.getValue());
}
mOkHttpClient.setCertificatePinner(cBuilder.build());
}
}
示例2: bindOkHttpClient
import com.squareup.okhttp.CertificatePinner; //导入依赖的package包/类
private void bindOkHttpClient() {
mRequestEngine.okHttpClient.setSslSocketFactory(mSSLSocketFactory);
mRequestEngine.okHttpClient.setHostnameVerifier(mHostnameVerifier);
mRequestEngine.okHttpClient.setProxy(mProxy);
mRequestEngine.okHttpClient.setConnectTimeout(mConnectTimeout, TimeUnit.MILLISECONDS);
mRequestEngine.okHttpClient.setReadTimeout(mReadTimeout, TimeUnit.MILLISECONDS);
mRequestEngine.okHttpClient.setWriteTimeout(mWriteTimeout, TimeUnit.MILLISECONDS);
if (!mPinners.isEmpty()) {
Set<Map.Entry<String, String>> sets = mPinners.entrySet();
CertificatePinner.Builder cBuilder = new CertificatePinner.Builder();
for (Map.Entry<String, String> entry : sets) {
cBuilder.add(entry.getKey(), entry.getValue());
}
mRequestEngine.okHttpClient.setCertificatePinner(cBuilder.build());
}
}
示例3: createHttpClient
import com.squareup.okhttp.CertificatePinner; //导入依赖的package包/类
/**
* @return a new http client
*/
private OkHttpClient createHttpClient() {
OkHttpClient client = new OkHttpClient();
client.setReadTimeout(connectorOptions.getReadTimeout(), TimeUnit.SECONDS);
client.setWriteTimeout(connectorOptions.getWriteTimeout(), TimeUnit.SECONDS);
client.setConnectTimeout(connectorOptions.getConnectTimeout(), TimeUnit.SECONDS);
client.setFollowRedirects(connectorOptions.isFollowRedirects());
client.setFollowSslRedirects(connectorOptions.isFollowRedirects());
client.setProxySelector(ProxySelector.getDefault());
client.setCookieHandler(CookieHandler.getDefault());
client.setCertificatePinner(CertificatePinner.DEFAULT);
client.setAuthenticator(AuthenticatorAdapter.INSTANCE);
client.setConnectionPool(ConnectionPool.getDefault());
client.setProtocols(Util.immutableList(Protocol.HTTP_1_1));
client.setConnectionSpecs(DEFAULT_CONNECTION_SPECS);
client.setSocketFactory(SocketFactory.getDefault());
Internal.instance.setNetwork(client, Network.DEFAULT);
return client;
}
示例4: HawkularMetricsClient
import com.squareup.okhttp.CertificatePinner; //导入依赖的package包/类
/**
* Constructor.
* @param metricsServer
*/
public HawkularMetricsClient(URL metricsServer) {
this.serverUrl = metricsServer;
httpClient = new OkHttpClient();
httpClient.setReadTimeout(DEFAULT_READ_TIMEOUT, TimeUnit.SECONDS);
httpClient.setWriteTimeout(DEFAULT_WRITE_TIMEOUT, TimeUnit.SECONDS);
httpClient.setConnectTimeout(DEFAULT_CONNECT_TIMEOUT, TimeUnit.SECONDS);
httpClient.setFollowRedirects(true);
httpClient.setFollowSslRedirects(true);
httpClient.setProxySelector(ProxySelector.getDefault());
httpClient.setCookieHandler(CookieHandler.getDefault());
httpClient.setCertificatePinner(CertificatePinner.DEFAULT);
httpClient.setAuthenticator(AuthenticatorAdapter.INSTANCE);
httpClient.setConnectionPool(ConnectionPool.getDefault());
httpClient.setProtocols(Util.immutableList(Protocol.HTTP_1_1));
httpClient.setConnectionSpecs(DEFAULT_CONNECTION_SPECS);
httpClient.setSocketFactory(SocketFactory.getDefault());
Internal.instance.setNetwork(httpClient, Network.DEFAULT);
}
示例5: createAddress
import com.squareup.okhttp.CertificatePinner; //导入依赖的package包/类
private static Address createAddress(OkHttpClient client, Request request) {
SSLSocketFactory sslSocketFactory = null;
HostnameVerifier hostnameVerifier = null;
CertificatePinner certificatePinner = null;
if (request.isHttps()) {
sslSocketFactory = client.getSslSocketFactory();
hostnameVerifier = client.getHostnameVerifier();
certificatePinner = client.getCertificatePinner();
}
return new Address(request.httpUrl().host(), request.httpUrl().port(), client.getDns(),
client.getSocketFactory(), sslSocketFactory, hostnameVerifier, certificatePinner, client.getAuthenticator(), client.getProxy(), client.getProtocols(), client.getConnectionSpecs(), client.getProxySelector());
}