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:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.nuxeo.ecm.platform.usermanager.UserManager
UserManager.MatchType
-
-
Constructor Summary
Constructors Constructor Description FakeUserManagerImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description BooleanareGroupsReadOnly()Returns true is users referential is read only (ie : LDAP) -> can not add users -> can not delete users.BooleanareUsersReadOnly()Returns true is groups referential is read only (ie : LDAP) -> can not add groups -> can not delete groups.Principalauthenticate(String name, String password)Get a principal object for the given username if the username / password pair is valid, otherwise returns null.booleancheckUsernamePassword(String username, String password)Check the password for the given username.DocumentModelcreateGroup(DocumentModel groupModel)Creates a group from given modelDocumentModelcreateUser(DocumentModel userModel)Creates user from given model.voiddeleteGroup(String groupId)Deletes group with given id.voiddeleteGroup(DocumentModel groupModel)Deletes group represented by given model.voiddeleteUser(String userId)Deletes user with given id.voiddeleteUser(DocumentModel userModel)Deletes user represented by given model.List<String>getAdministratorsGroups()Returns the list of administrators groups.List<String>getAncestorGroups(String groupId)Returns the ancestor groups of the group with the given id.StringgetAnonymousUserId()Gets the anonymous user id.DocumentModelgetBareGroupModel()Returns a bare group model.DocumentModelgetBareUserModel()Returns a bare user model.StringgetDefaultGroup()List<String>getDescendantGroups(String groupId)Returns the descendant groups of the group with the given id.StringgetDigestAuthDirectory()Gets the Digest Auth directory.StringgetDigestAuthRealm()Gets the Digest Auth realm.NuxeoGroupgetGroup(String groupName)Returns the nuxeo group with given name or null if it does not exist.GroupConfiggetGroupConfig()Returns the contributedGroupConfig.StringgetGroupDirectoryName()Gets the group directory name.StringgetGroupIdField()Returns the group directory id field.List<String>getGroupIds()Returns the list of all groups ids.StringgetGroupLabelField()Returns the group label field.StringgetGroupListingMode()StringgetGroupMembersField()Gets the group members field.DocumentModelgetGroupModel(String groupName)Return the group document model with this id or null if group does not exist.StringgetGroupParentGroupsField()Gets the group parent-groups field.StringgetGroupSchemaName()Returns the group directory schema name.Set<String>getGroupSearchFields()Gets the group search fields.List<String>getGroupsInGroup(String parentId)Returns the list of groups that belong to this group.StringgetGroupSubGroupsField()Gets the group sub-groups field.NuxeoPrincipalgetPrincipal(String username, boolean fetchReferences)Retrieves the principal with the given username or null if it does not exist.List<String>getTopLevelGroups()Returns the list of groups that are not members of other groups.StringgetUserDirectoryName()Gets the user directory name.StringgetUserEmailField()Gets the user email field.StringgetUserIdField()Returns the user directory id field.List<String>getUserIds()Returns the list of all user ids.StringgetUserListingMode()DocumentModelgetUserModel(String userName)Returns the document model representing user with given id or null if it does not exist.PatterngetUserPasswordPattern()StringgetUserSchemaName()Returns the user directory schema name.Set<String>getUserSearchFields()Gets the user search fields, the fields to use when a principal search is done.String[]getUsersForPermission(String perm, ACP acp)For an ACP, get the list of user that has a permission.List<String>getUsersInGroup(String groupId)Returns the list of users that belong to this group.List<String>getUsersInGroupAndSubGroups(String groupId)Get users from a group and its subgroups.StringgetUserSortField()voidhandleEvent(Event event)An event was received.voidnotifyGroupChanged(String groupName, String eventId, List<String> ancestorGroupNames)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 thegroupNameas the"id"property of the fired event.voidnotifyUserChanged(String userName, String eventId)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 theuserNameas the"id"property of the fired event.DocumentModelListsearchGroups(String pattern)Search matching groups through their defined search fieldsDocumentModelListsearchGroups(Map<String,Serializable> filter, Set<String> fulltext)Returns groups matching given criteria.DocumentModelListsearchGroups(QueryBuilder queryBuilder)Returns groups matching the given query.List<NuxeoPrincipal>searchPrincipals(String pattern)DocumentModelListsearchUsers(String pattern)Returns users matching given patternDocumentModelListsearchUsers(Map<String,Serializable> filter, Set<String> fulltext)Returns users matching given criteria.DocumentModelListsearchUsers(QueryBuilder queryBuilder)Returns users matching the given query.voidsetAnonymousUser(VirtualUser anonymousUser)voidsetConfiguration(UserManagerDescriptor descriptor)Sets the given configuration on the service.voidsetDefaultGroup(String defaultGroup)voidsetGroupDirectoryName(String groupDirectoryName)voidsetGroupListingMode(String groupListingMode)voidsetGroupMembersField(String groupMembersField)voidsetGroupParentGroupsField(String groupParentGroupsField)voidsetGroupSearchFields(Map<String,UserManager.MatchType> groupSearchFields)voidsetGroupSortField(String sortField)voidsetGroupSubGroupsField(String groupSubGroupsField)voidsetUserDirectoryName(String userDirectoryName)voidsetUserEmailField(String userEmailField)voidsetUserListingMode(String userListingMode)voidsetUserPasswordPattern(Pattern userPasswordPattern)voidsetUserSearchFields(Map<String,UserManager.MatchType> userSearchFields)voidsetUserSearchFields(Set<String> userSearchFields)voidsetUserSortField(String sortField)voidsetVirtualUsers(Map<String,VirtualUserDescriptor> virtualUsers)voidupdateGroup(DocumentModel groupModel)Updates group represented by given model.voidupdateUser(DocumentModel userModel)Updates user represented by given model.booleanvalidatePassword(String password)-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.nuxeo.ecm.platform.usermanager.UserManager
getPrincipal, notifyGroupChanged
-
-
-
-
Method Detail
-
getUserListingMode
public String getUserListingMode()
- Specified by:
getUserListingModein interfaceUserManager
-
setUserListingMode
public void setUserListingMode(String userListingMode)
-
getGroupListingMode
public String getGroupListingMode()
- Specified by:
getGroupListingModein interfaceUserManager
-
setGroupListingMode
public void setGroupListingMode(String groupListingMode)
-
getDefaultGroup
public String getDefaultGroup()
- Specified by:
getDefaultGroupin interfaceUserManager
-
setDefaultGroup
public void setDefaultGroup(String defaultGroup)
-
getUserSortField
public String getUserSortField()
- Specified by:
getUserSortFieldin interfaceUserManager
-
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:UserManagerGets the user directory name.- Specified by:
getUserDirectoryNamein interfaceUserManager- Returns:
- the user directory name.
-
setUserEmailField
public void setUserEmailField(String userEmailField)
-
getUserEmailField
public String getUserEmailField()
Description copied from interface:UserManagerGets the user email field.- Specified by:
getUserEmailFieldin interfaceUserManager- Returns:
- the user email field.
-
setUserSearchFields
public void setUserSearchFields(Map<String,UserManager.MatchType> userSearchFields)
-
getUserSearchFields
public Set<String> getUserSearchFields()
Description copied from interface:UserManagerGets the user search fields, the fields to use when a principal search is done.- Specified by:
getUserSearchFieldsin interfaceUserManager- Returns:
- the search fields.
-
setGroupSearchFields
public void setGroupSearchFields(Map<String,UserManager.MatchType> groupSearchFields)
-
getGroupSearchFields
public Set<String> getGroupSearchFields()
Description copied from interface:UserManagerGets the group search fields.- Specified by:
getGroupSearchFieldsin interfaceUserManager
-
setGroupDirectoryName
public void setGroupDirectoryName(String groupDirectoryName)
-
getGroupDirectoryName
public String getGroupDirectoryName()
Description copied from interface:UserManagerGets the group directory name.- Specified by:
getGroupDirectoryNamein interfaceUserManager- Returns:
- the group directory name.
-
setGroupMembersField
public void setGroupMembersField(String groupMembersField)
-
getGroupMembersField
public String getGroupMembersField()
Description copied from interface:UserManagerGets the group members field.- Specified by:
getGroupMembersFieldin interfaceUserManager- Returns:
- the group members field.
-
setGroupSubGroupsField
public void setGroupSubGroupsField(String groupSubGroupsField)
-
getGroupSubGroupsField
public String getGroupSubGroupsField()
Description copied from interface:UserManagerGets the group sub-groups field.- Specified by:
getGroupSubGroupsFieldin interfaceUserManager- Returns:
- the sub-groups field.
-
setGroupParentGroupsField
public void setGroupParentGroupsField(String groupParentGroupsField)
-
getGroupParentGroupsField
public String getGroupParentGroupsField()
Description copied from interface:UserManagerGets the group parent-groups field.- Specified by:
getGroupParentGroupsFieldin interfaceUserManager- Returns:
- the parent-groups field.
-
areGroupsReadOnly
public Boolean areGroupsReadOnly()
Description copied from interface:UserManagerReturns true is users referential is read only (ie : LDAP) -> can not add users -> can not delete users.- Specified by:
areGroupsReadOnlyin interfaceUserManager
-
areUsersReadOnly
public Boolean areUsersReadOnly()
Description copied from interface:UserManagerReturns true is groups referential is read only (ie : LDAP) -> can not add groups -> can not delete groups.- Specified by:
areUsersReadOnlyin interfaceUserManager
-
checkUsernamePassword
public boolean checkUsernamePassword(String username, String password)
Description copied from interface:AuthenticatorCheck the password for the given username. Returns true if the username / password pair match, false otherwise.- Specified by:
checkUsernamePasswordin interfaceAuthenticator- Specified by:
checkUsernamePasswordin interfaceUserManager- Parameters:
username- the usernamepassword- the password to check- Returns:
- true is valid, false otherwise
-
validatePassword
public boolean validatePassword(String password)
- Specified by:
validatePasswordin interfaceUserManager
-
getGroupsInGroup
public List<String> getGroupsInGroup(String parentId)
Description copied from interface:UserManagerReturns the list of groups that belong to this group.- Specified by:
getGroupsInGroupin interfaceUserManager- Parameters:
parentId- the name of the parent group.
-
getPrincipal
public NuxeoPrincipal getPrincipal(String username, boolean fetchReferences)
Description copied from interface:UserManagerRetrieves 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:
getPrincipalin interfaceUserManager- Parameters:
username- is the name of the entry in the user directoryfetchReferences- controls if the references (groups) of the user will be fetched
-
getTopLevelGroups
public List<String> getTopLevelGroups()
Description copied from interface:UserManagerReturns the list of groups that are not members of other groups.- Specified by:
getTopLevelGroupsin interfaceUserManager
-
getUsersInGroup
public List<String> getUsersInGroup(String groupId)
Description copied from interface:UserManagerReturns the list of users that belong to this group.- Specified by:
getUsersInGroupin interfaceUserManager- Parameters:
groupId- ID of the group
-
getUsersInGroupAndSubGroups
public List<String> getUsersInGroupAndSubGroups(String groupId)
Description copied from interface:UserManagerGet users from a group and its subgroups.- Specified by:
getUsersInGroupAndSubGroupsin interfaceUserManager- Parameters:
groupId- ID of the group
-
searchGroups
public DocumentModelList searchGroups(String pattern)
Description copied from interface:UserManagerSearch matching groups through their defined search fields- Specified by:
searchGroupsin interfaceUserManager
-
searchPrincipals
public List<NuxeoPrincipal> searchPrincipals(String pattern)
- Specified by:
searchPrincipalsin interfaceUserManager
-
getUserPasswordPattern
public Pattern getUserPasswordPattern()
- Specified by:
getUserPasswordPatternin interfaceUserManager
-
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:UserManagerGets the anonymous user id.- Specified by:
getAnonymousUserIdin interfaceUserManager- Returns:
- the anonymous user id, or the default one if none is defined.
-
getDigestAuthDirectory
public String getDigestAuthDirectory()
Description copied from interface:UserManagerGets the Digest Auth directory.- Specified by:
getDigestAuthDirectoryin interfaceUserManager
-
getDigestAuthRealm
public String getDigestAuthRealm()
Description copied from interface:UserManagerGets the Digest Auth realm.- Specified by:
getDigestAuthRealmin interfaceUserManager
-
setConfiguration
public void setConfiguration(UserManagerDescriptor descriptor)
Description copied from interface:UserManagerSets the given configuration on the service.- Specified by:
setConfigurationin interfaceUserManager- Parameters:
descriptor- the descriptor as parsed from xml, merged from the previous one if it exists.
-
getBareUserModel
public DocumentModel getBareUserModel()
Description copied from interface:UserManagerReturns a bare user model.Can be used for user creation/search screens.
- Specified by:
getBareUserModelin interfaceUserManager
-
createGroup
public DocumentModel createGroup(DocumentModel groupModel)
Description copied from interface:UserManagerCreates a group from given model- Specified by:
createGroupin interfaceUserManager- Returns:
- the created group model
-
createUser
public DocumentModel createUser(DocumentModel userModel)
Description copied from interface:UserManagerCreates user from given model.- Specified by:
createUserin interfaceUserManager
-
deleteGroup
public void deleteGroup(DocumentModel groupModel)
Description copied from interface:UserManagerDeletes group represented by given model.- Specified by:
deleteGroupin interfaceUserManager
-
deleteGroup
public void deleteGroup(String groupId)
Description copied from interface:UserManagerDeletes group with given id.- Specified by:
deleteGroupin interfaceUserManager
-
deleteUser
public void deleteUser(DocumentModel userModel)
Description copied from interface:UserManagerDeletes user represented by given model.- Specified by:
deleteUserin interfaceUserManager
-
deleteUser
public void deleteUser(String userId)
Description copied from interface:UserManagerDeletes user with given id.- Specified by:
deleteUserin interfaceUserManager
-
getBareGroupModel
public DocumentModel getBareGroupModel()
Description copied from interface:UserManagerReturns a bare group model.Can be used for group creation/search screens.
- Specified by:
getBareGroupModelin interfaceUserManager
-
getGroup
public NuxeoGroup getGroup(String groupName)
Description copied from interface:UserManagerReturns the nuxeo group with given name or null if it does not exist.- Specified by:
getGroupin interfaceUserManager
-
getGroupIds
public List<String> getGroupIds()
Description copied from interface:UserManagerReturns the list of all groups ids.- Specified by:
getGroupIdsin interfaceUserManager
-
getUserIds
public List<String> getUserIds()
Description copied from interface:UserManagerReturns the list of all user ids.- Specified by:
getUserIdsin interfaceUserManager
-
searchGroups
public DocumentModelList searchGroups(Map<String,Serializable> filter, Set<String> fulltext)
Description copied from interface:UserManagerReturns groups matching given criteria.- Specified by:
searchGroupsin interfaceUserManager- Parameters:
filter- filter with field names as keysfulltext- field names used for fulltext match
-
searchGroups
public DocumentModelList searchGroups(QueryBuilder queryBuilder)
Description copied from interface:UserManagerReturns groups matching the given query.- Specified by:
searchGroupsin interfaceUserManager- 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:UserManagerReturns users matching given criteria.- Specified by:
searchUsersin interfaceUserManager- Parameters:
filter- filter with field names as keysfulltext- field names used for fulltext match
-
searchUsers
public DocumentModelList searchUsers(String pattern)
Description copied from interface:UserManagerReturns users matching given patternPattern 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:
searchUsersin interfaceUserManager
-
searchUsers
public DocumentModelList searchUsers(QueryBuilder queryBuilder)
Description copied from interface:UserManagerReturns users matching the given query.- Specified by:
searchUsersin interfaceUserManager- Parameters:
queryBuilder- the query to use, including limit, offset, ordering and countTotal
-
updateGroup
public void updateGroup(DocumentModel groupModel)
Description copied from interface:UserManagerUpdates group represented by given model.- Specified by:
updateGroupin interfaceUserManager
-
updateUser
public void updateUser(DocumentModel userModel)
Description copied from interface:UserManagerUpdates user represented by given model.- Specified by:
updateUserin interfaceUserManager
-
getGroupModel
public DocumentModel getGroupModel(String groupName)
Description copied from interface:UserManagerReturn the group document model with this id or null if group does not exist.- Specified by:
getGroupModelin interfaceUserManager- Parameters:
groupName- the group identifier
-
getUserModel
public DocumentModel getUserModel(String userName)
Description copied from interface:UserManagerReturns the document model representing user with given id or null if it does not exist.- Specified by:
getUserModelin interfaceUserManager
-
getGroupIdField
public String getGroupIdField()
Description copied from interface:UserManagerReturns the group directory id field.- Specified by:
getGroupIdFieldin interfaceUserManager
-
getGroupLabelField
public String getGroupLabelField()
Description copied from interface:UserManagerReturns the group label field.- Specified by:
getGroupLabelFieldin interfaceUserManager
-
getGroupSchemaName
public String getGroupSchemaName()
Description copied from interface:UserManagerReturns the group directory schema name.- Specified by:
getGroupSchemaNamein interfaceUserManager
-
getUserIdField
public String getUserIdField()
Description copied from interface:UserManagerReturns the user directory id field.- Specified by:
getUserIdFieldin interfaceUserManager
-
getUserSchemaName
public String getUserSchemaName()
Description copied from interface:UserManagerReturns the user directory schema name.- Specified by:
getUserSchemaNamein interfaceUserManager
-
getAdministratorsGroups
public List<String> getAdministratorsGroups()
Description copied from interface:UserManagerReturns the list of administrators groups.- Specified by:
getAdministratorsGroupsin interfaceUserManager
-
getUsersForPermission
public String[] getUsersForPermission(String perm, ACP acp)
Description copied from interface:UserManagerFor 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:
getUsersForPermissionin interfaceUserManager- Parameters:
perm- the permissionacp- 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:AuthenticatorGet 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:
authenticatein interfaceAuthenticator- Returns:
- the authenticated principal if authentication succeded otherwise null
-
handleEvent
public void handleEvent(Event event)
Description copied from interface:EventListenerAn event was received.- Specified by:
handleEventin interfaceEventListener
-
getAncestorGroups
public List<String> getAncestorGroups(String groupId)
Description copied from interface:UserManagerReturns the ancestor groups of the group with the given id.- Specified by:
getAncestorGroupsin interfaceUserManager
-
getDescendantGroups
public List<String> getDescendantGroups(String groupId)
Description copied from interface:UserManagerReturns the descendant groups of the group with the given id.- Specified by:
getDescendantGroupsin interfaceUserManager
-
getGroupConfig
public GroupConfig getGroupConfig()
Description copied from interface:UserManagerReturns the contributedGroupConfig.- Specified by:
getGroupConfigin interfaceUserManager
-
notifyUserChanged
public void notifyUserChanged(String userName, String eventId)
Description copied from interface:UserManagerNotifies 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
userNameas the"id"property of the fired event.
- Specified by:
notifyUserChangedin interfaceUserManager
-
notifyGroupChanged
public void notifyGroupChanged(String groupName, String eventId, List<String> ancestorGroupNames)
Description copied from interface:UserManagerNotifies 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
groupNameas the"id"property of the fired event.
The
ancestorGroupNameslist must contain the ancestor groups of the given group. It can be computed by callingUserManager.getAncestorGroups(String). It will be passed as the"ancestorGroups"property of the fired core event.- Specified by:
notifyGroupChangedin interfaceUserManager
-
-