use of javax.net.ssl.SSLSocket in project robovm by robovm.
the class AbstractClientConnAdapter method getSSLSession.
// non-javadoc, see interface ManagedClientConnection
public SSLSession getSSLSession() {
OperatedClientConnection conn = getWrappedConnection();
assertValid(conn);
if (!isOpen())
return null;
SSLSession result = null;
Socket sock = conn.getSocket();
if (sock instanceof SSLSocket) {
result = ((SSLSocket) sock).getSession();
}
return result;
}
use of javax.net.ssl.SSLSocket in project robovm by robovm.
the class HandshakeCompletedEventTest method test_getCipherSuite.
/**
* @throws IOException
* javax.net.ssl.HandshakeCompletedEvent#getCipherSuite()
*/
public final void test_getCipherSuite() throws Exception {
mySSLSession session = new mySSLSession("localhost", 1080, null);
SSLSocket socket = (SSLSocket) SSLSocketFactory.getDefault().createSocket();
HandshakeCompletedEvent event = new HandshakeCompletedEvent(socket, session);
assertEquals("SuiteName", event.getCipherSuite());
}
use of javax.net.ssl.SSLSocket 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.SSLSocket 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.SSLSocket 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);
}
Aggregations