1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.commons.net.ftp;
19
20 import java.io.IOException;
21 import java.net.InetAddress;
22 import java.net.Socket;
23 import java.net.UnknownHostException;
24
25 import javax.net.SocketFactory;
26 import javax.net.ssl.SSLContext;
27
28
29
30
31
32
33
34 public class FTPSSocketFactory extends SocketFactory {
35
36 private final SSLContext context;
37
38
39
40
41
42
43 public FTPSSocketFactory(final SSLContext context) {
44 this.context = context;
45 }
46
47
48
49
50
51
52
53 @Deprecated
54 public java.net.ServerSocket createServerSocket(final int port) throws IOException {
55 return init(context.getServerSocketFactory().createServerSocket(port));
56 }
57
58
59
60
61
62
63
64
65 @Deprecated
66 public java.net.ServerSocket createServerSocket(final int port, final int backlog) throws IOException {
67 return init(context.getServerSocketFactory().createServerSocket(port, backlog));
68 }
69
70
71
72
73
74
75
76
77
78 @Deprecated
79 public java.net.ServerSocket createServerSocket(final int port, final int backlog, final InetAddress ifAddress) throws IOException {
80 return init(context.getServerSocketFactory().createServerSocket(port, backlog, ifAddress));
81 }
82
83
84 @Override
85 public Socket createSocket() throws IOException {
86 return context.getSocketFactory().createSocket();
87 }
88
89 @Override
90 public Socket createSocket(final InetAddress address, final int port) throws IOException {
91 return context.getSocketFactory().createSocket(address, port);
92 }
93
94
95
96 @Override
97 public Socket createSocket(final InetAddress address, final int port, final InetAddress localAddress, final int localPort) throws IOException {
98 return context.getSocketFactory().createSocket(address, port, localAddress, localPort);
99 }
100
101 @Override
102 public Socket createSocket(final String address, final int port) throws UnknownHostException, IOException {
103 return context.getSocketFactory().createSocket(address, port);
104 }
105
106 @Override
107 public Socket createSocket(final String address, final int port, final InetAddress localAddress, final int localPort)
108 throws UnknownHostException, IOException {
109 return context.getSocketFactory().createSocket(address, port, localAddress, localPort);
110 }
111
112
113
114
115
116
117
118 @Deprecated
119 public java.net.ServerSocket init(final java.net.ServerSocket socket) throws IOException {
120 ((javax.net.ssl.SSLServerSocket) socket).setUseClientMode(true);
121 return socket;
122 }
123
124 }