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.data.handler.ftps;
22
23 import io.netty.channel.ChannelPipeline;
24 import io.netty.channel.socket.SocketChannel;
25 import io.netty.handler.traffic.ChannelTrafficShapingHandler;
26
27 import org.waarp.ftp.core.command.FtpArgumentCode.TransferMode;
28 import org.waarp.ftp.core.command.FtpArgumentCode.TransferStructure;
29 import org.waarp.ftp.core.config.FtpConfiguration;
30 import org.waarp.ftp.core.data.handler.DataBusinessHandler;
31 import org.waarp.ftp.core.data.handler.DataNetworkHandler;
32 import org.waarp.ftp.core.data.handler.FtpDataModeCodec;
33 import org.waarp.ftp.core.data.handler.FtpDataInitializer;
34
35
36
37
38
39 public class FtpsDataInitializer extends FtpDataInitializer {
40
41
42
43
44
45
46
47
48 public FtpsDataInitializer(
49 Class<? extends DataBusinessHandler> dataBusinessHandler,
50 FtpConfiguration configuration, boolean active) {
51 super(dataBusinessHandler, configuration, active);
52 }
53
54
55
56
57
58 @Override
59 public void initChannel(SocketChannel ch) throws Exception {
60 ChannelPipeline pipeline = ch.pipeline();
61
62 pipeline.addLast(new FtpsTemporaryFirstHandler(configuration, isActive));
63
64 pipeline.addLast(FtpDataInitializer.CODEC_MODE, new FtpDataModeCodec(TransferMode.STREAM,
65 TransferStructure.FILE));
66 pipeline.addLast(FtpDataInitializer.CODEC_LIMIT, configuration
67 .getFtpInternalConfiguration()
68 .getGlobalTrafficShapingHandler());
69 ChannelTrafficShapingHandler limitChannel =
70 configuration
71 .getFtpInternalConfiguration()
72 .newChannelTrafficShapingHandler();
73 if (limitChannel != null) {
74 pipeline.addLast(FtpDataInitializer.CODEC_LIMIT + "CHANNEL", limitChannel);
75 }
76 pipeline.addLast(FtpDataInitializer.CODEC_TYPE, ftpDataTypeCodec);
77 pipeline.addLast(FtpDataInitializer.CODEC_STRUCTURE, ftpDataStructureCodec);
78
79 DataBusinessHandler newbusiness = dataBusinessHandler.newInstance();
80 DataNetworkHandler newNetworkHandler = new DataNetworkHandler(configuration, newbusiness, isActive);
81 pipeline.addLast(configuration.getFtpInternalConfiguration().getDataExecutor(),
82 FtpDataInitializer.HANDLER, newNetworkHandler);
83 }
84 }