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 public FTPSSocketFactory(SSLContext context) {
39 this.context = context;
40 }
41
42
43 @Override
44 public Socket createSocket() throws IOException{
45 return this.context.getSocketFactory().createSocket();
46 }
47
48 @Override
49 public Socket createSocket(String address, int port) throws UnknownHostException, IOException {
50 return this.context.getSocketFactory().createSocket(address, port);
51 }
52
53 @Override
54 public Socket createSocket(InetAddress address, int port) throws IOException {
55 return this.context.getSocketFactory().createSocket(address, port);
56 }
57
58 @Override
59 public Socket createSocket(String address, int port, InetAddress localAddress, int localPort) throws UnknownHostException, IOException {
60 return this.context.getSocketFactory().createSocket(address, port, localAddress, localPort);
61 }
62
63 @Override
64 public Socket createSocket(InetAddress address, int port, InetAddress localAddress, int localPort) throws IOException {
65 return this.context.getSocketFactory().createSocket(address, port, localAddress, localPort);
66 }
67
68
69
70
71
72 @Deprecated
73 public java.net.ServerSocket createServerSocket(int port) throws IOException {
74 return this.init(this.context.getServerSocketFactory().createServerSocket(port));
75 }
76
77
78 @Deprecated
79 public java.net.ServerSocket createServerSocket(int port, int backlog) throws IOException {
80 return this.init(this.context.getServerSocketFactory().createServerSocket(port, backlog));
81 }
82
83
84 @Deprecated
85 public java.net.ServerSocket createServerSocket(int port, int backlog, InetAddress ifAddress) throws IOException {
86 return this.init(this.context.getServerSocketFactory().createServerSocket(port, backlog, ifAddress));
87 }
88
89
90 @SuppressWarnings("unused")
91 @Deprecated
92 public java.net.ServerSocket init(java.net.ServerSocket socket) throws IOException {
93 ((javax.net.ssl.SSLServerSocket) socket).setUseClientMode(true);
94 return socket;
95 }
96
97 }