Code example for HandshakeCompletedEvent

Methods: getPeerCertificates

0
     * javax.net.ssl.HandshakeCompletedEvent#getPeerCertificates() 
     */ 
    public final void test_getPeerCertificates() throws IOException { 
        mySSLSession session = new mySSLSession("localhost", 1080, null);
        SSLSocket socket = (SSLSocket) SSLSocketFactory.getDefault().createSocket();
        HandshakeCompletedEvent event = new HandshakeCompletedEvent(socket, session);
        try { 
            event.getPeerCertificates();
            fail("SSLPeerUnverifiedException wasn't thrown");
        } catch (SSLPeerUnverifiedException expected) {
        } 
 
        session = new mySSLSession((X509Certificate[]) null);
        event = new HandshakeCompletedEvent(socket, session);
        Certificate[] res = event.getPeerCertificates();
        assertEquals(3, res.length);
    } 
 
    /** 
     * @throws IOException 
     * javax.net.ssl.HandshakeCompletedEvent#getPeerPrincipal()