Search in sources :

Example 21 with SecureCacheResponse

use of java.net.SecureCacheResponse in project cordova-android-chromeview by thedracle.

the class HttpsURLConnectionImpl method getCipherSuite.

@Override
public String getCipherSuite() {
    SecureCacheResponse cacheResponse = delegate.getSecureCacheResponse();
    if (cacheResponse != null) {
        return cacheResponse.getCipherSuite();
    }
    SSLSocket sslSocket = getSslSocket();
    if (sslSocket != null) {
        return sslSocket.getSession().getCipherSuite();
    }
    return null;
}
Also used : SecureCacheResponse(java.net.SecureCacheResponse) SSLSocket(javax.net.ssl.SSLSocket)

Example 22 with SecureCacheResponse

use of java.net.SecureCacheResponse in project cordova-android-chromeview by thedracle.

the class HttpsURLConnectionImpl method getPeerPrincipal.

@Override
public Principal getPeerPrincipal() throws SSLPeerUnverifiedException {
    SecureCacheResponse cacheResponse = delegate.getSecureCacheResponse();
    if (cacheResponse != null) {
        return cacheResponse.getPeerPrincipal();
    }
    SSLSocket sslSocket = getSslSocket();
    if (sslSocket != null) {
        return sslSocket.getSession().getPeerPrincipal();
    }
    return null;
}
Also used : SecureCacheResponse(java.net.SecureCacheResponse) SSLSocket(javax.net.ssl.SSLSocket)

Example 23 with SecureCacheResponse

use of java.net.SecureCacheResponse in project cordova-android-chromeview by thedracle.

the class HttpsURLConnectionImpl method getLocalCertificates.

@Override
public Certificate[] getLocalCertificates() {
    SecureCacheResponse cacheResponse = delegate.getSecureCacheResponse();
    if (cacheResponse != null) {
        List<Certificate> result = cacheResponse.getLocalCertificateChain();
        return result != null ? result.toArray(new Certificate[result.size()]) : null;
    }
    SSLSocket sslSocket = getSslSocket();
    if (sslSocket != null) {
        return sslSocket.getSession().getLocalCertificates();
    }
    return null;
}
Also used : SecureCacheResponse(java.net.SecureCacheResponse) SSLSocket(javax.net.ssl.SSLSocket) Certificate(java.security.cert.Certificate)

Example 24 with SecureCacheResponse

use of java.net.SecureCacheResponse in project cordova-android-chromeview by thedracle.

the class HttpsURLConnectionImpl method getLocalPrincipal.

@Override
public Principal getLocalPrincipal() {
    SecureCacheResponse cacheResponse = delegate.getSecureCacheResponse();
    if (cacheResponse != null) {
        return cacheResponse.getLocalPrincipal();
    }
    SSLSocket sslSocket = getSslSocket();
    if (sslSocket != null) {
        return sslSocket.getSession().getLocalPrincipal();
    }
    return null;
}
Also used : SecureCacheResponse(java.net.SecureCacheResponse) SSLSocket(javax.net.ssl.SSLSocket)

Example 25 with SecureCacheResponse

use of java.net.SecureCacheResponse in project okhttp by square.

the class JavaApiConverterTest method createJavaCacheResponse_httpPost.

@Test
public void createJavaCacheResponse_httpPost() throws Exception {
    Request okRequest = createArbitraryOkRequest().newBuilder().url("http://insecure/request").post(createRequestBody("RequestBody")).build();
    ResponseBody responseBody = createResponseBody("ResponseBody");
    Response okResponse = createArbitraryOkResponse(okRequest).newBuilder().protocol(Protocol.HTTP_1_1).code(200).message("Fantastic").addHeader("key1", "value1_1").addHeader("key2", "value2").addHeader("key1", "value1_2").body(responseBody).build();
    CacheResponse javaCacheResponse = JavaApiConverter.createJavaCacheResponse(okResponse);
    assertFalse(javaCacheResponse instanceof SecureCacheResponse);
    Map<String, List<String>> javaHeaders = javaCacheResponse.getHeaders();
    assertEquals(Arrays.asList("value1_1", "value1_2"), javaHeaders.get("key1"));
    assertEquals(Arrays.asList("HTTP/1.1 200 Fantastic"), javaHeaders.get(null));
    assertEquals("ResponseBody", readAll(javaCacheResponse.getBody()));
}
Also used : CacheResponse(java.net.CacheResponse) Response(okhttp3.Response) SecureCacheResponse(java.net.SecureCacheResponse) CacheResponse(java.net.CacheResponse) SecureCacheResponse(java.net.SecureCacheResponse) SecureCacheResponse(java.net.SecureCacheResponse) Request(okhttp3.Request) List(java.util.List) ResponseBody(okhttp3.ResponseBody) Test(org.junit.Test)

Aggregations

SecureCacheResponse (java.net.SecureCacheResponse)27 SSLSocket (javax.net.ssl.SSLSocket)15 Certificate (java.security.cert.Certificate)11 CacheResponse (java.net.CacheResponse)6 List (java.util.List)5 Request (okhttp3.Request)5 Response (okhttp3.Response)5 Handshake (okhttp3.Handshake)4 ResponseBody (okhttp3.ResponseBody)4 Test (org.junit.Test)4 Headers (okhttp3.Headers)3 URI (java.net.URI)2 JavaNetHeaders (okhttp3.internal.JavaNetHeaders)2 HttpHeaders (okhttp3.internal.http.HttpHeaders)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 Proxy (java.net.Proxy)1 ProxySelector (java.net.ProxySelector)1 Principal (java.security.Principal)1 X509Certificate (java.security.cert.X509Certificate)1 LinkedHashMap (java.util.LinkedHashMap)1