We've build a custom Confluence Plugin for managing Space permissions.
In Confluence 5.9 we've used com.atlassian.confluence.spaces.Space.removePermission to remove a existing permission from a Space. This does not work anymore with Confluence 6.x
Does somebody know how to implement this in newer Confluence Versions?
@Andreas von Euw did you ever find an answer? The only way I see in the 6.x Java API to get user-related permissions:
DefaultSpaceManager.getAllPermissionsForUser(ConfluenceUser user)
...but its protected and not accessible via the API.
I have a list of ConfluenceUser(s) and have to remove them from a specific space's permissions. I see no way of accomplishing this aside from a nuclear option:
//Remove all permissions entirely
DefaultSpaceManager.removeAllPermissions(Space space)
...then rebuilding all remaining users based on a predefined role-permission mapping
Forgot to add, if you have the SpacePermission already you can use this:
removePermission(SpacePermission permission, SpacePermissionContext context)
creating the SpacePermissionContext is straightforward:
SpacePermissionContext context = SpacePermissionContext.builder().build();
You can add event-related options to the context if you want to suppress them, etc.
@Steven Klingwhich classes removePermission() are you using, since most of them are deprecated in the most recent versions. Also I have issues using Classes from the package com.atlassian.confluence.internal.security (like SpacePermissionContext from you solution).
I suppose they are protected? Is there a way to use them?
Thanks in advance!
EDIT:
I also settled to use removeAllPermissions() which is also quite hacky as you need to prevent the side effects that result from this method call (space attribute of the permissions are set to null and the list is cleared).
A prettier solution for that would be appreciated I think
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I am stuck @exactly the same spot. Everything I try to use is deprecated or not working. Everything new I try to import is protected. So frustrating to write scheduled Tasks for this.. Software... #annoyedPluginDeveloperwhocantfindthingsheneeds
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
My latest fail:
fired my problem:
SpacesQuery query = SpacesQuery.newQuery().forUser(null).withSpaceType(SpaceType.GLOBAL).withPermission(SpacePermission.VIEWSPACE_PERMISSION).build();
ListBuilder<Space> bereichebuilder = spaceManager.getSpaces(query);
if (bereichebuilder.getAvailableSize() != 0) {
List<Space> bereiche = bereichebuilder.getRange(0, bereichebuilder.getAvailableSize());
for (Space aktspace : bereiche) {
if (aktspace.getKey().equals("FUNFACTORY")) {
List<SpacePermission> spaceperms = new ArrayList<SpacePermission>();
SpacePermission myperm;
myperm = SpacePermission.createAnonymousSpacePermission(SpacePermission.REMOVE_OWN_CONTENT_PERMISSION, aktspace);
spaceperms.add(myperm);
ConfluenceUser aktuser = userAccessor.getUserByName("myadminaccountname");
AuthenticatedUserImpersonator.REQUEST_AGNOSTIC.asUser(() ->{
aktspace.setPermissions(spaceperms);
return null;
}, aktuser);
} //if
} // for
} //if
Not Working.. even trying to add a permission @ the moment.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.