I'm trying to use multiple user property files for an application I'm
building with ftpServer embedded. The basic concept is the central
application runs ftpServer and loads up default users from a file, then
'plugin' applications can connect and add their own users. I can do this
through the API without much problem but ideally I would like the 'plugin'
application to be able to have it's own properties file which it passes to
the main application.
I have tried implementing this by manually reading in a properties file as
follows:
PropertiesUserManagerFactory userManagerFactory = new
PropertiesUserManagerFactory();
userManagerFactory.setFile(userFile); //userFile - user properties
file
UserManager um = userManagerFactory.createUserManager();
String[] users = um.getAllUserNames();
List<User> userBeans = new ArrayList<User>();
for (int i=0; i<users.length; i++){
userBeans.add(um.getUserByName(users[i]));
System.out.println("Password: " +
um.getUserByName(users[i]).getPassword());
}
The UserManager.getUserByName(name) doesn't seem to populate the encrypted
password in the User bean, any reason for this? I can populate the password
by reading the property in myself but then I'm presented with another
problem. Once I have a list of users from the file, I try and save them
using UserManager.save(user) but the UserManager.getPassword() method
re-encrypts the password (it assums you are passing a plaintext password).
Is there no way to save a user with an already encrypted password? I can't
override the getPassword() method as it is private.
Any suggestions welcome.
Cheers
O