// foreach group in the system
Iterator groupsIterator = getAllGroups().elements();
while(groupsIterator.hasNext())
{
Group group = (Group)groupsIterator.next();
// get roles of user in the group
RoleSet groupRoles = RolePeer.retrieveSet( user, group );
// put the Set into roles(group)
roles.put(group, groupRoles);
// collect all permissoins in this group