Search in sources :

Example 6 with SSLClientSessionCache

use of com.android.org.conscrypt.SSLClientSessionCache in project android_frameworks_base by crdroidandroid.

the class SSLSessionCacheTest method testInstall_compatibleContext.

public void testInstall_compatibleContext() throws Exception {
    final SSLContext ctx = SSLContext.getDefault();
    final SSLClientSessionCache mock = LittleMock.mock(SSLClientSessionCache.class);
    final ClientSessionContext clientCtx = (ClientSessionContext) ctx.getClientSessionContext();
    try {
        SSLSessionCache.install(new SSLSessionCache(mock), ctx);
        clientCtx.getSession("www.foogle.com", 443);
        LittleMock.verify(mock).getSessionData(LittleMock.anyString(), LittleMock.anyInt());
    } finally {
        // Restore cacheless behaviour.
        SSLSessionCache.install(null, ctx);
        clientCtx.getSession("www.foogle.com", 443);
        LittleMock.verifyNoMoreInteractions(mock);
    }
}
Also used : ClientSessionContext(com.android.org.conscrypt.ClientSessionContext) SSLContext(javax.net.ssl.SSLContext) SSLClientSessionCache(com.android.org.conscrypt.SSLClientSessionCache)

Aggregations

SSLClientSessionCache (com.android.org.conscrypt.SSLClientSessionCache)6 ClientSessionContext (com.android.org.conscrypt.ClientSessionContext)5 SSLContext (javax.net.ssl.SSLContext)5 OpenSSLContextImpl (com.android.org.conscrypt.OpenSSLContextImpl)1 IOException (java.io.IOException)1 KeyManagementException (java.security.KeyManagementException)1 X509Certificate (java.security.cert.X509Certificate)1 TrustManager (javax.net.ssl.TrustManager)1 X509TrustManager (javax.net.ssl.X509TrustManager)1