Package com.atlassian.confluence.user
Interface UserAccessor
- All Superinterfaces:
ConfluenceUserResolver
,com.atlassian.user.search.query.EntityQueryParser
,GroupMembershipAccessor
,GroupResolver
,UserExistenceChecker
,UserPreferencesAccessor
,UserProfilePictureAccessor
- All Known Subinterfaces:
UserAccessorInternal
- All Known Implementing Classes:
DefaultUserAccessor
,ReadOnlyUserAccessor
public interface UserAccessor
extends com.atlassian.user.search.query.EntityQueryParser, UserPreferencesAccessor, ConfluenceUserResolver, UserProfilePictureAccessor, GroupResolver, GroupMembershipAccessor, UserExistenceChecker
This interface will be deprecated and removed in a future release once alternatives are made available.
It is a combination of several interfaces that are more specific and should be used instead.
-
Field Summary
FieldsModifier and TypeFieldDescriptionDeprecated.since 5.2.static final String
The name of the group with special administration privileges in the application.static final String
Deprecated.since 5.2.static final String
Relative path to default profile pictures in the web application, used to determine whether a user has uploaded a custom profile picture. -
Method Summary
Modifier and TypeMethodDescriptioncom.atlassian.user.Group
Creates a group with the specified name and returns it.void
addMembership
(com.atlassian.user.Group group, com.atlassian.user.User user) void
addMembership
(String groupname, String username) com.atlassian.user.User
Deprecated.since 3.5 usecreateUser(User, Credential)
com.atlassian.user.User
Deprecated.since 3.5 usecreateUser(User, Credential)
andaddMembership(Group, User)
void
alterPassword
(com.atlassian.user.User user, String plainTextPassword) void
alterPassword
(com.atlassian.user.User user, String plainTextPassword, String token) boolean
authenticate
(String username, String password) int
Returns the number of users which have access to use Confluence AND consume a Confluence license.int
Get a count of all unsynced users in Confluence.com.atlassian.user.Group
createGroup
(String groupname) createUser
(com.atlassian.user.User userTemplate, com.atlassian.user.security.password.Credential password) void
deactivateUser
(com.atlassian.user.User user) Deactivate the specified user, which prevents them logging in.void
deactivateUserLocally
(com.atlassian.user.User user) Deactivate the specified user, which prevents them logging in.List
<com.atlassian.user.User> findUsersAsList
(com.atlassian.user.search.query.Query<com.atlassian.user.User> search) Deprecated.Since 5.2.com.atlassian.user.Group
getGroupNames
(com.atlassian.user.User user) Gets the list of group names representing the groups the passed in user is a member of.getGroupNamesForUserName
(String userName) Gets the list of group names representing the groups the passed in user is a member of.com.atlassian.user.search.page.Pager
<com.atlassian.user.Group> Returns a pager of all groups in the system.com.atlassian.user.search.page.Pager
<com.atlassian.user.Group> getGroups
(com.atlassian.user.User user) List
<com.atlassian.user.Group> List
<com.atlassian.user.Group> getGroupsByGroupNames
(List<String> groupNames) Returns a list of Group objects where the names match that of the provided list of group names.getMemberNamesAsList
(com.atlassian.user.Group group) Same asGroupMembershipAccessor.getMemberNames(com.atlassian.user.Group)
but returns a List of user names asString
s rather than a Pager.getMembers
(com.atlassian.user.Group group) Returns users who are members of the specified group (either directly or as a member of a nested group).getMembers
(com.atlassian.user.Group group, int limit) Returns users who are members of the specified group.Deprecated.since 5.2.com.opensymphony.module.propertyset.PropertySet
getPropertySet
(ConfluenceUser user) Deprecated, for removal: This API element is subject to removal in a future version.since 7.7, read-only from 10.0, for removal in 11.0.com.atlassian.user.User
Deprecated.since 5.2.com.atlassian.user.search.page.Pager
<String> Returns a pager of all usernames in the system.Returns the names of all users with access to use Confluence.com.atlassian.user.search.page.Pager
<com.atlassian.user.User> getUsers()
Returns a pager of all users in the system.com.atlassian.user.search.SearchResult
<com.atlassian.user.User> getUsersByEmail
(String email) List
<com.atlassian.user.Group> Gets all editable groups.boolean
hasMembership
(com.atlassian.user.Group group, com.atlassian.user.User user) Returnstrue
if the specified user and group both exist, and the user is a member of the group (either directly or as a member of a nested group).boolean
hasMembership
(String groupName, String username) Returnstrue
if the specified user and group both exist, and the user is a member of the group (either directly or as a member of a nested group).boolean
isDeactivated
(com.atlassian.user.User user) Deprecated.since 7.17 UseDisabledUserManager.isDisabled(User)
boolean
isDeactivated
(String username) Deprecated.since 7.17 UseDisabledUserManager.isDisabled(String)
boolean
Deprecated.since 7.17 useUserChecker.isLicensedToAddMoreUsers()
boolean
isReadOnly
(com.atlassian.user.Group group) Returnstrue
if the group cannot be modified or removed.boolean
isReadOnly
(com.atlassian.user.User user) Returnstrue
if the user cannot be modified or removed.boolean
isSuperUser
(com.atlassian.user.User user) Deprecated.since 3.5boolean
isUserRemovable
(com.atlassian.user.User user) void
reactivateUser
(com.atlassian.user.User user) Marks the specified user as active, which allows them to log in.void
reactivateUserLocally
(com.atlassian.user.User user) Marks the specified user as active, which allows them to log in.void
removeGroup
(com.atlassian.user.Group group) Removes the specified group.boolean
removeMembership
(com.atlassian.user.Group group, com.atlassian.user.User user) boolean
removeMembership
(String groupname, String username) void
removeUser
(com.atlassian.user.User user) Removes the specified user.renameUser
(ConfluenceUser user, String newUsername) Updates the username of the given user.void
saveUser
(com.atlassian.user.User user) Persists changes made to a user (e.g.void
setUserProfilePicture
(com.atlassian.user.User user, Attachment attachment) Set the user profile picture to the given attachment.void
setUserProfilePicture
(com.atlassian.user.User targetUser, String imagePath) Set the user profile picture to a built-in image.Methods inherited from interface com.atlassian.confluence.user.ConfluenceUserResolver
getExistingByApiUser, getExistingUserByKey, getExistingUserByPerson, getUserByKey, getUserByName, getUsers, getUsersByUserKeys
Methods inherited from interface com.atlassian.user.search.query.EntityQueryParser
findGroups, findGroups, findUsers, findUsers
Methods inherited from interface com.atlassian.confluence.user.GroupMembershipAccessor
getMemberNames
Methods inherited from interface com.atlassian.confluence.user.GroupResolver
getGroup
Methods inherited from interface com.atlassian.confluence.user.UserExistenceChecker
exists
Methods inherited from interface com.atlassian.confluence.user.UserPreferencesAccessor
getUserPreferences
Methods inherited from interface com.atlassian.confluence.user.UserProfilePictureAccessor
getUserProfilePicture
-
Field Details
-
GROUP_CONFLUENCE_USERS
Deprecated.since 5.2. Use @link{com.atlassian.confluence.setup.settings.Settings#getDefaultUsersGroup()} instead.- See Also:
-
GROUP_CONFLUENCE_ADMINS
The name of the group with special administration privileges in the application.- See Also:
-
DEFAULT_GROUP_NAMES
Deprecated.since 5.2. UsegetAllDefaultGroupNames()
instead. -
PROFILE_PICTURE_BUILTIN_PATH
Relative path to default profile pictures in the web application, used to determine whether a user has uploaded a custom profile picture.- See Also:
-
-
Method Details
-
getUser
Deprecated.since 5.2. SeeConfluenceUserResolver.getUserByName(String)
Returns the user with the specified name, ornull
if the user doesn't exist or the name isnull
. Note that use rname lookups are case-insensitive, so the user you get back may not have exactly the same name as the name passed to this method.- Parameters:
name
- the user name of the user- Returns:
- the User with the supplied user name or null.
-
createUser
ConfluenceUser createUser(com.atlassian.user.User userTemplate, com.atlassian.user.security.password.Credential password) -
isReadOnly
boolean isReadOnly(com.atlassian.user.User user) Returnstrue
if the user cannot be modified or removed. However, returningfalse
does necessarily confirm that the user can be modified or removed. Depending on the user management configuration, it is not always possible for Confluence to determine whether a user is read-only.In an internal-only user management configuration, this method always returns
false
. -
isReadOnly
boolean isReadOnly(com.atlassian.user.Group group) Returnstrue
if the group cannot be modified or removed. However, returningfalse
does necessarily confirm that the group can be modified or removed. Depending on the user management configuration, it is not always possible for Confluence to determine whether a group is read-only. Indeed, groups can span across multiple directories with different access control mechanisms, so it may be possible to modify certain memberships of a group but not others.In an internal-only user management configuration, this method always returns
false
. -
isSuperUser
Deprecated.since 3.5Return true is the user is a super user. This should not be used to infer any special permission exempt behaviours. In general, relying on group memberships for special behaviour is a bad idea. Permission checks in the application likeinvalid reference
com.atlassian.confluence.security.PermissionManager#hasPermission(User, Permission, Object)
invalid reference
com.atlassian.confluence.security.PermissionManager#isConfluenceAdministrator(User)
AlphabeticalListPagesAction.getFilter(ConfluenceUser)
- Parameters:
user
- the user to check for (the null user will always return false)- Returns:
- true if the user is super-user, false otherwise.
-
getGroupsAsList
List<com.atlassian.user.Group> getGroupsAsList() -
getMemberNamesAsList
Same asGroupMembershipAccessor.getMemberNames(com.atlassian.user.Group)
but returns a List of user names asString
s rather than a Pager.- Specified by:
getMemberNamesAsList
in interfaceGroupMembershipAccessor
- Parameters:
group
- to retrieve the member names from- Returns:
- a list of
String
s
-
getMembers
Returns users who are members of the specified group (either directly or as a member of a nested group). Returns an empty iterable if the group is null or the group doesn't exist.Elements are generated on demand and it is recommended to fetch only as many elements as are needed.
- Parameters:
group
- group to get members for- Returns:
- users who are members of the specified group
-
getMembers
Returns users who are members of the specified group. This API will only return users upto the given limit (either directly or as a member of a nested group). Returns an empty iterable if the group is null or the group doesn't exist.Elements are generated on demand and it is recommended to fetch only as many elements as are needed.
- Parameters:
group
- group to get members forlimit
- maximum number of users to return- Returns:
- users who are members of the specified group
-
getGroupNames
Gets the list of group names representing the groups the passed in user is a member of.- Parameters:
user
- the user to perform the membership check for- Returns:
- a list of group names
-
getGroupNamesForUserName
Gets the list of group names representing the groups the passed in user is a member of.- Parameters:
userName
- the name of the user to perform the membership check for- Returns:
- a list of group names
-
getWriteableGroups
List<com.atlassian.user.Group> getWriteableGroups()Gets all editable groups. That is, returns any groups that belong to read/write repositories. Groups in readonly repositories that are ReadOnly are not returned.- Returns:
- list of
Group
s that can be edited.
-
getPropertySet
@Deprecated(forRemoval=true) com.opensymphony.module.propertyset.PropertySet getPropertySet(ConfluenceUser user) Deprecated, for removal: This API element is subject to removal in a future version.since 7.7, read-only from 10.0, for removal in 11.0. UseUserPreferencesAccessor.getUserPreferences(ConfluenceUser)
instead.- Returns:
- the property set for the supplied user
- Since:
- 5.2
-
getUserNamesWithConfluenceAccess
Returns the names of all users with access to use Confluence. If you only need to know the number of users, you should callUserChecker.getNumberOfRegisteredUsers()
, as that caches its results.- See Also:
-
countLicenseConsumingUsers
int countLicenseConsumingUsers()Returns the number of users which have access to use Confluence AND consume a Confluence license. Callers are strongly recommended to use theUserChecker.getNumberOfRegisteredUsers()
to retrieve this info, as that caches its results.- Since:
- 5.5
- See Also:
-
findUsersAsList
List<com.atlassian.user.User> findUsersAsList(com.atlassian.user.search.query.Query<com.atlassian.user.User> search) throws com.atlassian.user.EntityException - Throws:
com.atlassian.user.EntityException
-
setUserProfilePicture
Set the user profile picture to the given attachment. The attachment should be an image attached to that user's personal information, of size 48x48. No check is performed in this method that the image is valid or the right size.- Parameters:
user
- the user to set a profile picture forattachment
- the attachment containing the user's profile picture- Throws:
IllegalArgumentException
- if the image is not attached to the user's personal information
-
setUserProfilePicture
Set the user profile picture to a built-in image. The path should be the web-application-root-relative path to the image to be used as the user's profile picture and should be size 48x48. Neither are checked by the implementation- Parameters:
targetUser
- the user to set a profile picture forimagePath
- the image path to that picture.
-
getAllDefaultGroupNames
Deprecated.Since 5.2. This method is vague and returns a collection containing the result ofSettings.getDefaultUsersGroup()
andGROUP_CONFLUENCE_ADMINS
. Clients should explicitly decide what they need and use that.Get the list of default group names.- Returns:
- a list with the default group names.
-
getNewUserDefaultGroupName
Deprecated.since 5.2. UseSettings.getDefaultUsersGroup()
viaSettingsManager.getGlobalSettings()
.Get the name of the default group for a new user.- Returns:
- the default group for a new user.
-
renameUser
ConfluenceUser renameUser(ConfluenceUser user, String newUsername) throws com.atlassian.user.EntityException Updates the username of the given user.- Parameters:
user
- user to renamenewUsername
- username to use for renaming- Returns:
- renamed user
- Throws:
com.atlassian.user.impl.EntityValidationException
- if the new username does not meet the username requirementscom.atlassian.user.EntityException
- if the operation is not allowed for the userUserManagementOperationFailedException
- if the operation fails for unknown reasoncom.atlassian.user.impl.DuplicateEntityException
- if the username is already taken- Since:
- 5.2
-
getGroupsByGroupNames
Returns a list of Group objects where the names match that of the provided list of group names. If no names are provided an empty list will be returned.- Parameters:
groupNames
- the list group names for which the matching Group objects must be returned- Returns:
- the list of resolved groups
- Since:
- 7.5.0
-
countUnsyncedUsers
int countUnsyncedUsers()Get a count of all unsynced users in Confluence. An unsynced user is a user that was managed in an external directory but has since been removed from the directory without being deleted in Confluence.- Returns:
- the total number of all unsynced users.
- Since:
- 6.13.0
-
isLicensedToAddMoreUsers
Deprecated.since 7.17 useUserChecker.isLicensedToAddMoreUsers()
-
isDeactivated
Deprecated.since 7.17 UseDisabledUserManager.isDisabled(User)
-
isDeactivated
Deprecated.since 7.17 UseDisabledUserManager.isDisabled(String)
-
alterPassword
void alterPassword(com.atlassian.user.User user, String plainTextPassword, String token) throws com.atlassian.user.EntityException - Throws:
com.atlassian.user.EntityException
-
deactivateUserLocally
void deactivateUserLocally(com.atlassian.user.User user) throws com.atlassian.user.EntityException Deactivate the specified user, which prevents them logging in. Does nothing if the user is already deactivated. This only deactivates the user from local confluence db, even if the user is coming from remote directory- Parameters:
user
- theUser
to be deactivated- Throws:
com.atlassian.user.impl.EntityValidationException
- if the user is invalid or cannot be deactivatedcom.atlassian.user.EntityException
-
reactivateUserLocally
void reactivateUserLocally(com.atlassian.user.User user) throws com.atlassian.user.EntityException Marks the specified user as active, which allows them to log in. Does nothing if the user is already active. This only activates the user from local confluence db, even if the user is coming from remote directory- Parameters:
user
- theUser
to be reactivated- Throws:
com.atlassian.user.impl.EntityValidationException
- if the user is invalid or cannot be reactivatedcom.atlassian.user.EntityException
-
addUser
@Deprecated com.atlassian.user.User addUser(String username, String password, String email, String fullname, String[] groups) Deprecated.since 3.5 usecreateUser(User, Credential)
andaddMembership(Group, User)
-
addUser
@Deprecated com.atlassian.user.User addUser(String username, String password, String email, String fullname) Deprecated.since 3.5 usecreateUser(User, Credential)
-
getUserNames
com.atlassian.user.search.page.Pager<String> getUserNames()Returns a pager of all usernames in the system. Clients should not normally use this method, but perform a search usingEntityQueryParser.findUsers(Query)
or the CrowdService API instead. -
getUsers
com.atlassian.user.search.page.Pager<com.atlassian.user.User> getUsers()Returns a pager of all users in the system. Clients should not normally use this method, but perform a search usingEntityQueryParser.findUsers(Query)
or the CrowdService API instead. -
getGroups
com.atlassian.user.search.page.Pager<com.atlassian.user.Group> getGroups()Returns a pager of all groups in the system. Clients should not normally use this method, but perform a search usingEntityQueryParser.findGroups(Query)
or the CrowdService API instead. -
addGroup
Creates a group with the specified name and returns it.- Throws:
IllegalArgumentException
- if the group name is empty or nullcom.atlassian.core.exception.InfrastructureException
- if the group could not be created
-
removeGroup
void removeGroup(com.atlassian.user.Group group) Removes the specified group. Does nothing if the group does not exist.- Throws:
com.atlassian.core.exception.InfrastructureException
- if the group could not be removed
-
removeUser
void removeUser(com.atlassian.user.User user) throws com.atlassian.core.exception.InfrastructureException Removes the specified user. Does nothing if the user does not exist.- Throws:
com.atlassian.core.exception.InfrastructureException
- if the user could not be removed
-
getGroupCreateIfNecessary
-
saveUser
void saveUser(com.atlassian.user.User user) Persists changes made to a user (e.g. changing email or full name).- Throws:
com.atlassian.core.exception.InfrastructureException
- if the user could not be updated successfully
-
getUsersByEmail
-
deactivateUser
void deactivateUser(com.atlassian.user.User user) Deactivate the specified user, which prevents them logging in. Does nothing if the user is already deactivated. -
reactivateUser
void reactivateUser(com.atlassian.user.User user) Marks the specified user as active, which allows them to log in. Does nothing if the user is already active. -
isUserRemovable
boolean isUserRemovable(com.atlassian.user.User user) throws com.atlassian.user.EntityException - Throws:
com.atlassian.user.EntityException
-
getGroups
com.atlassian.user.search.page.Pager<com.atlassian.user.Group> getGroups(com.atlassian.user.User user) -
hasMembership
boolean hasMembership(com.atlassian.user.Group group, com.atlassian.user.User user) Returnstrue
if the specified user and group both exist, and the user is a member of the group (either directly or as a member of a nested group). In all other circumstances, returnsfalse
. -
hasMembership
Returnstrue
if the specified user and group both exist, and the user is a member of the group (either directly or as a member of a nested group). In all other circumstances, returnsfalse
. -
addMembership
void addMembership(com.atlassian.user.Group group, com.atlassian.user.User user) -
addMembership
-
removeMembership
boolean removeMembership(com.atlassian.user.Group group, com.atlassian.user.User user) -
createGroup
-
authenticate
-
alterPassword
void alterPassword(com.atlassian.user.User user, String plainTextPassword) throws com.atlassian.user.EntityException - Throws:
com.atlassian.user.EntityException
-
removeMembership
-