Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal


  • Give kudos
  • Received
  • Given


  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Is there a Java API to remove a permissions from a Space

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?

1 answer

@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 (like SpacePermissionContext from you solution).

I suppose they are protected? Is there a way to use them?

Thanks in advance!



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

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

Like Damian Jesionek likes this

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);
ConfluenceUser aktuser = userAccessor.getUserByName("myadminaccountname");

 AuthenticatedUserImpersonator.REQUEST_AGNOSTIC.asUser(() ->{
    return null;
}, aktuser);

} //if
} // for
} //if

Not Working.. even trying to add a permission @ the moment.

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted in Confluence

What do you think is the most *delightful* Confluence feature? Comment for a prize!

- Create your own custom emoji 🔥 - "Shake for Feedback" on mobile 📱 - An endless supply of GIFs via GIPHY 🤩 Is there anything quite as nice as a pleasant surprise? Comment below with what...

415 views 23 8
Join discussion

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you