[ 
https://issues.apache.org/jira/browse/FTPSERVER-450?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13798974#comment-13798974
 ] 

Aizaz AZ edited comment on FTPSERVER-450 at 10/18/13 10:10 AM:
---------------------------------------------------------------

Yes exactly. It loads if from class path and reads it but when it comes to save 
it doesn't load it from class path but check the "userDataFile" class variable 
and of course it is not initialized and it goes back without writing the file. 
You can check it just save users and it will never save them on properties file.

There are two things:
1) if "userDataFile" is null see if it exists in class path then initialize it
2) Good approach will be when user calls {code} setFile {code} on factory and 
then calls {code} createFactory {code} then it should initialize it in 
constructor as I did.


{code}
package org.apache.ftpserver.usermanager.impl.PropertiesUserManager
 /**
     * Internal constructor, do not use directly. Use {@link 
PropertiesUserManagerFactory} instead.
     */
    public PropertiesUserManager(PasswordEncryptor passwordEncryptor,
            File userDataFile, String adminName) {
        super(adminName, passwordEncryptor);
        
        this.userDataFile = userDataFile;
        
        loadFromFile(userDataFile);
    }
{code}

I have also attached file in which I have fixed the issue you can see the svn 
compare of this file with current version.

Regards,
AZ


was (Author: az_):
Yes exactly. It loads if from class path and reads it but when it comes to save 
it doesn't load it from class path but check the "userDataFile" class variable 
and of course it is not initialized and it goes back without writing the file. 
You can check it just save users and it will never save them on properties file.

There are two things:
1) if "userDataFile" is null see if it exists in class path then initialize it
2) Good approach will be when user calls {code} setFile {code} on factory and 
then calls {code} createFactory {code} then it should initialize it in 
constructor as I did.

> PropertiesUserManager userDataFile is always NULL. 
> ---------------------------------------------------
>
>                 Key: FTPSERVER-450
>                 URL: https://issues.apache.org/jira/browse/FTPSERVER-450
>             Project: FtpServer
>          Issue Type: Bug
>          Components: Core
>    Affects Versions: 1.0.6
>         Environment: JDK 6
> Windows 7 64 BIT
>            Reporter: Aizaz AZ
>            Priority: Blocker
>         Attachments: FTPSERVER-450.patch, PropertiesUserManager.java
>
>
> PropertiesUserManager userDataFile is always NULL. Because you didn't set  
> your class variable value equal to what you get in constructor when 
> PropertiesUserManagerFactory calls your constructor new 
> PropertiesUserManager(passwordEncryptor, userDataFile, adminName); of 
> PropertiesUserManager,just need to do below super this.userDataFile = 
> userDataFile; and issue is fixed
> PropertiesUserManagerFactory propUserManagerFactory = new 
> PropertiesUserManagerFactory();
>               propUserManagerFactory.setFile(new File("ftpusers.properties"));
>               propUserManagerFactory.setPasswordEncryptor(new 
> ClearTextPasswordEncryptor());
>               mUserManager = (PropertiesUserManager) 
> propUserManagerFactory.createUserManager();
>               mFTPServerFactory.setUserManager(mUserManager);
> Set file has no effect because factory will call your constructor 
> PropertiesUserManager(passwordEncryptor, userDataFile,
>                     adminName)
> and you didn't set this.userDataFile = userDataFile;
> complete
>   public PropertiesUserManager(PasswordEncryptor passwordEncryptor,
>             File userDataFile, String adminName) {
>         super(adminName, passwordEncryptor);
>         
>         this.userDataFile = userDataFile;
>         
>         loadFromFile(userDataFile);
>     }
> Issue fixed



--
This message was sent by Atlassian JIRA
(v6.1#6144)

Reply via email to