org.apache.james.userrepository
Class UsersLDAPRepository

java.lang.Object
  extended by org.apache.avalon.framework.logger.AbstractLogEnabled
      extended by org.apache.james.impl.jamesuser.AbstractUsersRepository
          extended by org.apache.james.userrepository.UsersLDAPRepository
All Implemented Interfaces:
org.apache.avalon.framework.activity.Initializable, org.apache.avalon.framework.configuration.Configurable, org.apache.avalon.framework.logger.LogEnabled, UsersRepository, VirtualUserTable, JamesUsersRepository

public class UsersLDAPRepository
extends AbstractUsersRepository
implements org.apache.avalon.framework.configuration.Configurable, org.apache.avalon.framework.activity.Initializable

Implementation of a Repository to store users. This clas is a dummy for the proposal! TODO: Check for aliases (mail attribute)

Version:
This is $Revision: 521427 $

Field Summary
 
Fields inherited from class org.apache.james.impl.jamesuser.AbstractUsersRepository
enableAliases, enableForwarding, ignoreCase
 
Fields inherited from interface org.apache.james.api.user.UsersRepository
ROLE, USER
 
Fields inherited from interface org.apache.james.api.vut.VirtualUserTable
ALIASDOMAIN_PREFIX, ERROR_PREFIX, REGEX_PREFIX, ROLE
 
Constructor Summary
UsersLDAPRepository()
           
 
Method Summary
 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 conf)
           
 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.
 void dispose()
          Disposes of all open directory contexts
protected  void doAddUser(User user)
          Adds userName to the MemberAttribute (specified in conf.xml) of this node.
protected  void doUpdateUser(User user)
          Updates a user record to match the supplied User.
 java.lang.String getChildDestination(java.lang.String childName)
           
 java.lang.String getRealName(java.lang.String name)
          Returns the user name of the user matching name on an equalsIgnoreCase basis.
 java.lang.String getRealName(java.lang.String name, boolean ignoreCase)
          Return the real name, given the ignoreCase boolean parameter
 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 removeGroupFromUser(java.lang.String userName)
           
 void removeUser(java.lang.String userName)
          Removes a user from the repository
 void setBase(java.lang.String base)
           
 void setServerRoot()
           
 boolean test(java.lang.String name, java.lang.String testPassword)
          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.james.impl.jamesuser.AbstractUsersRepository
addUser, getMappings, setEnableAliases, setEnableForwarding, setIgnoreCase
 
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
 

Constructor Detail

UsersLDAPRepository

public UsersLDAPRepository()
Method Detail

configure

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

setServerRoot

public void setServerRoot()

setBase

public void setBase(java.lang.String base)

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()

getChildDestination

public java.lang.String getChildDestination(java.lang.String childName)

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. Unsupported for this user repository type.

Specified by:
addUser in interface UsersRepository
Overrides:
addUser in class AbstractUsersRepository
Parameters:
user - the user to be added
Returns:
false

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
See Also:
UsersRepository.getUserByName(java.lang.String)

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
See Also:
UsersRepository.getUserByNameCaseInsensitive(java.lang.String)

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
See Also:
UsersRepository.containsCaseInsensitive(java.lang.String)

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
See Also:
UsersRepository.getRealName(java.lang.String)

getRealName

public java.lang.String getRealName(java.lang.String name,
                                    boolean ignoreCase)
Return the real name, given the ignoreCase boolean parameter


updateUser

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

Specified by:
updateUser in interface UsersRepository
Overrides:
updateUser in class AbstractUsersRepository
Parameters:
user - the user to be updated
Returns:
true if successful.
See Also:
UsersRepository.updateUser(org.apache.james.api.user.User)

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
See Also:
UsersRepository.addUser(java.lang.String, java.lang.String)

removeUser

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

Specified by:
removeUser in interface UsersRepository
Parameters:
userName - the user to remove from the repository
See Also:
UsersRepository.removeUser(java.lang.String)

removeGroupFromUser

public void removeGroupFromUser(java.lang.String userName)

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
See Also:
UsersRepository.contains(java.lang.String)

test

public boolean test(java.lang.String name,
                    java.lang.String testPassword)
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
testPassword - 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
See Also:
UsersRepository.test(java.lang.String, java.lang.String)

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
See Also:
UsersRepository.countUsers()

dispose

public void dispose()
             throws java.lang.Exception
Disposes of all open directory contexts

Throws:
java.lang.Exception - if an error is encountered during shutdown

doAddUser

protected void doAddUser(User user)
Adds userName to the MemberAttribute (specified in conf.xml) of this node. If ManageGroupAttribute (conf.xml) is TRUE then calls addGroupToUser.

Specified by:
doAddUser in class AbstractUsersRepository
Parameters:
user - the user to add

doUpdateUser

protected void doUpdateUser(User user)
Description copied from class: AbstractUsersRepository
Updates a user record to match the supplied User.

Specified by:
doUpdateUser in class AbstractUsersRepository
Parameters:
user - the user to update


Copyright ? 2002-2009 The Apache Software Foundation. All Rights Reserved.