From 27be3324d05e272067ffd8cca8b1c1b2527c2ebe Mon Sep 17 00:00:00 2001 From: Javier Montalvo Orus Date: Tue, 14 Nov 2006 14:28:36 +0000 Subject: [PATCH] Fixing 164009 - FTP connection shows as connected when login fails Fixing 164306 - [ftp] FTP console shows plaintext passwords --- .../rse/services/files/ftp/FTPService.java | 36 ++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/rse/plugins/org.eclipse.rse.services.files.ftp/src/org/eclipse/rse/services/files/ftp/FTPService.java b/rse/plugins/org.eclipse.rse.services.files.ftp/src/org/eclipse/rse/services/files/ftp/FTPService.java index 422eba64dd3..8b2fabfe16f 100644 --- a/rse/plugins/org.eclipse.rse.services.files.ftp/src/org/eclipse/rse/services/files/ftp/FTPService.java +++ b/rse/plugins/org.eclipse.rse.services.files.ftp/src/org/eclipse/rse/services/files/ftp/FTPService.java @@ -28,6 +28,8 @@ * Javier Montalvo Orus (Symbian) - Fixing 163264 - FTP Only can not delete first subfolder * Michael Scharf (Wind River) - Fix 164223 - Wrong call for setting binary transfer mode * Martin Oberhuber (Wind River) - Add Javadoc for getFTPClient(), modify move() to use single connected session + * Javier Montalvo Orus (Symbian) - Fixing 164009 - FTP connection shows as connected when login fails + * Javier Montalvo Orus (Symbian) - Fixing 164306 - [ftp] FTP console shows plaintext passwords ********************************************************************************/ package org.eclipse.rse.services.files.ftp; @@ -138,7 +140,39 @@ public class FTPService extends AbstractFileService implements IFileService, IFT } else { _ftpClient.connect(_hostName, _portNumber); } - _ftpClient.login(_userId, _password); + + int userReply = _ftpClient.user(_userId); + + if(FTPReply.isPositiveIntermediate(userReply)) + { + //intermediate response, provide password and hide it from the console + + String newLine = System.getProperty("line.separator"); //$NON-NLS-1$ + + _ftpClient.registerSpyStream(null); + + _ftpLoggingOutputStream.write(("PASS ******"+newLine).getBytes()); //$NON-NLS-1$ + int passReply = _ftpClient.pass(_password); + _ftpLoggingOutputStream.write((_ftpClient.getReplyString()+newLine).getBytes()); + + if(_ftpLoggingOutputStream!=null) + { + _ftpClient.registerSpyStream(_ftpLoggingOutputStream); + } + + if(!FTPReply.isPositiveCompletion(passReply)) + { + String lastMessage = _ftpClient.getReplyString(); + disconnect(); + throw new Exception(lastMessage); + } + } + else if(!FTPReply.isPositiveCompletion(userReply)) + { + String lastMessage = _ftpClient.getReplyString(); + disconnect(); + throw new Exception(lastMessage); + } _userHome = _ftpClient.printWorkingDirectory(); }