public class

DefaultUserAccessor

extends DefaultUserAccessor
implements UserAccessor
java.lang.Object
   ↳ bucket.user.DefaultUserAccessor
     ↳ com.atlassian.confluence.user.DefaultUserAccessor

Class Overview

This implementation of UserAccessor takes care of all the Confluence-related actions around user management: checking permissions, publishing events, and ensuring the integrity of data in Confluence related to users.

Summary

[Expand]
Inherited Constants
From interface com.atlassian.confluence.user.UserAccessor
[Expand]
Inherited Fields
From class bucket.user.DefaultUserAccessor
From interface com.atlassian.confluence.user.UserAccessor
Public Constructors
DefaultUserAccessor(RepositoryAccessor repositoryAccessor, SpacePermissionManager spacePermissionManager, ContentEntityManager contentEntityManager, NotificationManager notificationManager, PersonalInformationManager personalInformationManager, UserChecker userChecker, AttachmentManager attachmentManager, SettingsManager settingsManager, EventManager eventManager, ContentPermissionManager contentPermissionManager, PermissionManager permissionManager, UserStatusManager userStatusManager, FollowManager followManager, CrowdService crowdService, DisabledUserManager disabledUserManager, HibernateSessionManager sessionManager)
Public Methods
Group addGroup(String groupname)
Adds a group with the specified name.
void addMembership(Group group, User user)
Adds the specified user to this group.
User addUser(String username, String password, String email, String fullname, String[] groups)
Adds a new user.
int countUsersWithConfluenceAccess()
Returns the number of users which have access to use Confluence.
Group createGroup(String groupname)
Method was added for consistency.
User createUser(User userTemplate, Credential credential)
User createUser(String username)
void deactivateUser(User user)
Deactivate the specified user, which prevents them logging in.
List<Group> filterUnaccessibleGroups(List<Group> groupList, User user)
Pager<Group> filterUnaccessibleGroups(Pager<Group> groupPager, User user)
Filters a pager of groups based on the passed User.
Pager<User> filterUnaccessibleUsers(Pager<User> userPager, User user)
This method is deprecated. since 2.8, use filterUnaccessibleUsers(java.util.List, com.atlassian.user.User) instead
List<User> filterUnaccessibleUsers(List<User> userNameList, User user)
Filters out unaccessible users from the passed in list.
List<User> findUsersAsList(Query<User> search)
ConfluenceUserPreferences getConfluenceUserPreferences(User user)
List<String> getGroupNames(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<Group> getGroupsAsList()
List<Group> getGroupsAsList(User user)
ProfilePictureInfo getLogoForUser(User user)
List<String> getMemberNamesAsList(Group group)
Same as getMemberNames(com.atlassian.user.Group) but returns a List of user names as Strings rather than a Pager.
User getUserIfAvailable(String username)
Get the User if visible to the currently authenticated user in shared mode.
List<String> getUserNamesWithConfluenceAccess()
Returns the names of all users with access to use Confluence.
ProfilePictureInfo getUserProfilePicture(User user)
Retrieve the path to a user's personal picture
ProfilePictureInfo getUserProfilePicture(String username)
Retrieve the path to a user's personal picture
Pager<User> getUsersWithConfluenceAccess()
Returns all the users with access to use Confluence.
List<User> getUsersWithConfluenceAccessAsList()
Returns all the users which have access to use Confluence.
List<Group> getWriteableGroups()
Gets all editable groups.
boolean isDeactivated(User user)
Returns true if the user exists and is unable to log in, otherwise false.
boolean isDeactivated(String username)
Returns true if the user with the specified username exists and is unable to log in, otherwise false.
boolean isLicensedToAddMoreUsers()
boolean isReadOnly(Group group)
Returns true if the group cannot be modified or removed.
boolean isReadOnly(User user)
Returns true if the user cannot be modified or removed.
boolean isSuperUser(User user)
Return true if the user is an all-powerful super-user (member of the confluence-administrators group).
void reactivateUser(User user)
Marks the specified user as active, which allows them to log in.
void removeGroup(Group group)
Removes the specified group.
boolean removeMembership(Group group, User user)
Removes the specified user from this group.
void removeUser(User user)
Removes the specified user.
void savePersonalInformation(PersonalInformation newInfo, PersonalInformation oldInfo)
void setUserProfilePicture(User user, String imagePath)
Set the user profile picture to a built-in image.
void setUserProfilePicture(User user, Attachment attachment)
Set the user profile picture to the given attachment.
[Expand]
Inherited Methods
From class bucket.user.DefaultUserAccessor
From class java.lang.Object
From interface bucket.user.UserAccessor
From interface com.atlassian.confluence.user.UserAccessor
From interface com.atlassian.user.search.query.EntityQueryParser

Public Constructors

public DefaultUserAccessor (RepositoryAccessor repositoryAccessor, SpacePermissionManager spacePermissionManager, ContentEntityManager contentEntityManager, NotificationManager notificationManager, PersonalInformationManager personalInformationManager, UserChecker userChecker, AttachmentManager attachmentManager, SettingsManager settingsManager, EventManager eventManager, ContentPermissionManager contentPermissionManager, PermissionManager permissionManager, UserStatusManager userStatusManager, FollowManager followManager, CrowdService crowdService, DisabledUserManager disabledUserManager, HibernateSessionManager sessionManager)

Public Methods

public Group addGroup (String groupname)

Adds a group with the specified name.

Returns
  • the group created
Throws
InsufficientPrivilegeException if the current user does not have permission to add this group

public void addMembership (Group group, User user)

Adds the specified user to this group.

Throws
InsufficientPrivilegeException if the currently logged in user does not have the permissions to add this user to this group. Check permissions using EDIT on PermissionManager on the group first.

public User addUser (String username, String password, String email, String fullname, String[] groups)

Adds a new user.

Parameters
groups a string array of group names to add the new user to. if the groups don't exist they will be created.
Returns
  • the newly created user
Throws
InsufficientPrivilegeException if the current user does not have permission to add a user to any of the specified groups
LicensingException if you are not licensed to add any more users

public int countUsersWithConfluenceAccess ()

Returns the number of users which have access to use Confluence.

public Group createGroup (String groupname)

Method was added for consistency. We will need to decide whether we want to lowercase all group names upon creation. Currently createGroup() preserves the casing of the name and addGroup() will lowercase the name. Both methods were in use by Confluence, but only one overwritten to publish an event.

public User createUser (User userTemplate, Credential credential)

public User createUser (String username)

public void deactivateUser (User user)

Deactivate the specified user, which prevents them logging in. Does nothing if the user is already deactivated.

public List<Group> filterUnaccessibleGroups (List<Group> groupList, User user)

public Pager<Group> filterUnaccessibleGroups (Pager<Group> groupPager, User user)

Filters a pager of groups based on the passed User. If in "shared" mode and the user isn't a global administrator, only the groups of the user will be returned. Otherwise, the pager will be returned unmodified.

Parameters
groupPager The pager of groups
user The user to filter against
Returns
  • A filtered Pager of Group objects

public Pager<User> filterUnaccessibleUsers (Pager<User> userPager, User user)

This method is deprecated.
since 2.8, use filterUnaccessibleUsers(java.util.List, com.atlassian.user.User) instead

Filters a pager of Users based on the groups of the passed com.atlassian.user.User. If in "shared" mode and the user isn't a global administrator, only users who are members of the same groups will be returned. Otherwise, the pager will be returned unmodified.

Parameters
userPager A Pager of User objects
user The user to filter against
Returns
  • a filtered Pager of com.atlassian.user.User objects

public List<User> filterUnaccessibleUsers (List<User> userNameList, User user)

Filters out unaccessible users from the passed in list. Users are inaccessible if they shared mode is turned on and they do not share a group with the user.

Parameters
userNameList list of user names as Strings to be filtered.
user the user whose permission to view the list of users is being checked.
Returns
  • userNameList with some stuff removed.

public List<User> findUsersAsList (Query<User> search)

Throws
EntityException

public ConfluenceUserPreferences getConfluenceUserPreferences (User user)

public List<String> getGroupNames (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

public 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

public List<Group> getGroupsAsList ()

public List<Group> getGroupsAsList (User user)

public ProfilePictureInfo getLogoForUser (User user)

public List<String> getMemberNamesAsList (Group group)

Same as getMemberNames(com.atlassian.user.Group) but returns a List of user names as Strings rather than a Pager.

Parameters
group to retrieve the member names from
Returns

public User getUserIfAvailable (String username)

Get the User if visible to the currently authenticated user in shared mode. If not in shared mode, the User will be returned if not null.

public List<String> getUserNamesWithConfluenceAccess ()

Returns the names of all users with access to use Confluence.

public ProfilePictureInfo getUserProfilePicture (User user)

Retrieve the path to a user's personal picture

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.

public ProfilePictureInfo getUserProfilePicture (String username)

Retrieve the path to a user's personal picture

Parameters
username 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.

public Pager<User> getUsersWithConfluenceAccess ()

Returns all the users with access to use Confluence.

public List<User> getUsersWithConfluenceAccessAsList ()

Returns all the users which have access to use Confluence.

public List<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 Groups that can be edited.

public boolean isDeactivated (User user)

Returns true if the user exists and is unable to log in, otherwise false. Returns false if the user is null.

Returns
  • true if the user exists and is unable to log in, otherwise false.

public boolean isDeactivated (String username)

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.

Returns
  • true if the user with the specified username exists and is unable to log in, otherwise false.

public boolean isLicensedToAddMoreUsers ()

public boolean isReadOnly (Group group)

Returns true if the group cannot be modified or removed. However, returning false 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.

public boolean isReadOnly (User user)

Returns true if the user cannot be modified or removed. However, returning false 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.

public boolean isSuperUser (User user)

Return true if the user is an all-powerful super-user (member of the confluence-administrators group).

Parameters
user the user to check for (the null user will always return false
Returns
  • true if the user is a super-user, false otherwise.

public void reactivateUser (User user)

Marks the specified user as active, which allows them to log in. Does nothing if the user is already active.

public void removeGroup (Group group)

Removes the specified group. Does nothing if the group does not exist.

Throws
InsufficientPrivilegeException if you do not have sufficient permissions to remove this group. Check permissions using REMOVE and PermissionManager on the group first.

public boolean removeMembership (Group group, User user)

Removes the specified user from this group.

Throws
InsufficientPrivilegeException if the currently logged in user does not have the permissions to remove this user from this group. Check permissions using REMOVE and PermissionManager on the group first.

public void removeUser (User user)

Removes the specified user.

Throws
IllegalArgumentException if the specified user is null
InsufficientPrivilegeException if the currently logged in user does not permissions to remove this user. Check permissions using REMOVE and PermissionManager on the user first.

public void savePersonalInformation (PersonalInformation newInfo, PersonalInformation oldInfo)

public void setUserProfilePicture (User user, 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
user the user to set a profile picture for
imagePath the image path to that picture.

public void setUserProfilePicture (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 for
attachment the attachment containing the user's profile picture