When it invokes ftp.login(user,pwd) it starts printing password and username which is kind of sensitive to expose to. Is there a way around to not have it printing the password.
Output:
220 <xxxx>- FTP Server ready
USER <prints username here>
331 Password required for <username>
PASS <printspassword here>
230 User <username> logged in
Code:
public FTPDownloadBB(String host, String user, String pwd) throws Exception
{
FTPClient ftp ftp = new FTPClient();
ftp.addProtocolCommandListener(new PrintCommandListener(new PrintWriter(System.out)));
int reply;
ftp.connect(host);
reply = ftp.getReplyCode();
if (!FTPReply.isPositiveCompletion(reply))
{
ftp.disconnect();
throw new Exception("Exception in connecting to FTP Server");
}
ftp.login(user, pwd);
ftp.setFileType(FTP.BINARY_FILE_TYPE);
ftp.enterLocalPassiveMode();
}
You can suppress the login details while retaining protocol logging by passing an additional boolean into the PrintCommandListener like so:
According to the JavaDoc, this overloaded constructor provides the following utility:
Which we can see here in the resultant logging, where the user and password information are suppressed: