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