[AUTH] Get list of roles hardly

View: New views
1 Messages — Rating Filter:   Alert me  

[AUTH] Get list of roles hardly

by g.imbrogno :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi all, I had a problem displaying the role description stored in the security.xml. To display the description of roles, I have to write some lines of code and I spent more than one hour to do this:

Permission perm1=null;
Collection perm = domainAuth.listPermissions(User.get());
Collection roles = new HashSet();
Iterator it = perm.iterator();
while (it.hasNext()){
        perm1 = (Permission)it.next();
        Role role = (Role) RoleFactory.getInstance().findByKey(perm1.getRoleId());
        roles.add(role);
}

I think that it will be simple to do a method in the class "User" that returns the Set of roles that are associated to the current User.