net.sf.hermesftp.usermanager.impl
Class XmlFileUserManager

java.lang.Object
  extended by net.sf.hermesftp.usermanager.impl.XmlFileUserManager
All Implemented Interfaces:
UserManager

public class XmlFileUserManager
extends java.lang.Object
implements UserManager

Author:
Lars Behnke

Constructor Summary
XmlFileUserManager()
           
 
Method Summary
 boolean authenticate(java.lang.String user, java.lang.String password, FtpSessionContext ctx)
          Validates the passed user credentials.
 void checkResourceConsumption(java.lang.String user, java.lang.String[] limitNames)
          Checks the resource consumption of the passed users.
 java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.Long>> getAllStatistics()
          Returns the logged statistics for all user and all available dates (since the server was started).
 XmlFileReader getFileReader()
          Getter method for the java bean fileReader.
 GroupDataList getGroupDataList(java.lang.String username)
          Returns object representations of all groups the passed user belongs to.
 UserData getUserData(java.lang.String username)
          Returns object representations of all registered users.
 java.util.List<UserData> getUserDataList()
          Returns object representations of all registered users.
 java.util.Map<java.lang.String,java.lang.Long> getUserStatistics(java.lang.String user)
          Returns the resource consumption statistics for a given user.
 boolean isLoaded()
          Checks if the configuration is loaded.
 void load()
          (Re)loads the configuration.
 void setFileReader(XmlFileReader fileReader)
          Setter method for the java bean fileReader.
 void updateAverageStatistics(java.lang.String user, java.lang.String avgKey, long value)
          Registers the current user's transfer rate.
 void updateIncrementalStatistics(java.lang.String user, java.lang.String limitName, long value)
          Registers the current user's resource consumption.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XmlFileUserManager

public XmlFileUserManager()
Method Detail

authenticate

public boolean authenticate(java.lang.String user,
                            java.lang.String password,
                            FtpSessionContext ctx)
                     throws FtpConfigException
Validates the passed user credentials.

Specified by:
authenticate in interface UserManager
Parameters:
user - The username.
password - The password
ctx - The context of the current session.
Returns:
True, if credentials are valid.
Throws:
FtpConfigException - Error on reading or processing a configuration file.

getGroupDataList

public GroupDataList getGroupDataList(java.lang.String username)
                               throws FtpConfigException
Returns object representations of all groups the passed user belongs to.

Specified by:
getGroupDataList in interface UserManager
Parameters:
username - The user's name.
Returns:
The group data.
Throws:
FtpConfigException - Error in configuration.

getUserDataList

public java.util.List<UserData> getUserDataList()
                                         throws FtpConfigException
Returns object representations of all registered users.

Specified by:
getUserDataList in interface UserManager
Returns:
The users.
Throws:
FtpConfigException - Error in configuration.

load

public void load()
          throws FtpConfigException
(Re)loads the configuration.

Specified by:
load in interface UserManager
Throws:
FtpConfigException - Error on reading or processing a configuration file.

getFileReader

public XmlFileReader getFileReader()
Getter method for the java bean fileReader.

Returns:
Returns the value of the java bean fileReader.

setFileReader

public void setFileReader(XmlFileReader fileReader)
Setter method for the java bean fileReader.

Parameters:
fileReader - The value of fileReader to set.

checkResourceConsumption

public void checkResourceConsumption(java.lang.String user,
                                     java.lang.String[] limitNames)
                              throws FtpQuotaException
Checks the resource consumption of the passed users. Only the passed limits are condidered.

Specified by:
checkResourceConsumption in interface UserManager
Parameters:
user - The user name.
limitNames - The resource limits to condider.
Throws:
FtpQuotaException - Thrown if at least one limit has been reached.

updateIncrementalStatistics

public void updateIncrementalStatistics(java.lang.String user,
                                        java.lang.String limitName,
                                        long value)
                                 throws FtpQuotaException
Registers the current user's resource consumption. That is, downloaded or uploaded bytes or files.

Specified by:
updateIncrementalStatistics in interface UserManager
Parameters:
user - The user name.
limitName - The name of the consumption type (resource limit).
value - The consumed resources.
Throws:
FtpQuotaException - Thrown if resource limit has been reached.

updateAverageStatistics

public void updateAverageStatistics(java.lang.String user,
                                    java.lang.String avgKey,
                                    long value)
Registers the current user's transfer rate. A mean value is calculated.

Specified by:
updateAverageStatistics in interface UserManager
Parameters:
user - The user name.
avgKey - The key of the transfer rate (resource limit).
value - The consumed resources.

getUserStatistics

public java.util.Map<java.lang.String,java.lang.Long> getUserStatistics(java.lang.String user)
Returns the resource consumption statistics for a given user.

Specified by:
getUserStatistics in interface UserManager
Parameters:
user - The user.
Returns:
The statistics.

getAllStatistics

public java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.Long>> getAllStatistics()
Returns the logged statistics for all user and all available dates (since the server was started).

Specified by:
getAllStatistics in interface UserManager
Returns:
The statistics.

isLoaded

public boolean isLoaded()
                 throws FtpConfigException
Checks if the configuration is loaded.

Specified by:
isLoaded in interface UserManager
Returns:
True, if configuration has already been loaded.
Throws:
FtpConfigException - Error on reading or processing a configuration file.

getUserData

public UserData getUserData(java.lang.String username)
                     throws FtpConfigException
Returns object representations of all registered users.

Specified by:
getUserData in interface UserManager
Parameters:
username - The user's name.
Returns:
The user data.
Throws:
FtpConfigException - Error in configuration.


Copyright © 2005-2007 Lars Behnke. All Rights Reserved.