pt.digitalis.dif.controller.security.managers.impl
Class IdentityManagerStaticImpl

java.lang.Object
  extended by pt.digitalis.dif.controller.security.managers.impl.AbstractIdentityManager
      extended by pt.digitalis.dif.controller.security.managers.impl.IdentityManagerStaticImpl
All Implemented Interfaces:
IIdentityManager, IIdentityManagerPrivate

public class IdentityManagerStaticImpl
extends AbstractIdentityManager

Default implementation for the identity manager.

Author:
Rodrigo Gonçalves rgoncalves@digitalis.pt
, Pedro Viegas pviegas@digitalis.pt, Fábio Souto fsouto@digitalis.pt
Created on:
2007/12/04

Field Summary
 
Fields inherited from class pt.digitalis.dif.controller.security.managers.impl.AbstractIdentityManager
N_A
 
Constructor Summary
IdentityManagerStaticImpl()
           
 
Method Summary
 void addGroup(IDIFGroup newGroup)
          Adds a new group to the manager.
 void addUser(IDIFUser newUser)
          Adds a new user to the manager.
 void addUserToGroup(String userID, String groupID)
          Adds an existing user to an existing group.
 void changePassword(String userID, String newPassword)
          Changes the password for the supplied user.
 int countAllGroups()
          Counts the number of groups in the system
 int countAllGroupsOfUser(String userId)
          Counts all groups of a given user.
 int countAllUsers()
          Counts the number of users in the system
 int countAllUsers(String groupID)
          Counts all users of a given group.
 int countUsers(Map<String,String> attributes)
          Count the number of users in the system which match all of the provided attributes
 List<String> gatherManagedAttributes()
          Gathers the managed attributes.
 Set<IDIFGroup> getAllGroups()
          Get all the groups registered in the system
 Set<IDIFUser> getAllUsers()
          Get all the users in the system
 String getExclusionCharaters()
          Get the exclusion charaters
 IDIFGroup getGroup(String groupID)
          Returns null if the group doesn't exist.
 String getGroupAttributeName()
          Gets the group attribute name
 Map<String,IDIFGroup> getGroupGroups(String parentGroupID)
          Returns the list of groups whose parent group is the given group
 Set<IDIFGroup> getGroups(Pagination page)
          Returns a subset of all groups in the system, according to the parameters
 Map<String,IDIFUser> getGroupUsers(String groupID)
          Returns the list of users of a given group
 String getMailAttributeName()
          Gets the mail attribute name
 String getNameAttributeName()
          Gets the name attribute name
 IDIFUser getUser(String userID)
          Returns null if the user doesn't exist.
 Map<String,IDIFGroup> getUserGroups(String userID)
          Returns the list of groups of a given user
 Set<String> getUserGroupsIDs(String userID)
          Returns the list of group IDs of a given user
 Map<String,IDIFGroup> getUserGroupsPagination(String userID, Pagination page)
          Returns the list of groups of a given user, with pagination.
 Set<String> getUserIDsInGroup(String groupID)
          Returns the list of user IDs of a given group
 String getUserLoginAttributeName()
          Gets the user login attribute name
 String getUserParentGroupAttributeName()
          Returns the user parent group attribute name
 Set<IDIFUser> getUsers(Pagination page)
          Returns a subset of all users in the system, according to the parameters
 Set<IDIFUser> getUsersByAttribute(String attribute, String value)
          Returns the list of users with a given attribute value.
 Set<IDIFUser> getUsersByAttributes(Map<String,String> attributes)
          Get users that match specified attributes.
 Set<IDIFUser> getUsersByAttributes(Map<String,String> attributes, Pagination page)
          Get users that match specified attributes.
 Set<IDIFUser> getUsersByEmail(String value)
          Returns the list of users with a given email attribute value.
 boolean groupExists(String groupID)
          Checks if a group exists on the manager.
 void initializeStaticCustomUsers()
          Initializes users from custom static file "users.xml"
 boolean isIdentityValid(String userID, String suppliedPassword)
          Checks if the supplied password matches the one defined for a user with a given ID.
 boolean isReadOnly()
          Get the ldap readOnly configuration value.
 boolean isUserInGroup(String userID, String groupID)
          Checks if a given user belongs to a given group.
 void persistUserAttribute(String userID, String attributeID, Object attributeValue)
          Persists an attribute value on a given user on the underlying repository.
 void persistUserAttributes(String userID, Map<String,Object> attributes)
          Persists all attributes values on a given user on the underlying repository.
 void removeGroup(String groupID)
          Removes an existing group from the manager, if it exists.
 void removeUser(String userID)
          Removes an existing user from the manager, if it exists.
 void removeUserFromGroup(String userID, String groupID)
          Removes an existing user from an existing group.
 void resetIdentityManager()
          Resets the identity manager.
 String toString()
           
 void updateGroup(IDIFGroup existingGroup)
          Updates an existing group.
 void updateUser(IDIFUser existingUser, String userID)
          Updates an existing user.
 void updateUserAttribute(String userID, String attributeID, Object attributeValue)
          Updates an attribute value on a given user and persists it.
 void updateUserAttributes(String userID, Map<String,Object> attributes)
          Updates all of the user's attributes.
 boolean userExists(String userID)
          Checks if a user exists on the manager.
 
Methods inherited from class pt.digitalis.dif.controller.security.managers.impl.AbstractIdentityManager
addManagedAttribute, addManagedAttributes, containsUserParameter, countAllGroupsOfUser, getManagedAttributes, getUserGroups, getUserGroupsIDs, getUserParameter, getUserParameters, isUserInGroup, removeUserParameter, setUserParameter, setUserParameters
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

IdentityManagerStaticImpl

public IdentityManagerStaticImpl()
Method Detail

addGroup

public void addGroup(IDIFGroup newGroup)
              throws IdentityManagerException
Description copied from interface: IIdentityManager
Adds a new group to the manager.

Parameters:
newGroup - the group to add
Throws:
IdentityManagerException - if the user can't be added
See Also:
IIdentityManager.addGroup(IDIFGroup)

addUser

public void addUser(IDIFUser newUser)
             throws IdentityManagerException
Description copied from interface: IIdentityManager
Adds a new user to the manager.

Parameters:
newUser - the new user to add to the manager
Throws:
IdentityManagerException - if the user can't be added
See Also:
IIdentityManager.addUser(IDIFUser)

addUserToGroup

public void addUserToGroup(String userID,
                           String groupID)
Description copied from interface: IIdentityManager
Adds an existing user to an existing group.

Parameters:
userID - the user ID
groupID - the group ID
See Also:
IIdentityManager.addUserToGroup(String, String)

changePassword

public void changePassword(String userID,
                           String newPassword)
                    throws IdentityManagerException
Description copied from interface: IIdentityManager
Changes the password for the supplied user.

Parameters:
userID - the user ID
newPassword - the new password
Throws:
IdentityManagerException - if the password can't be changed
See Also:
IIdentityManager.changePassword(java.lang.String, java.lang.String)

countAllGroups

public int countAllGroups()
                   throws IdentityManagerException
Description copied from interface: IIdentityManager
Counts the number of groups in the system

Returns:
The number of groups in the system
Throws:
IdentityManagerException - * If the operation cannot be executed
See Also:
IIdentityManager.countAllGroups()

countAllGroupsOfUser

public int countAllGroupsOfUser(String userId)
                         throws IdentityManagerException
Description copied from interface: IIdentityManager
Counts all groups of a given user.

Parameters:
userId - The user identifier
Returns:
The number of groups of this user.
Throws:
IdentityManagerException
See Also:
IIdentityManager.countAllGroupsOfUser(String)

countAllUsers

public int countAllUsers()
                  throws IdentityManagerException
Description copied from interface: IIdentityManager
Counts the number of users in the system

Returns:
The number of users on the system
Throws:
IdentityManagerException - If the operation cannot be executed
See Also:
IIdentityManager.countAllUsers()

countAllUsers

public int countAllUsers(String groupID)
                  throws IdentityManagerException
Description copied from interface: IIdentityManager
Counts all users of a given group.

Parameters:
groupID - The group identifier
Returns:
The number of users of this group.
Throws:
IdentityManagerException
See Also:
IIdentityManager.countAllUsers(java.lang.String)

countUsers

public int countUsers(Map<String,String> attributes)
               throws IdentityManagerException
Description copied from interface: IIdentityManager
Count the number of users in the system which match all of the provided attributes

Parameters:
attributes - The attributes
Returns:
The number of users in the system which match all of the provided attributes
Throws:
IdentityManagerException - If the operation cannot be executed
See Also:
IIdentityManager.countUsers(java.util.Map)

gatherManagedAttributes

public List<String> gatherManagedAttributes()
Description copied from interface: IIdentityManager
Gathers the managed attributes. This method must be used to initialize the managed attributes.

Specified by:
gatherManagedAttributes in interface IIdentityManager
Specified by:
gatherManagedAttributes in class AbstractIdentityManager
Returns:
The list containing the managed attributes
See Also:
AbstractIdentityManager.gatherManagedAttributes()

getAllGroups

public Set<IDIFGroup> getAllGroups()
Description copied from interface: IIdentityManager
Get all the groups registered in the system

Returns:
A set containing all the groups
See Also:
IIdentityManager.getAllGroups()

getAllUsers

public Set<IDIFUser> getAllUsers()
Description copied from interface: IIdentityManager
Get all the users in the system

Returns:
A set containing all the users
See Also:
IIdentityManager.getAllUsers()

getExclusionCharaters

public String getExclusionCharaters()
Description copied from interface: IIdentityManager
Get the exclusion charaters

Returns:
value
See Also:
IIdentityManager.getExclusionCharaters()

getGroup

public IDIFGroup getGroup(String groupID)
Returns null if the group doesn't exist.

Parameters:
groupID - the group id
Returns:
the group with the given id if it exists, null otherwise
See Also:
IIdentityManager.getGroup(String)

getGroupAttributeName

public String getGroupAttributeName()
Description copied from interface: IIdentityManager
Gets the group attribute name

Returns:
The string containing the attribute name
See Also:
IIdentityManager.getGroupAttributeName()

getGroupGroups

public Map<String,IDIFGroup> getGroupGroups(String parentGroupID)
                                     throws IdentityManagerException
Description copied from interface: IIdentityManager
Returns the list of groups whose parent group is the given group

Parameters:
parentGroupID - the parent group to search for children groups
Returns:
the list of groups
Throws:
IdentityManagerException - if the group's groups can't be found
See Also:
IIdentityManager.getGroupGroups(java.lang.String)

getGroups

public Set<IDIFGroup> getGroups(Pagination page)
                         throws IdentityManagerException
Description copied from interface: IIdentityManager
Returns a subset of all groups in the system, according to the parameters

Parameters:
page - The required page
Returns:
A set of groups containing the specified subset
Throws:
IdentityManagerException - If the operation can't be executed
See Also:
IIdentityManager.getGroups(Pagination)

getGroupUsers

public Map<String,IDIFUser> getGroupUsers(String groupID)
Description copied from interface: IIdentityManager
Returns the list of users of a given group

Parameters:
groupID - the group
Returns:
the list of users
See Also:
IIdentityManager.getGroupUsers(java.lang.String)

getMailAttributeName

public String getMailAttributeName()
Description copied from interface: IIdentityManager
Gets the mail attribute name

Returns:
The string containing the attribute name.
See Also:
IIdentityManager.getMailAttributeName()

getNameAttributeName

public String getNameAttributeName()
Description copied from interface: IIdentityManager
Gets the name attribute name

Returns:
The string containing the attribute name.
See Also:
IIdentityManager.getNameAttributeName()

getUser

public IDIFUser getUser(String userID)
Returns null if the user doesn't exist.

Parameters:
userID - the user id
Returns:
the user that matches the supplied id if it exists, null otherwise
See Also:
IIdentityManager.getUser(String)

getUserGroups

public Map<String,IDIFGroup> getUserGroups(String userID)
                                    throws IdentityManagerException
Description copied from interface: IIdentityManager
Returns the list of groups of a given user

Parameters:
userID - the user
Returns:
the list of groups
Throws:
IdentityManagerException - if the group's users can't be found
See Also:
IIdentityManager.getUserGroups(java.lang.String)

getUserGroupsIDs

public Set<String> getUserGroupsIDs(String userID)
Description copied from interface: IIdentityManager
Returns the list of group IDs of a given user

Parameters:
userID - the user
Returns:
the list of groups
See Also:
IIdentityManager.getUserGroupsIDs(java.lang.String)

getUserGroupsPagination

public Map<String,IDIFGroup> getUserGroupsPagination(String userID,
                                                     Pagination page)
                                              throws IdentityManagerException
Description copied from interface: IIdentityManager
Returns the list of groups of a given user, with pagination. This method doesn't consider the profile as a group.

Parameters:
userID - the user
page - The page to be returned
Returns:
the list of groups
Throws:
IdentityManagerException - if the group's users can't be found
See Also:
IIdentityManager.getUserGroupsPagination(java.lang.String, pt.digitalis.dif.utils.Pagination)

getUserIDsInGroup

public Set<String> getUserIDsInGroup(String groupID)
Description copied from interface: IIdentityManager
Returns the list of user IDs of a given group

Parameters:
groupID - the group
Returns:
the list of users
See Also:
IIdentityManager.getUserIDsInGroup(java.lang.String)

getUserLoginAttributeName

public String getUserLoginAttributeName()
Description copied from interface: IIdentityManager
Gets the user login attribute name

Returns:
The string containing the attribute name.
See Also:
IIdentityManager.getUserLoginAttributeName()

getUserParentGroupAttributeName

public String getUserParentGroupAttributeName()
Description copied from interface: IIdentityManager
Returns the user parent group attribute name

Returns:
A string containing the user parent group attribute name
See Also:
IIdentityManager.getUserParentGroupAttributeName()

getUsers

public Set<IDIFUser> getUsers(Pagination page)
                       throws IdentityManagerException
Description copied from interface: IIdentityManager
Returns a subset of all users in the system, according to the parameters

Parameters:
page - The required page
Returns:
A set of users containing the specified subset
Throws:
IdentityManagerException - If the operation can't be executed
See Also:
IIdentityManager.getUsers(Pagination)

getUsersByAttribute

public Set<IDIFUser> getUsersByAttribute(String attribute,
                                         String value)
                                  throws IdentityManagerException
Description copied from interface: IIdentityManager
Returns the list of users with a given attribute value.
Supports partial matches by adding "%" or "*" before and/or after the attribute value

Parameters:
attribute - the attribute to search
value - the value for the attribute
Returns:
the LDAPUser with the given login name
Throws:
IdentityManagerException - if the operation cannot be executed
See Also:
IIdentityManager.getUsersByAttribute(java.lang.String, java.lang.String)

getUsersByAttributes

public Set<IDIFUser> getUsersByAttributes(Map<String,String> attributes)
                                   throws IdentityManagerException
Description copied from interface: IIdentityManager
Get users that match specified attributes.
Supports partial matches by adding "%" or "*" before and/or after the attribute value

Parameters:
attributes - A map of attributes to be searched, where the keys are the attribute names, and the values are the attribute values.
Returns:
A set containing the users that obey all of the specified criteria
Throws:
IdentityManagerException - If the operation cannot be completed.
See Also:
IIdentityManager.getUsersByAttributes(java.util.Map)

getUsersByAttributes

public Set<IDIFUser> getUsersByAttributes(Map<String,String> attributes,
                                          Pagination page)
                                   throws IdentityManagerException
Description copied from interface: IIdentityManager
Get users that match specified attributes.
Supports partial matches by adding "%" or "*" before and/or after the attribute value

Parameters:
attributes - A map of attributes to be searched, where the keys are the attribute names, and the values are the attribute values.
page - The page to be obtained
Returns:
A set containing the users that obey all of the specified criteria
Throws:
IdentityManagerException - If the operation can't be executed
See Also:
IIdentityManager.getUsersByAttributes(java.util.Map, pt.digitalis.dif.utils.Pagination)

getUsersByEmail

public Set<IDIFUser> getUsersByEmail(String value)
                              throws IdentityManagerException
Description copied from interface: IIdentityManager
Returns the list of users with a given email attribute value.

Parameters:
value - the value for the attribute email
Returns:
the LDAPUser with the given login name
Throws:
IdentityManagerException - if the operation cannot be executed
See Also:
IIdentityManager.getUsersByEmail(java.lang.String)

groupExists

public boolean groupExists(String groupID)
Description copied from interface: IIdentityManager
Checks if a group exists on the manager.

Parameters:
groupID - the ID of the group
Returns:
T if the group exists, F otherwise
See Also:
IIdentityManager.groupExists(String)

initializeStaticCustomUsers

public void initializeStaticCustomUsers()
Initializes users from custom static file "users.xml"


isIdentityValid

public boolean isIdentityValid(String userID,
                               String suppliedPassword)
Description copied from interface: IIdentityManager
Checks if the supplied password matches the one defined for a user with a given ID.

Parameters:
userID - the user ID
suppliedPassword - the supplied user password
Returns:
T if user if its identity is valid, F otherwise
See Also:
IIdentityManager.isIdentityValid(java.lang.String, java.lang.String)

isReadOnly

public boolean isReadOnly()
Description copied from interface: IIdentityManager
Get the ldap readOnly configuration value.

Returns:
true or false
See Also:
IIdentityManager.isReadOnly()

isUserInGroup

public boolean isUserInGroup(String userID,
                             String groupID)
Description copied from interface: IIdentityManager
Checks if a given user belongs to a given group.

Parameters:
userID - the user ID
groupID - the group ID
Returns:
T if the user belongs to the group, F otherwise
See Also:
IIdentityManager.isUserInGroup(String, String)

persistUserAttribute

public void persistUserAttribute(String userID,
                                 String attributeID,
                                 Object attributeValue)
                          throws IdentityManagerException
Description copied from interface: IIdentityManagerPrivate
Persists an attribute value on a given user on the underlying repository.

Parameters:
userID - the ID of the user to update
attributeID - the ID of the attribute to update
attributeValue - the value of the attribute to update
Throws:
IdentityManagerException - if the attribute can't be updated
See Also:
IIdentityManagerPrivate.persistUserAttribute(java.lang.String, java.lang.String, java.lang.Object)

persistUserAttributes

public void persistUserAttributes(String userID,
                                  Map<String,Object> attributes)
                           throws IdentityManagerException
Description copied from interface: IIdentityManagerPrivate
Persists all attributes values on a given user on the underlying repository.

Parameters:
userID - the ID of the user to update
attributes - the attributes to update
Throws:
IdentityManagerException - if the attribute can't be updated
See Also:
IIdentityManagerPrivate.persistUserAttributes(java.lang.String, java.util.Map)

removeGroup

public void removeGroup(String groupID)
Description copied from interface: IIdentityManager
Removes an existing group from the manager, if it exists.

Parameters:
groupID - the id of the group to remove
See Also:
IIdentityManager.removeGroup(String)

removeUser

public void removeUser(String userID)
Description copied from interface: IIdentityManager
Removes an existing user from the manager, if it exists.

Parameters:
userID - the id of the user to remove
See Also:
IIdentityManager.removeUser(String)

removeUserFromGroup

public void removeUserFromGroup(String userID,
                                String groupID)
Description copied from interface: IIdentityManager
Removes an existing user from an existing group.

Parameters:
userID - the user ID
groupID - the group ID
See Also:
IIdentityManager.removeUserFromGroup(String, String)

resetIdentityManager

public void resetIdentityManager()
Description copied from interface: IIdentityManager
Resets the identity manager. Different implementations will offer distinct types of reset.

See Also:
IIdentityManager.resetIdentityManager()

toString

public String toString()
Overrides:
toString in class Object
See Also:
Object.toString()

updateGroup

public void updateGroup(IDIFGroup existingGroup)
Description copied from interface: IIdentityManager
Updates an existing group. Does nothing if the group doesn't exist.

Parameters:
existingGroup - the group to update
See Also:
IIdentityManager.updateGroup(IDIFGroup)

updateUser

public void updateUser(IDIFUser existingUser,
                       String userID)
Description copied from interface: IIdentityManager
Updates an existing user. Does nothing if the user doesn't exist.

Parameters:
existingUser - the user to update
userID - the user ID (must be supplied separately to ensure data integrity if the user ID is changed)
See Also:
IIdentityManager.updateUser(pt.digitalis.dif.controller.security.objects.IDIFUser, java.lang.String)

updateUserAttribute

public void updateUserAttribute(String userID,
                                String attributeID,
                                Object attributeValue)
                         throws IdentityManagerException
Description copied from interface: IIdentityManager
Updates an attribute value on a given user and persists it.

Parameters:
userID - the ID of the user to update
attributeID - the ID of the attribute to update
attributeValue - the value of the attribute to update
Throws:
IdentityManagerException - if the attribute can't be updated
See Also:
IIdentityManager.updateUserAttribute(java.lang.String, java.lang.String, java.lang.Object)

updateUserAttributes

public void updateUserAttributes(String userID,
                                 Map<String,Object> attributes)
                          throws IdentityManagerException
Description copied from interface: IIdentityManager
Updates all of the user's attributes.

Parameters:
userID - the ID of the user to update
attributes - the attributes to update
Throws:
IdentityManagerException - if the attribute can't be updated
See Also:
IIdentityManager.updateUserAttributes(java.lang.String, java.util.Map)

userExists

public boolean userExists(String userID)
Description copied from interface: IIdentityManager
Checks if a user exists on the manager.

Parameters:
userID - the ID of the user
Returns:
T if the user exists, F otherwise
See Also:
IIdentityManager.userExists(String)


Copyright © 2014 Digitalis Informática Lda. All Rights Reserved.