我将apache ftpserver嵌入到我的java web应用程序中,我尝试了几种不同的方法,每次尝试通过ftp连接到服务器时,它都会说身份验证失败。我已经附加了我的代码,以及当我尝试登录时的控制台输出。有人有什么建议吗?我试着在OSX和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
最佳答案
我的问题听起来很愚蠢,但是
我可以在日志中看到
12:04:14233信息[stdout]12:04:14233信息[ftploggingfilter]已接收:通过*****
这是5颗星,你的密码长度是8:d
我可以看到你传递了一个属性文件,有没有可能你有密码在里面?
最后,你创建了一个用户管理器,你不需要把这个对象传递到某个地方?