|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface UserManager
Simple user utilities that do not require an implementation with too many dependencies.
Nested Class Summary | |
---|---|
static class |
UserManager.UserState
The current state of a user with regard to the same username existing in other user directories. |
Method Summary | |
---|---|
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(com.atlassian.crowd.embedded.api.User 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 |
canUpdateUser(com.atlassian.crowd.embedded.api.User user)
Deprecated. Use canUpdateUser(ApplicationUser) instead. Since v6.0. |
boolean |
canUpdateUserPassword(com.atlassian.crowd.embedded.api.User user)
Test if this user's password can be updated, i.e. |
com.atlassian.crowd.embedded.api.User |
findUserInDirectory(String userName,
Long directoryId)
Returns a User based on user name and directoryId |
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<com.atlassian.crowd.embedded.api.User> |
getAllUsers()
Returns all users defined in JIRA, regardless of whether they are active or not. |
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. |
int |
getTotalUserCount()
Returns the total number of users defined in JIRA, regardless of whether they are active or not. |
com.atlassian.crowd.embedded.api.User |
getUser(String userName)
Deprecated. Use getUserByKey(String) or getUserByName(String) instead. Since v6.0. |
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. |
com.atlassian.crowd.embedded.api.User |
getUserEvenWhenUnknown(String userName)
Deprecated. Use getUserByKeyEvenWhenUnknown(String) or getUserByNameEvenWhenUnknown(String) instead. Since v6.0. |
com.atlassian.crowd.embedded.api.User |
getUserObject(String userName)
Deprecated. Use getUserByKey(String) or getUserByName(String) instead. Since v6.0. |
Collection<com.atlassian.crowd.embedded.api.User> |
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. |
UserManager.UserState |
getUserState(com.atlassian.crowd.embedded.api.User user)
This convenience method is equivalent to getUserState(user.getName(), user.getDirectoryId())
except that a null user is permitted and returns UserManager.UserState.INVALID_USER . |
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 |
updateUser(ApplicationUser user)
Updates the ApplicationUser . |
void |
updateUser(com.atlassian.crowd.embedded.api.User user)
Updates the User . |
Method Detail |
---|
int getTotalUserCount()
@Nonnull Set<com.atlassian.crowd.embedded.api.User> getAllUsers()
@Nonnull Collection<com.atlassian.crowd.embedded.api.User> getUsers()
getAllUsers()
.
getAllUsers()
@Nonnull Collection<ApplicationUser> getAllApplicationUsers()
com.atlassian.crowd.embedded.api.User getUser(@Nullable String userName)
getUserByKey(String)
or getUserByName(String)
instead. Since v6.0.
User
based on user name.
userName
- the user name of the user
com.atlassian.crowd.embedded.api.User getUserObject(@Nullable String userName)
getUserByKey(String)
or getUserByName(String)
instead. Since v6.0.
User
based on user name.
userName
- the user name of the user
@Nullable ApplicationUser getUserByKey(@Nullable String userKey)
ApplicationUser
based on user key.
userKey
- the key of the user
@Nullable ApplicationUser getUserByName(@Nullable String userName)
ApplicationUser
based on user name.
userName
- the user name of the user
IllegalStateException
- if the CrowdService
is able to resolve userName
to a User
, but the
UserKeyService
does not have a key mapped for it.
This is not a valid configuration.@Nullable ApplicationUser getUserByKeyEvenWhenUnknown(@Nullable String userKey)
ApplicationUser
based on user key.
If you want to check if given user is known user - please use isUserExisting(com.atlassian.jira.user.ApplicationUser)
userKey
- the key of the user
@Nullable ApplicationUser getUserByNameEvenWhenUnknown(@Nullable String userName)
ApplicationUser
based on user name.
If you want to check if given user is known user - please use isUserExisting(com.atlassian.jira.user.ApplicationUser)
userName
- the user name of the user
IllegalStateException
- if the CrowdService
is able to resolve userName
to a User
, but the
UserKeyService
does not have a key mapped for it.
This is not a valid configuration.@Nullable com.atlassian.crowd.embedded.api.User findUserInDirectory(@Nullable String userName, Long directoryId)
User
based on user name and directoryId
userName
- the user name of the userdirectoryId
- the Directory to look in
@Nullable com.atlassian.crowd.embedded.api.User getUserEvenWhenUnknown(@Nullable String userName)
getUserByKeyEvenWhenUnknown(String)
or getUserByNameEvenWhenUnknown(String)
instead. Since v6.0.
User
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.
userName
- the user name of the user
boolean canUpdateUser(@Nullable com.atlassian.crowd.embedded.api.User user)
canUpdateUser(ApplicationUser)
instead. Since v6.0.
If the "External user management" setting is on, then you cannot update the user.
user
- The user to update.
null
and can be updated.boolean canUpdateUser(@Nullable ApplicationUser user)
user
- The user to update.
null
and can be updated.boolean canRenameUser(@Nullable ApplicationUser user)
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.
user
- The user to rename.
null
and can be renamed.void updateUser(com.atlassian.crowd.embedded.api.User user)
User
. The user must have non-null names and email address.
user
- The user to update.
com.atlassian.crowd.exception.runtime.UserNotFoundException
- If the supplied user does not exist in the directory
.
com.atlassian.crowd.exception.runtime.OperationFailedException
- If the underlying directory implementation failed to execute the operation.
IllegalArgumentException
- If something is wrong with the provided user objectvoid updateUser(ApplicationUser user)
ApplicationUser
. 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.
user
- The user to update.
com.atlassian.crowd.exception.runtime.UserNotFoundException
- If the supplied user does not exist in the directory
.
com.atlassian.crowd.exception.runtime.OperationFailedException
- If the underlying directory implementation failed to execute the operation.
IllegalArgumentException
- If something is wrong with the provided user objectboolean canUpdateUserPassword(@Nullable com.atlassian.crowd.embedded.api.User user)
If the "External user management", or "External password management" setting is on, then you cannot update the password.
user
- The user to update.
null
and the user's password can be updated.boolean canUpdateGroupMembershipForUser(com.atlassian.crowd.embedded.api.User user)
user
- The user to update.
null
and can be updated.@IncompatibleReturnType(since="5.0", was="java.util.Set") Set<com.atlassian.crowd.embedded.api.Group> getAllGroups()
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.
Collection<com.atlassian.crowd.embedded.api.Group> getGroups()
getAllGroups()
.
getAllGroups()
@IncompatibleReturnType(since="5.0", was="com.opensymphony.user.User") com.atlassian.crowd.embedded.api.Group getGroup(@Nullable String groupName)
Group
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.
groupName
- the user name of the group
com.atlassian.crowd.embedded.api.Group getGroupObject(@Nullable String groupName)
Group
based on user name.
Legacy synonym for getGroup(String)
.
groupName
- the user name of the group
getGroup(String)
@Nonnull List<com.atlassian.crowd.embedded.api.Directory> getWritableDirectories()
hasWritableDirectory()
boolean hasWritableDirectory()
This is equivalent to:
getWritableDirectories().size() > 0
getWritableDirectories()
,
hasPasswordWritableDirectory()
,
hasGroupWritableDirectory()
boolean hasPasswordWritableDirectory()
Note that this is not quite the same as hasWritableDirectory()
because of "Internal with LDAP Authentication" directories.
These directories are generally read-write but passwords are read-only.
hasWritableDirectory()
boolean hasGroupWritableDirectory()
Note that this will not always return the same results as 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.
hasWritableDirectory()
boolean canDirectoryUpdateUserPassword(@Nullable com.atlassian.crowd.embedded.api.Directory directory)
directory
- the Directory
com.atlassian.crowd.embedded.api.Directory getDirectory(Long directoryId)
boolean isUserExisting(@Nullable ApplicationUser user)
user
- possible existing user object - i.e. recieved from getUserByKeyEvenWhenUnknown(String)
or getUserByNameEvenWhenUnknown(String)
true
if given user is real user, false
otherwise (also when given object is null
)getUserByKeyEvenWhenUnknown(String)
,
getUserByNameEvenWhenUnknown(String)
@ExperimentalApi @Nonnull UserManager.UserState getUserState(@Nonnull String username, long directoryId)
username
- the username to checkdirectoryId
- the directory ID of the user directory that the user came from
@ExperimentalApi @Nonnull UserManager.UserState getUserState(@Nullable com.atlassian.crowd.embedded.api.User user)
getUserState(user.getName(), user.getDirectoryId())
except that a null
user is permitted and returns UserManager.UserState.INVALID_USER
.
user
- the user to check
@ExperimentalApi @Nonnull UserManager.UserState getUserState(@Nullable ApplicationUser user)
getUserState(user.getUsername(), user.getDirectoryId())
except that a null
user is permitted and returns UserManager.UserState.INVALID_USER
.
user
- the user to check
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |