OpenSslPrivateKeyMethodAdapter Class — netty Architecture
Architecture documentation for the OpenSslPrivateKeyMethodAdapter class in OpenSslPrivateKeyMethodTest.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD b64a66d0_62e7_ce9c_e091_5e0a556ec80a["OpenSslPrivateKeyMethodAdapter"] 81a6c13b_b22c_6ee8_08c1_85d9e192525a["OpenSslPrivateKeyMethodTest.java"] b64a66d0_62e7_ce9c_e091_5e0a556ec80a -->|defined in| 81a6c13b_b22c_6ee8_08c1_85d9e192525a a82618c3_8367_7f44_9004_0168ab968e1c["OpenSslPrivateKeyMethodAdapter()"] b64a66d0_62e7_ce9c_e091_5e0a556ec80a -->|method| a82618c3_8367_7f44_9004_0168ab968e1c 1558c9b0_1905_5fc4_ab74_483e05181c96["sign()"] b64a66d0_62e7_ce9c_e091_5e0a556ec80a -->|method| 1558c9b0_1905_5fc4_ab74_483e05181c96 64891399_7257_b41d_2d83_0a7379197ce0["decrypt()"] b64a66d0_62e7_ce9c_e091_5e0a556ec80a -->|method| 64891399_7257_b41d_2d83_0a7379197ce0
Relationship Graph
Source Code
handler/src/test/java/io/netty/handler/ssl/OpenSslPrivateKeyMethodTest.java lines 418–482
private static final class OpenSslPrivateKeyMethodAdapter implements OpenSslAsyncPrivateKeyMethod {
private final OpenSslPrivateKeyMethod keyMethod;
private final boolean newThread;
OpenSslPrivateKeyMethodAdapter(OpenSslPrivateKeyMethod keyMethod, boolean newThread) {
this.keyMethod = keyMethod;
this.newThread = newThread;
}
@Override
public Future<byte[]> sign(final SSLEngine engine, final int signatureAlgorithm, final byte[] input) {
final Promise<byte[]> promise = ImmediateEventExecutor.INSTANCE.newPromise();
try {
if (newThread) {
// Let's run these in an extra thread to ensure that this would also work if the promise is
// notified later.
new DelegateThread(new Runnable() {
@Override
public void run() {
try {
// Let's sleep for some time to ensure we would notify in an async fashion
Thread.sleep(ThreadLocalRandom.current().nextLong(100, 500));
promise.setSuccess(keyMethod.sign(engine, signatureAlgorithm, input));
} catch (Throwable cause) {
promise.setFailure(cause);
}
}
}).start();
} else {
promise.setSuccess(keyMethod.sign(engine, signatureAlgorithm, input));
}
} catch (Throwable cause) {
promise.setFailure(cause);
}
return promise;
}
@Override
public Future<byte[]> decrypt(final SSLEngine engine, final byte[] input) {
final Promise<byte[]> promise = ImmediateEventExecutor.INSTANCE.newPromise();
try {
if (newThread) {
// Let's run these in an extra thread to ensure that this would also work if the promise is
// notified later.
new DelegateThread(new Runnable() {
@Override
public void run() {
try {
// Let's sleep for some time to ensure we would notify in an async fashion
Thread.sleep(ThreadLocalRandom.current().nextLong(100, 500));
promise.setSuccess(keyMethod.decrypt(engine, input));
} catch (Throwable cause) {
promise.setFailure(cause);
}
}
}).start();
} else {
promise.setSuccess(keyMethod.decrypt(engine, input));
}
} catch (Throwable cause) {
promise.setFailure(cause);
}
return promise;
}
}
Source
Frequently Asked Questions
What is the OpenSslPrivateKeyMethodAdapter class?
OpenSslPrivateKeyMethodAdapter is a class in the netty codebase, defined in handler/src/test/java/io/netty/handler/ssl/OpenSslPrivateKeyMethodTest.java.
Where is OpenSslPrivateKeyMethodAdapter defined?
OpenSslPrivateKeyMethodAdapter is defined in handler/src/test/java/io/netty/handler/ssl/OpenSslPrivateKeyMethodTest.java at line 418.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free