Permission resolvePermission(
        PermissionEntry pe,
        GrantEntry ge, KeyStore ks,
        boolean resolve
    )
        throws Exception
    {
        String className = pe.getKlass();
        String name = pe.getName();
        String actions = pe.getActions();
        String signer = pe.getSigners();
        if( name != null )
        {
            name = propertyExpander.expandGeneral( name, new PermissionExpander( ge, ks ) );
        }
        if( resolve )
        {
            if( name != null )
            {
                name = propertyExpander.expand( name );
            }
            if( actions != null )
            {
                actions =propertyExpander.expand( actions );
            }
            if( signer != null )
            {
                signer = propertyExpander.expand( signer );
            }
        }
        Certificate[] signers = ( signer == null ) ? null : resolveSigners(
            ks, signer );
        try
        {
            Class<?> klass = Class.forName( className );
            if( PolicyUtils.matchSubset( signers, klass.getSigners() ) )
            {
                return PolicyUtils.instantiatePermission( klass, name, actions );
            }
        }
        catch( ClassNotFoundException cnfe )
        {
            // do nothing
        }
        //maybe properly signed class will be loaded later
        return new UnresolvedPermission( className, name, actions, signers );
    }