User macro to show users and permissions in current space

Dear all,

I would like to create a user-macro to get on start-page of the space an overview of keyusers and users.
user: can everything, but can’t do administrative tasks, can’t set/change permissions
keyuser: can everything, but can’t do administrative task, can set/change permissions
admin: can everything

I have only small spaces (20 Users for each).

So I would like to work with the permissionhelper and will show keyusers by filtering user objects which having right to “canSetPermissions” but which are no confluenceadministrators (to filter out Superuser).

So find my “quick & dirty” code below.
The problem: I was Setting permissions to a Group (keyuser) and add user to this group. But the permissionHelber didn’t resolve the activated option “can set permissions”

#set($containerManagerClass = $content.class.forName('com.atlassian.spring.container.ContainerManager'))
#set($getInstanceMethod = $containerManagerClass.getDeclaredMethod('getInstance',null))
#set($containerManager = $getInstanceMethod.invoke(null,null))
#set($containerContext = $containerManager.containerContext)
#set($users = $userAccessor.getUsers())
#set($spaces = $spaceManager.getAllSpaces())
<table class="aui">
    <th class="confluenceTh">KeyUser</th>
#foreach($spacer in $spaces)
#if ($spacer.key == $space.key)
#foreach($user in $users)
#if ($permissionHelper.canSetPermissions($user, $spacer) and not $permissionHelper.isConfluenceAdministrator($user))
      <td class="confluenceTd">#usernameLink($</td>

pretty old question, but I’ll still try…
The permissionHelper returns the permissions on the requested object (in this case the space). But only space admins are allowed to set permissions on the space level.
What you want to display, is the permission to change restrictions on pages inside a space. This is not handled by the permission helper.
I didn’t dig deep, but check the SpacePermissionManager class in the Confluence Java API.