I am trying to set up a ftp server using apache ftp server
http://mina.apache.org/ftpserver/
I want to use a file based management, and have only one user that can login.
At first, I create the file this way :
String username = "ftp";
String password = "ftp";
String ftproot = "data";
// prepares the user manager
PropertiesUserManagerFactory userManagerFactory = new PropertiesUserManagerFactory();
userManagerFactory.setFile(new File(propFile));
userManagerFactory.setPasswordEncryptor(new SaltedPasswordEncryptor());
UserManager um = userManagerFactory.createUserManager();
// set up my user
BaseUser user = new BaseUser();
user.setName(username);
user.setPassword(password);
user.setHomeDirectory(ftproot);
List<Authority> authorities = new ArrayList<Authority>();
authorities.add(new WritePermission());
user.setAuthorities(authorities);
um.save(user);
// adds the user
serverFactory.setUserManager(um);
The file seems ok, and the ftp server works fine if I go through these steps at each startup.
What I would like is to be able to set this file once, and then just load the property file so that the user/password can be removed from the code.
I try for some time but can’t get anything this way to run.
Any help would be greatly appreciated.
Thank you by advance !
Ok, once again the “tell it to your teddy bear” method worked just fine.
I found the solution two minutes after posting.
Instead of going through the all configuration dance, one just need to set the user manager.
Here is my whole load the config method.
Hope this will help someone.
I think the apache ftp server would really need some more documentation though :S.