LdapPrincipal user = ( ( ServerContext ) InvocationStack.getInstance().peek().getCaller() ).getPrincipal();
Invocation invocation = InvocationStack.getInstance().peek(); LdapPrincipal user = ( ( ServerContext ) invocation.getCaller() ).getPrincipal();
    public void modifyRn( NextInterceptor next, Name name, String newRn, boolean deleteOldRn ) throws NamingException    {        // Access the principal requesting the operation, and bypass checks if it is the admin        Attributes entry = nexus.lookup( name );        LdapPrincipal user = ( ( ServerContext ) InvocationStack.getInstance().peek().getCaller() ).getPrincipal();        Name newName = ( Name ) name.clone();        newName.remove( name.size() - 1 );        newName.add( newRn );        if ( user.getName().equalsIgnoreCase( DirectoryPartitionNexus.ADMIN_PRINCIPAL ) || ! enabled )        {            next.modifyRn( name, newRn, deleteOldRn );            tupleCache.subentryRenamed( name, newName );            groupCache.groupRenamed( name, newName );            return;        }        Set userGroups = groupCache.getGroups( user.getName() );        Collection tuples = new HashSet();        addPerscriptiveAciTuples( tuples, name, entry );        addEntryAciTuples( tuples, entry );        addSubentryAciTuples( tuples, name, entry );        engine.checkPermission( next, userGroups, user.getJndiName(), user.getAuthenticationLevel(), name, null,                null, Collections.singleton( MicroOperation.RENAME ), tuples, entry );//        if ( deleteOldRn )//        {//            String oldRn = name.get( name.size() - 1 );//            if ( NamespaceTools.hasCompositeComponents( oldRn ) )//            {//                String[] comps = NamespaceTools.getCompositeComponents( oldRn );//                for ( int ii = 0; ii < comps.length; ii++ )//                {//                    String id = NamespaceTools.getRdnAttribute( comps[ii] );//                    String value = NamespaceTools.getRdnValue( comps[ii] );//                    engine.checkPermission( next, userGroups, user.getJndiName(),//                            user.getAuthenticationLevel(), name, id,//                            value, Collections.singleton( MicroOperation.REMOVE ),//                            tuples, entry );//                }//            }//            else//            {//                String id = NamespaceTools.getRdnAttribute( oldRn );//                String value = NamespaceTools.getRdnValue( oldRn );//                engine.checkPermission( next, userGroups, user.getJndiName(),//                        user.getAuthenticationLevel(), name, id,//                        value, Collections.singleton( MicroOperation.REMOVE ),//                        tuples, entry );//            }//        }        next.modifyRn( name, newRn, deleteOldRn );        tupleCache.subentryRenamed( name, newName );        groupCache.groupRenamed( name, newName );    }