I am new to FTP. I have a problem with my FTPSClient program. Only control channel is encrypted. I need both the control and data channel to be encrypted.
public boolean login(String usrName,char[] passwd){
try {
ftpClient = new FTPSClient(protocol,false); // SSL FTP
ftpClient.connect(strHost);
int reply = ftpClient.getReplyCode(); // After connection attempt, you should check the reply code to verify success.
if (!FTPReply.isPositiveCompletion(reply)) {
ftpClient.disconnect();
log.error("FTP server refused connection.");
return false;
}
ftpClient.setBufferSize(1000);
if (!ftpClient.login(strUsrName,new String(passwd))){
ftpClient.logout();
bLoginStatus = false;
return false;
}
else
bLoginStatus = true;
if(iMode == LOCAL_ACTIVE_MODE)
ftpClient.enterLocalActiveMode();
else if(iMode == LOCAL_PASSIVE_MODE)
ftpClient.enterLocalPassiveMode();
} catch (SocketException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch(Throwable t){
t.printStackTrace();
}finally {
if (bLoginStatus == false && ftpClient.isConnected()){
try{
ftpClient.disconnect();
}
catch (IOException f){
// do nothing
}
}
}
if(ftpClient.isConnected())
return true;
else
return false;
}