{
for ( String userName : group.getUserArray() )
{
if ( userName.equals( user.getName() ) )
{
Group memoryGroup = userList.getGroup( group.getName() );
if ( memoryGroup != null )
{
if (logger.isDebugEnabled()) {
logger.debug("USER : " + memoryUser.getName() + " in GROUP : " + memoryGroup.getName() );
}
// User and Group hold references to each other
memoryGroup.addUser( memoryUser );
memoryUser.addGroup( memoryGroup );
// user inherits this group's roles.
for ( Role memoryRole : memoryGroup.getRoles() )
{
memoryUser.addRole ( memoryRole );
}
}