use of javax.net.ssl.SSLEngine in project robovm by robovm.
the class SSLEngineTest method test_unwrap_ByteBuffer$ByteBuffer_02.
/**
* javax.net.ssl.SSLEngine#unwrap(ByteBuffer src, ByteBuffer[] dsts)
* ReadOnlyBufferException should be thrown.
*/
@KnownFailure("Fixed on DonutBurger, Wrong Exception thrown")
public void test_unwrap_ByteBuffer$ByteBuffer_02() {
String host = "new host";
int port = 8080;
ByteBuffer bbs = ByteBuffer.allocate(10);
ByteBuffer bbR = ByteBuffer.allocate(100).asReadOnlyBuffer();
ByteBuffer[] bbA = { bbR, ByteBuffer.allocate(10), ByteBuffer.allocate(100) };
SSLEngine sse = getEngine(host, port);
sse.setUseClientMode(true);
try {
sse.unwrap(bbs, bbA);
fail("ReadOnlyBufferException wasn't thrown");
} catch (ReadOnlyBufferException iobe) {
//expected
} catch (Exception e) {
fail(e + " was thrown instead of ReadOnlyBufferException");
}
}
use of javax.net.ssl.SSLEngine in project robovm by robovm.
the class SSLEngineTest method test_wrap_06.
/**
* javax.net.ssl.SSLEngine#wrap(ByteBuffer[] srcs, int offset,
* int length, ByteBuffer dst)
*/
public void test_wrap_06() {
String host = "new host";
int port = 8080;
ByteBuffer bb = ByteBuffer.allocate(10);
ByteBuffer[] bbA = { ByteBuffer.allocate(5), ByteBuffer.allocate(10), ByteBuffer.allocate(5) };
SSLEngine sse = getEngine(host, port);
sse.setUseClientMode(true);
try {
sse.wrap(bbA, 0, bbA.length, bb);
} catch (Exception ex) {
fail("Unexpected exception: " + ex);
}
}
use of javax.net.ssl.SSLEngine in project robovm by robovm.
the class SSLEngineTest method test_beginHandshake.
/**
* @throws NoSuchAlgorithmException
* javax.net.ssl.SSLEngine#beginHandshake()
*/
public void test_beginHandshake() throws NoSuchAlgorithmException {
SSLEngine sse = getEngine();
try {
sse.beginHandshake();
fail("IllegalStateException wasn't thrown");
} catch (IllegalStateException se) {
//expected
} catch (Exception e) {
fail(e + " was thrown instead of IllegalStateException");
}
sse = getEngine("new host", 1080);
try {
sse.beginHandshake();
fail("IllegalStateException wasn't thrown");
} catch (IllegalStateException ise) {
//expected
} catch (Exception e) {
fail(e + " was thrown instead of IllegalStateException");
}
sse = getEngine();
try {
sse.setUseClientMode(true);
sse.beginHandshake();
} catch (Exception ex) {
fail("Unexpected exception " + ex);
}
}
use of javax.net.ssl.SSLEngine in project robovm by robovm.
the class SSLEngineTest method test_SSLEngine_getSSLParameters.
public void test_SSLEngine_getSSLParameters() throws Exception {
TestSSLContext c = TestSSLContext.create();
SSLEngine e = c.clientContext.createSSLEngine();
SSLParameters p = e.getSSLParameters();
assertNotNull(p);
String[] cipherSuites = p.getCipherSuites();
StandardNames.assertValidCipherSuites(StandardNames.CIPHER_SUITES, cipherSuites);
assertNotSame(cipherSuites, e.getEnabledCipherSuites());
assertEquals(Arrays.asList(cipherSuites), Arrays.asList(e.getEnabledCipherSuites()));
String[] protocols = p.getProtocols();
StandardNames.assertValidProtocols(StandardNames.SSL_SOCKET_PROTOCOLS, protocols);
assertNotSame(protocols, e.getEnabledProtocols());
assertEquals(Arrays.asList(protocols), Arrays.asList(e.getEnabledProtocols()));
assertEquals(p.getWantClientAuth(), e.getWantClientAuth());
assertEquals(p.getNeedClientAuth(), e.getNeedClientAuth());
c.close();
}
use of javax.net.ssl.SSLEngine in project robovm by robovm.
the class SSLEngineTest method test_SSLEngine_getEnabledProtocols.
public void test_SSLEngine_getEnabledProtocols() throws Exception {
TestSSLContext c = TestSSLContext.create();
SSLEngine e = c.clientContext.createSSLEngine();
String[] protocols = e.getEnabledProtocols();
StandardNames.assertValidProtocols(StandardNames.SSL_SOCKET_PROTOCOLS, protocols);
assertNotSame(protocols, e.getEnabledProtocols());
c.close();
}
Aggregations