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
25
26
27
28 public abstract class DelegatingSslContext extends SslContext {
29
30 private final SslContext ctx;
31
32 protected DelegatingSslContext(SslContext ctx) {
33 this.ctx = ObjectUtil.checkNotNull(ctx, "ctx");
34 }
35
36 @Override
37 public final boolean isClient() {
38 return ctx.isClient();
39 }
40
41 @Override
42 public final List<String> cipherSuites() {
43 return ctx.cipherSuites();
44 }
45
46 @Override
47 public final long sessionCacheSize() {
48 return ctx.sessionCacheSize();
49 }
50
51 @Override
52 public final long sessionTimeout() {
53 return ctx.sessionTimeout();
54 }
55
56 @Override
57 public final ApplicationProtocolNegotiator applicationProtocolNegotiator() {
58 return ctx.applicationProtocolNegotiator();
59 }
60
61 @Override
62 public final SSLEngine newEngine(ByteBufAllocator alloc) {
63 SSLEngine engine = ctx.newEngine(alloc);
64 initEngine(engine);
65 return engine;
66 }
67
68 @Override
69 public final SSLEngine newEngine(ByteBufAllocator alloc, String peerHost, int peerPort) {
70 SSLEngine engine = ctx.newEngine(alloc, peerHost, peerPort);
71 initEngine(engine);
72 return engine;
73 }
74
75 @Override
76 protected final SslHandler newHandler(ByteBufAllocator alloc, boolean startTls) {
77 SslHandler handler = ctx.newHandler(alloc, startTls);
78 initHandler(handler);
79 return handler;
80 }
81
82 @Override
83 protected final SslHandler newHandler(ByteBufAllocator alloc, String peerHost, int peerPort, boolean startTls) {
84 SslHandler handler = ctx.newHandler(alloc, peerHost, peerPort, startTls);
85 initHandler(handler);
86 return handler;
87 }
88
89 @Override
90 public final SSLSessionContext sessionContext() {
91 return ctx.sessionContext();
92 }
93
94
95
96
97 protected abstract void initEngine(SSLEngine engine);
98
99
100
101
102
103 protected void initHandler(SslHandler handler) {
104 initEngine(handler.engine());
105 }
106 }