Class LdapUserManagementHelper
- java.lang.Object
-
- com.atlassian.confluence.it.usermanagement.LdapUserManagementHelper
-
- All Implemented Interfaces:
UserManagementHelper
public final class LdapUserManagementHelper extends Object implements UserManagementHelper
Implementation ofUserManagementHelper
that 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 toLdapServer
using the LDAP connections provided by theldapTemplate
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
activateUser(String username)
void
addGroupToGroup(Group childGroup, Group parentGroup)
Add childGroup to parentGroup.void
addUserToGroup(User user, Group group)
void
addUserToGroup(String userName, String groupName)
void
changePassword(String username, String newPassword)
Change a user's password.void
createGroup(Group group)
void
createGroup(String groupName)
List<User>
createMultipleUsers(int numUsers)
Helper to create multiple users (callsUserManagementHelper.createUser(com.atlassian.confluence.it.User)
)User
createUser(User user)
Creates the user, adds it to the default users group, and ensures the user profile is created (to work around CONF-6404).void
deactivateUser(String username)
void
endBatch()
Flag that the batch transactions are complete, that a sync should be performed immediately, and that syncing should be re-enabled for future requests.void
fixUser(User user)
Ensure that the user's details in the system match those inuser
.static LdapUserManagementHelper
fromTestLdapProperties(ConfluenceRpc rpc)
Construct using theTestProperties
('ldap.'-prefixed properties, e.g.Set<String>
getUserGroups(User user)
boolean
isExternal()
Return false if this helper modifies Users, Groups and Group Memberships via RPC (Confluence-managed directories).void
removeFromDefaultLicenseGroup(User user)
Remove user from the group that has licensed accessvoid
removeGroup(Group group)
void
removeGroup(String groupName)
void
removeGroupUncleanly(Group group)
Removes a group but do not remove their dependent permissions.void
removeMultipleUsers(List<User> users)
Removes the list of users (callsUserManagementHelper.removeUser(User)
)void
removeUser(User user)
void
removeUser(String username)
void
removeUserFromGroup(User user, Group group)
void
removeUserUncleanly(User user)
Removes a user but do not remove their dependent permissions or pages.void
removeUserUncleanly(String username)
Removes a user with the given username but do not remove their dependent permissions or pages.void
renameUser(String oldUsername, String newUsername)
void
resetData(Set<User> usersToKeep, Set<Group> groupsToKeep, Map<Group,HashSet<User>> userGroupMembershipsToKeep)
Return the User/Group/Membership data to a clean state.void
setAutoSync(boolean autoSync)
void
startBatch()
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.void
synchronise()
Force a synchronisation with an external user directory.boolean
userExists(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 toLdapServer
using 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:UserManagementHelper
Force a synchronisation with an external user directory.- Specified by:
synchronise
in interfaceUserManagementHelper
-
addUserToGroup
public void addUserToGroup(String userName, String groupName)
- Specified by:
addUserToGroup
in interfaceUserManagementHelper
-
addUserToGroup
public void addUserToGroup(User user, Group group)
- Specified by:
addUserToGroup
in interfaceUserManagementHelper
-
addGroupToGroup
public void addGroupToGroup(Group childGroup, Group parentGroup)
Description copied from interface:UserManagementHelper
Add childGroup to parentGroup. Does nothing if the membership already exists.- Specified by:
addGroupToGroup
in interfaceUserManagementHelper
-
getUserGroups
public Set<String> getUserGroups(User user)
- Specified by:
getUserGroups
in 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:UserManagementHelper
Creates the user, adds it to the default users group, and ensures the user profile is created (to work around CONF-6404).- Specified by:
createUser
in interfaceUserManagementHelper
-
resetData
public void resetData(Set<User> usersToKeep, Set<Group> groupsToKeep, Map<Group,HashSet<User>> userGroupMembershipsToKeep)
Description copied from interface:UserManagementHelper
Return the User/Group/Membership data to a clean state.- Specified by:
resetData
in interfaceUserManagementHelper
-
isExternal
public boolean isExternal()
Description copied from interface:UserManagementHelper
Return 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:
isExternal
in interfaceUserManagementHelper
-
userExists
public boolean userExists(String username)
-
removeUser
public void removeUser(String username)
- Specified by:
removeUser
in interfaceUserManagementHelper
-
removeUser
public void removeUser(User user)
- Specified by:
removeUser
in interfaceUserManagementHelper
-
createGroup
public void createGroup(String groupName)
- Specified by:
createGroup
in interfaceUserManagementHelper
-
createGroup
public void createGroup(Group group)
- Specified by:
createGroup
in interfaceUserManagementHelper
-
removeUserFromGroup
public void removeUserFromGroup(User user, Group group)
- Specified by:
removeUserFromGroup
in interfaceUserManagementHelper
-
removeGroup
public void removeGroup(String groupName)
- Specified by:
removeGroup
in interfaceUserManagementHelper
-
createMultipleUsers
public List<User> createMultipleUsers(int numUsers)
Description copied from interface:UserManagementHelper
Helper to create multiple users (callsUserManagementHelper.createUser(com.atlassian.confluence.it.User)
)- Specified by:
createMultipleUsers
in 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:UserManagementHelper
Removes the list of users (callsUserManagementHelper.removeUser(User)
)- Specified by:
removeMultipleUsers
in 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:UserManagementHelper
Removes a user with the given username but do not remove their dependent permissions or pages.- Specified by:
removeUserUncleanly
in interfaceUserManagementHelper
- Parameters:
username
- the username of the user to remove
-
removeUserUncleanly
public void removeUserUncleanly(User user)
Description copied from interface:UserManagementHelper
Removes a user but do not remove their dependent permissions or pages.- Specified by:
removeUserUncleanly
in interfaceUserManagementHelper
- Parameters:
user
- the user to remove
-
removeGroupUncleanly
public void removeGroupUncleanly(Group group)
Description copied from interface:UserManagementHelper
Removes a group but do not remove their dependent permissions.- Specified by:
removeGroupUncleanly
in interfaceUserManagementHelper
- Parameters:
group
- the group to remove
-
fixUser
public void fixUser(User user)
Description copied from interface:UserManagementHelper
Ensure 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:
fixUser
in interfaceUserManagementHelper
- Parameters:
user
- a user to set the details of
-
changePassword
public void changePassword(String username, String newPassword)
Description copied from interface:UserManagementHelper
Change a user's password.- Specified by:
changePassword
in interfaceUserManagementHelper
- Parameters:
username
- Username of the user whose password to changenewPassword
- Password
-
setAutoSync
public void setAutoSync(boolean autoSync)
- Specified by:
setAutoSync
in interfaceUserManagementHelper
-
startBatch
public void startBatch()
Description copied from interface:UserManagementHelper
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.- Specified by:
startBatch
in interfaceUserManagementHelper
-
endBatch
public void endBatch()
Description copied from interface:UserManagementHelper
Flag 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:
endBatch
in interfaceUserManagementHelper
-
renameUser
public void renameUser(String oldUsername, String newUsername)
- Specified by:
renameUser
in interfaceUserManagementHelper
-
deactivateUser
public void deactivateUser(String username)
- Specified by:
deactivateUser
in interfaceUserManagementHelper
-
activateUser
public void activateUser(String username)
- Specified by:
activateUser
in interfaceUserManagementHelper
-
removeFromDefaultLicenseGroup
public void removeFromDefaultLicenseGroup(User user)
Description copied from interface:UserManagementHelper
Remove user from the group that has licensed access- Specified by:
removeFromDefaultLicenseGroup
in interfaceUserManagementHelper
-
-