use of io.netty.buffer.ByteBufAllocator in project netty by netty.
the class ReferenceCountedOpenSslContext method toBIO.
/**
* Return the pointer to a <a href="https://www.openssl.org/docs/crypto/BIO_get_mem_ptr.html">in-memory BIO</a>
* or {@code 0} if the {@code key} is {@code null}. The BIO contains the content of the {@code key}.
*/
static long toBIO(PrivateKey key) throws Exception {
if (key == null) {
return 0;
}
ByteBufAllocator allocator = ByteBufAllocator.DEFAULT;
PemEncoded pem = PemPrivateKey.toPEM(allocator, true, key);
try {
return toBIO(allocator, pem.retain());
} finally {
pem.release();
}
}
use of io.netty.buffer.ByteBufAllocator in project netty by netty.
the class ReferenceCountedOpenSslContext method toBIO.
/**
* Return the pointer to a <a href="https://www.openssl.org/docs/crypto/BIO_get_mem_ptr.html">in-memory BIO</a>
* or {@code 0} if the {@code certChain} is {@code null}. The BIO contains the content of the {@code certChain}.
*/
static long toBIO(X509Certificate... certChain) throws Exception {
if (certChain == null) {
return 0;
}
if (certChain.length == 0) {
throw new IllegalArgumentException("certChain can't be empty");
}
ByteBufAllocator allocator = ByteBufAllocator.DEFAULT;
PemEncoded pem = PemX509Certificate.toPEM(allocator, true, certChain);
try {
return toBIO(allocator, pem.retain());
} finally {
pem.release();
}
}
use of io.netty.buffer.ByteBufAllocator in project netty by netty.
the class AbstractTestsuiteTest method run.
protected void run() throws Throwable {
List<TestsuitePermutation.BootstrapFactory<T>> combos = newFactories();
for (ByteBufAllocator allocator : newAllocators()) {
int i = 0;
for (TestsuitePermutation.BootstrapFactory<T> e : combos) {
cb = e.newInstance();
configure(cb, allocator);
logger.info(String.format("Running: %s %d of %d with %s", testName.getMethodName(), ++i, combos.size(), StringUtil.simpleClassName(allocator)));
try {
Method m = getClass().getMethod(TestUtils.testMethodName(testName), clazz);
m.invoke(this, cb);
} catch (InvocationTargetException ex) {
throw ex.getCause();
}
}
}
}
use of io.netty.buffer.ByteBufAllocator in project netty by netty.
the class Http2FrameWriterBenchmark method boostrapEmbeddedEnv.
private static Environment boostrapEmbeddedEnv(final EnvironmentType environmentType) {
final ByteBufAllocator alloc = environmentType.params().clientAllocator();
final EmbeddedEnvironment env = new EmbeddedEnvironment(new DefaultHttp2FrameWriter());
final Http2Connection connection = new DefaultHttp2Connection(false);
Http2ConnectionEncoder encoder = new DefaultHttp2ConnectionEncoder(connection, env.writer());
Http2ConnectionDecoder decoder = new DefaultHttp2ConnectionDecoder(connection, encoder, new DefaultHttp2FrameReader());
Http2ConnectionHandler connectionHandler = new Http2ConnectionHandlerBuilder().encoderEnforceMaxConcurrentStreams(false).frameListener(new Http2FrameAdapter()).codec(decoder, encoder).build();
env.context(new EmbeddedChannelWriteReleaseHandlerContext(alloc, connectionHandler) {
@Override
protected void handleException(Throwable t) {
handleUnexpectedException(t);
}
});
return env;
}
use of io.netty.buffer.ByteBufAllocator in project neo4j by neo4j.
the class BoltProtocolV1Test method newChannelMock.
private static Channel newChannelMock() {
Channel channel = mock(Channel.class);
ByteBufAllocator allocator = mock(ByteBufAllocator.class, RETURNS_MOCKS);
when(channel.alloc()).thenReturn(allocator);
return channel;
}
Aggregations