}
List<String> roles = new ArrayList<String>();
Iterator uroles = user.getRoles();
while(uroles.hasNext()) {
Role role = (Role)uroles.next();
roles.add(role.getName());
}
Iterator groups = user.getGroups();
while(groups.hasNext()) {
Group group = (Group)groups.next();
uroles = group.getRoles();
while(uroles.hasNext()) {
Role role = (Role)uroles.next();
roles.add(role.getName());
}
}
return new GenericPrincipal(this, username, user.getPassword(), roles, user);
}