本文整理汇总了Java中java.net.SecureCacheResponse.getServerCertificateChain方法的典型用法代码示例。如果您正苦于以下问题:Java SecureCacheResponse.getServerCertificateChain方法的具体用法?Java SecureCacheResponse.getServerCertificateChain怎么用?Java SecureCacheResponse.getServerCertificateChain使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.net.SecureCacheResponse
的用法示例。
在下文中一共展示了SecureCacheResponse.getServerCertificateChain方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getServerCertificates
import java.net.SecureCacheResponse; //导入方法依赖的package包/类
@Override public Certificate[] getServerCertificates() throws SSLPeerUnverifiedException {
SecureCacheResponse cacheResponse = delegate.getSecureCacheResponse();
if (cacheResponse != null) {
List<Certificate> result = cacheResponse.getServerCertificateChain();
return result != null ? result.toArray(new Certificate[result.size()]) : null;
}
SSLSocket sslSocket = getSslSocket();
if (sslSocket != null) {
return sslSocket.getSession().getPeerCertificates();
}
return null;
}
示例2: getServerCertificates
import java.net.SecureCacheResponse; //导入方法依赖的package包/类
@Override
public Certificate[] getServerCertificates() throws SSLPeerUnverifiedException {
SecureCacheResponse cacheResponse = delegate.getSecureCacheResponse();
if (cacheResponse != null) {
List<Certificate> result = cacheResponse.getServerCertificateChain();
return result != null ? result.toArray(new Certificate[result.size()]) : null;
}
SSLSocket sslSocket = getSslSocket();
if (sslSocket != null) {
return sslSocket.getSession().getPeerCertificates();
}
return null;
}
示例3: createOkResponseForCacheGet
import java.net.SecureCacheResponse; //导入方法依赖的package包/类
/**
* Creates an OkHttp {@link Response} using the supplied {@link Request} and {@link CacheResponse}
* to supply the data.
*/
static Response createOkResponseForCacheGet(Request request, CacheResponse javaResponse)
throws IOException {
// Build a cache request for the response to use.
Headers responseHeaders = createHeaders(javaResponse.getHeaders());
Headers varyHeaders;
if (HttpHeaders.hasVaryAll(responseHeaders)) {
// "*" means that this will be treated as uncacheable anyway.
varyHeaders = new Headers.Builder().build();
} else {
varyHeaders = HttpHeaders.varyHeaders(request.headers(), responseHeaders);
}
Request cacheRequest = new Request.Builder()
.url(request.url())
.method(request.method(), null)
.headers(varyHeaders)
.build();
Response.Builder okResponseBuilder = new Response.Builder();
// Request: Use the cacheRequest we built.
okResponseBuilder.request(cacheRequest);
// Status line: Java has this as one of the headers.
StatusLine statusLine = StatusLine.parse(extractStatusLine(javaResponse));
okResponseBuilder.protocol(statusLine.protocol);
okResponseBuilder.code(statusLine.code);
okResponseBuilder.message(statusLine.message);
// Response headers
Headers okHeaders = extractOkHeaders(javaResponse, okResponseBuilder);
okResponseBuilder.headers(okHeaders);
// Response body
ResponseBody okBody = createOkBody(okHeaders, javaResponse);
okResponseBuilder.body(okBody);
// Handle SSL handshake information as needed.
if (javaResponse instanceof SecureCacheResponse) {
SecureCacheResponse javaSecureCacheResponse = (SecureCacheResponse) javaResponse;
// Handshake doesn't support null lists.
List<Certificate> peerCertificates;
try {
peerCertificates = javaSecureCacheResponse.getServerCertificateChain();
} catch (SSLPeerUnverifiedException e) {
peerCertificates = Collections.emptyList();
}
List<Certificate> localCertificates = javaSecureCacheResponse.getLocalCertificateChain();
if (localCertificates == null) {
localCertificates = Collections.emptyList();
}
String cipherSuiteString = javaSecureCacheResponse.getCipherSuite();
CipherSuite cipherSuite = CipherSuite.forJavaName(cipherSuiteString);
Handshake handshake = Handshake.get(null, cipherSuite, peerCertificates, localCertificates);
okResponseBuilder.handshake(handshake);
}
return okResponseBuilder.build();
}
示例4: createOkResponseForCacheGet
import java.net.SecureCacheResponse; //导入方法依赖的package包/类
/**
* Creates an OkHttp {@link Response} using the supplied {@link Request} and {@link CacheResponse}
* to supply the data.
*/
static Response createOkResponseForCacheGet(Request request, CacheResponse javaResponse)
throws IOException {
// Build a cache request for the response to use.
Headers responseHeaders = createHeaders(javaResponse.getHeaders());
Headers varyHeaders;
if (HttpHeaders.hasVaryAll(responseHeaders)) {
// "*" means that this will be treated as uncacheable anyway.
varyHeaders = new Headers.Builder().build();
} else {
varyHeaders = HttpHeaders.varyHeaders(request.headers(), responseHeaders);
}
Request cacheRequest = new Request.Builder()
.url(request.url())
.method(request.method(), null)
.headers(varyHeaders)
.build();
Response.Builder okResponseBuilder = new Response.Builder();
// Request: Use the cacheRequest we built.
okResponseBuilder.request(cacheRequest);
// Status line: Java has this as one of the headers.
StatusLine statusLine = StatusLine.parse(extractStatusLine(javaResponse));
okResponseBuilder.protocol(statusLine.protocol);
okResponseBuilder.code(statusLine.code);
okResponseBuilder.message(statusLine.message);
// Response headers
Headers okHeaders = extractOkHeaders(javaResponse, okResponseBuilder);
okResponseBuilder.headers(okHeaders);
// Response body
ResponseBody okBody = createOkBody(okHeaders, javaResponse);
okResponseBuilder.body(okBody);
// Handle SSL handshake information as needed.
if (javaResponse instanceof SecureCacheResponse) {
SecureCacheResponse javaSecureCacheResponse = (SecureCacheResponse) javaResponse;
// Handshake doesn't support null lists.
List<Certificate> peerCertificates;
try {
peerCertificates = javaSecureCacheResponse.getServerCertificateChain();
} catch (SSLPeerUnverifiedException e) {
peerCertificates = Collections.emptyList();
}
List<Certificate> localCertificates = javaSecureCacheResponse.getLocalCertificateChain();
if (localCertificates == null) {
localCertificates = Collections.emptyList();
}
String cipherSuiteString = javaSecureCacheResponse.getCipherSuite();
CipherSuite cipherSuite = CipherSuite.forJavaName(cipherSuiteString);
Handshake handshake = Handshake.get(
TlsVersion.SSL_3_0, cipherSuite, peerCertificates, localCertificates);
okResponseBuilder.handshake(handshake);
}
return okResponseBuilder.build();
}
示例5: createOkResponseForCacheGet
import java.net.SecureCacheResponse; //导入方法依赖的package包/类
/**
* Creates an OkHttp {@link Response} using the supplied {@link Request} and {@link CacheResponse}
* to supply the data.
*/
static Response createOkResponseForCacheGet(Request request, CacheResponse javaResponse)
throws IOException {
// Build a cache request for the response to use.
Headers responseHeaders = createHeaders(javaResponse.getHeaders());
Headers varyHeaders;
if (OkHeaders.hasVaryAll(responseHeaders)) {
// "*" means that this will be treated as uncacheable anyway.
varyHeaders = new Headers.Builder().build();
} else {
varyHeaders = OkHeaders.varyHeaders(request.headers(), responseHeaders);
}
Request cacheRequest = new Request.Builder()
.url(request.url())
.method(request.method(), null)
.headers(varyHeaders)
.build();
Response.Builder okResponseBuilder = new Response.Builder();
// Request: Use the cacheRequest we built.
okResponseBuilder.request(cacheRequest);
// Status line: Java has this as one of the headers.
StatusLine statusLine = StatusLine.parse(extractStatusLine(javaResponse));
okResponseBuilder.protocol(statusLine.protocol);
okResponseBuilder.code(statusLine.code);
okResponseBuilder.message(statusLine.message);
// Response headers
Headers okHeaders = extractOkHeaders(javaResponse);
okResponseBuilder.headers(okHeaders);
// Response body
ResponseBody okBody = createOkBody(okHeaders, javaResponse);
okResponseBuilder.body(okBody);
// Handle SSL handshake information as needed.
if (javaResponse instanceof SecureCacheResponse) {
SecureCacheResponse javaSecureCacheResponse = (SecureCacheResponse) javaResponse;
// Handshake doesn't support null lists.
List<Certificate> peerCertificates;
try {
peerCertificates = javaSecureCacheResponse.getServerCertificateChain();
} catch (SSLPeerUnverifiedException e) {
peerCertificates = Collections.emptyList();
}
List<Certificate> localCertificates = javaSecureCacheResponse.getLocalCertificateChain();
if (localCertificates == null) {
localCertificates = Collections.emptyList();
}
String cipherSuiteString = javaSecureCacheResponse.getCipherSuite();
CipherSuite cipherSuite = CipherSuite.forJavaName(cipherSuiteString);
Handshake handshake = Handshake.get(null, cipherSuite, peerCertificates, localCertificates);
okResponseBuilder.handshake(handshake);
}
return okResponseBuilder.build();
}