Package com.atlassian.confluence.user
Interface UserAccessor
-
- All Superinterfaces:
ConfluenceUserResolver
,com.atlassian.user.search.query.EntityQueryParser
,GroupMembershipAccessor
,GroupResolver
,UserAccessor
,UserExistenceChecker
,UserPreferencesAccessor
,UserProfilePictureAccessor
- All Known Subinterfaces:
UserAccessorInternal
- All Known Implementing Classes:
DefaultUserAccessor
,ReadOnlyUserAccessor
public interface UserAccessor extends UserAccessor, UserPreferencesAccessor, ConfluenceUserResolver, UserProfilePictureAccessor, GroupResolver, GroupMembershipAccessor, UserExistenceChecker
-
-
Field Summary
Fields Modifier and Type Field Description static List<String>
DEFAULT_GROUP_NAMES
Deprecated.since 5.2.static String
GROUP_CONFLUENCE_ADMINS
The name of the group with special administration privileges in the application.static String
GROUP_CONFLUENCE_USERS
Deprecated.since 5.2.static String
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.
-
Method Summary
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description void
alterPassword(com.atlassian.user.User user, String plainTextPassword, String token)
int
countLicenseConsumingUsers()
Returns the number of users which have access to use Confluence AND consume a Confluence license.int
countUnsyncedUsers()
Get a count of all unsynced users in Confluence.ConfluenceUser
createUser(com.atlassian.user.User userTemplate, com.atlassian.user.security.password.Credential password)
boolean
exists(String name)
Returns true if a user exists with the given username.List<com.atlassian.user.User>
findUsersAsList(com.atlassian.user.search.query.Query<com.atlassian.user.User> search)
List<String>
getAllDefaultGroupNames()
Deprecated.Since 5.2.ConfluenceUserPreferences
getConfluenceUserPreferences(@Nullable com.atlassian.user.User user)
@Nullable ConfluenceUser
getExistingUserByKey(com.atlassian.sal.api.user.UserKey key)
Returns the user with the specified user key, ornull
if the user doesn't exist or the key isnull
.List<String>
getGroupNames(com.atlassian.user.User user)
Gets the list of group names representing the groups the passed in user is a member of.List<String>
getGroupNamesForUserName(String userName)
Gets the list of group names representing the groups the passed in user is a member of.List<com.atlassian.user.Group>
getGroupsAsList()
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.List<String>
getMemberNamesAsList(com.atlassian.user.Group group)
Same asUserAccessor.getMemberNames(com.atlassian.user.Group)
but returns a List of user names asString
s rather than a Pager.Iterable<ConfluenceUser>
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).String
getNewUserDefaultGroupName()
Deprecated.since 5.2.com.opensymphony.module.propertyset.PropertySet
getPropertySet(ConfluenceUser user)
Deprecated.since 7.7 Plugins should useUserSettingsService
.com.opensymphony.module.propertyset.PropertySet
getPropertySet(com.atlassian.user.User user)
Deprecated.since 5.2 Plugins should useUserSettingsService
.com.atlassian.user.User
getUser(String name)
Deprecated.since 5.2.@Nullable ConfluenceUser
getUserByKey(com.atlassian.sal.api.user.UserKey key)
Returns the user with the specified user key, ornull
if the user has never existed or the key isnull
.@Nullable ConfluenceUser
getUserByName(String name)
Returns the ConfluenceUser with the supplied user name or null if the user doesn't exist or the supplied name is null.List<String>
getUserNamesWithConfluenceAccess()
Returns the names of all users with access to use Confluence.ProfilePictureInfo
getUserProfilePicture(@Nullable com.atlassian.user.User user)
Retrieve the path to a user's personal pictureList<ConfluenceUser>
getUsersByUserKeys(List<com.atlassian.sal.api.user.UserKey> userKeys)
Returns a list of ConfluenceUser with the supplied UserKeys or an empty list if the users do not exist.List<com.atlassian.user.Group>
getWriteableGroups()
Gets all editable groups.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
isLicensedToAddMoreUsers()
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.5ConfluenceUser
renameUser(ConfluenceUser user, String newUsername)
Updates the username of the given user.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, getExistingUserByPerson, getUsers
-
Methods inherited from interface com.atlassian.user.search.query.EntityQueryParser
findGroups, findGroups, 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 bucket.user.UserAccessor
addGroup, addMembership, addMembership, addUser, addUser, alterPassword, authenticate, createGroup, deactivateUser, findUsers, getGroup, getGroupCreateIfNecessary, getGroups, getGroups, getMemberNames, getUserNames, getUserPreferences, getUsers, getUsersByEmail, hasMembership, hasMembership, isUserRemovable, reactivateUser, removeGroup, removeMembership, removeMembership, removeUser, saveUser
-
-
-
-
Field Detail
-
GROUP_CONFLUENCE_USERS
@Deprecated static final String GROUP_CONFLUENCE_USERS
Deprecated.since 5.2. Use @link{com.atlassian.confluence.setup.settings.Settings#getDefaultUsersGroup()} instead.- See Also:
- Constant Field Values
-
GROUP_CONFLUENCE_ADMINS
static final String GROUP_CONFLUENCE_ADMINS
The name of the group with special administration privileges in the application.- See Also:
- Constant Field Values
-
DEFAULT_GROUP_NAMES
@Deprecated static final List<String> DEFAULT_GROUP_NAMES
Deprecated.since 5.2. Use @link{#getAllDefaultGroupNames()} instead.
-
PROFILE_PICTURE_BUILTIN_PATH
static final String 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:
- Constant Field Values
-
-
Method Detail
-
getUser
@Deprecated com.atlassian.user.User getUser(String name)
Deprecated.since 5.2. SeegetUserByName(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.- Specified by:
getUser
in interfaceUserAccessor
- Parameters:
name
- the user name of the user- Returns:
- the User with the supplied user name or null.
-
getUserByName
@Nullable ConfluenceUser getUserByName(String name)
Returns the ConfluenceUser with the supplied user name or null if the user doesn't exist or the supplied name is null.Note that user name lookups are case-insensitive, so the user you get back may not have exactly the same name as the name passed to this method.
- Specified by:
getUserByName
in interfaceConfluenceUserResolver
- Parameters:
name
- the user name of the user- Returns:
- the ConfluenceUser with the supplied user name or null.
- Since:
- 5.2
-
getUserByKey
@Nullable ConfluenceUser getUserByKey(com.atlassian.sal.api.user.UserKey key)
Returns the user with the specified user key, ornull
if the user has never existed or the key isnull
.WARNING: This method can return deleted users. Use
getExistingUserByKey(com.atlassian.sal.api.user.UserKey)
to get only users that exist.- Specified by:
getUserByKey
in interfaceConfluenceUserResolver
- Since:
- 5.2
-
getExistingUserByKey
@Nullable ConfluenceUser getExistingUserByKey(com.atlassian.sal.api.user.UserKey key)
Returns the user with the specified user key, ornull
if the user doesn't exist or the key isnull
.- Specified by:
getExistingUserByKey
in interfaceConfluenceUserResolver
- Since:
- 5.3
-
exists
boolean exists(String name)
Returns true if a user exists with the given username. This method is significantly faster thangetUser(name) != null
.- Specified by:
exists
in interfaceUserExistenceChecker
- Parameters:
name
- username of the user- Returns:
- true if a user exists with the given username
- Since:
- 5.2
-
createUser
ConfluenceUser createUser(com.atlassian.user.User userTemplate, com.atlassian.user.security.password.Credential password)
- Specified by:
createUser
in interfaceUserAccessor
-
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
.
-
getUserProfilePicture
ProfilePictureInfo getUserProfilePicture(@Nullable com.atlassian.user.User user)
Retrieve the path to a user's personal picture- Specified by:
getUserProfilePicture
in interfaceUserProfilePictureAccessor
- Parameters:
user
- the user whose picture to look up.- Returns:
- The path to a user's personal picture, or null if they don't have one set.
-
getConfluenceUserPreferences
ConfluenceUserPreferences getConfluenceUserPreferences(@Nullable com.atlassian.user.User user)
- Specified by:
getConfluenceUserPreferences
in interfaceUserPreferencesAccessor
-
isSuperUser
@Deprecated boolean isSuperUser(com.atlassian.user.User user)
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 likePermissionManager.hasPermission(User, Permission, Object)
already take care of super-user permission exempt checks and more. If checking for exemption from any permission checks is still required explicitly, usePermissionManager.isConfluenceAdministrator(User)
instead. It also takes care of more checks than a group-membership for permission exemption. e.g. Checking exemptions before applying permission related query and/or filter, seeAlphabeticalListPagesAction.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
List<String> getMemberNamesAsList(com.atlassian.user.Group group)
Same asUserAccessor.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
Iterable<ConfluenceUser> 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). 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
-
getGroupNames
List<String> getGroupNames(com.atlassian.user.User user)
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
List<String> getGroupNamesForUserName(String userName)
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 com.opensymphony.module.propertyset.PropertySet getPropertySet(com.atlassian.user.User user)
Deprecated.since 5.2 Plugins should useUserSettingsService
.- Specified by:
getPropertySet
in interfaceUserAccessor
-
getPropertySet
@Deprecated com.opensymphony.module.propertyset.PropertySet getPropertySet(ConfluenceUser user)
Deprecated.since 7.7 Plugins should useUserSettingsService
.- Parameters:
user
-- Returns:
- the property set for the supplied user
- Since:
- 5.2
-
getUserNamesWithConfluenceAccess
List<String> 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:
UserChecker
-
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:
UserChecker
-
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
void setUserProfilePicture(com.atlassian.user.User user, Attachment attachment)
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
void setUserProfilePicture(com.atlassian.user.User targetUser, String imagePath)
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 List<String> 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 String 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
-
getUsersByUserKeys
List<ConfluenceUser> getUsersByUserKeys(List<com.atlassian.sal.api.user.UserKey> userKeys)
Returns a list of ConfluenceUser with the supplied UserKeys or an empty list if the users do not exist. This method returns ConfluenceUser instances with pre-populated backing EmbeddedCrowdUser.- Specified by:
getUsersByUserKeys
in interfaceConfluenceUserResolver
- Parameters:
userKeys
- the user keys- Returns:
- the list of ConfluenceUsers with UserKeys
- Since:
- 6.12.0
-
getGroupsByGroupNames
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. 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 boolean isLicensedToAddMoreUsers()
Deprecated.since 7.17 useUserChecker.isLicensedToAddMoreUsers()
- Specified by:
isLicensedToAddMoreUsers
in interfaceUserAccessor
-
isDeactivated
@Deprecated boolean isDeactivated(com.atlassian.user.User user)
Deprecated.since 7.17 UseDisabledUserManager.isDisabled(User)
Description copied from interface:UserAccessor
Returns true if the user exists and is unable to log in, otherwise false. Returns false if the user is null.- Specified by:
isDeactivated
in interfaceUserAccessor
- Returns:
- true if the user exists and is unable to log in, otherwise false.
-
isDeactivated
@Deprecated boolean isDeactivated(String username)
Deprecated.since 7.17 UseDisabledUserManager.isDisabled(String)
Description copied from interface:UserAccessor
Returns true if the user with the specified username exists and is unable to log in, otherwise false. Returns false if the username is null.- Specified by:
isDeactivated
in interfaceUserAccessor
- Returns:
- true if the user with the specified username exists and is unable to log in, otherwise false.
-
-