@Override
protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals) {
try {
Long userId = (Long) (principals.fromRealm(getName()).iterator().next());
User user = (User) identityManagerment.findById(userId);
if (user != null) {
SimpleAuthorizationInfo info = new SimpleAuthorizationInfo();
for (Role role : user.getRoles()) {
info.addRole(role.getName());
info.addStringPermissions(role.getPermissions());
}
return info;
} else {