forked from pquiring/javaforce
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFTPS.java
More file actions
45 lines (39 loc) · 1.11 KB
/
Copy pathFTPS.java
File metadata and controls
45 lines (39 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package javaforce;
import java.io.*;
import java.net.*;
/** FTPS (Secure FTP).
*
* @author pquiring
*/
public class FTPS extends FTP {
public boolean connect(String host) throws Exception {
return connect(host, 990);
}
public boolean connect(String host, int port) throws Exception {
active = true;
s = new Socket(host, port);
s = JF.connectSSL(s, KeyMgmt.getDefaultClient());
if (s == null) {
throw new Exception("SSL Upgrade failed");
}
is = s.getInputStream();
br = new BufferedReader(new InputStreamReader(is));
os = s.getOutputStream();
this.host = host;
reader = new Reader();
reader.start();
wait4Response();
if (getLastResponse().startsWith("220")) {
return true;
}
disconnect(); //not valid FTP site
return false;
}
protected ServerSocket createServerSocket() throws Exception {
return JF.createServerSocketSSL(KeyMgmt.getDefaultClient());
}
protected Socket connectData(String host, int port) throws Exception {
Socket s = new Socket(host, port);
return JF.connectSSL(s, KeyMgmt.getDefaultClient());
}
}