org.apache.ftpserver.usermanager.impl
Class PropertiesUserManager

java.lang.Object
  extended by org.apache.ftpserver.usermanager.impl.AbstractUserManager
      extended by org.apache.ftpserver.usermanager.impl.PropertiesUserManager
All Implemented Interfaces:
UserManager

public class PropertiesUserManager
extends AbstractUserManager

Internal class, do not use directly.

Properties file based UserManager implementation. We use user.properties file to store user data.

The file will use the following properties for storing users:

Property Documentation
ftpserver.user.{username}.homedirectory Path to the home directory for the user, based on the file system implementation used
ftpserver.user.{username}.userpassword The password for the user. Can be in clear text, MD5 hash or salted SHA hash based on the configuration on the user manager
ftpserver.user.{username}.enableflag true if the user is enabled, false otherwise
ftpserver.user.{username}.writepermission true if the user is allowed to upload files and create directories, false otherwise
ftpserver.user.{username}.idletime The number of seconds the user is allowed to be idle before disconnected. 0 disables the idle timeout
ftpserver.user.{username}.maxloginnumber The maximum number of concurrent logins by the user. 0 disables the check.
ftpserver.user.{username}.maxloginperip The maximum number of concurrent logins from the same IP address by the user. 0 disables the check.
ftpserver.user.{username}.uploadrate The maximum number of bytes per second the user is allowed to upload files. 0 disables the check.
ftpserver.user.{username}.downloadrate The maximum number of bytes per second the user is allowed to download files. 0 disables the check.

Example:

 ftpserver.user.admin.homedirectory=/ftproot
 ftpserver.user.admin.userpassword=admin
 ftpserver.user.admin.enableflag=true
 ftpserver.user.admin.writepermission=true
 ftpserver.user.admin.idletime=0
 ftpserver.user.admin.maxloginnumber=0
 ftpserver.user.admin.maxloginperip=0
 ftpserver.user.admin.uploadrate=0
 ftpserver.user.admin.downloadrate=0
 

Author:
Apache MINA Project

Field Summary
 
Fields inherited from class org.apache.ftpserver.usermanager.impl.AbstractUserManager
ATTR_ENABLE, ATTR_HOME, ATTR_LOGIN, ATTR_MAX_DOWNLOAD_RATE, ATTR_MAX_IDLE_TIME, ATTR_MAX_LOGIN_NUMBER, ATTR_MAX_LOGIN_PER_IP, ATTR_MAX_UPLOAD_RATE, ATTR_PASSWORD, ATTR_WRITE_PERM
 
Constructor Summary
PropertiesUserManager(PasswordEncryptor passwordEncryptor, File userDataFile, String adminName)
          Internal constructor, do not use directly.
PropertiesUserManager(PasswordEncryptor passwordEncryptor, URL userDataPath, String adminName)
          Internal constructor, do not use directly.
 
Method Summary
 User authenticate(Authentication authentication)
          User authenticate method
 void delete(String usrName)
          Delete an user.
 void dispose()
          Close the user manager - remove existing entries.
 boolean doesExist(String name)
          User existance check
 String[] getAllUserNames()
          Get all user names.
 File getFile()
          Retrive the file backing this user manager
 User getUserByName(String userName)
          Load user data.
 void refresh()
          Reloads the contents of the user.properties file.
 void save(User usr)
          Save user data.
 
Methods inherited from class org.apache.ftpserver.usermanager.impl.AbstractUserManager
getAdminName, getPasswordEncryptor, isAdmin
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PropertiesUserManager

public PropertiesUserManager(PasswordEncryptor passwordEncryptor,
                             File userDataFile,
                             String adminName)
Internal constructor, do not use directly. Use PropertiesUserManagerFactory instead.


PropertiesUserManager

public PropertiesUserManager(PasswordEncryptor passwordEncryptor,
                             URL userDataPath,
                             String adminName)
Internal constructor, do not use directly. Use PropertiesUserManagerFactory instead.

Method Detail

refresh

public void refresh()
Reloads the contents of the user.properties file. This allows any manual modifications to the file to be recognised by the running server.


getFile

public File getFile()
Retrive the file backing this user manager

Returns:
The file

save

public void save(User usr)
          throws FtpException
Save user data. Store the properties.

Parameters:
usr - the Uset to save
Throws:
FtpException - when the UserManager can't fulfill the request.

delete

public void delete(String usrName)
            throws FtpException
Delete an user. Removes all this user entries from the properties. After removing the corresponding from the properties, save the data.

Parameters:
usrName - The name of the User to delete
Throws:
FtpException - when the UserManager can't fulfill the request.

getAllUserNames

public String[] getAllUserNames()
Get all user names.

Returns:
an array of username strings, note that the result should never be null, if there is no users the result is an empty array.

getUserByName

public User getUserByName(String userName)
Load user data.

Parameters:
userName - the name to search for.
Returns:
the user with the specified name, or null if a such user does not exist.

doesExist

public boolean doesExist(String name)
User existance check

Parameters:
name - the name of the user to check.
Returns:
true if the user exist, false otherwise.

authenticate

public User authenticate(Authentication authentication)
                  throws AuthenticationFailedException
User authenticate method

Parameters:
authentication - The Authentication that proves the users identity
Returns:
the authenticated account.
Throws:
AuthenticationFailedException

dispose

public void dispose()
Close the user manager - remove existing entries.



Copyright © 2003-2011 Apache Software Foundation. All Rights Reserved.