org.apache.james.userrepository
Class UsersFileRepository

java.lang.Object
  extended by org.apache.avalon.framework.logger.AbstractLogEnabled
      extended by org.apache.james.userrepository.UsersFileRepository
All Implemented Interfaces:
org.apache.avalon.framework.activity.Initializable, org.apache.avalon.framework.configuration.Configurable, org.apache.avalon.framework.logger.LogEnabled, org.apache.avalon.framework.service.Serviceable, UsersRepository

public class UsersFileRepository
extends org.apache.avalon.framework.logger.AbstractLogEnabled
implements UsersRepository, org.apache.avalon.framework.configuration.Configurable, org.apache.avalon.framework.service.Serviceable, org.apache.avalon.framework.activity.Initializable

Implementation of a Repository to store users on the File System. Requires a configuration element in the .conf.xml file of the form: <repository destinationURL="file://path-to-root-dir-for-repository" type="USERS" model="SYNCHRONOUS"/> Requires a logger called UsersRepository.

Version:
CVS $Revision: 407988 $

Field Summary
protected static boolean DEEP_DEBUG
          Whether 'deep debugging' is turned on.
 
Fields inherited from interface org.apache.james.services.UsersRepository
ROLE, USER
 
Constructor Summary
UsersFileRepository()
           
 
Method Summary
 void addUser(java.lang.String name, java.lang.Object attributes)
          Adds a user to the repository with the specified attributes.
 boolean addUser(java.lang.String username, java.lang.String password)
          Adds a user to the repository with the specified password
 boolean addUser(User user)
          Update the repository with the specified user object.
 void configure(org.apache.avalon.framework.configuration.Configuration configuration)
           
 boolean contains(java.lang.String name)
          Returns whether or not this user is in the repository
 boolean containsCaseInsensitive(java.lang.String name)
          Returns whether or not this user is in the repository.
 int countUsers()
          Returns a count of the users in the repository.
 java.lang.String getRealName(java.lang.String name)
          Returns the user name of the user matching name on an equalsIgnoreCase basis.
 User getUserByName(java.lang.String name)
          Get the user object with the specified user name.
 User getUserByNameCaseInsensitive(java.lang.String name)
          Get the user object with the specified user name.
 void initialize()
           
 java.util.Iterator list()
          List users in repository.
 void removeUser(java.lang.String name)
          Removes a user from the repository
 void service(org.apache.avalon.framework.service.ServiceManager componentManager)
           
 boolean test(java.lang.String name, java.lang.String password)
          Test if user with name 'name' has password 'password'.
 boolean updateUser(User user)
          Update the repository with the specified user object.
 
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEEP_DEBUG

protected static boolean DEEP_DEBUG
Whether 'deep debugging' is turned on.

Constructor Detail

UsersFileRepository

public UsersFileRepository()
Method Detail

service

public void service(org.apache.avalon.framework.service.ServiceManager componentManager)
             throws org.apache.avalon.framework.service.ServiceException
Specified by:
service in interface org.apache.avalon.framework.service.Serviceable
Throws:
org.apache.avalon.framework.service.ServiceException
See Also:
Serviceable.service(ServiceManager)

configure

public void configure(org.apache.avalon.framework.configuration.Configuration configuration)
               throws org.apache.avalon.framework.configuration.ConfigurationException
Specified by:
configure in interface org.apache.avalon.framework.configuration.Configurable
Throws:
org.apache.avalon.framework.configuration.ConfigurationException
See Also:
Configurable.configure(Configuration)

initialize

public void initialize()
                throws java.lang.Exception
Specified by:
initialize in interface org.apache.avalon.framework.activity.Initializable
Throws:
java.lang.Exception
See Also:
Initializable.initialize()

list

public java.util.Iterator list()
List users in repository.

Specified by:
list in interface UsersRepository
Returns:
Iterator over a collection of Strings, each being one user in the repository.

addUser

public boolean addUser(User user)
Update the repository with the specified user object. A user object with this username must already exist.

Specified by:
addUser in interface UsersRepository
Parameters:
user - the user to be added.
Returns:
true if successful.

addUser

public void addUser(java.lang.String name,
                    java.lang.Object attributes)
Description copied from interface: UsersRepository
Adds a user to the repository with the specified attributes. In current implementations, the Object attributes is generally a String password.

Specified by:
addUser in interface UsersRepository
Parameters:
name - the name of the user to be added
attributes - see decription

addUser

public boolean addUser(java.lang.String username,
                       java.lang.String password)
Description copied from interface: UsersRepository
Adds a user to the repository with the specified password

Specified by:
addUser in interface UsersRepository
Parameters:
username - the username of the user to be added
password - the password of the user to add
Returns:
true if succesful, false otherwise

getUserByName

public User getUserByName(java.lang.String name)
Description copied from interface: UsersRepository
Get the user object with the specified user name. Return null if no such user.

Specified by:
getUserByName in interface UsersRepository
Parameters:
name - the name of the user to retrieve
Returns:
the user being retrieved, null if the user doesn't exist

getUserByNameCaseInsensitive

public User getUserByNameCaseInsensitive(java.lang.String name)
Description copied from interface: UsersRepository
Get the user object with the specified user name. Match user naems on a case insensitive basis. Return null if no such user.

Specified by:
getUserByNameCaseInsensitive in interface UsersRepository
Parameters:
name - the name of the user to retrieve
Returns:
the user being retrieved, null if the user doesn't exist

getRealName

public java.lang.String getRealName(java.lang.String name)
Description copied from interface: UsersRepository
Returns the user name of the user matching name on an equalsIgnoreCase basis. Returns null if no match.

Specified by:
getRealName in interface UsersRepository
Parameters:
name - the name to case-correct
Returns:
the case-correct name of the user, null if the user doesn't exist

updateUser

public boolean updateUser(User user)
Description copied from interface: UsersRepository
Update the repository with the specified user object. A user object with this username must already exist.

Specified by:
updateUser in interface UsersRepository
Returns:
true if successful.

removeUser

public void removeUser(java.lang.String name)
Description copied from interface: UsersRepository
Removes a user from the repository

Specified by:
removeUser in interface UsersRepository
Parameters:
name - the user to remove from the repository

contains

public boolean contains(java.lang.String name)
Description copied from interface: UsersRepository
Returns whether or not this user is in the repository

Specified by:
contains in interface UsersRepository
Parameters:
name - the name to check in the repository
Returns:
whether the user is in the repository

containsCaseInsensitive

public boolean containsCaseInsensitive(java.lang.String name)
Description copied from interface: UsersRepository
Returns whether or not this user is in the repository. Names are matched on a case insensitive basis.

Specified by:
containsCaseInsensitive in interface UsersRepository
Parameters:
name - the name to check in the repository
Returns:
whether the user is in the repository

test

public boolean test(java.lang.String name,
                    java.lang.String password)
Description copied from interface: UsersRepository
Test if user with name 'name' has password 'password'.

Specified by:
test in interface UsersRepository
Parameters:
name - the name of the user to be tested
password - the password to be tested
Returns:
true if the test is successful, false if the user doesn't exist or if the password is incorrect

countUsers

public int countUsers()
Description copied from interface: UsersRepository
Returns a count of the users in the repository.

Specified by:
countUsers in interface UsersRepository
Returns:
the number of users in the repository


Copyright © 2002-2007 The Apache Software Foundation. All Rights Reserved.