When a client and server computer want to exchange secrets, they need to negotiate too, public keys, encryption methods, ports and more needed.
import com.jscape.inet.ftp.*;
import com.jscape.inet.ftps.*;
import java.io.*;
import java.util.Enumeration;
public class SecureUpload extends FtpAdapter {
private String hostname;
private String username;
private String password;
// perform multiple file upload
public void doUpload(String hostname, String username, String password) throws FtpException {
Ftps ftp = new Ftps(hostname,username,password);
//capture Ftps related events
ftp.addFtpListener(this);
// Set the connection type. Explicit is Ftps.AUTH_TLS.
// Implicit (which is deprecated) is Ftps.IMPLICIT_SSL
ftp.setConnectionType(Ftps.AUTH_TLS);
ftp.connect();
ftp.setBinary();
ftp.mupload(".*\\.gif");
ftp.disconnect();
}
public static void main(String[] args) {
String hostname = "ftp.somewebsite.com";
String username = "IFeelSecure";
String password = "zip1a2dee3doo4dah";
try {
SecureUpload theUploader = new SecureUpload();
theUploader.doUpload(hostname,username,password);
}
catch(Exception e) {
e.printStackTrace();
}
}
}