Search in sources :

Example 26 with SSLSession

use of javax.net.ssl.SSLSession in project robovm by robovm.

the class MySSLSession method test_getName.

/**
     * javax.net.ssl.SSLSessionBindingEvent#getName()
     */
public void test_getName() {
    SSLSession ses = new MySSLSession();
    SSLSessionBindingEvent event = new SSLSessionBindingEvent(ses, "test");
    assertEquals("Incorrect session name", "test", event.getName());
    event = new SSLSessionBindingEvent(ses, null);
    assertEquals("Incorrect session name", null, event.getName());
}
Also used : SSLSessionBindingEvent(javax.net.ssl.SSLSessionBindingEvent) SSLSession(javax.net.ssl.SSLSession)

Example 27 with SSLSession

use of javax.net.ssl.SSLSession in project robovm by robovm.

the class SSLSessionBindingListenerTest method test_valueUnbound.

/**
     * @throws IOException
     * @throws UnknownHostException
     * javax.net.ssl.SSLSessionBindingListener#valueUnbound(SSLSessionBindingEvent event)
     */
public void test_valueUnbound() throws UnknownHostException, IOException {
    SSLSocket sock = (SSLSocket) SSLSocketFactory.getDefault().createSocket();
    SSLSession ss = sock.getSession();
    mySSLSessionBindingListener sbl = new mySSLSessionBindingListener();
    ss.putValue("test", sbl);
    ss.removeValue("test");
    assertTrue("valueUnbound was not called.", sbl.unboundDone);
}
Also used : SSLSocket(javax.net.ssl.SSLSocket) SSLSession(javax.net.ssl.SSLSession)

Example 28 with SSLSession

use of javax.net.ssl.SSLSession in project robovm by robovm.

the class HttpsURLConnectionTest method checkConnectionStateParameters.

/**
     * Checks the HttpsURLConnection getter's values and compares
     * them with actual corresponding values of remote peer.
     */
public static void checkConnectionStateParameters(HttpsURLConnection clientConnection, SSLSocket serverPeer) throws Exception {
    SSLSession session = serverPeer.getSession();
    assertEquals(session.getCipherSuite(), clientConnection.getCipherSuite());
    assertEquals(session.getLocalPrincipal(), clientConnection.getPeerPrincipal());
    assertEquals(session.getPeerPrincipal(), clientConnection.getLocalPrincipal());
    Certificate[] serverCertificates = clientConnection.getServerCertificates();
    Certificate[] localCertificates = session.getLocalCertificates();
    assertTrue("Server certificates differ from expected", Arrays.equals(serverCertificates, localCertificates));
    localCertificates = clientConnection.getLocalCertificates();
    serverCertificates = session.getPeerCertificates();
    assertTrue("Local certificates differ from expected", Arrays.equals(serverCertificates, localCertificates));
}
Also used : SSLSession(javax.net.ssl.SSLSession) Certificate(java.security.cert.Certificate)

Example 29 with SSLSession

use of javax.net.ssl.SSLSession in project robovm by robovm.

the class SSLSessionTest method test_invalidate.

/**
     * javax.net.ssl.SSLSession#invalidate()
     * javax.net.ssl.SSLSession#isValid()
     */
public void test_invalidate() {
    SSLSession s = clientSession;
    assertTrue(s.isValid());
    s.invalidate();
    assertFalse(s.isValid());
}
Also used : SSLSession(javax.net.ssl.SSLSession)

Example 30 with SSLSession

use of javax.net.ssl.SSLSession in project robovm by robovm.

the class HandshakeCompletedEventTest method test_getSession.

/**
     * @throws IOException
     * javax.net.ssl.HandshakeCompletedEvent#getSession()
     */
public final void test_getSession() throws IOException {
    mySSLSession session = new mySSLSession("localhost", 1080, null);
    SSLSocket socket = (SSLSocket) SSLSocketFactory.getDefault().createSocket();
    HandshakeCompletedEvent event = new HandshakeCompletedEvent(socket, session);
    SSLSession ss = event.getSession();
    assertNotNull(ss);
    assertEquals(session, ss);
}
Also used : HandshakeCompletedEvent(javax.net.ssl.HandshakeCompletedEvent) SSLSocket(javax.net.ssl.SSLSocket) SSLSession(javax.net.ssl.SSLSession) org.apache.harmony.xnet.tests.support.mySSLSession(org.apache.harmony.xnet.tests.support.mySSLSession) org.apache.harmony.xnet.tests.support.mySSLSession(org.apache.harmony.xnet.tests.support.mySSLSession)

Aggregations

SSLSession (javax.net.ssl.SSLSession)340 HostnameVerifier (javax.net.ssl.HostnameVerifier)121 SSLContext (javax.net.ssl.SSLContext)74 IOException (java.io.IOException)65 X509Certificate (java.security.cert.X509Certificate)64 CertificateException (java.security.cert.CertificateException)49 SSLSocket (javax.net.ssl.SSLSocket)49 TrustManager (javax.net.ssl.TrustManager)45 X509TrustManager (javax.net.ssl.X509TrustManager)43 Test (org.junit.Test)39 Certificate (java.security.cert.Certificate)33 SecureRandom (java.security.SecureRandom)31 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)29 SSLPeerUnverifiedException (javax.net.ssl.SSLPeerUnverifiedException)28 SSLSocketFactory (javax.net.ssl.SSLSocketFactory)28 URL (java.net.URL)24 HttpsURLConnection (javax.net.ssl.HttpsURLConnection)24 KeyManagementException (java.security.KeyManagementException)23 SSLException (javax.net.ssl.SSLException)22 InputStream (java.io.InputStream)18