views:

19

answers:

1

Hi, I am embedding the apache ftpserver in my java web app, I have tried a couple different things and everytime I try to connect to the server via FTP, it says Authentication failed. I have attached my code, and also the console output when I try to do the logging in. Does anyone have any suggestions? I tried running this on OS X and Centos Linux.

PropertiesUserManagerFactory userManagerFactory = new PropertiesUserManagerFactory();
userManagerFactory.setFile(new File("/ftpdata/myusers.properties"));
//userManagerFactory.setPasswordEncryptor(new SaltedPasswordEncryptor());
userManagerFactory.setPasswordEncryptor(new ClearTextPasswordEncryptor());
UserManager um = userManagerFactory.createUserManager();
BaseUser user = new BaseUser();
user.setName("andy");
user.setPassword("12345678");
user.setHomeDirectory("/ftpdata/");
um.save(user);

FtpServerFactory serverFactory = new FtpServerFactory();
ListenerFactory factory = new ListenerFactory();
factory.setPort(2225);
serverFactory.addListener("default", factory.createListener());
FtpServer server = serverFactory.createServer();
server.start();








12:03:28,768 INFO  [STDOUT] 12:03:28,768 INFO  [DefaultFtpServer] FTP server started
12:04:14,200 INFO  [STDOUT] 12:04:14,200 INFO  [FtpLoggingFilter] CREATED
12:04:14,208 INFO  [STDOUT] 12:04:14,208 INFO  [FtpLoggingFilter] OPENED
12:04:14,228 INFO  [STDOUT] 12:04:14,228 INFO  [FtpLoggingFilter] RECEIVED: USER andy
12:04:14,230 INFO  [STDOUT] 12:04:14,230 INFO  [FtpLoggingFilter] SENT: 220 Service ready for new user.
12:04:14,232 INFO  [STDOUT] 12:04:14,232 INFO  [FtpLoggingFilter] SENT: 331 User name okay, need password for andy.
12:04:14,233 INFO  [STDOUT] 12:04:14,233 INFO  [FtpLoggingFilter] RECEIVED: PASS *****
12:04:14,236 INFO  [STDOUT] 12:04:14,236 WARN  [PASS] User failed to log in
12:04:14,736 INFO  [STDOUT] 12:04:14,736 WARN  [PASS] Login failure - andy
12:04:14,740 INFO  [STDOUT] 12:04:14,740 INFO  [FtpLoggingFilter] RECEIVED: QUIT
12:04:14,746 INFO  [STDOUT] 12:04:14,746 INFO  [FtpLoggingFilter] SENT: 530 Authentication failed.
12:04:14,746 INFO  [STDOUT] 12:04:14,746 INFO  [FtpLoggingFilter] SENT: 221 Goodbye.
12:04:14,747 INFO  [STDOUT] 12:04:14,746 INFO  [FtpLoggingFilter] CLOSED
A: 

my question may sound stupid but i can see in the log

12:04:14,233 INFO [STDOUT] 12:04:14,233 INFO [FtpLoggingFilter] RECEIVED: PASS *

These are 5 stars , your password length is 8 :D

I can see that you pass a property file, is there any chance that you have a password in there?

At last, you create a UserManager, you dont have to pass this object somewhere?

Thomas Sofras
Yes, you are right. Thanks for looking over my code. The solution was to pass the usermanager object to the server factory:I added this line: serverFactory.setUserManager(um);before FtpServer server = serverFactory.createServer();
Andy
happy about this :D
Thomas Sofras