Class LdapUserManagementHelper
- java.lang.Object
-
- com.atlassian.confluence.it.usermanagement.LdapUserManagementHelper
-
- All Implemented Interfaces:
UserManagementHelper
public final class LdapUserManagementHelper extends Object implements UserManagementHelper
Implementation ofUserManagementHelperthat talks directly to the configured LDAP server. The underlying LDAP operations are handled byLdapServer.Synchronises after each modification to ensure Confluence's local copy of LDAP data is up-to-date.
-
-
Constructor Summary
Constructors Constructor Description LdapUserManagementHelper(ConfluenceRpc rpc)Creates an instance which delegates toLdapServer, using the default connection properties from ldapTemplate.LdapUserManagementHelper(ConfluenceRpc rpc, org.springframework.ldap.core.LdapTemplate ldapTemplate, Set<User> initialUsers, Set<Group> initialGroups)Creates an instance which delegates toLdapServerusing the LDAP connections provided by theldapTemplate.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidactivateUser(String username)voidaddGroupToGroup(Group childGroup, Group parentGroup)Add childGroup to parentGroup.voidaddUserToGroup(User user, Group group)voidaddUserToGroup(String userName, String groupName)voidchangePassword(String username, String newPassword)Change a user's password.voidcreateGroup(Group group)voidcreateGroup(String groupName)List<User>createMultipleUsers(int numUsers)Helper to create multiple users (callsUserManagementHelper.createUser(com.atlassian.confluence.it.User))UsercreateUser(User user)Creates the user, adds it to the default users group, and ensures the user profile is created (to work around CONF-6404).voiddeactivateUser(String username)voidendBatch()Flag that the batch transactions are complete, that a sync should be performed immediately, and that syncing should be re-enabled for future requests.voidfixUser(User user)Ensure that the user's details in the system match those inuser.static LdapUserManagementHelperfromTestLdapProperties(ConfluenceRpc rpc)Construct using theTestProperties('ldap.'-prefixed properties, e.g.Set<String>getUserGroups(User user)booleanisExternal()Return false if this helper modifies Users, Groups and Group Memberships via RPC (Confluence-managed directories).voidremoveFromDefaultLicenseGroup(User user)Remove user from the group that has licensed accessvoidremoveGroup(Group group)voidremoveGroup(String groupName)voidremoveGroupUncleanly(Group group)Removes a group but do not remove their dependent permissions.voidremoveMultipleUsers(List<User> users)Removes the list of users (callsUserManagementHelper.removeUser(User))voidremoveUser(User user)voidremoveUser(String username)voidremoveUserFromGroup(User user, Group group)voidremoveUserUncleanly(User user)Removes a user but do not remove their dependent permissions or pages.voidremoveUserUncleanly(String username)Removes a user with the given username but do not remove their dependent permissions or pages.voidrenameUser(String oldUsername, String newUsername)voidresetData(Set<User> usersToKeep, Set<Group> groupsToKeep, Map<Group,HashSet<User>> userGroupMembershipsToKeep)Return the User/Group/Membership data to a clean state.voidsetAutoSync(boolean autoSync)voidstartBatch()Flag that a number of user/group transactions are about to be performed in a block, and any syncing should pause until the batch is finished.voidsynchronise()Force a synchronisation with an external user directory.booleanuserExists(String username)
-
-
-
Constructor Detail
-
LdapUserManagementHelper
public LdapUserManagementHelper(ConfluenceRpc rpc)
Creates an instance which delegates toLdapServer, using the default connection properties from ldapTemplate.- Parameters:
rpc- The rpc helper
-
LdapUserManagementHelper
public LdapUserManagementHelper(ConfluenceRpc rpc, org.springframework.ldap.core.LdapTemplate ldapTemplate, Set<User> initialUsers, Set<Group> initialGroups)
Creates an instance which delegates toLdapServerusing the LDAP connections provided by theldapTemplate.- Parameters:
rpc- Confluence RPC interfaceldapTemplate- used to connect to the LDAP serverinitialUsers- the users which already exist in the LDAP serverinitialGroups- the groups which already exist in the LDAP server
-
-
Method Detail
-
fromTestLdapProperties
public static LdapUserManagementHelper fromTestLdapProperties(ConfluenceRpc rpc)
Construct using theTestProperties('ldap.'-prefixed properties, e.g. from the maven profiles in confluence-multi-test)
-
synchronise
public void synchronise()
Description copied from interface:UserManagementHelperForce a synchronisation with an external user directory.- Specified by:
synchronisein interfaceUserManagementHelper
-
addUserToGroup
public void addUserToGroup(String userName, String groupName)
- Specified by:
addUserToGroupin interfaceUserManagementHelper
-
addUserToGroup
public void addUserToGroup(User user, Group group)
- Specified by:
addUserToGroupin interfaceUserManagementHelper
-
addGroupToGroup
public void addGroupToGroup(Group childGroup, Group parentGroup)
Description copied from interface:UserManagementHelperAdd childGroup to parentGroup. Does nothing if the membership already exists.- Specified by:
addGroupToGroupin interfaceUserManagementHelper
-
getUserGroups
public Set<String> getUserGroups(User user)
- Specified by:
getUserGroupsin interfaceUserManagementHelper- Parameters:
user- the user who's group membership is to be checked.- Returns:
- the set of groups the user belongs to or an empty Set if none.
-
createUser
public User createUser(User user)
Description copied from interface:UserManagementHelperCreates the user, adds it to the default users group, and ensures the user profile is created (to work around CONF-6404).- Specified by:
createUserin interfaceUserManagementHelper
-
resetData
public void resetData(Set<User> usersToKeep, Set<Group> groupsToKeep, Map<Group,HashSet<User>> userGroupMembershipsToKeep)
Description copied from interface:UserManagementHelperReturn the User/Group/Membership data to a clean state.- Specified by:
resetDatain interfaceUserManagementHelper
-
isExternal
public boolean isExternal()
Description copied from interface:UserManagementHelperReturn false if this helper modifies Users, Groups and Group Memberships via RPC (Confluence-managed directories). Return true if this helper makes calls to different server, e.g. LDAP or Crowd (externally-managed directories).- Specified by:
isExternalin interfaceUserManagementHelper
-
userExists
public boolean userExists(String username)
-
removeUser
public void removeUser(String username)
- Specified by:
removeUserin interfaceUserManagementHelper
-
removeUser
public void removeUser(User user)
- Specified by:
removeUserin interfaceUserManagementHelper
-
createGroup
public void createGroup(String groupName)
- Specified by:
createGroupin interfaceUserManagementHelper
-
createGroup
public void createGroup(Group group)
- Specified by:
createGroupin interfaceUserManagementHelper
-
removeUserFromGroup
public void removeUserFromGroup(User user, Group group)
- Specified by:
removeUserFromGroupin interfaceUserManagementHelper
-
removeGroup
public void removeGroup(String groupName)
- Specified by:
removeGroupin interfaceUserManagementHelper
-
createMultipleUsers
public List<User> createMultipleUsers(int numUsers)
Description copied from interface:UserManagementHelperHelper to create multiple users (callsUserManagementHelper.createUser(com.atlassian.confluence.it.User))- Specified by:
createMultipleUsersin interfaceUserManagementHelper- Parameters:
numUsers- the number of users to create- Returns:
- the list of users created
-
removeMultipleUsers
public void removeMultipleUsers(List<User> users)
Description copied from interface:UserManagementHelperRemoves the list of users (callsUserManagementHelper.removeUser(User))- Specified by:
removeMultipleUsersin interfaceUserManagementHelper- Parameters:
users- the list of users to remove
-
removeGroup
public void removeGroup(Group group)
-
removeUserUncleanly
public void removeUserUncleanly(String username)
Description copied from interface:UserManagementHelperRemoves a user with the given username but do not remove their dependent permissions or pages.- Specified by:
removeUserUncleanlyin interfaceUserManagementHelper- Parameters:
username- the username of the user to remove
-
removeUserUncleanly
public void removeUserUncleanly(User user)
Description copied from interface:UserManagementHelperRemoves a user but do not remove their dependent permissions or pages.- Specified by:
removeUserUncleanlyin interfaceUserManagementHelper- Parameters:
user- the user to remove
-
removeGroupUncleanly
public void removeGroupUncleanly(Group group)
Description copied from interface:UserManagementHelperRemoves a group but do not remove their dependent permissions.- Specified by:
removeGroupUncleanlyin interfaceUserManagementHelper- Parameters:
group- the group to remove
-
fixUser
public void fixUser(User user)
Description copied from interface:UserManagementHelperEnsure that the user's details in the system match those inuser. That is, it finds the user in the system by its username, and sets the full name and email address.- Specified by:
fixUserin interfaceUserManagementHelper- Parameters:
user- a user to set the details of
-
changePassword
public void changePassword(String username, String newPassword)
Description copied from interface:UserManagementHelperChange a user's password.- Specified by:
changePasswordin interfaceUserManagementHelper- Parameters:
username- Username of the user whose password to changenewPassword- Password
-
setAutoSync
public void setAutoSync(boolean autoSync)
- Specified by:
setAutoSyncin interfaceUserManagementHelper
-
startBatch
public void startBatch()
Description copied from interface:UserManagementHelperFlag that a number of user/group transactions are about to be performed in a block, and any syncing should pause until the batch is finished.- Specified by:
startBatchin interfaceUserManagementHelper
-
endBatch
public void endBatch()
Description copied from interface:UserManagementHelperFlag that the batch transactions are complete, that a sync should be performed immediately, and that syncing should be re-enabled for future requests.- Specified by:
endBatchin interfaceUserManagementHelper
-
renameUser
public void renameUser(String oldUsername, String newUsername)
- Specified by:
renameUserin interfaceUserManagementHelper
-
deactivateUser
public void deactivateUser(String username)
- Specified by:
deactivateUserin interfaceUserManagementHelper
-
activateUser
public void activateUser(String username)
- Specified by:
activateUserin interfaceUserManagementHelper
-
removeFromDefaultLicenseGroup
public void removeFromDefaultLicenseGroup(User user)
Description copied from interface:UserManagementHelperRemove user from the group that has licensed access- Specified by:
removeFromDefaultLicenseGroupin interfaceUserManagementHelper
-
-