for (Iterator groupsIterator = getAllGroups().iterator();
groupsIterator.hasNext();)
{
Group group = (Group) groupsIterator.next();
// get roles of user in the group
RoleSet groupRoles = RolePeerManager.retrieveSet(user, group);
// put the Set into roles(group)
roles.put(group, groupRoles);
// collect all permissions in this group
PermissionSet groupPermissions = new PermissionSet();
// foreach role in Set
for (Iterator rolesIterator = groupRoles.iterator();
rolesIterator.hasNext();)
{
Role role = (Role) rolesIterator.next();
// get permissions of the role
PermissionSet rolePermissions =