1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package org.waarp.ftp.core.control.ftps;
22
23 import io.netty.channel.ChannelPipeline;
24 import io.netty.channel.socket.SocketChannel;
25 import io.netty.handler.codec.DelimiterBasedFrameDecoder;
26 import io.netty.handler.ssl.SslHandler;
27 import io.netty.util.concurrent.EventExecutorGroup;
28
29 import org.waarp.common.crypto.ssl.WaarpSecureKeyStore;
30 import org.waarp.common.crypto.ssl.WaarpSslContextFactory;
31 import org.waarp.ftp.core.config.FtpConfiguration;
32 import org.waarp.ftp.core.control.BusinessHandler;
33 import org.waarp.ftp.core.control.FtpInitializer;
34 import org.waarp.ftp.core.session.FtpSession;
35
36
37
38
39
40 public class FtpsInitializer extends FtpInitializer {
41
42 public static WaarpSslContextFactory waarpSslContextFactory;
43 public static WaarpSecureKeyStore waarpSecureKeyStore;
44
45
46
47
48
49
50
51 public FtpsInitializer(Class<? extends BusinessHandler> businessHandler,
52 FtpConfiguration configuration) {
53 super(businessHandler, configuration);
54 }
55
56
57
58
59
60 @Override
61 public void initChannel(SocketChannel ch) throws Exception {
62 ChannelPipeline pipeline = ch.pipeline();
63
64 SslHandler handler = waarpSslContextFactory.initInitializer(true,
65 waarpSslContextFactory.needClientAuthentication());
66 pipeline.addLast("SSL", handler);
67
68 pipeline.addLast("framer", new DelimiterBasedFrameDecoder(8192, delimiter));
69 pipeline.addLast("decoder", ftpControlStringDecoder);
70 pipeline.addLast("encoder", ftpControlStringEncoder);
71
72
73 EventExecutorGroup executorGroup = configuration.getFtpInternalConfiguration().getExecutor();
74
75 BusinessHandler newbusiness = businessHandler.newInstance();
76 SslNetworkHandler newNetworkHandler = new SslNetworkHandler(new FtpSession(
77 configuration, newbusiness));
78 pipeline.addLast(executorGroup, "handler", newNetworkHandler);
79 }
80 }