I tried to use the (autowired) PermissionManager in a Confluence Rest Module as follows:
ConfluenceUser confluenceUser = AuthenticatedUserThreadLocal.get();
if(!permissionManager.isConfluenceAdministrator(confluenceUser)) {
throw....
}
If the user is not logged-in the exception is thrown and everything is fine but if the user is logged-in and has admin permissions I get a NullPointerException in the isConfluenceAdministrator method. The user object seems to be fine (and not NULL). The code is within a POST Method. I send the request from a custom settings page (location: system.admin).