Class FakeUserManagerImpl

java.lang.Object
org.nuxeo.ecm.platform.usermanager.FakeUserManagerImpl
All Implemented Interfaces:
Serializable, UserManager, Authenticator, EventListener

public class FakeUserManagerImpl extends Object implements UserManager
Author:
Florent Guillaume
See Also:
  • Constructor Details

    • FakeUserManagerImpl

      public FakeUserManagerImpl()
  • Method Details

    • getUserListingMode

      public String getUserListingMode()
      Specified by:
      getUserListingMode in interface UserManager
    • setUserListingMode

      public void setUserListingMode(String userListingMode)
    • getGroupListingMode

      public String getGroupListingMode()
      Specified by:
      getGroupListingMode in interface UserManager
    • setGroupListingMode

      public void setGroupListingMode(String groupListingMode)
    • getDefaultGroup

      public String getDefaultGroup()
      Specified by:
      getDefaultGroup in interface UserManager
    • setDefaultGroup

      public void setDefaultGroup(String defaultGroup)
    • getUserSortField

      public String getUserSortField()
      Specified by:
      getUserSortField in interface UserManager
    • setUserSortField

      public void setUserSortField(String sortField)
    • setGroupSortField

      public void setGroupSortField(String sortField)
    • setUserDirectoryName

      public void setUserDirectoryName(String userDirectoryName)
    • getUserDirectoryName

      public String getUserDirectoryName()
      Description copied from interface: UserManager
      Gets the user directory name.
      Specified by:
      getUserDirectoryName in interface UserManager
      Returns:
      the user directory name.
    • setUserEmailField

      public void setUserEmailField(String userEmailField)
    • getUserEmailField

      public String getUserEmailField()
      Description copied from interface: UserManager
      Gets the user email field.
      Specified by:
      getUserEmailField in interface UserManager
      Returns:
      the user email field.
    • setUserSearchFields

      public void setUserSearchFields(Set<String> userSearchFields)
    • setUserSearchFields

      public void setUserSearchFields(Map<String,UserManager.MatchType> userSearchFields)
    • getUserSearchFields

      public Set<String> getUserSearchFields()
      Description copied from interface: UserManager
      Gets the user search fields, the fields to use when a principal search is done.
      Specified by:
      getUserSearchFields in interface UserManager
      Returns:
      the search fields.
    • setGroupSearchFields

      public void setGroupSearchFields(Map<String,UserManager.MatchType> groupSearchFields)
    • getGroupSearchFields

      public Set<String> getGroupSearchFields()
      Description copied from interface: UserManager
      Gets the group search fields.
      Specified by:
      getGroupSearchFields in interface UserManager
    • setGroupDirectoryName

      public void setGroupDirectoryName(String groupDirectoryName)
    • getGroupDirectoryName

      public String getGroupDirectoryName()
      Description copied from interface: UserManager
      Gets the group directory name.
      Specified by:
      getGroupDirectoryName in interface UserManager
      Returns:
      the group directory name.
    • setGroupMembersField

      public void setGroupMembersField(String groupMembersField)
    • getGroupMembersField

      public String getGroupMembersField()
      Description copied from interface: UserManager
      Gets the group members field.
      Specified by:
      getGroupMembersField in interface UserManager
      Returns:
      the group members field.
    • setGroupSubGroupsField

      public void setGroupSubGroupsField(String groupSubGroupsField)
    • getGroupSubGroupsField

      public String getGroupSubGroupsField()
      Description copied from interface: UserManager
      Gets the group sub-groups field.
      Specified by:
      getGroupSubGroupsField in interface UserManager
      Returns:
      the sub-groups field.
    • setGroupParentGroupsField

      public void setGroupParentGroupsField(String groupParentGroupsField)
    • getGroupParentGroupsField

      public String getGroupParentGroupsField()
      Description copied from interface: UserManager
      Gets the group parent-groups field.
      Specified by:
      getGroupParentGroupsField in interface UserManager
      Returns:
      the parent-groups field.
    • areGroupsReadOnly

      public Boolean areGroupsReadOnly()
      Description copied from interface: UserManager
      Returns true is users referential is read only (ie : LDAP) -> can not add users -> can not delete users.
      Specified by:
      areGroupsReadOnly in interface UserManager
    • areUsersReadOnly

      public Boolean areUsersReadOnly()
      Description copied from interface: UserManager
      Returns true is groups referential is read only (ie : LDAP) -> can not add groups -> can not delete groups.
      Specified by:
      areUsersReadOnly in interface UserManager
    • checkUsernamePassword

      public boolean checkUsernamePassword(String username, String password)
      Description copied from interface: Authenticator
      Check the password for the given username. Returns true if the username / password pair match, false otherwise.
      Specified by:
      checkUsernamePassword in interface Authenticator
      Specified by:
      checkUsernamePassword in interface UserManager
      Parameters:
      username - the username
      password - the password to check
      Returns:
      true is valid, false otherwise
    • validatePassword

      public boolean validatePassword(String password)
      Specified by:
      validatePassword in interface UserManager
    • getGroupsInGroup

      public List<String> getGroupsInGroup(String parentId)
      Description copied from interface: UserManager
      Returns the list of groups that belong to this group.
      Specified by:
      getGroupsInGroup in interface UserManager
      Parameters:
      parentId - the name of the parent group.
    • getPrincipal

      public NuxeoPrincipal getPrincipal(String username, boolean fetchReferences)
      Description copied from interface: UserManager
      Retrieves the principal with the given username or null if it does not exist.

      Can build principals for anonymous and virtual users as well as for users defined in the users directory.

      Specified by:
      getPrincipal in interface UserManager
      Parameters:
      username - is the name of the entry in the user directory
      fetchReferences - controls if the references (groups) of the user will be fetched
    • getTopLevelGroups

      public List<String> getTopLevelGroups()
      Description copied from interface: UserManager
      Returns the list of groups that are not members of other groups.
      Specified by:
      getTopLevelGroups in interface UserManager
    • getUsersInGroup

      public List<String> getUsersInGroup(String groupId)
      Description copied from interface: UserManager
      Returns the list of users that belong to this group.
      Specified by:
      getUsersInGroup in interface UserManager
      Parameters:
      groupId - ID of the group
    • getUsersInGroupAndSubGroups

      public List<String> getUsersInGroupAndSubGroups(String groupId)
      Description copied from interface: UserManager
      Get users from a group and its subgroups.
      Specified by:
      getUsersInGroupAndSubGroups in interface UserManager
      Parameters:
      groupId - ID of the group
    • searchGroups

      public DocumentModelList searchGroups(String pattern)
      Description copied from interface: UserManager
      Search matching groups through their defined search fields
      Specified by:
      searchGroups in interface UserManager
    • searchPrincipals

      public List<NuxeoPrincipal> searchPrincipals(String pattern)
      Specified by:
      searchPrincipals in interface UserManager
    • getUserPasswordPattern

      public Pattern getUserPasswordPattern()
      Specified by:
      getUserPasswordPattern in interface UserManager
    • setUserPasswordPattern

      public void setUserPasswordPattern(Pattern userPasswordPattern)
    • setAnonymousUser

      public void setAnonymousUser(VirtualUser anonymousUser)
    • setVirtualUsers

      public void setVirtualUsers(Map<String,VirtualUserDescriptor> virtualUsers)
    • getAnonymousUserId

      public String getAnonymousUserId()
      Description copied from interface: UserManager
      Gets the anonymous user id.
      Specified by:
      getAnonymousUserId in interface UserManager
      Returns:
      the anonymous user id, or the default one if none is defined.
    • getDigestAuthDirectory

      public String getDigestAuthDirectory()
      Description copied from interface: UserManager
      Gets the Digest Auth directory.
      Specified by:
      getDigestAuthDirectory in interface UserManager
    • getDigestAuthRealm

      public String getDigestAuthRealm()
      Description copied from interface: UserManager
      Gets the Digest Auth realm.
      Specified by:
      getDigestAuthRealm in interface UserManager
    • setConfiguration

      public void setConfiguration(UserManagerDescriptor descriptor)
      Description copied from interface: UserManager
      Sets the given configuration on the service.
      Specified by:
      setConfiguration in interface UserManager
      Parameters:
      descriptor - the descriptor as parsed from xml, merged from the previous one if it exists.
    • getBareUserModel

      public DocumentModel getBareUserModel()
      Description copied from interface: UserManager
      Returns a bare user model.

      Can be used for user creation/search screens.

      Specified by:
      getBareUserModel in interface UserManager
    • createGroup

      public DocumentModel createGroup(DocumentModel groupModel)
      Description copied from interface: UserManager
      Creates a group from given model
      Specified by:
      createGroup in interface UserManager
      Returns:
      the created group model
    • createUser

      public DocumentModel createUser(DocumentModel userModel)
      Description copied from interface: UserManager
      Creates user from given model.
      Specified by:
      createUser in interface UserManager
    • deleteGroup

      public void deleteGroup(DocumentModel groupModel)
      Description copied from interface: UserManager
      Deletes group represented by given model.
      Specified by:
      deleteGroup in interface UserManager
    • deleteGroup

      public void deleteGroup(String groupId)
      Description copied from interface: UserManager
      Deletes group with given id.
      Specified by:
      deleteGroup in interface UserManager
    • deleteUser

      public void deleteUser(DocumentModel userModel)
      Description copied from interface: UserManager
      Deletes user represented by given model.
      Specified by:
      deleteUser in interface UserManager
    • deleteUser

      public void deleteUser(String userId)
      Description copied from interface: UserManager
      Deletes user with given id.
      Specified by:
      deleteUser in interface UserManager
    • getBareGroupModel

      public DocumentModel getBareGroupModel()
      Description copied from interface: UserManager
      Returns a bare group model.

      Can be used for group creation/search screens.

      Specified by:
      getBareGroupModel in interface UserManager
    • getGroup

      public NuxeoGroup getGroup(String groupName)
      Description copied from interface: UserManager
      Returns the nuxeo group with given name or null if it does not exist.
      Specified by:
      getGroup in interface UserManager
    • getGroupIds

      public List<String> getGroupIds()
      Description copied from interface: UserManager
      Returns the list of all groups ids.
      Specified by:
      getGroupIds in interface UserManager
    • getUserIds

      public List<String> getUserIds()
      Description copied from interface: UserManager
      Returns the list of all user ids.
      Specified by:
      getUserIds in interface UserManager
    • searchGroups

      public DocumentModelList searchGroups(Map<String,Serializable> filter, Set<String> fulltext)
      Description copied from interface: UserManager
      Returns groups matching given criteria.
      Specified by:
      searchGroups in interface UserManager
      Parameters:
      filter - filter with field names as keys
      fulltext - field names used for fulltext match
    • searchGroups

      public DocumentModelList searchGroups(QueryBuilder queryBuilder)
      Description copied from interface: UserManager
      Returns groups matching the given query.
      Specified by:
      searchGroups in interface UserManager
      Parameters:
      queryBuilder - the query to use, including limit, offset, ordering and countTotal
    • searchUsers

      public DocumentModelList searchUsers(Map<String,Serializable> filter, Set<String> fulltext)
      Description copied from interface: UserManager
      Returns users matching given criteria.
      Specified by:
      searchUsers in interface UserManager
      Parameters:
      filter - filter with field names as keys
      fulltext - field names used for fulltext match
    • searchUsers

      public DocumentModelList searchUsers(String pattern)
      Description copied from interface: UserManager
      Returns users matching given pattern

      Pattern is used to fill a filter and fulltext map according to users search fields configuration. Search is performed on each of these fields (OR).

      Specified by:
      searchUsers in interface UserManager
    • searchUsers

      public DocumentModelList searchUsers(QueryBuilder queryBuilder)
      Description copied from interface: UserManager
      Returns users matching the given query.
      Specified by:
      searchUsers in interface UserManager
      Parameters:
      queryBuilder - the query to use, including limit, offset, ordering and countTotal
    • updateGroup

      public void updateGroup(DocumentModel groupModel)
      Description copied from interface: UserManager
      Updates group represented by given model.
      Specified by:
      updateGroup in interface UserManager
    • updateUser

      public void updateUser(DocumentModel userModel)
      Description copied from interface: UserManager
      Updates user represented by given model.
      Specified by:
      updateUser in interface UserManager
    • getGroupModel

      public DocumentModel getGroupModel(String groupName)
      Description copied from interface: UserManager
      Return the group document model with this id or null if group does not exist.
      Specified by:
      getGroupModel in interface UserManager
      Parameters:
      groupName - the group identifier
    • getUserModel

      public DocumentModel getUserModel(String userName)
      Description copied from interface: UserManager
      Returns the document model representing user with given id or null if it does not exist.
      Specified by:
      getUserModel in interface UserManager
    • getGroupIdField

      public String getGroupIdField()
      Description copied from interface: UserManager
      Returns the group directory id field.
      Specified by:
      getGroupIdField in interface UserManager
    • getGroupLabelField

      public String getGroupLabelField()
      Description copied from interface: UserManager
      Returns the group label field.
      Specified by:
      getGroupLabelField in interface UserManager
    • getGroupSchemaName

      public String getGroupSchemaName()
      Description copied from interface: UserManager
      Returns the group directory schema name.
      Specified by:
      getGroupSchemaName in interface UserManager
    • getUserIdField

      public String getUserIdField()
      Description copied from interface: UserManager
      Returns the user directory id field.
      Specified by:
      getUserIdField in interface UserManager
    • getUserSchemaName

      public String getUserSchemaName()
      Description copied from interface: UserManager
      Returns the user directory schema name.
      Specified by:
      getUserSchemaName in interface UserManager
    • getAdministratorsGroups

      public List<String> getAdministratorsGroups()
      Description copied from interface: UserManager
      Returns the list of administrators groups.
      Specified by:
      getAdministratorsGroups in interface UserManager
    • getUsersForPermission

      public String[] getUsersForPermission(String perm, ACP acp)
      Description copied from interface: UserManager
      For an ACP, get the list of user that has a permission. This method should be use with care as it can cause performance issues while getting the list of users.
      Specified by:
      getUsersForPermission in interface UserManager
      Parameters:
      perm - the permission
      acp - The access control policy of the document
      Returns:
      the list of user ids
    • authenticate

      public Principal authenticate(String name, String password)
      Description copied from interface: Authenticator
      Get a principal object for the given username if the username / password pair is valid, otherwise returns null.

      This method is doing the authentication of the given username / password pair and returns the corresponding principal object if authentication succeeded otherwise returns null.

      Specified by:
      authenticate in interface Authenticator
      Returns:
      the authenticated principal if authentication succeded otherwise null
    • handleEvent

      public void handleEvent(Event event)
      Description copied from interface: EventListener
      An event was received.
      Specified by:
      handleEvent in interface EventListener
    • getAncestorGroups

      public List<String> getAncestorGroups(String groupId)
      Description copied from interface: UserManager
      Returns the ancestor groups of the group with the given id.
      Specified by:
      getAncestorGroups in interface UserManager
    • getDescendantGroups

      public List<String> getDescendantGroups(String groupId)
      Description copied from interface: UserManager
      Returns the descendant groups of the group with the given id.
      Specified by:
      getDescendantGroups in interface UserManager
    • getGroupConfig

      public GroupConfig getGroupConfig()
      Description copied from interface: UserManager
      Returns the contributed GroupConfig.
      Specified by:
      getGroupConfig in interface UserManager
    • notifyUserChanged

      public void notifyUserChanged(String userName, String eventId)
      Description copied from interface: UserManager
      Notifies that the given user has changed with the given event:
      • At the runtime level so that the JaasCacheFlusher listener can make sure the principal cache is reset.
      • At the core level, passing the userName as the "id" property of the fired event.
      Specified by:
      notifyUserChanged in interface UserManager
    • notifyGroupChanged

      public void notifyGroupChanged(String groupName, String eventId, List<String> ancestorGroupNames)
      Description copied from interface: UserManager
      Notifies that the given group has changed with the given event:
      • At the runtime level so that the JaasCacheFlusher listener can make sure the principal cache is reset.
      • At the core level, passing the groupName as the "id" property of the fired event.

      The ancestorGroupNames list must contain the ancestor groups of the given group. It can be computed by calling UserManager.getAncestorGroups(String). It will be passed as the "ancestorGroups" property of the fired core event.

      Specified by:
      notifyGroupChanged in interface UserManager