You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2010/05/29 17:34:29 UTC

svn commit: r949402 - in /directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core: authz/AciAuthorizationInterceptor.java event/EventInterceptor.java exception/ExceptionInterceptor.java referral/ReferralInterceptor.java

Author: elecharny
Date: Sat May 29 15:34:28 2010
New Revision: 949402

URL: http://svn.apache.org/viewvc?rev=949402&view=rev
Log:
o Really removed the calls to lookup() mwhen it's useless
o Removed commented code

Modified:
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authz/AciAuthorizationInterceptor.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/event/EventInterceptor.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/exception/ExceptionInterceptor.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/referral/ReferralInterceptor.java

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authz/AciAuthorizationInterceptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authz/AciAuthorizationInterceptor.java?rev=949402&r1=949401&r2=949402&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authz/AciAuthorizationInterceptor.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authz/AciAuthorizationInterceptor.java Sat May 29 15:34:28 2010
@@ -545,11 +545,10 @@ public class AciAuthorizationInterceptor
     @SuppressWarnings("PMD.CollapsibleIfStatements")
     public void modify( NextInterceptor next, ModifyOperationContext opContext ) throws Exception
     {
-        DN name = opContext.getDn();
+        DN dn = opContext.getDn();
 
         // Access the principal requesting the operation, and bypass checks if it is the admin
-        Entry entry = opContext.lookup( name, ByPassConstants.LOOKUP_BYPASS );
-        //         Entry entry = opContext.getEntry();
+        Entry entry = opContext.getEntry();
 
         LdapPrincipal principal = opContext.getSession().getEffectivePrincipal();
         DN principalDn = principal.getDN();
@@ -567,23 +566,24 @@ public class AciAuthorizationInterceptor
         if ( isPrincipalAnAdministrator( principalDn ) )
         {
             next.modify( opContext );
+
             /**
              * @TODO: A virtual entry can be created here for not hitting the backend again.
              */
-            Entry modifiedEntry = opContext.lookup( name, ByPassConstants.LOOKUP_BYPASS );
-            tupleCache.subentryModified( name, mods, modifiedEntry );
-            groupCache.groupModified( name, mods, entry, schemaManager );
+            Entry modifiedEntry = opContext.lookup( dn, ByPassConstants.LOOKUP_BYPASS );
+            tupleCache.subentryModified( dn, mods, modifiedEntry );
+            groupCache.groupModified( dn, mods, entry, schemaManager );
             return;
         }
 
         Set<DN> userGroups = groupCache.getGroups( principalDn.getName() );
         Collection<ACITuple> tuples = new HashSet<ACITuple>();
-        addPerscriptiveAciTuples( opContext, tuples, name, ( ( ClonedServerEntry ) entry ).getOriginalEntry() );
+        addPerscriptiveAciTuples( opContext, tuples, dn, ( ( ClonedServerEntry ) entry ).getOriginalEntry() );
         addEntryAciTuples( tuples, entry );
-        addSubentryAciTuples( opContext, tuples, name, entry );
+        addSubentryAciTuples( opContext, tuples, dn, entry );
 
         engine.checkPermission( schemaManager, opContext, userGroups, principalDn, principal.getAuthenticationLevel(),
-            name, null, null, Collections.singleton( MicroOperation.MODIFY ), tuples, entry, null );
+            dn, null, null, Collections.singleton( MicroOperation.MODIFY ), tuples, entry, null );
 
         Collection<MicroOperation> perms = null;
         Entry entryView = ( Entry ) entry.clone();
@@ -602,7 +602,7 @@ public class AciAuthorizationInterceptor
                     {
                         // ... we also need to check if adding the attribute is permitted
                         engine.checkPermission( schemaManager, opContext, userGroups, principalDn, principal
-                            .getAuthenticationLevel(), name, attr.getId(), null, perms, tuples, entry, null );
+                            .getAuthenticationLevel(), dn, attr.getId(), null, perms, tuples, entry, null );
                     }
 
                     break;
@@ -618,7 +618,7 @@ public class AciAuthorizationInterceptor
                         {
                             // ... we also need to check if removing the attribute at all is permitted
                             engine.checkPermission( schemaManager, opContext, userGroups, principalDn, principal
-                                .getAuthenticationLevel(), name, attr.getId(), null, perms, tuples, entry, null );
+                                .getAuthenticationLevel(), dn, attr.getId(), null, perms, tuples, entry, null );
                         }
                     }
 
@@ -647,7 +647,7 @@ public class AciAuthorizationInterceptor
             for ( Value<?> value : attr )
             {
                 engine.checkPermission( schemaManager, opContext, userGroups, principalDn, principal
-                    .getAuthenticationLevel(), name, attr.getId(), value, perms, tuples, entry, entryView );
+                    .getAuthenticationLevel(), dn, attr.getId(), value, perms, tuples, entry, entryView );
             }
         }
 
@@ -655,9 +655,9 @@ public class AciAuthorizationInterceptor
         /**
          * @TODO: A virtual entry can be created here for not hitting the backend again.
          */
-        Entry modifiedEntry = opContext.lookup( name, ByPassConstants.LOOKUP_BYPASS );
-        tupleCache.subentryModified( name, mods, modifiedEntry );
-        groupCache.groupModified( name, mods, entry, schemaManager );
+        Entry modifiedEntry = opContext.lookup( dn, ByPassConstants.LOOKUP_BYPASS );
+        tupleCache.subentryModified( dn, mods, modifiedEntry );
+        groupCache.groupModified( dn, mods, entry, schemaManager );
     }
 
 

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/event/EventInterceptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/event/EventInterceptor.java?rev=949402&r1=949401&r2=949402&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/event/EventInterceptor.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/event/EventInterceptor.java Sat May 29 15:34:28 2010
@@ -187,8 +187,7 @@ public class EventInterceptor extends Ba
 
     public void modify( NextInterceptor next, final ModifyOperationContext opContext ) throws Exception
     {
-        Entry oriEntry = opContext.lookup( opContext.getDn(), ByPassConstants.LOOKUP_BYPASS );
-        //        Entry oriEntry = opContext.getEntry();
+        Entry oriEntry = opContext.getEntry();
 
         List<RegistrationEntry> selecting = getSelectingRegistrations( opContext.getDn(), oriEntry );
 

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/exception/ExceptionInterceptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/exception/ExceptionInterceptor.java?rev=949402&r1=949401&r2=949402&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/exception/ExceptionInterceptor.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/exception/ExceptionInterceptor.java Sat May 29 15:34:28 2010
@@ -300,8 +300,7 @@ public class ExceptionInterceptor extend
 
         assertHasEntry( opContext, msg );
 
-        Entry entry = opContext.lookup( opContext.getDn(), ByPassConstants.LOOKUP_BYPASS );
-        //         Entry entry = opContext.getEntry();
+        Entry entry = opContext.getEntry();
 
         List<Modification> items = opContext.getModItems();
 

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/referral/ReferralInterceptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/referral/ReferralInterceptor.java?rev=949402&r1=949401&r2=949402&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/referral/ReferralInterceptor.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/referral/ReferralInterceptor.java Sat May 29 15:34:28 2010
@@ -19,6 +19,7 @@
  */
 package org.apache.directory.server.core.referral;
 
+
 import javax.naming.Context;
 import javax.naming.NamingException;
 
@@ -38,9 +39,9 @@ import org.apache.directory.server.core.
 import org.apache.directory.server.i18n.I18n;
 import org.apache.directory.shared.ldap.codec.util.LdapURLEncodingException;
 import org.apache.directory.shared.ldap.constants.SchemaConstants;
-import org.apache.directory.shared.ldap.entry.StringValue;
-import org.apache.directory.shared.ldap.entry.EntryAttribute;
 import org.apache.directory.shared.ldap.entry.Entry;
+import org.apache.directory.shared.ldap.entry.EntryAttribute;
+import org.apache.directory.shared.ldap.entry.StringValue;
 import org.apache.directory.shared.ldap.entry.Value;
 import org.apache.directory.shared.ldap.filter.SearchScope;
 import org.apache.directory.shared.ldap.name.DN;
@@ -74,9 +75,9 @@ public class ReferralInterceptor extends
     private ReferralManager referralManager;
 
     /** A normalized form for the SubschemaSubentry DN */
-    private String subschemaSubentryDnNorm;
+    private DN subschemaSubentryDn;
+
 
-    
     static private void checkRefAttributeValue( Value<?> value ) throws NamingException, LdapURLEncodingException
     {
         StringValue ref = ( StringValue ) value;
@@ -140,7 +141,7 @@ public class ReferralInterceptor extends
         }
     }
 
-    
+
     // This will suppress PMD.EmptyCatchBlock warnings in this method
     @SuppressWarnings("PMD.EmptyCatchBlock")
     static private boolean isReferral( Entry entry ) throws NamingException
@@ -152,7 +153,7 @@ public class ReferralInterceptor extends
         {
             return false;
         }
-        
+
         EntryAttribute oc = entry.get( SchemaConstants.OBJECT_CLASS_AT );
 
         if ( oc == null )
@@ -209,9 +210,8 @@ public class ReferralInterceptor extends
         directoryService.setReferralManager( referralManager );
 
         Value<?> subschemaSubentry = nexus.getRootDSE( null ).get( SchemaConstants.SUBSCHEMA_SUBENTRY_AT ).get();
-        DN subschemaSubentryDn = new DN( subschemaSubentry.getString() );
+        subschemaSubentryDn = new DN( subschemaSubentry.getString() );
         subschemaSubentryDn.normalize( schemaManager.getNormalizerMapping() );
-        subschemaSubentryDnNorm = subschemaSubentryDn.getNormName();
     }
 
 
@@ -235,13 +235,13 @@ public class ReferralInterceptor extends
     public void add( NextInterceptor next, AddOperationContext opContext ) throws Exception
     {
         Entry entry = opContext.getEntry();
-        
+
         // Check if the entry is a referral itself
         boolean isReferral = isReferral( entry );
 
         // We add the entry into the server
         next.add( opContext );
-        
+
         // If the addition is successful, we update the referralManager 
         if ( isReferral )
         {
@@ -272,7 +272,7 @@ public class ReferralInterceptor extends
     {
         // First delete the entry into the server
         next.delete( opContext );
-        
+
         Entry entry = opContext.getEntry();
 
         // Check if the entry exists and is a referral itself
@@ -303,20 +303,19 @@ public class ReferralInterceptor extends
         boolean isReferral = isReferral( opContext.getEntry() );
 
         next.move( opContext );
-        
-        
-        if ( isReferral ) 
+
+        if ( isReferral )
         {
             // Update the referralManager
             LookupOperationContext lookupContext = new LookupOperationContext( opContext.getSession(), newName );
-            
+
             Entry newEntry = nexus.lookup( lookupContext );
-            
+
             referralManager.lockWrite();
-            
+
             referralManager.addReferral( newEntry );
             referralManager.removeReferral( opContext.getEntry() );
-            
+
             referralManager.unlock();
         }
     }
@@ -334,19 +333,19 @@ public class ReferralInterceptor extends
         boolean isReferral = isReferral( opContext.getEntry() );
 
         next.moveAndRename( opContext );
-        
-        if ( isReferral ) 
+
+        if ( isReferral )
         {
             // Update the referralManager
             LookupOperationContext lookupContext = new LookupOperationContext( opContext.getSession(), newName );
-            
+
             Entry newEntry = nexus.lookup( lookupContext );
-            
+
             referralManager.lockWrite();
-            
+
             referralManager.addReferral( newEntry );
             referralManager.removeReferral( opContext.getEntry() );
-            
+
             referralManager.unlock();
         }
     }
@@ -361,37 +360,38 @@ public class ReferralInterceptor extends
         boolean isReferral = isReferral( opContext.getEntry() );
 
         next.rename( opContext );
-        
-        if ( isReferral ) 
+
+        if ( isReferral )
         {
             // Update the referralManager
-            LookupOperationContext lookupContext = new LookupOperationContext( opContext.getSession(), opContext.getNewDn() );
-            
+            LookupOperationContext lookupContext = new LookupOperationContext( opContext.getSession(), opContext
+                .getNewDn() );
+
             Entry newEntry = nexus.lookup( lookupContext );
-            
+
             referralManager.lockWrite();
-            
+
             referralManager.addReferral( newEntry );
             referralManager.removeReferral( opContext.getEntry().getOriginalEntry() );
-            
+
             referralManager.unlock();
         }
     }
-    
+
 
     /**
      * Modify an entry in the server.
      */
     public void modify( NextInterceptor next, ModifyOperationContext opContext ) throws Exception
     {
-        DN name = opContext.getDn();
-        
+        DN dn = opContext.getDn();
+
         // handle a normal modify without following referrals
         next.modify( opContext );
 
         // Check if we are trying to modify the schema or the rootDSE,
         // if so, we don't modify the referralManager
-        if ( ( name == DN.EMPTY_DN ) || ( subschemaSubentryDnNorm.equals( name.getNormName() ) ) )
+        if ( dn.isEmpty() || dn.equals( subschemaSubentryDn ) )
         {
             // Do nothing
             return;
@@ -401,8 +401,8 @@ public class ReferralInterceptor extends
         // as it has been modified, before updating the ReferralManager
         // TODO: this can be spare, as we build the entry later.
         // But we will have to store the modified entry into the opContext
-        LookupOperationContext lookupContext = new LookupOperationContext( opContext.getSession(), name );
-        
+        LookupOperationContext lookupContext = new LookupOperationContext( opContext.getSession(), dn );
+
         Entry newEntry = nexus.lookup( lookupContext );
 
         // Check that we have the entry, just in case
@@ -416,46 +416,8 @@ public class ReferralInterceptor extends
                 referralManager.removeReferral( opContext.getEntry() );
                 referralManager.addReferral( newEntry );
             }
-            
+
             referralManager.unlock();
         }
     }
-
-
-    /**
-     * When adding a new context partition, we have to update the referralManager
-     * by injecting all the new referrals into it. This is done using the init()
-     * method of the referralManager.
-     *
-    public void addContextPartition( NextInterceptor next, AddContextPartitionOperationContext opContext )
-        throws Exception
-    {
-        // First, inject the partition
-        next.addContextPartition( opContext );
-
-        Partition partition = opContext.getPartition();
-        DN suffix = partition.getSuffixDn();
-        
-        // add referrals immediately after adding the new partition
-        referralManager.init( directoryService, new String[]{ suffix.getNormName() } );
-    }
-
-
-    /**
-     * Remove a partion's referrals from the server. We have to first
-     * clear the referrals manager from all of this partition's referrals,
-     * then we can delete the partition.
-     *
-    public void removeContextPartition( NextInterceptor next, RemoveContextPartitionOperationContext opContext )
-        throws Exception
-    {
-        // get the partition suffix
-        DN suffix = opContext.getDn();
-
-        // remove referrals immediately before removing the partition
-        referralManager.remove( directoryService, suffix );
-
-        // And remove the partition from the server
-        next.removeContextPartition( opContext );
-    }*/
 }