1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package io.netty5.handler.ssl;
17
18 import io.netty5.buffer.api.BufferAllocator;
19
20 import javax.net.ssl.SSLEngine;
21 import javax.net.ssl.SSLSessionContext;
22 import java.util.List;
23 import java.util.concurrent.Executor;
24
25 import static java.util.Objects.requireNonNull;
26
27
28
29
30 public abstract class DelegatingSslContext extends SslContext {
31
32 private final SslContext ctx;
33
34 protected DelegatingSslContext(SslContext ctx) {
35 this.ctx = requireNonNull(ctx, "ctx");
36 }
37
38 @Override
39 public final boolean isClient() {
40 return ctx.isClient();
41 }
42
43 @Override
44 public final List<String> cipherSuites() {
45 return ctx.cipherSuites();
46 }
47
48 @Override
49 public final long sessionCacheSize() {
50 return ctx.sessionCacheSize();
51 }
52
53 @Override
54 public final long sessionTimeout() {
55 return ctx.sessionTimeout();
56 }
57
58 @Override
59 public final ApplicationProtocolNegotiator applicationProtocolNegotiator() {
60 return ctx.applicationProtocolNegotiator();
61 }
62
63 @Override
64 public final SSLEngine newEngine(BufferAllocator alloc) {
65 SSLEngine engine = ctx.newEngine(alloc);
66 initEngine(engine);
67 return engine;
68 }
69
70 @Override
71 public final SSLEngine newEngine(BufferAllocator alloc, String peerHost, int peerPort) {
72 SSLEngine engine = ctx.newEngine(alloc, peerHost, peerPort);
73 initEngine(engine);
74 return engine;
75 }
76
77 @Override
78 protected final SslHandler newHandler(BufferAllocator alloc, boolean startTls) {
79 SslHandler handler = ctx.newHandler(alloc, startTls);
80 initHandler(handler);
81 return handler;
82 }
83
84 @Override
85 protected final SslHandler newHandler(BufferAllocator alloc, String peerHost, int peerPort, boolean startTls) {
86 SslHandler handler = ctx.newHandler(alloc, peerHost, peerPort, startTls);
87 initHandler(handler);
88 return handler;
89 }
90
91 @Override
92 protected SslHandler newHandler(BufferAllocator alloc, boolean startTls, Executor executor) {
93 SslHandler handler = ctx.newHandler(alloc, startTls, executor);
94 initHandler(handler);
95 return handler;
96 }
97
98 @Override
99 protected SslHandler newHandler(BufferAllocator alloc, String peerHost, int peerPort,
100 boolean startTls, Executor executor) {
101 SslHandler handler = ctx.newHandler(alloc, peerHost, peerPort, startTls, executor);
102 initHandler(handler);
103 return handler;
104 }
105
106 @Override
107 public final SSLSessionContext sessionContext() {
108 return ctx.sessionContext();
109 }
110
111
112
113
114 protected abstract void initEngine(SSLEngine engine);
115
116
117
118
119
120 protected void initHandler(SslHandler handler) {
121 initEngine(handler.engine());
122 }
123 }