com.uwyn.rife.authentication.credentialsmanagers
Class MemoryUsers

java.lang.Object
  extended by com.uwyn.rife.authentication.credentialsmanagers.MemoryUsers
All Implemented Interfaces:
CredentialsManager, IdentifiableUsersManager, RoleUsersManager, PasswordEncrypting

public class MemoryUsers
extends Object
implements CredentialsManager, RoleUsersManager, PasswordEncrypting


Field Summary
static String DEFAULT_PARTICIPANT_NAME
           
protected  StringEncryptor mPasswordEncryptor
           
 
Constructor Summary
MemoryUsers()
           
MemoryUsers(String xmlPath, ResourceFinder resourceFinder)
           
 
Method Summary
 MemoryUsers addRole(String role)
           
 MemoryUsers addUser(String login, RoleUserAttributes attributes)
           
 void clearUsers()
           
 boolean containsRole(String role)
           
 boolean containsUser(String login)
           
 long countRoles()
           
 long countUsers()
           
 RoleUserAttributes getAttributes(String login)
          Retrieves the attributes of a particular user according to its unique login.
 String getLogin(long userId)
          Retrieves the login of a particular user according to its unique ID.
 StringEncryptor getPasswordEncryptor()
           
static MemoryUsers getRepInstance()
           
 long getUserId(String login)
           
 String getXmlPath()
          Retrieves the path of the XML document that populated this MemoryUsers instance.
static boolean hasRepInstance()
           
 boolean isUserInRole(long userId, String role)
           
 boolean listRoles(ListRoles processor)
           
 boolean listUserRoles(String login, ListRoles processor)
           
 boolean listUsers(ListUsers processor)
           
 boolean listUsers(ListUsers processor, int limit, int offset)
           
 boolean listUsersInRole(ListUsers processor, String role)
           
 boolean removeRole(String name)
           
 boolean removeUser(long userId)
           
 boolean removeUser(String login)
           
 void setPasswordEncryptor(StringEncryptor passwordEncryptor)
          Sets the password encryptor to use to encrypt this credentials manager's passwords.
 void storeToXml()
           
 void storeToXml(File destination)
           
 String toXml()
           
 boolean updateUser(String login, RoleUserAttributes attributes)
           
 long verifyCredentials(Credentials credentials)
          Verifies the validity of the provided Credentials instance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_PARTICIPANT_NAME

public static final String DEFAULT_PARTICIPANT_NAME
See Also:
Constant Field Values

mPasswordEncryptor

protected StringEncryptor mPasswordEncryptor
Constructor Detail

MemoryUsers

public MemoryUsers()

MemoryUsers

public MemoryUsers(String xmlPath,
                   ResourceFinder resourceFinder)
            throws CredentialsManagerException
Throws:
CredentialsManagerException
Method Detail

getXmlPath

public String getXmlPath()
Retrieves the path of the XML document that populated this MemoryUsers instance.

Returns:
the path of the XML document that populated this MemoryUsers instance
Since:
1.0

getPasswordEncryptor

public StringEncryptor getPasswordEncryptor()

setPasswordEncryptor

public void setPasswordEncryptor(StringEncryptor passwordEncryptor)
Description copied from interface: PasswordEncrypting
Sets the password encryptor to use to encrypt this credentials manager's passwords.

Specified by:
setPasswordEncryptor in interface PasswordEncrypting
Parameters:
passwordEncryptor - the password ecryptor that will be used

hasRepInstance

public static boolean hasRepInstance()

getRepInstance

public static MemoryUsers getRepInstance()

verifyCredentials

public long verifyCredentials(Credentials credentials)
                       throws CredentialsManagerException
Description copied from interface: CredentialsManager
Verifies the validity of the provided Credentials instance.

Specified by:
verifyCredentials in interface CredentialsManager
Parameters:
credentials - The Credentials instance that needs to be verified.
Returns:
A long that uniquely identifies the user that corresponds to the validated credentials; or

-1 if the credentials are invalid.

Throws:
CredentialsManagerException - An undefined number of exceptional cases or error situations can occur when credentials are verified. They are all indicated by throwing an instance of CredentialsManagerException. It's up to the implementations of this interface to give more specific meanings to these exceptions.

addRole

public MemoryUsers addRole(String role)
                    throws CredentialsManagerException
Specified by:
addRole in interface RoleUsersManager
Throws:
CredentialsManagerException

countRoles

public long countRoles()
Specified by:
countRoles in interface RoleUsersManager

containsRole

public boolean containsRole(String role)
Specified by:
containsRole in interface RoleUsersManager

addUser

public MemoryUsers addUser(String login,
                           RoleUserAttributes attributes)
                    throws CredentialsManagerException
Specified by:
addUser in interface RoleUsersManager
Throws:
CredentialsManagerException

getAttributes

public RoleUserAttributes getAttributes(String login)
Description copied from interface: IdentifiableUsersManager
Retrieves the attributes of a particular user according to its unique login.

Specified by:
getAttributes in interface IdentifiableUsersManager
Parameters:
login - the login of the user whose attributes need to be retrieved
Returns:
the requested user attributes; or

null if the user couldn't be found


countUsers

public long countUsers()
Specified by:
countUsers in interface RoleUsersManager

listRoles

public boolean listRoles(ListRoles processor)
Specified by:
listRoles in interface RoleUsersManager

listUsers

public boolean listUsers(ListUsers processor)
Specified by:
listUsers in interface RoleUsersManager

listUsers

public boolean listUsers(ListUsers processor,
                         int limit,
                         int offset)
Specified by:
listUsers in interface RoleUsersManager

containsUser

public boolean containsUser(String login)
Specified by:
containsUser in interface RoleUsersManager

listUsersInRole

public boolean listUsersInRole(ListUsers processor,
                               String role)
                        throws CredentialsManagerException
Specified by:
listUsersInRole in interface RoleUsersManager
Throws:
CredentialsManagerException

isUserInRole

public boolean isUserInRole(long userId,
                            String role)
Specified by:
isUserInRole in interface RoleUsersManager

getLogin

public String getLogin(long userId)
Description copied from interface: IdentifiableUsersManager
Retrieves the login of a particular user according to its unique ID.

Specified by:
getLogin in interface IdentifiableUsersManager
Parameters:
userId - the ID of the user whose login will be retrieved
Returns:
the requested user login; or

null if the user couldn't be found


getUserId

public long getUserId(String login)
Specified by:
getUserId in interface RoleUsersManager

updateUser

public boolean updateUser(String login,
                          RoleUserAttributes attributes)
                   throws CredentialsManagerException
Specified by:
updateUser in interface RoleUsersManager
Throws:
CredentialsManagerException

removeUser

public boolean removeUser(String login)
Specified by:
removeUser in interface RoleUsersManager

removeUser

public boolean removeUser(long userId)
Specified by:
removeUser in interface RoleUsersManager

removeRole

public boolean removeRole(String name)
Specified by:
removeRole in interface RoleUsersManager

clearUsers

public void clearUsers()
Specified by:
clearUsers in interface RoleUsersManager

listUserRoles

public boolean listUserRoles(String login,
                             ListRoles processor)
                      throws CredentialsManagerException
Specified by:
listUserRoles in interface RoleUsersManager
Throws:
CredentialsManagerException

toXml

public String toXml()

storeToXml

public void storeToXml()
                throws CredentialsManagerException
Throws:
CredentialsManagerException

storeToXml

public void storeToXml(File destination)
                throws CredentialsManagerException
Throws:
CredentialsManagerException


Copyright © 2001-2007 Uwyn sprl/bvba. All Rights Reserved.