}
@Override
protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals) {
// the current user has been previously loaded via doGetAuthenticationInfo before, use those permissions
User user = UserService.current();
if (!principals.getPrimaryPrincipal().equals(user.getName())) {
log.info("retrieving loaded user {} from per-request user cache", principals.getPrimaryPrincipal());
user = (User) Http.Context.current().args.get("perRequestUsersCache:" + principals.getPrimaryPrincipal().toString());
if (user == null) {
log.error("Cannot find previously loaded user, need to load it explicitely. This is unimplemented.");
return null;
}
}
final List<String> permissions = user.getPermissions();
final SimpleAuthorizationInfo authzInfo = new SimpleAuthorizationInfo();
if (log.isTraceEnabled()) {
log.trace("Permissions for {} are {}", user.getName(), Ordering.natural().sortedCopy(user.getPermissions()));
}
authzInfo.setStringPermissions(Sets.newHashSet(permissions));
return authzInfo;
}