*/
public final Principal resolvePrincipal( String name )
{
if( !m_useJAAS )
{
return new UnresolvedPrincipal(name);
}
// Check built-in Roles first
Role role = new Role(name);
if ( Role.isBuiltInRole( role ) )
{
return role;
}
// Check Authorizer Roles
Principal principal = m_authorizer.findRole( name );
if ( principal != null )
{
return principal;
}
// Check Groups
principal = m_engine.getGroupManager().findRole( name );
if ( principal != null )
{
return principal;
}
// Ok, no luck---this must be a user principal
Principal[] principals = null;
UserProfile profile = null;
UserDatabase db = m_engine.getUserManager().getUserDatabase();
try
{
profile = db.find( name );
principals = db.getPrincipals( profile.getLoginName() );
for (int i = 0; i < principals.length; i++)
{
principal = principals[i];
if ( principal.getName().equals( name ) )
{
return principal;
}
}
}
catch( NoSuchPrincipalException e )
{
// We couldn't find the user...
}
// Ok, no luck---mark this as unresolved and move on
return new UnresolvedPrincipal( name );
}