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.client;
22
23 import java.util.concurrent.ExecutorService;
24 import java.util.concurrent.Executors;
25
26 import org.jboss.netty.channel.ChannelPipeline;
27 import org.jboss.netty.channel.Channels;
28 import org.jboss.netty.handler.codec.frame.DelimiterBasedFrameDecoder;
29 import org.jboss.netty.handler.codec.frame.Delimiters;
30 import org.jboss.netty.handler.codec.string.StringDecoder;
31 import org.jboss.netty.handler.codec.string.StringEncoder;
32
33 import goldengate.commandexec.client.LocalExecClientHandler;
34 import goldengate.commandexec.client.LocalExecClientPipelineFactory;
35 import goldengate.common.crypto.ssl.GgSslContextFactory;
36
37
38
39
40
41
42
43
44 public class LocalExecSslClientPipelineFactory extends LocalExecClientPipelineFactory {
45
46 private final GgSslContextFactory ggSslContextFactory;
47 private final ExecutorService executor = Executors.newCachedThreadPool();
48
49 public LocalExecSslClientPipelineFactory(GgSslContextFactory ggSslContextFactory) {
50 this.ggSslContextFactory = ggSslContextFactory;
51 }
52
53 public ChannelPipeline getPipeline() throws Exception {
54
55 ChannelPipeline pipeline = Channels.pipeline();
56
57
58 pipeline.addLast("ssl",
59 ggSslContextFactory.initPipelineFactory(false,
60 ggSslContextFactory.needClientAuthentication(), false, executor));
61
62 pipeline.addLast("framer", new DelimiterBasedFrameDecoder(8192,
63 Delimiters.lineDelimiter()));
64 pipeline.addLast("decoder", new StringDecoder());
65 pipeline.addLast("encoder", new StringEncoder());
66
67
68 LocalExecClientHandler localExecClientHandler = new LocalExecClientHandler(this);
69 pipeline.addLast("handler", localExecClientHandler);
70
71 return pipeline;
72 }
73
74
75
76 public void releaseResources() {
77 super.releaseResources();
78 this.executor.shutdownNow();
79 }
80
81 }