ArrayList principalRoles = new ArrayList();
// Retrieve all roles of the user (Roles are members of the Group.class)
Set principals = subject.getPrincipals(Group.class);
Iterator iterator = principals.iterator();
while (iterator.hasNext()) {
Group group = (Group) iterator.next();
// Signed group (empty group that contains a signature)?
if (group instanceof JSigned) {
continue;
}
Enumeration e = group.members();
while (e.hasMoreElements()) {
Principal p = (Principal) e.nextElement();
principalRoles.add(p.getName());
}
}