use of org.webpieces.ssl.api.SSLMetrics in project webpieces by deanhiller.
the class TestSslBasicSvr method setup.
@Before
public void setup() throws GeneralSecurityException, IOException, InterruptedException, ExecutionException, TimeoutException {
System.setProperty("jdk.tls.server.protocols", "TLSv1.2");
System.setProperty("jdk.tls.client.protocols", "TLSv1.2");
SSLEngineFactoryForTestOld sslFactory = new SSLEngineFactoryForTestOld();
MeterRegistry meters = Metrics.globalRegistry;
ChannelManagerFactory factory = ChannelManagerFactory.createFactory(mockJdk, meters);
ChannelManager mgr = factory.createMultiThreadedChanMgr("test'n", new TwoPools("pl", new SimpleMeterRegistry()), new BackpressureConfig(), new DirectExecutor());
AsyncServerManager svrMgr = AsyncServerMgrFactory.createAsyncServer(mgr, meters);
server = svrMgr.createTcpServer(new AsyncConfig(), listener, sslFactory);
XFuture<Void> future = server.start(new InetSocketAddress(8443));
Assert.assertFalse(future.isDone());
mockJdk.setThread(Thread.currentThread());
mockJdk.fireSelector();
future.get(2, TimeUnit.SECONDS);
BufferPool pool = new TwoPools("p1", new SimpleMeterRegistry());
SSLEngine clientSsl = sslFactory.createEngineForSocket();
SSLMetrics sslMetrics = new SSLMetrics("", meters);
clientSslParser = AsyncSSLFactory.create("svr", clientSsl, pool, sslMetrics);
SslAction result = clientSslParser.beginHandshake();
// simulate the jdk firing the selector with a new channel...
mockSvrChannel.addNewChannel(mockChannel);
mockJdk.setThread(Thread.currentThread());
mockJdk.fireSelector();
// assert connectionOpened was called with value of isReadyForWrites=false
// (This feature is specifically so clients can start a time and timeout the connection if they do not
// receive a valid payload in a certain amount of time).
ConnectionOpen connectionOpenedInfo = listener.getConnectionOpenedInfo();
channel = connectionOpenedInfo.channel;
Assert.assertEquals(false, connectionOpenedInfo.isReadyForWrites);
mockChannel.setNumBytesToConsume(100000);
mockChannel.forceDataRead(mockJdk, result.getEncryptedData());
}
use of org.webpieces.ssl.api.SSLMetrics in project webpieces by deanhiller.
the class TestSslCloseSvr method createClientParser.
private SSLParser createClientParser() {
SSLEngineFactoryForTestOld sslFactory = new SSLEngineFactoryForTestOld();
BufferPool pool = new TwoPools("p1", new SimpleMeterRegistry());
SSLEngine clientSsl = sslFactory.createEngineForSocket();
SSLMetrics sslMetrics = new SSLMetrics("", new SimpleMeterRegistry());
SSLParser clientSslParser1 = AsyncSSLFactory.create("svr", clientSsl, pool, sslMetrics);
return clientSslParser1;
}
use of org.webpieces.ssl.api.SSLMetrics in project webpieces by deanhiller.
the class TestSslCloseClient method createSslSvrParser.
public static SSLParser createSslSvrParser() throws GeneralSecurityException, IOException {
MockSSLEngineFactory sslFactory = new MockSSLEngineFactory();
BufferPool pool = new TwoPools("pSvr", new SimpleMeterRegistry());
SSLEngine svrSsl = sslFactory.createEngineForServerSocket();
SSLMetrics metrics = new SSLMetrics("", new SimpleMeterRegistry());
return AsyncSSLFactory.create("svr", svrSsl, pool, metrics);
}
use of org.webpieces.ssl.api.SSLMetrics in project webpieces by deanhiller.
the class SslChannelService method createTCPChannel.
@Override
public TCPChannel createTCPChannel(String id, SSLEngine engine) {
if (engine == null || id == null)
throw new IllegalArgumentException("no arguments can be null");
Function<SslListener, AsyncSSLEngine> function = l -> AsyncSSLFactory.create(id, engine, pool, l, sslMetrics);
TCPChannel channel = mgr.createTCPChannel(id);
SslTCPChannel sslChannel = new SslTCPChannel(function, channel, sslMetrics);
return sslChannel;
}
Aggregations