public class MockUserManager extends Object implements UserManager
UserManager.UserState| Constructor and Description | 
|---|
MockUserManager()  | 
MockUserManager(MockCrowdService crowdService)  | 
MockUserManager(MockUserKeyService mockUserKeyService)  | 
| Modifier and Type | Method and Description | 
|---|---|
ApplicationUser | 
addUser(ApplicationUser user)  | 
MockUserManager | 
alwaysReturnUsers()  | 
boolean | 
canDirectoryUpdateUserPassword(com.atlassian.crowd.embedded.api.Directory directory)
Checks if the given directory is able to update user passwords. 
 | 
boolean | 
canRenameUser(ApplicationUser user)
Test if this user can be renamed. 
 | 
boolean | 
canUpdateGroupMembershipForUser(ApplicationUser user)
Test if this user's group membership can be updated, i.e. 
 | 
boolean | 
canUpdateUser(ApplicationUser user)
Test if this user can be updated, i.e. 
 | 
boolean | 
canUpdateUserPassword(ApplicationUser user)
Test if this user's password can be updated, i.e. 
 | 
ApplicationUser | 
createUser(UserDetails userData)
Creates a user in the specified directory (userDirectoryId). 
 | 
MockUserManager | 
doNotUseCrowdServiceToGetUsers()  | 
ApplicationUser | 
findUserInDirectory(String userName,
                   Long directoryId)
Returns a  
User based on user name and directoryId | 
String | 
generateRandomPassword()
Generates a random password that can be used when the admin has entered a blank password. 
 | 
Collection<ApplicationUser> | 
getAllApplicationUsers()
Returns all users defined in JIRA, regardless of whether they are active or not. 
 | 
Set<com.atlassian.crowd.embedded.api.Group> | 
getAllGroups()
Returns all groups defined in JIRA. 
 | 
Set<ApplicationUser> | 
getAllUsers()
Returns all users defined in JIRA, regardless of whether they are active or not. 
 | 
Optional<com.atlassian.crowd.embedded.api.Directory> | 
getDefaultCreateDirectory()
Get the  
Directory in which users will be created by default | 
com.atlassian.crowd.embedded.api.Directory | 
getDirectory(Long directoryId)  | 
com.atlassian.crowd.embedded.api.Group | 
getGroup(String groupName)
Returns a  
Group based on user name. | 
com.atlassian.crowd.embedded.api.Group | 
getGroupObject(String groupName)
Returns a  
Group based on user name. | 
Collection<com.atlassian.crowd.embedded.api.Group> | 
getGroups()
Returns all groups defined in JIRA. 
 | 
MockUserKeyService | 
getMockUserKeyService()  | 
int | 
getTotalUserCount()
Returns the total number of users defined in JIRA, regardless of whether they are active or not. 
 | 
ApplicationUser | 
getUser(String userName)
Returns a  
User based on user name. | 
Optional<ApplicationUser> | 
getUserById(Long id)
Returns a user based in id. 
 | 
ApplicationUser | 
getUserByKey(String userKey)
Returns an  
ApplicationUser based on user key. | 
ApplicationUser | 
getUserByKeyEvenWhenUnknown(String userKey)
Returns an  
ApplicationUser based on user key. | 
ApplicationUser | 
getUserByName(String userName)
Returns an  
ApplicationUser based on user name. | 
ApplicationUser | 
getUserByNameEvenWhenUnknown(String userName)
Returns an  
ApplicationUser based on user name. | 
ApplicationUser | 
getUserEvenWhenUnknown(String userName)
Returns a  
User based on user name. | 
Optional<UserIdentity> | 
getUserIdentityById(Long id)
Returns an identity of the user with the specified id. 
 | 
Optional<UserIdentity> | 
getUserIdentityByKey(String key)
Returns an identity of the user with the specified key. 
 | 
Optional<UserIdentity> | 
getUserIdentityByUsername(String username)
Returns an identity of the user with the specified username. 
 | 
ApplicationUser | 
getUserObject(String userName)
Returns a  
User based on user name. | 
Collection<ApplicationUser> | 
getUsers()
Returns all users defined in JIRA, regardless of whether they are active or not. 
 | 
UserManager.UserState | 
getUserState(ApplicationUser user)
This convenience method is equivalent to
  
getUserState(user.getUsername(), user.getDirectoryId())
 except that a null user is permitted and returns UserManager.UserState.INVALID_USER. | 
UserManager.UserState | 
getUserState(String username,
            long directoryId)
Checks for the existence of this user across all directories to determine
 whether or not the user exists in the specified directory and whether or not
 it is shadowing or shadowed by a user with the same username in another
 active user directory. 
 | 
List<com.atlassian.crowd.embedded.api.Directory> | 
getWritableDirectories()
Returns an ordered list of directories that have "read-write" permission. 
 | 
boolean | 
hasGroupWritableDirectory()
Returns true if any of the directories have permission to update groups. 
 | 
boolean | 
hasPasswordWritableDirectory()
Returns true if any of the directories have permission to update user passwords, false if otherwise. 
 | 
boolean | 
hasWritableDirectory()
Returns true if at least one User Directory has "read-write" permission. 
 | 
boolean | 
isUserExisting(ApplicationUser user)
Checks if given user is existing user 
 | 
void | 
putDirectory(Long directoryId,
            com.atlassian.crowd.embedded.api.Directory directory)  | 
void | 
setCrowdService(MockCrowdService crowdService)  | 
void | 
setGroupWritableDirectory(boolean groupWritableDirectory)  | 
void | 
setWritableDirectory(boolean writableDirectory)  | 
void | 
updateUser(ApplicationUser user)
Updates the  
ApplicationUser. | 
MockUserManager | 
useCrowdServiceToGetUsers()  | 
boolean | 
userCanUpdateOwnDetails(ApplicationUser user)
Check if this user is allowed to update their own user details. 
 | 
public MockUserManager()
public MockUserManager(MockUserKeyService mockUserKeyService)
public MockUserManager(MockCrowdService crowdService)
public MockUserManager alwaysReturnUsers()
public MockUserManager useCrowdServiceToGetUsers()
public MockUserManager doNotUseCrowdServiceToGetUsers()
public Optional<ApplicationUser> getUserById(Long id)
UserManagergetUserById in interface UserManagerid - user idpublic void setCrowdService(MockCrowdService crowdService)
public int getTotalUserCount()
UserManagergetTotalUserCount in interface UserManager@Nonnull public Set<ApplicationUser> getAllUsers()
UserManagergetAllUsers in interface UserManagerpublic ApplicationUser getUser(@Nullable String userName)
UserManagerUser based on user name.
 getUser in interface UserManageruserName - the user name of the userpublic ApplicationUser getUserObject(@Nullable String userName)
UserManagerUser based on user name.
 getUserObject in interface UserManageruserName - the user name of the userpublic ApplicationUser getUserByKey(@Nullable String userKey)
UserManagerApplicationUser based on user key.getUserByKey in interface UserManageruserKey - the key of the userpublic ApplicationUser getUserByName(@Nullable String userName)
UserManagerApplicationUser based on user name.getUserByName in interface UserManageruserName - the user name of the userpublic ApplicationUser getUserByKeyEvenWhenUnknown(@Nullable String userKey)
UserManagerApplicationUser based on user key.
 
 If you want to check if given user is known user - please use UserManager.isUserExisting(com.atlassian.jira.user.ApplicationUser)
getUserByKeyEvenWhenUnknown in interface UserManageruserKey - the key of the userpublic ApplicationUser getUserByNameEvenWhenUnknown(@Nullable String userName)
UserManagerApplicationUser based on user name.
 
 If you want to check if given user is known user - please use UserManager.isUserExisting(com.atlassian.jira.user.ApplicationUser)
getUserByNameEvenWhenUnknown in interface UserManageruserName - the user name of the userpublic ApplicationUser findUserInDirectory(String userName, Long directoryId)
UserManagerUser based on user name and directoryIdfindUserInDirectory in interface UserManageruserName - the user name of the userdirectoryId - the Directory to look inpublic ApplicationUser getUserEvenWhenUnknown(String userName)
UserManagerUser based on user name.
 
 If a null username is passed, then a null User object is returned, but it is guaranteed to return a non-null User in all other cases.
 If the username is not null, but the User is not found then a proxy unknown immutable User object is returned.
getUserEvenWhenUnknown in interface UserManageruserName - the user name of the userpublic boolean canUpdateUser(ApplicationUser user)
UserManagercanUpdateUser in interface UserManageruser - The user to update.public boolean userCanUpdateOwnDetails(@Nonnull ApplicationUser user)
UserManagerReturns true if the given user is in a read-write directory AND the "External user management" setting is off.
userCanUpdateOwnDetails in interface UserManageruser - The userpublic boolean canRenameUser(ApplicationUser user)
UserManagerUserManager.canUpdateUser(ApplicationUser),
 renaming a user is only allowed when:
 
INTERNAL
 or DELEGATING user directory;
 ANDAPKeys.JIRA_OPTION_USER_CROWD_ALLOW_RENAME
 is enabled to bypass this check.canRenameUser in interface UserManageruser - The user to rename.null and can be renamed.public void updateUser(ApplicationUser user)
UserManagerApplicationUser. The user must have non-null names and email address.  If the user's name
 does not match the name that is currently associated with the key, then
 this is implicitly treated as a request to rename the user.updateUser in interface UserManageruser - The user to update.public boolean canUpdateUserPassword(ApplicationUser user)
UserManagerIf the "External user management", or "External password management" setting is on, then you cannot update the password.
canUpdateUserPassword in interface UserManageruser - The user to update.null and the user's password can be updated.public boolean canUpdateGroupMembershipForUser(ApplicationUser user)
UserManagercanUpdateGroupMembershipForUser in interface UserManageruser - The user to update.null and can be updated.public Set<com.atlassian.crowd.embedded.api.Group> getAllGroups()
UserManager
 Warning: previous incarnations of this method returned com.opensymphony.user.User. This class
 has now been removed from the JIRA API, meaning that the 5.0 version is not binary or source compatible with
 earlier versions.
getAllGroups in interface UserManagerpublic com.atlassian.crowd.embedded.api.Group getGroup(@Nullable String groupName)
UserManagerGroup based on user name.
 
 Warning: previous incarnations of this method returned com.opensymphony.user.User. This class
 has now been removed from the JIRA API, meaning that the 5.0 version is not binary or source compatible with
 earlier versions.
getGroup in interface UserManagergroupName - the user name of the grouppublic com.atlassian.crowd.embedded.api.Group getGroupObject(@Nullable String groupName)
UserManagerGroup based on user name.
 
 Legacy synonym for UserManager.getGroup(String).
getGroupObject in interface UserManagergroupName - the user name of the groupUserManager.getGroup(String)@Nonnull public List<com.atlassian.crowd.embedded.api.Directory> getWritableDirectories()
UserManagergetWritableDirectories in interface UserManagerUserManager.hasWritableDirectory()@Nonnull public Optional<com.atlassian.crowd.embedded.api.Directory> getDefaultCreateDirectory()
UserManagerDirectory in which users will be created by defaultgetDefaultCreateDirectory in interface UserManagerDirectory or Option.none() in case there is no writable directoriespublic boolean hasWritableDirectory()
UserManager
 This is equivalent to:
   getWritableDirectories().size() > 0
hasWritableDirectory in interface UserManagerUserManager.getWritableDirectories(), 
UserManager.hasPasswordWritableDirectory(), 
UserManager.hasGroupWritableDirectory()public void setWritableDirectory(boolean writableDirectory)
public boolean hasPasswordWritableDirectory()
UserManager
 Note that this is not quite the same as UserManager.hasWritableDirectory() because of "Internal with LDAP Authentication" directories.
 These directories are generally read-write but passwords are read-only.
hasPasswordWritableDirectory in interface UserManagerUserManager.hasWritableDirectory()public boolean hasGroupWritableDirectory()
UserManager
 Note that this will not always return the same results as UserManager.hasWritableDirectory() because you can set "Read-Only with Local Groups" to LDAP directories.
 These directories are generally read-only but you can create local gropus and assign users to them.
hasGroupWritableDirectory in interface UserManagerUserManager.hasWritableDirectory()public void setGroupWritableDirectory(boolean groupWritableDirectory)
public boolean canDirectoryUpdateUserPassword(com.atlassian.crowd.embedded.api.Directory directory)
UserManagercanDirectoryUpdateUserPassword in interface UserManagerdirectory - the Directorypublic com.atlassian.crowd.embedded.api.Directory getDirectory(Long directoryId)
getDirectory in interface UserManagerpublic boolean isUserExisting(@Nullable ApplicationUser user)
UserManagerisUserExisting in interface UserManageruser - possible existing user object - i.e. recieved from UserManager.getUserByKeyEvenWhenUnknown(String) or UserManager.getUserByNameEvenWhenUnknown(String)true if given user is real user, false otherwise (also when given object is null)UserManager.getUserByKeyEvenWhenUnknown(String), 
UserManager.getUserByNameEvenWhenUnknown(String)@Nonnull public String generateRandomPassword()
UserManagerThe password is guaranteed to contain at least one upper-case letter, lower-case letter and number in case the backend user Directory has password restrictions.
generateRandomPassword in interface UserManager@Nonnull public Collection<ApplicationUser> getUsers()
UserManager
 Legacy synonym for UserManager.getAllUsers().
getUsers in interface UserManagerUserManager.getAllUsers()@Nonnull public Collection<ApplicationUser> getAllApplicationUsers()
UserManagergetAllApplicationUsers in interface UserManagerpublic Collection<com.atlassian.crowd.embedded.api.Group> getGroups()
UserManager
 Legacy synonym for UserManager.getAllGroups().
getGroups in interface UserManagerUserManager.getAllGroups()public ApplicationUser addUser(ApplicationUser user)
public MockUserKeyService getMockUserKeyService()
@Nonnull public UserManager.UserState getUserState(@Nullable ApplicationUser user)
UserManagergetUserState(user.getUsername(), user.getDirectoryId())
 except that a null user is permitted and returns UserManager.UserState.INVALID_USER.getUserState in interface UserManageruser - the user to check@Nonnull public ApplicationUser createUser(@Nonnull UserDetails userData) throws CreateException, PermissionException
UserManagerOption.none(),
 the user is created in the default directory (usually an Embedded Crowd internal directory).createUser in interface UserManageruserData - the user request containing user details.CreateException - unable to create user.PermissionException - unable to create user due to permission error.public Optional<UserIdentity> getUserIdentityById(Long id)
UserManagergetUserIdentityById in interface UserManagerid - user idpublic Optional<UserIdentity> getUserIdentityByKey(String key)
UserManagergetUserIdentityByKey in interface UserManagerkey - user keypublic Optional<UserIdentity> getUserIdentityByUsername(String username)
UserManagergetUserIdentityByUsername in interface UserManagerusername - user name@Nonnull public UserManager.UserState getUserState(@Nonnull String username, long directoryId)
UserManagergetUserState in interface UserManagerusername - the username to checkdirectoryId - the directory ID of the user directory that the user came frompublic void putDirectory(Long directoryId, com.atlassian.crowd.embedded.api.Directory directory)
Copyright © 2002-2017 Atlassian. All Rights Reserved.