org.apache.james.user.jpa
Class JPAUsersRepository

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

public class JPAUsersRepository
extends java.lang.Object
implements UsersRepository, Configurable, LogEnabled

JPA based UserRepository


Field Summary
 
Fields inherited from interface org.apache.james.user.api.UsersRepository
ROLE, USER
 
Constructor Summary
JPAUsersRepository()
           
 
Method Summary
 void addUser(java.lang.String name, java.lang.Object attributes)
          Deprecated. James 2.4 user is always added using username/password and eventually modified by retrieving it later.
 boolean addUser(java.lang.String username, java.lang.String password)
          Adds a user to the repository with the specified password
 boolean addUser(User user)
          Deprecated. James 2.4 user should be added using username/password because specific implementations of UsersRepository will support specific implementations of users object.
 void configure(org.apache.commons.configuration.HierarchicalConfiguration config)
           
 boolean contains(java.lang.String name)
          Returns whether or not this user is in the repository
 boolean containsCaseInsensitive(java.lang.String name)
          Deprecated. James 2.4 now caseSensitive is a property of the repository implementations and the contains will search according to this property.
 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)
          Deprecated. James 2.4 now caseSensitive is a property of the repository implementations and the getUserByName will search according to this property.
 java.util.Iterator<java.lang.String> list()
          List users in repository.
 void removeUser(java.lang.String name)
          Removes a user from the repository
 void setEntityManagerFactory(javax.persistence.EntityManagerFactory entityManagerFactory)
          Sets entity manager.
 void setLog(org.apache.commons.logging.Log log)
           
 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 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:
entityManager - the entityManager to set

addUser

public boolean addUser(User user)
Deprecated. James 2.4 user should be added using username/password because specific implementations of UsersRepository will support specific implementations of users object.

Adds a user to the repository with the specified User object.

Specified by:
addUser in interface UsersRepository
Parameters:
user - the user to be added
Returns:
true if succesful, false otherwise
Since:
James 1.2.2

addUser

public void addUser(java.lang.String name,
                    java.lang.Object attributes)
Deprecated. James 2.4 user is always added using username/password and eventually modified by retrieving it later.

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)
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
Since:
James 2.3.0

getUserByName

public User getUserByName(java.lang.String name)
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
Since:
James 1.2.2

getUserByNameCaseInsensitive

public User getUserByNameCaseInsensitive(java.lang.String name)
Deprecated. James 2.4 now caseSensitive is a property of the repository implementations and the getUserByName will search according to this property.

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

getRealName

public java.lang.String getRealName(java.lang.String name)
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)
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)
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)
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)
Deprecated. James 2.4 now caseSensitive is a property of the repository implementations and the contains will search according to this property.

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

countUsers

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

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

list

public java.util.Iterator<java.lang.String> 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.

configure

public void configure(org.apache.commons.configuration.HierarchicalConfiguration config)
               throws org.apache.commons.configuration.ConfigurationException
Specified by:
configure in interface Configurable
Throws:
org.apache.commons.configuration.ConfigurationException

setLog

public void setLog(org.apache.commons.logging.Log log)
Specified by:
setLog in interface LogEnabled


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