use of javax.net.ssl.HandshakeCompletedEvent in project robovm by robovm.
the class HandshakeCompletedEventTest method test_getPeerCertificateChain.
/**
* @throws IOException
* javax.net.ssl.HandshakeCompletedEvent#getPeerCertificateChain()
*/
public final void test_getPeerCertificateChain() throws Exception {
ByteArrayInputStream bis = new ByteArrayInputStream(certificate.getBytes());
mySSLSession session = new mySSLSession((X509Certificate[]) null);
SSLSocket socket = (SSLSocket) SSLSocketFactory.getDefault().createSocket();
HandshakeCompletedEvent event = new HandshakeCompletedEvent(socket, session);
try {
event.getPeerCertificateChain();
fail("SSLPeerUnverifiedException wasn't thrown");
} catch (SSLPeerUnverifiedException expected) {
}
X509Certificate xc = X509Certificate.getInstance(bis);
X509Certificate[] xcs = { xc };
session = new mySSLSession(xcs);
event = new HandshakeCompletedEvent(socket, session);
X509Certificate[] res = event.getPeerCertificateChain();
assertEquals(1, res.length);
}
use of javax.net.ssl.HandshakeCompletedEvent in project robovm by robovm.
the class HandshakeCompletedEventTest method test_getPeerCertificates.
/**
* @throws IOException
* 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);
}
use of javax.net.ssl.HandshakeCompletedEvent 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);
}
use of javax.net.ssl.HandshakeCompletedEvent in project robovm by robovm.
the class HandshakeCompletedEventTest method test_getLocalPrincipal.
/**
* @throws IOException
* javax.net.ssl.HandshakeCompletedEvent#getLocalPrincipal()
*/
public final void test_getLocalPrincipal() throws Exception {
mySSLSession session = new mySSLSession("localhost", 1080, null);
SSLSocket socket = (SSLSocket) SSLSocketFactory.getDefault().createSocket();
HandshakeCompletedEvent event = new HandshakeCompletedEvent(socket, session);
assertNull(event.getLocalPrincipal());
}
use of javax.net.ssl.HandshakeCompletedEvent in project robovm by robovm.
the class HandshakeCompletedEventTest method test_getLocalCertificates.
/**
* @throws IOException
* javax.net.ssl.HandshakeCompletedEvent#getLocalCertificates()
*/
public final void test_getLocalCertificates() throws Exception {
mySSLSession session = new mySSLSession("localhost", 1080, null);
SSLSocket socket = (SSLSocket) SSLSocketFactory.getDefault().createSocket();
HandshakeCompletedEvent event = new HandshakeCompletedEvent(socket, session);
assertNull(event.getLocalCertificates());
}
Aggregations