// metadata principals never have group membership
if ( !( principal instanceof Group ) && !( principal instanceof AdminPrincipal )
&& !( principal instanceof AclMetadataPrincipal ) ) {
UserDetails user = internalGetUserDetails( principal.getName() );
if ( user == null ) {
return new PrincipalIteratorAdapter( groups );
}
for ( final GrantedAuthority role : user.getAuthorities() ) {
final String roleAuthority = role.getAuthority();
Principal fromCache;
synchronized ( roleCache ) {
fromCache = (Principal) roleCache.get( roleAuthority );
}
if ( fromCache != null ) {
groups.add( fromCache );
} else {
groups.add( createSpringSecurityRolePrincipal( roleAuthority ) );
}
}
}
groups.add( EveryonePrincipal.getInstance() );
if ( logger.isTraceEnabled() ) {
logger.trace( "group membership for principal=" + principal + " is " + groups ); //$NON-NLS-1$ //$NON-NLS-2$
}
return new PrincipalIteratorAdapter( groups );
}