*/
public void connect(String host, Authentication auth)
throws ProtocolException {
// server cannot be null
if (host == null) {
throw new ProtocolException("Tried to connect to server == NULL");
}
try {
ftp.connect(host);
ftp.enterLocalPassiveMode();
} catch (Exception e) {
throw new ProtocolException("Failed to connect to server : "
+ e.getMessage());
}
try {
// try logging in
if (!ftp.login(auth.getUser(), auth.getPass())) {
throw new ProtocolException("Failed logging into host " + host
+ " as user " + auth.getUser());
}
// set file type to binary
ftp.setFileType(FTPClient.BINARY_FILE_TYPE);
homeDir = ftp.printWorkingDirectory();
} catch (Exception e) {
// login failed
throw new ProtocolException("Exception thrown while logging into host "
+ host + " as user " + auth.getUser());
}
}