1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package openr66.protocol.http.adminssl;
22
23
24 import java.util.concurrent.ExecutorService;
25
26 import openr66.protocol.configuration.Configuration;
27
28 import org.jboss.netty.channel.ChannelPipeline;
29 import org.jboss.netty.channel.ChannelPipelineFactory;
30 import org.jboss.netty.channel.Channels;
31 import org.jboss.netty.handler.codec.http.HttpChunkAggregator;
32 import org.jboss.netty.handler.codec.http.HttpContentCompressor;
33 import org.jboss.netty.handler.codec.http.HttpRequestDecoder;
34 import org.jboss.netty.handler.codec.http.HttpResponseEncoder;
35 import org.jboss.netty.handler.execution.ExecutionHandler;
36
37
38
39
40
41 public class HttpSslPipelineFactory implements ChannelPipelineFactory {
42 private final ExecutorService executorService;
43 public boolean useHttpCompression = false;
44 public boolean enableRenegotiation = false;
45
46 public HttpSslPipelineFactory(boolean useHttpCompression,
47 boolean enableRenegotiation,
48 ExecutorService executor) {
49 this.useHttpCompression = useHttpCompression;
50 this.enableRenegotiation = enableRenegotiation;
51 this.executorService = executor;
52 }
53
54 @Override
55 public ChannelPipeline getPipeline() {
56 final ChannelPipeline pipeline = Channels.pipeline();
57
58 pipeline.addLast("ssl",
59 Configuration.ggSslContextFactory.initPipelineFactory(true,
60 false,
61 enableRenegotiation, executorService));
62
63 pipeline.addLast("decoder", new HttpRequestDecoder());
64 pipeline.addLast("aggregator", new HttpChunkAggregator(1048576));
65 pipeline.addLast("encoder", new HttpResponseEncoder());
66 pipeline.addLast("pipelineExecutor", new ExecutionHandler(
67 Configuration.configuration.getHttpPipelineExecutor()));
68 if (useHttpCompression) {
69 pipeline.addLast("deflater", new HttpContentCompressor());
70 }
71 pipeline.addLast("handler", new HttpSslHandler());
72 return pipeline;
73 }
74 }