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 2007/04/06 16:39:34 UTC

svn commit: r526182 - in /directory/apacheds/trunk/core/src: main/java/org/apache/directory/server/core/authn/ main/java/org/apache/directory/server/core/interceptor/ main/java/org/apache/directory/server/core/interceptor/context/ main/java/org/apache/...

Author: elecharny
Date: Fri Apr  6 07:39:32 2007
New Revision: 526182

URL: http://svn.apache.org/viewvc?view=rev&rev=526182
Log:
Modified the isSuffix() method : using a SuffixServiceContext instead of a LdapDN

Added:
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/interceptor/context/SuffixServiceContext.java
Modified:
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authn/AuthenticationService.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/interceptor/BaseInterceptor.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/interceptor/Interceptor.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/interceptor/InterceptorChain.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/interceptor/NextInterceptor.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/normalization/NormalizationService.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/AbstractPartition.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/DefaultPartitionNexus.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/Partition.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/PartitionNexusProxy.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/BTreePartition.java
    directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/interceptor/InterceptorChainTest.java

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authn/AuthenticationService.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authn/AuthenticationService.java?view=diff&rev=526182&r1=526181&r2=526182
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authn/AuthenticationService.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authn/AuthenticationService.java Fri Apr  6 07:39:32 2007
@@ -44,6 +44,7 @@
 import org.apache.directory.server.core.interceptor.context.BindServiceContext;
 import org.apache.directory.server.core.interceptor.context.LookupServiceContext;
 import org.apache.directory.server.core.interceptor.context.ServiceContext;
+import org.apache.directory.server.core.interceptor.context.SuffixServiceContext;
 import org.apache.directory.server.core.invocation.InvocationStack;
 import org.apache.directory.server.core.jndi.LdapJndiProperties;
 import org.apache.directory.server.core.jndi.ServerContext;
@@ -272,15 +273,15 @@
     }
 
 
-    public boolean isSuffix( NextInterceptor next, LdapDN name ) throws NamingException
+    public boolean isSuffix( NextInterceptor next, ServiceContext suffixContext ) throws NamingException
     {
         if ( IS_DEBUG )
         {
-            log.debug( "Testing suffix for name = '" + name.toString() + "'" );
+            log.debug( "Testing suffix for name = '" + ((SuffixServiceContext)suffixContext).getSuffixDn().getUpName() + "'" );
         }
 
         checkAuthenticated();
-        return next.isSuffix( name );
+        return next.isSuffix( suffixContext );
     }
 
 

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/interceptor/BaseInterceptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/interceptor/BaseInterceptor.java?view=diff&rev=526182&r1=526181&r2=526182
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/interceptor/BaseInterceptor.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/interceptor/BaseInterceptor.java Fri Apr  6 07:39:32 2007
@@ -135,9 +135,9 @@
     }
 
 
-    public boolean isSuffix( NextInterceptor next, LdapDN name ) throws NamingException
+    public boolean isSuffix( NextInterceptor next, ServiceContext suffixContext ) throws NamingException
     {
-        return next.isSuffix( name );
+        return next.isSuffix( suffixContext );
     }
 
 

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/interceptor/Interceptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/interceptor/Interceptor.java?view=diff&rev=526182&r1=526181&r2=526182
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/interceptor/Interceptor.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/interceptor/Interceptor.java Fri Apr  6 07:39:32 2007
@@ -210,9 +210,9 @@
 
 
     /**
-     * Filters {@link Partition#isSuffix(org.apache.directory.shared.ldap.name.LdapDN)} call.
+     * Filters {@link Partition#isSuffix(ServiceContext)} call.
      */
-    boolean isSuffix( NextInterceptor next, LdapDN name ) throws NamingException;
+    boolean isSuffix( NextInterceptor next, ServiceContext suffixContext ) throws NamingException;
 
 
     /**

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/interceptor/InterceptorChain.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/interceptor/InterceptorChain.java?view=diff&rev=526182&r1=526181&r2=526182
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/interceptor/InterceptorChain.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/interceptor/InterceptorChain.java Fri Apr  6 07:39:32 2007
@@ -158,9 +158,9 @@
         }
 
 
-        public boolean isSuffix( NextInterceptor next, LdapDN name ) throws NamingException
+        public boolean isSuffix( NextInterceptor next, ServiceContext suffixContext ) throws NamingException
         {
-            return nexus.isSuffix( name );
+            return nexus.isSuffix( suffixContext );
         }
 
 
@@ -881,14 +881,14 @@
     }
 
 
-    public boolean isSuffix( LdapDN name ) throws NamingException
+    public boolean isSuffix( ServiceContext suffixContext ) throws NamingException
     {
         Entry entry = getStartingEntry();
         Interceptor head = entry.configuration.getInterceptor();
         NextInterceptor next = entry.nextInterceptor;
         try
         {
-            return head.isSuffix( next, name );
+            return head.isSuffix( next, suffixContext );
         }
         catch ( NamingException ne )
         {
@@ -1295,14 +1295,14 @@
                 }
 
 
-                public boolean isSuffix( LdapDN name ) throws NamingException
+                public boolean isSuffix( ServiceContext suffixContext ) throws NamingException
                 {
                     Entry next = getNextEntry();
                     Interceptor interceptor = next.configuration.getInterceptor();
 
                     try
                     {
-                        return interceptor.isSuffix( next.nextInterceptor, name );
+                        return interceptor.isSuffix( next.nextInterceptor, suffixContext );
                     }
                     catch ( NamingException ne )
                     {

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/interceptor/NextInterceptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/interceptor/NextInterceptor.java?view=diff&rev=526182&r1=526181&r2=526182
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/interceptor/NextInterceptor.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/interceptor/NextInterceptor.java Fri Apr  6 07:39:32 2007
@@ -35,7 +35,6 @@
 import org.apache.directory.shared.ldap.message.ModificationItemImpl;
 import org.apache.directory.shared.ldap.name.LdapDN;
 
-
 /**
  * Represents the next {@link Interceptor} in the interceptor chain.
  *
@@ -138,9 +137,9 @@
 
 
     /**
-     * Calls the next interceptor's {@link Interceptor#isSuffix(NextInterceptor,org.apache.directory.shared.ldap.name.LdapDN)}.
+     * Calls the next interceptor's {@link Interceptor#isSuffix(NextInterceptor, ServiceContext)}.
      */
-    boolean isSuffix( LdapDN name ) throws NamingException;
+    boolean isSuffix( ServiceContext suffixContext ) throws NamingException;
 
 
     /**

Added: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/interceptor/context/SuffixServiceContext.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/interceptor/context/SuffixServiceContext.java?view=auto&rev=526182
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/interceptor/context/SuffixServiceContext.java (added)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/interceptor/context/SuffixServiceContext.java Fri Apr  6 07:39:32 2007
@@ -0,0 +1,78 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.server.core.interceptor.context;
+
+import org.apache.directory.shared.ldap.name.LdapDN;
+
+/**
+ * A Suffix context used for Interceptors. It contains all the informations
+ * needed for the isSuffix operation, and used by all the interceptors
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class SuffixServiceContext implements ServiceContext
+{
+    /** The principal DN */
+    private LdapDN suffixDn;
+
+    /**
+     * Creates a new instance of SuffixServiceContext.
+     */
+    public SuffixServiceContext()
+    {
+    }
+    
+    /**
+     * Creates a new instance of SuffixServiceContext.
+     *
+     * @param suffixDn The principal DN from which the suffix must be hecked
+     */
+    public SuffixServiceContext( LdapDN suffixDn )
+    {
+        this.suffixDn = suffixDn;
+    }
+    
+    /**
+     * @return The Suffix DN
+     */
+    public LdapDN getSuffixDn()
+    {
+        return suffixDn;
+    }
+    
+    /**
+     * Set the Suffix DN.
+     *
+     * @param unbindDn The Suffix DN
+     */
+    public void setSuffixDn( LdapDN suffixDn )
+    {
+        this.suffixDn = suffixDn;
+    }
+    
+    /**
+     * @see Object#toString()
+     */
+    public String toString()
+    {
+        return "SuffixContext for DN '" + suffixDn.getUpName() + "'";
+    }
+}

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/normalization/NormalizationService.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/normalization/NormalizationService.java?view=diff&rev=526182&r1=526181&r2=526182
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/normalization/NormalizationService.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/normalization/NormalizationService.java Fri Apr  6 07:39:32 2007
@@ -36,6 +36,7 @@
 import org.apache.directory.server.core.interceptor.context.BindServiceContext;
 import org.apache.directory.server.core.interceptor.context.LookupServiceContext;
 import org.apache.directory.server.core.interceptor.context.ServiceContext;
+import org.apache.directory.server.core.interceptor.context.SuffixServiceContext;
 import org.apache.directory.server.core.partition.PartitionNexus;
 import org.apache.directory.server.schema.ConcreteNameComponentNormalizer;
 import org.apache.directory.server.schema.registries.AttributeTypeRegistry;
@@ -351,10 +352,10 @@
     }
 
 
-    public boolean isSuffix( NextInterceptor nextInterceptor, LdapDN name ) throws NamingException
+    public boolean isSuffix( NextInterceptor nextInterceptor, ServiceContext suffixContext ) throws NamingException
     {
-        name = LdapDN.normalize( name, attrNormalizers );
-        return nextInterceptor.isSuffix( name );
+        LdapDN.normalize( ((SuffixServiceContext)suffixContext).getSuffixDn(), attrNormalizers );
+        return nextInterceptor.isSuffix( suffixContext );
     }
 
 

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/AbstractPartition.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/AbstractPartition.java?view=diff&rev=526182&r1=526181&r2=526182
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/AbstractPartition.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/AbstractPartition.java Fri Apr  6 07:39:32 2007
@@ -34,6 +34,7 @@
 import org.apache.directory.server.core.configuration.PartitionConfiguration;
 import org.apache.directory.server.core.interceptor.context.LookupServiceContext;
 import org.apache.directory.server.core.interceptor.context.ServiceContext;
+import org.apache.directory.server.core.interceptor.context.SuffixServiceContext;
 import org.apache.directory.shared.ldap.message.ModificationItemImpl;
 import org.apache.directory.shared.ldap.name.LdapDN;
 
@@ -179,9 +180,9 @@
     }
 
 
-    public final boolean isSuffix( LdapDN name ) throws NamingException
+    public final boolean isSuffix( ServiceContext suffixContext ) throws NamingException
     {
-        return getSuffix().equals( name );
+        return getSuffix().equals( ((SuffixServiceContext)suffixContext).getSuffixDn() );
     }
 
 

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/DefaultPartitionNexus.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/DefaultPartitionNexus.java?view=diff&rev=526182&r1=526181&r2=526182
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/DefaultPartitionNexus.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/DefaultPartitionNexus.java Fri Apr  6 07:39:32 2007
@@ -47,6 +47,7 @@
 import org.apache.directory.server.core.interceptor.context.BindServiceContext;
 import org.apache.directory.server.core.interceptor.context.LookupServiceContext;
 import org.apache.directory.server.core.interceptor.context.ServiceContext;
+import org.apache.directory.server.core.interceptor.context.SuffixServiceContext;
 import org.apache.directory.server.core.interceptor.context.UnbindServiceContext;
 import org.apache.directory.server.core.partition.impl.btree.MutableBTreePartitionConfiguration;
 import org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmPartition;
@@ -947,9 +948,9 @@
     /**
      * @see Partition#isSuffix(org.apache.directory.shared.ldap.name.LdapDN)
      */
-    public boolean isSuffix( LdapDN dn )
+    public boolean isSuffix( ServiceContext suffixContext )
     {
-        return partitions.containsKey( dn.toString() );
+        return partitions.containsKey( ((SuffixServiceContext)suffixContext).getSuffixDn().getNormName() );
     }
 
 

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/Partition.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/Partition.java?view=diff&rev=526182&r1=526181&r2=526182
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/Partition.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/Partition.java Fri Apr  6 07:39:32 2007
@@ -216,11 +216,11 @@
     /**
      * Checks to see if name is a context suffix.
      *
-     * @param name the normalized distinguished/absolute name of the context
+     * @param suffixContext the context associated with the isSuffix operation
      * @return true if the name is a context suffix, false if it is not.
      * @throws NamingException if there are any problems
      */
-    boolean isSuffix( LdapDN name ) throws NamingException;
+    boolean isSuffix( ServiceContext suffixContext ) throws NamingException;
 
 
     /**

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/PartitionNexusProxy.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/PartitionNexusProxy.java?view=diff&rev=526182&r1=526181&r2=526182
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/PartitionNexusProxy.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/PartitionNexusProxy.java Fri Apr  6 07:39:32 2007
@@ -543,21 +543,21 @@
     }
 
 
-    public boolean isSuffix( LdapDN name ) throws NamingException
+    public boolean isSuffix( ServiceContext suffixContext ) throws NamingException
     {
-        return isSuffix( name, null );
+        return isSuffix( suffixContext, null );
     }
 
 
-    public boolean isSuffix( LdapDN name, Collection bypass ) throws NamingException
+    public boolean isSuffix( ServiceContext suffixContext, Collection bypass ) throws NamingException
     {
         ensureStarted();
         InvocationStack stack = InvocationStack.getInstance();
         stack.push( new Invocation( this, caller, "isSuffix", new Object[]
-            { name }, bypass ) );
+            { suffixContext }, bypass ) );
         try
         {
-            return this.configuration.getInterceptorChain().isSuffix( name );
+            return this.configuration.getInterceptorChain().isSuffix( suffixContext );
         }
         finally
         {

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/BTreePartition.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/BTreePartition.java?view=diff&rev=526182&r1=526181&r2=526182
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/BTreePartition.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/BTreePartition.java Fri Apr  6 07:39:32 2007
@@ -36,6 +36,7 @@
 import org.apache.directory.server.core.enumeration.SearchResultEnumeration;
 import org.apache.directory.server.core.interceptor.context.LookupServiceContext;
 import org.apache.directory.server.core.interceptor.context.ServiceContext;
+import org.apache.directory.server.core.interceptor.context.SuffixServiceContext;
 import org.apache.directory.server.core.partition.Partition;
 import org.apache.directory.server.core.partition.Oid;
 import org.apache.directory.server.core.partition.impl.btree.gui.PartitionViewer;
@@ -486,9 +487,9 @@
     public abstract boolean isInitialized();
 
 
-    public boolean isSuffix( LdapDN dn ) throws NamingException
+    public boolean isSuffix( ServiceContext suffixContext ) throws NamingException
     {
-        return getSuffix().equals( dn );
+        return getSuffix().equals( ((SuffixServiceContext)suffixContext).getSuffixDn() );
     }
 
 

Modified: directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/interceptor/InterceptorChainTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/interceptor/InterceptorChainTest.java?view=diff&rev=526182&r1=526181&r2=526182
==============================================================================
--- directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/interceptor/InterceptorChainTest.java (original)
+++ directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/interceptor/InterceptorChainTest.java Fri Apr  6 07:39:32 2007
@@ -397,10 +397,10 @@
         }
 
 
-        public boolean isSuffix( NextInterceptor next, LdapDN name ) throws NamingException
+        public boolean isSuffix( NextInterceptor next, ServiceContext suffixContext ) throws NamingException
         {
             interceptors.add( this );
-            return next.isSuffix( name );
+            return next.isSuffix( suffixContext );
         }