1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package goldengate.commandexec.ssl.server;
22
23 import static org.jboss.netty.channel.Channels.pipeline;
24
25 import java.util.concurrent.ExecutorService;
26 import java.util.concurrent.Executors;
27
28 import org.jboss.netty.channel.ChannelPipeline;
29 import org.jboss.netty.handler.codec.frame.DelimiterBasedFrameDecoder;
30 import org.jboss.netty.handler.codec.frame.Delimiters;
31 import org.jboss.netty.handler.codec.string.StringDecoder;
32 import org.jboss.netty.handler.codec.string.StringEncoder;
33
34 import goldengate.commandexec.server.LocalExecServerHandler;
35 import goldengate.commandexec.server.LocalExecServerPipelineFactory;
36 import goldengate.commandexec.utils.LocalExecDefaultResult;
37 import goldengate.common.crypto.ssl.GgSslContextFactory;
38
39
40
41
42
43
44
45 public class LocalExecSslServerPipelineFactory extends LocalExecServerPipelineFactory {
46
47 private final GgSslContextFactory ggSslContextFactory;
48 private final ExecutorService executor = Executors.newCachedThreadPool();
49
50 private long delay = LocalExecDefaultResult.MAXWAITPROCESS;
51
52
53
54
55
56 public LocalExecSslServerPipelineFactory(GgSslContextFactory ggSslContextFactory) {
57
58 this.ggSslContextFactory = ggSslContextFactory;
59 }
60
61
62
63
64
65
66 public LocalExecSslServerPipelineFactory(GgSslContextFactory ggSslContextFactory, long newdelay) {
67 delay = newdelay;
68 this.ggSslContextFactory = ggSslContextFactory;
69 }
70
71 public ChannelPipeline getPipeline() throws Exception {
72
73 ChannelPipeline pipeline = pipeline();
74
75
76 pipeline.addLast("ssl",
77 ggSslContextFactory.initPipelineFactory(true,
78 ggSslContextFactory.needClientAuthentication(), false, executor));
79
80 pipeline.addLast("framer", new DelimiterBasedFrameDecoder(8192,
81 Delimiters.lineDelimiter()));
82 pipeline.addLast("decoder", new StringDecoder());
83 pipeline.addLast("encoder", new StringEncoder());
84
85
86
87 pipeline.addLast("handler", new LocalExecServerHandler(this, delay));
88
89 return pipeline;
90 }
91
92
93
94
95 public void releaseResources() {
96 super.releaseResources();
97 this.executor.shutdownNow();
98 }
99
100 }