org.apache.james.user.jpa
Class JPAUsersRepository

java.lang.Object
  extended by org.apache.james.user.lib.AbstractUsersRepository
      extended by org.apache.james.user.jpa.JPAUsersRepository
All Implemented Interfaces:
Configurable, LogEnabled, UsersRepository

public class JPAUsersRepository
extends AbstractUsersRepository

JPA based UserRepository


Constructor Summary
JPAUsersRepository()
           
 
Method Summary
 boolean contains(String name)
          Returns whether or not this user is in the repository
 int countUsers()
          Returns a count of the users in the repository.
protected  void doAddUser(String username, String password)
           
 void doConfigure(org.apache.commons.configuration.HierarchicalConfiguration config)
           
 String getRealName(String name)
          Returns the user name of the user matching name on an equalsIgnoreCase basis.
 User getUserByName(String name)
          Get the user object with the specified user name.
 void init()
           
 Iterator<String> list()
          List users in repository.
 void removeUser(String name)
          Removes a user from the repository
 void setEntityManagerFactory(javax.persistence.EntityManagerFactory entityManagerFactory)
          Sets entity manager.
 boolean test(String name, String password)
          Test if user with name 'name' has password 'password'.
 void updateUser(User user)
          Update the repository with the specified user object.
 
Methods inherited from class org.apache.james.user.lib.AbstractUsersRepository
addUser, configure, getLogger, isValidUsername, setDomainList, setEnableVirtualHosting, setLog, supportVirtualHosting
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JPAUsersRepository

public JPAUsersRepository()
Method Detail

setEntityManagerFactory

public final void setEntityManagerFactory(javax.persistence.EntityManagerFactory entityManagerFactory)
Sets entity manager.

Parameters:
entityManagerFactory - the entityManager to set

init

@PostConstruct
public void init()

getUserByName

public User getUserByName(String name)
                   throws UsersRepositoryException
Get the user object with the specified user name. Return null if no such user.

Parameters:
name - the name of the user to retrieve
Returns:
the user being retrieved, null if the user doesn't exist
Throws:
UsersRepositoryException
Since:
James 1.2.2

getRealName

public String getRealName(String name)
                   throws UsersRepositoryException
Returns the user name of the user matching name on an equalsIgnoreCase basis. Returns null if no match.

Parameters:
name - the name to case-correct
Returns:
the case-correct name of the user, null if the user doesn't exist
Throws:
UsersRepositoryException

updateUser

public void updateUser(User user)
                throws UsersRepositoryException
Update the repository with the specified user object. A user object with this username must already exist.

Throws:
UsersRepositoryException

removeUser

public void removeUser(String name)
                throws UsersRepositoryException
Removes a user from the repository

Parameters:
name - the user to remove from the repository
Throws:
UsersRepositoryException

contains

public boolean contains(String name)
                 throws UsersRepositoryException
Returns whether or not this user is in the repository

Parameters:
name - the name to check in the repository
Returns:
whether the user is in the repository
Throws:
UsersRepositoryException

test

public boolean test(String name,
                    String password)
             throws UsersRepositoryException
Test if user with name 'name' has password 'password'.

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
Throws:
UsersRepositoryException
Since:
James 1.2.2

countUsers

public int countUsers()
               throws UsersRepositoryException
Returns a count of the users in the repository.

Returns:
the number of users in the repository
Throws:
UsersRepositoryException

list

public Iterator<String> list()
                      throws UsersRepositoryException
List users in repository.

Returns:
Iterator over a collection of Strings, each being one user in the repository.
Throws:
UsersRepositoryException

doConfigure

public void doConfigure(org.apache.commons.configuration.HierarchicalConfiguration config)
                 throws org.apache.commons.configuration.ConfigurationException
Overrides:
doConfigure in class AbstractUsersRepository
Throws:
org.apache.commons.configuration.ConfigurationException
See Also:
AbstractUsersRepository.doConfigure(org.apache.commons.configuration.HierarchicalConfiguration)

doAddUser

protected void doAddUser(String username,
                         String password)
                  throws UsersRepositoryException
Specified by:
doAddUser in class AbstractUsersRepository
Throws:
UsersRepositoryException
See Also:
AbstractUsersRepository.doAddUser(java.lang.String, java.lang.String)


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