directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r326075 - in /directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server: authz/ collective/ enumeration/ jndi/ operational/ schema/ subtree/
Date Tue, 18 Oct 2005 10:14:07 GMT
Author: akarasulu
Date: Tue Oct 18 03:13:54 2005
New Revision: 326075

URL: http://svn.apache.org/viewcvs?rev=326075&view=rev
Log:
changes ...


 o now passing the Invocation object to the filter instead of the JNDI 
   ServerContext so that we do not need to expose access to the Nexus 
   proxy from the JNDI context
 o ServerContext now does not expose the proxy any longer


Modified:
    directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/authz/AuthorizationService.java
    directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/authz/OldAuthorizationService.java
    directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/collective/CollectiveAttributeService.java
    directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/enumeration/SearchResultFilter.java
    directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/enumeration/SearchResultFilteringEnumeration.java
    directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/ServerContext.java
    directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/operational/OperationalAttributeService.java
    directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/schema/SchemaService.java
    directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/subtree/SubentryService.java

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/authz/AuthorizationService.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/authz/AuthorizationService.java?rev=326075&r1=326074&r2=326075&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/authz/AuthorizationService.java
(original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/authz/AuthorizationService.java
Tue Oct 18 03:13:54 2005
@@ -49,7 +49,6 @@
 import javax.naming.Name;
 import javax.naming.NamingException;
 import javax.naming.NamingEnumeration;
-import javax.naming.ldap.LdapContext;
 import javax.naming.directory.*;
 import java.util.*;
 import java.text.ParseException;
@@ -756,7 +755,8 @@
 
     public NamingEnumeration list( NextInterceptor next, Name base ) throws NamingException
     {
-        ServerLdapContext ctx = ( ServerLdapContext ) InvocationStack.getInstance().peek().getCaller();
+        Invocation invocation = InvocationStack.getInstance().peek();
+        ServerLdapContext ctx = ( ServerLdapContext ) invocation.getCaller();
         LdapPrincipal user = ctx.getPrincipal();
         NamingEnumeration e = next.list( base );
         if ( user.getName().equalsIgnoreCase( DirectoryPartitionNexus.ADMIN_PRINCIPAL ) ||
! enabled )
@@ -764,14 +764,15 @@
             return e;
         }
         AuthorizationFilter authzFilter = new AuthorizationFilter();
-        return new SearchResultFilteringEnumeration( e, DEFUALT_SEARCH_CONTROLS, ctx, authzFilter
);
+        return new SearchResultFilteringEnumeration( e, DEFUALT_SEARCH_CONTROLS, invocation,
authzFilter );
     }
 
 
     public NamingEnumeration search( NextInterceptor next, Name base, Map env, ExprNode filter,
                                      SearchControls searchCtls ) throws NamingException
     {
-        ServerLdapContext ctx = ( ServerLdapContext ) InvocationStack.getInstance().peek().getCaller();
+        Invocation invocation = InvocationStack.getInstance().peek();
+        ServerLdapContext ctx = ( ServerLdapContext ) invocation.getCaller();
         LdapPrincipal user = ctx.getPrincipal();
         NamingEnumeration e = next.search( base, env, filter, searchCtls );
         if ( user.getName().equalsIgnoreCase( DirectoryPartitionNexus.ADMIN_PRINCIPAL ) ||
! enabled )
@@ -779,7 +780,7 @@
             return e;
         }
         AuthorizationFilter authzFilter = new AuthorizationFilter();
-        return new SearchResultFilteringEnumeration( e, searchCtls, ctx, authzFilter );
+        return new SearchResultFilteringEnumeration( e, searchCtls, invocation, authzFilter
);
     }
 
 
@@ -829,7 +830,7 @@
         SEARCH_ATTRVAL_PERMS = Collections.singleton( MicroOperation.READ );
     }
 
-    private boolean filter( ServerLdapContext ctx, Name normName, SearchResult result ) throws
NamingException
+    private boolean filter( Invocation invocation, Name normName, SearchResult result ) throws
NamingException
     {
        /*
         * First call hasPermission() for entry level "Browse" and "ReturnDN" perm
@@ -837,6 +838,7 @@
         * process and return false.
         */
         Attributes entry = nexus.lookup( normName );
+        ServerLdapContext ctx = ( ServerLdapContext ) invocation.getCaller();
         Name userDn = ctx.getPrincipal().getJndiName();
         Set userGroups = groupCache.getGroups( userDn.toString() );
         Collection tuples = new HashSet();
@@ -844,7 +846,7 @@
         addEntryAciTuples( tuples, entry );
         addSubentryAciTuples( tuples, normName, entry );
 
-        if ( ! engine.hasPermission( ctx.getNexusProxy(), userGroups, userDn,
+        if ( ! engine.hasPermission( invocation.getProxy(), userGroups, userDn,
                 ctx.getPrincipal().getAuthenticationLevel(),
                 normName, null, null, SEARCH_ENTRY_PERMS, tuples, entry ) )
         {
@@ -863,7 +865,7 @@
         {
             // if attribute type scope access is not allowed then remove the attribute and
continue
             Attribute attr = ( Attribute ) attributeList.next();
-            if ( ! engine.hasPermission( ctx.getNexusProxy(), userGroups, userDn,
+            if ( ! engine.hasPermission( invocation.getProxy(), userGroups, userDn,
                     ctx.getPrincipal().getAuthenticationLevel(),
                     normName, attr.getID(), null, SEARCH_ATTRVAL_PERMS, tuples, entry ) )
             {
@@ -879,7 +881,7 @@
             // attribute type scope is ok now let's determine value level scope
             for ( int ii = 0; ii < attr.size(); ii++ )
             {
-                if ( ! engine.hasPermission( ctx.getNexusProxy(), userGroups, userDn,
+                if ( ! engine.hasPermission( invocation.getProxy(), userGroups, userDn,
                         ctx.getPrincipal().getAuthenticationLevel(), normName,
                         attr.getID(), attr.get( ii ), SEARCH_ATTRVAL_PERMS, tuples, entry
) )
                 {
@@ -911,10 +913,9 @@
         }
 
 
-        public boolean accept( LdapContext ctx, SearchResult result, SearchControls controls
) throws NamingException
+        public boolean accept( Invocation invocation, SearchResult result, SearchControls
controls ) throws NamingException
         {
             Name normName = parser.parse( result.getName() );
-            ServerLdapContext srvCtx = ( ServerLdapContext ) ctx;
 
 // looks like isRelative returns true even when the names for results are absolute!!!!
 // @todo this is a big bug in JNDI provider
@@ -925,7 +926,7 @@
 //                normName = base.addAll( normName );
 //            }
 
-            return filter( srvCtx, normName, result );
+            return filter( invocation, normName, result );
         }
     }
 }

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/authz/OldAuthorizationService.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/authz/OldAuthorizationService.java?rev=326075&r1=326074&r2=326075&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/authz/OldAuthorizationService.java
(original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/authz/OldAuthorizationService.java
Tue Oct 18 03:13:54 2005
@@ -40,6 +40,7 @@
 import org.apache.ldap.server.interceptor.Interceptor;
 import org.apache.ldap.server.interceptor.NextInterceptor;
 import org.apache.ldap.server.invocation.InvocationStack;
+import org.apache.ldap.server.invocation.Invocation;
 import org.apache.ldap.server.jndi.ServerContext;
 import org.apache.ldap.server.partition.DirectoryPartitionNexus;
 import org.apache.ldap.server.schema.AttributeTypeRegistry;
@@ -412,14 +413,14 @@
         //    return null;
         //}
         
-        LdapContext ctx = ( LdapContext ) InvocationStack.getInstance().peek().getCaller();
-        return new SearchResultFilteringEnumeration( e, searchCtls, ctx,
+        Invocation invocation = InvocationStack.getInstance().peek();
+        return new SearchResultFilteringEnumeration( e, searchCtls, invocation,
             new SearchResultFilter()
             {
-                public boolean accept( LdapContext ctx, SearchResult result, SearchControls
controls )
+                public boolean accept( Invocation invocation, SearchResult result, SearchControls
controls )
                         throws NamingException
                 {
-                    return OldAuthorizationService.this.isSearchable( ctx, result );
+                    return OldAuthorizationService.this.isSearchable( invocation, result
);
                 }
             });
     }
@@ -432,22 +433,21 @@
         {
             return e;
         }
-        LdapContext ctx = ( LdapContext ) InvocationStack.getInstance().peek().getCaller();
-        
-        return new SearchResultFilteringEnumeration( e, null, ctx,
+
+        Invocation invocation = InvocationStack.getInstance().peek();
+        return new SearchResultFilteringEnumeration( e, null, invocation,
             new SearchResultFilter()
             {
-                public boolean accept( LdapContext ctx, SearchResult result,
-                                       SearchControls controls )
+                public boolean accept( Invocation invocation, SearchResult result, SearchControls
controls )
                         throws NamingException
                 {
-                    return OldAuthorizationService.this.isSearchable( ctx, result );
+                    return OldAuthorizationService.this.isSearchable( invocation, result
);
                 }
             } );
     }
 
 
-    private boolean isSearchable( LdapContext ctx, SearchResult result )
+    private boolean isSearchable( Invocation invocataion, SearchResult result )
             throws NamingException
     {
         Name dn;
@@ -457,7 +457,7 @@
             dn = dnParser.parse( result.getName() );
         }
 
-        Name principalDn = ( ( ServerContext ) ctx ).getPrincipal().getJndiName();
+        Name principalDn = ( ( ServerContext ) invocataion.getCaller() ).getPrincipal().getJndiName();
         if ( !principalDn.equals( ADMIN_DN ) )
         {
             if ( dn.size() > 2 )

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/collective/CollectiveAttributeService.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/collective/CollectiveAttributeService.java?rev=326075&r1=326074&r2=326075&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/collective/CollectiveAttributeService.java
(original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/collective/CollectiveAttributeService.java
Tue Oct 18 03:13:54 2005
@@ -25,6 +25,7 @@
 import org.apache.ldap.server.schema.AttributeTypeRegistry;
 import org.apache.ldap.server.subtree.SubentryService;
 import org.apache.ldap.server.invocation.InvocationStack;
+import org.apache.ldap.server.invocation.Invocation;
 import org.apache.ldap.server.enumeration.SearchResultFilteringEnumeration;
 import org.apache.ldap.server.enumeration.SearchResultFilter;
 import org.apache.ldap.common.filter.ExprNode;
@@ -35,7 +36,6 @@
 import javax.naming.NamingException;
 import javax.naming.NamingEnumeration;
 import javax.naming.Name;
-import javax.naming.ldap.LdapContext;
 import javax.naming.directory.Attributes;
 import javax.naming.directory.SearchControls;
 import javax.naming.directory.Attribute;
@@ -63,7 +63,7 @@
      */
     private final SearchResultFilter SEARCH_FILTER = new SearchResultFilter()
     {
-        public boolean accept( LdapContext ctx, SearchResult result, SearchControls controls
)
+        public boolean accept( Invocation invocation, SearchResult result, SearchControls
controls )
                 throws NamingException
         {
                 return filter( result.getAttributes() );
@@ -106,7 +106,7 @@
          * may have case variance.
          */
         Attribute collectiveExclusions = entry.get( "collectiveExclusions" );
-        Set exclusions = null;
+        Set exclusions;
         if ( collectiveExclusions != null )
         {
             if ( collectiveExclusions.contains( "2.5.18.0" ) ||
@@ -265,9 +265,8 @@
     public NamingEnumeration list( NextInterceptor nextInterceptor, Name base ) throws NamingException
     {
         NamingEnumeration e = nextInterceptor.list( base );
-        LdapContext ctx =
-            ( LdapContext ) InvocationStack.getInstance().peek().getCaller();
-        return new SearchResultFilteringEnumeration( e, new SearchControls(), ctx, SEARCH_FILTER
);
+        Invocation invocation = InvocationStack.getInstance().peek();
+        return new SearchResultFilteringEnumeration( e, new SearchControls(), invocation,
SEARCH_FILTER );
     }
 
 
@@ -276,8 +275,7 @@
             SearchControls searchCtls ) throws NamingException
     {
         NamingEnumeration e = nextInterceptor.search( base, env, filter, searchCtls );
-        LdapContext ctx =
-            ( LdapContext ) InvocationStack.getInstance().peek().getCaller();
-        return new SearchResultFilteringEnumeration( e, searchCtls, ctx, SEARCH_FILTER );
+        Invocation invocation = InvocationStack.getInstance().peek();
+        return new SearchResultFilteringEnumeration( e, searchCtls, invocation, SEARCH_FILTER
);
     }
 }

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/enumeration/SearchResultFilter.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/enumeration/SearchResultFilter.java?rev=326075&r1=326074&r2=326075&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/enumeration/SearchResultFilter.java
(original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/enumeration/SearchResultFilter.java
Tue Oct 18 03:13:54 2005
@@ -17,6 +17,8 @@
 package org.apache.ldap.server.enumeration;
 
 
+import org.apache.ldap.server.invocation.Invocation;
+
 import javax.naming.NamingException;
 import javax.naming.directory.SearchControls;
 import javax.naming.directory.SearchResult;
@@ -44,6 +46,6 @@
      * @return true if the result is to be returned, false if it is to be
      * discarded from the result set
      */
-    boolean accept( LdapContext ctx, SearchResult result, SearchControls controls )
+    boolean accept( Invocation invocation, SearchResult result, SearchControls controls )
         throws NamingException;
 }

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/enumeration/SearchResultFilteringEnumeration.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/enumeration/SearchResultFilteringEnumeration.java?rev=326075&r1=326074&r2=326075&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/enumeration/SearchResultFilteringEnumeration.java
(original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/enumeration/SearchResultFilteringEnumeration.java
Tue Oct 18 03:13:54 2005
@@ -25,10 +25,10 @@
 import javax.naming.NamingException;
 import javax.naming.directory.SearchControls;
 import javax.naming.directory.SearchResult;
-import javax.naming.ldap.LdapContext;
 
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+//import org.slf4j.Logger;
+//import org.slf4j.LoggerFactory;
+import org.apache.ldap.server.invocation.Invocation;
 
 
 /**
@@ -41,8 +41,8 @@
  */
 public class SearchResultFilteringEnumeration implements NamingEnumeration
 {
-    private static final Logger log = LoggerFactory.getLogger( SearchResultFilteringEnumeration.class
);
-
+//    private static final Logger log = LoggerFactory.getLogger( SearchResultFilteringEnumeration.class
);
+//
     /** the list of filters to be applied */
     private final List filters;
     /** the underlying decorated enumeration */
@@ -54,8 +54,8 @@
     private boolean isClosed = false;
     /** the controls associated with the search operation */
     private final SearchControls searchControls;
-    /** the LDAP context that made the search creating this enumeration */
-    private final LdapContext ctx;
+    /** the Invocation that representing the search creating this enumeration */
+    private final Invocation invocation;
 
 
     // ------------------------------------------------------------------------
@@ -70,17 +70,16 @@
      * @param decorated the underlying decorated enumeration
      * @param searchControls the search controls associated with the search
      * creating this enumeration
-     * @param ctx the LDAP context that made the search creating this
-     * enumeration
+     * @param invocation the invocation representing the seach that created this enumeration
      */
     public SearchResultFilteringEnumeration( NamingEnumeration decorated,
-                                       SearchControls searchControls,
-                                       LdapContext ctx,
-                                       SearchResultFilter filter )
+                                             SearchControls searchControls,
+                                             Invocation invocation,
+                                             SearchResultFilter filter )
             throws NamingException
     {
         this.searchControls = searchControls;
-        this.ctx = ctx;
+        this.invocation = invocation;
         this.filters = new ArrayList();
         this.filters.add( filter );
         this.decorated = decorated;
@@ -102,17 +101,16 @@
      * @param decorated the underlying decorated enumeration
      * @param searchControls the search controls associated with the search
      * creating this enumeration
-     * @param ctx the LDAP context that made the search creating this
-     * enumeration
+     * @param invocation the invocation representing the seach that created this enumeration
      */
     public SearchResultFilteringEnumeration( NamingEnumeration decorated,
-                                       SearchControls searchControls,
-                                       LdapContext ctx,
-                                       List filters )
+                                             SearchControls searchControls,
+                                             Invocation invocation,
+                                             List filters )
             throws NamingException
     {
         this.searchControls = searchControls;
-        this.ctx = ctx;
+        this.invocation = invocation;
         this.filters = new ArrayList();
         this.filters.addAll( filters );
         this.decorated = decorated;
@@ -241,8 +239,9 @@
      */
     private void prefetch() throws NamingException
     {
-        SearchResult tmp = null;
+        SearchResult tmp;
 
+        outer:
         while( decorated.hasMore() )
         {
             boolean accepted = true;
@@ -257,7 +256,7 @@
             else if ( filters.size() == 1 )
             {
                 accepted = ( ( SearchResultFilter ) filters.get( 0 ) )
-                        .accept( ctx, tmp, searchControls );
+                        .accept( invocation, tmp, searchControls );
                 if ( accepted )
                 {
                     this.prefetched = tmp;
@@ -271,11 +270,11 @@
             for ( int ii = 0; ii < filters.size(); ii ++ )
             {
                 SearchResultFilter filter = ( SearchResultFilter ) filters.get( ii );
-                accepted &= filter.accept( ctx, tmp, searchControls );
+                accepted &= filter.accept( invocation, tmp, searchControls );
 
                 if ( ! accepted )
                 {
-                    continue;
+                    continue outer;
                 }
             }
 

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/ServerContext.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/ServerContext.java?rev=326075&r1=326074&r2=326075&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/ServerContext.java
(original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/ServerContext.java
Tue Oct 18 03:13:54 2005
@@ -194,20 +194,20 @@
     }
 
 
+    // ------------------------------------------------------------------------
+    // Protected Accessor Methods
+    // ------------------------------------------------------------------------
+
+
     /**
      * Gets the RootNexus proxy.
      *
      * @return the proxy to the backend nexus.
      */
-    public DirectoryPartitionNexusProxy getNexusProxy()
+    protected DirectoryPartitionNexus getNexusProxy()
     {
-       return ( DirectoryPartitionNexusProxy ) nexusProxy ;
+       return nexusProxy ;
     }
-
-
-    // ------------------------------------------------------------------------
-    // Protected Accessor Methods
-    // ------------------------------------------------------------------------
 
 
     /**

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/operational/OperationalAttributeService.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/operational/OperationalAttributeService.java?rev=326075&r1=326074&r2=326075&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/operational/OperationalAttributeService.java
(original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/operational/OperationalAttributeService.java
Tue Oct 18 03:13:54 2005
@@ -30,7 +30,6 @@
 import javax.naming.directory.ModificationItem;
 import javax.naming.directory.SearchControls;
 import javax.naming.directory.SearchResult;
-import javax.naming.ldap.LdapContext;
 
 import org.apache.ldap.common.filter.ExprNode;
 import org.apache.ldap.common.schema.AttributeType;
@@ -44,6 +43,7 @@
 import org.apache.ldap.server.interceptor.Interceptor;
 import org.apache.ldap.server.interceptor.NextInterceptor;
 import org.apache.ldap.server.invocation.InvocationStack;
+import org.apache.ldap.server.invocation.Invocation;
 import org.apache.ldap.server.partition.DirectoryPartitionNexus;
 import org.apache.ldap.server.schema.AttributeTypeRegistry;
 
@@ -64,7 +64,7 @@
      */
     private final SearchResultFilter SEARCH_FILTER = new SearchResultFilter()
     {
-        public boolean accept( LdapContext ctx, SearchResult result, SearchControls controls
)
+        public boolean accept( Invocation invocation, SearchResult result, SearchControls
controls )
                 throws NamingException
         {
             if ( controls.getReturningAttributes() == null )
@@ -242,9 +242,8 @@
     public NamingEnumeration list( NextInterceptor nextInterceptor, Name base ) throws NamingException
     {
         NamingEnumeration e = nextInterceptor.list( base );
-        LdapContext ctx =
-            ( LdapContext ) InvocationStack.getInstance().peek().getCaller();
-        return new SearchResultFilteringEnumeration( e, new SearchControls(), ctx, SEARCH_FILTER
);
+        Invocation invocation = InvocationStack.getInstance().peek();
+        return new SearchResultFilteringEnumeration( e, new SearchControls(), invocation,
SEARCH_FILTER );
     }
 
 
@@ -252,15 +251,14 @@
             Name base, Map env, ExprNode filter,
             SearchControls searchCtls ) throws NamingException
     {
+        Invocation invocation = InvocationStack.getInstance().peek();
         NamingEnumeration e = nextInterceptor.search( base, env, filter, searchCtls );
         if ( searchCtls.getReturningAttributes() != null )
         {
             return e;
         }
 
-        LdapContext ctx =
-            ( LdapContext ) InvocationStack.getInstance().peek().getCaller();
-        return new SearchResultFilteringEnumeration( e, searchCtls, ctx, SEARCH_FILTER );
+        return new SearchResultFilteringEnumeration( e, searchCtls, invocation, SEARCH_FILTER
);
     }
 
 

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/schema/SchemaService.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/schema/SchemaService.java?rev=326075&r1=326074&r2=326075&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/schema/SchemaService.java
(original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/schema/SchemaService.java
Tue Oct 18 03:13:54 2005
@@ -27,7 +27,6 @@
 import javax.naming.NamingEnumeration;
 import javax.naming.NamingException;
 import javax.naming.directory.*;
-import javax.naming.ldap.LdapContext;
 
 import org.apache.ldap.common.filter.ExprNode;
 import org.apache.ldap.common.filter.PresenceNode;
@@ -52,12 +51,13 @@
 import org.apache.ldap.common.exception.LdapInvalidAttributeIdentifierException;
 import org.apache.ldap.common.exception.LdapNoSuchAttributeException;
 import org.apache.ldap.server.DirectoryServiceConfiguration;
+import org.apache.ldap.server.invocation.Invocation;
+import org.apache.ldap.server.invocation.InvocationStack;
 import org.apache.ldap.server.configuration.InterceptorConfiguration;
 import org.apache.ldap.server.enumeration.SearchResultFilteringEnumeration;
 import org.apache.ldap.server.enumeration.SearchResultFilter;
 import org.apache.ldap.server.interceptor.BaseInterceptor;
 import org.apache.ldap.server.interceptor.NextInterceptor;
-import org.apache.ldap.server.jndi.ServerLdapContext;
 import org.apache.ldap.server.partition.DirectoryPartitionNexus;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -132,8 +132,8 @@
     public NamingEnumeration list( NextInterceptor nextInterceptor, Name base ) throws NamingException
     {
         NamingEnumeration e = nextInterceptor.list( base );
-        LdapContext ctx = getContext();
-        return new SearchResultFilteringEnumeration( e, new SearchControls(), ctx, binaryAttributeFilter
);
+        Invocation invocation = InvocationStack.getInstance().peek();
+        return new SearchResultFilteringEnumeration( e, new SearchControls(), invocation,
binaryAttributeFilter );
     }
 
 
@@ -184,8 +184,8 @@
             return e;
         }
 
-        LdapContext ctx = getContext();
-        return new SearchResultFilteringEnumeration( e, searchCtls, ctx, binaryAttributeFilter
);
+        Invocation invocation = InvocationStack.getInstance().peek();
+        return new SearchResultFilteringEnumeration( e, searchCtls, invocation, binaryAttributeFilter
);
     }
 
 
@@ -198,7 +198,7 @@
 
         Set set = new HashSet();
         LockableAttributesImpl attrs = new LockableAttributesImpl();
-        LockableAttributeImpl attr = null;
+        LockableAttributeImpl attr;
 
         for ( int ii = 0; ii < ids.length; ii++ )
         {
@@ -373,9 +373,8 @@
     public Attributes lookup( NextInterceptor nextInterceptor, Name name ) throws NamingException
     {
         Attributes result = nextInterceptor.lookup( name );
-
-        ServerLdapContext ctx = ( ServerLdapContext ) getContext();
-        doFilter( ctx, result );
+        Invocation invocation = InvocationStack.getInstance().peek();
+        doFilter( invocation, result );
         return result;
     }
 
@@ -388,8 +387,8 @@
             return null;
         }
 
-        ServerLdapContext ctx = ( ServerLdapContext ) getContext();
-        doFilter( ctx, result );
+        Invocation invocation = InvocationStack.getInstance().peek();
+        doFilter( invocation, result );
         return result;
     }
 
@@ -458,12 +457,8 @@
         {
             changedEntryAttr.remove( change.get( jj ) );
         }
-        if ( changedEntryAttr.size() == 0 )
-        {
-            return true;
-        }
 
-        return false;
+        return changedEntryAttr.size() == 0;
     }
 
 
@@ -558,12 +553,12 @@
         ModificationItem objectClassMod = null;
         for ( int ii = 0; ii < mods.length; ii++ )
         {
-            if ( ( ( String ) mods[ii].getAttribute().getID() ).equalsIgnoreCase( "objectclass"
) )
+            if ( mods[ii].getAttribute().getID().equalsIgnoreCase( "objectclass" ) )
             {
                 objectClassMod = mods[ii];
             }
         }
-        Attribute objectClass = null;
+        Attribute objectClass;
 
         if ( objectClassMod == null )
         {
@@ -616,14 +611,14 @@
     }
 
 
-    private void doFilter( LdapContext ctx, Attributes entry )
+    private void doFilter( Invocation invocation, Attributes entry )
             throws NamingException
     {
         // set of AttributeType objects that are to behave as binaries
         Set binaries;
 
         // construct the set for fast lookups while filtering
-        String binaryIds = ( String ) ctx.getEnvironment().get( BINARY_KEY );
+        String binaryIds = ( String ) invocation.getCaller().getEnvironment().get( BINARY_KEY
);
 
         if ( binaryIds == null )
         {
@@ -712,9 +707,9 @@
         }
 
 
-        public boolean accept( LdapContext ctx, SearchResult result, SearchControls controls
) throws NamingException
+        public boolean accept( Invocation invocation, SearchResult result, SearchControls
controls ) throws NamingException
         {
-            doFilter( ctx, result.getAttributes() );
+            doFilter( invocation, result.getAttributes() );
             return true;
         }
     }

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/subtree/SubentryService.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/subtree/SubentryService.java?rev=326075&r1=326074&r2=326075&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/subtree/SubentryService.java
(original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/subtree/SubentryService.java
Tue Oct 18 03:13:54 2005
@@ -23,6 +23,7 @@
 import org.apache.ldap.server.enumeration.SearchResultFilter;
 import org.apache.ldap.server.enumeration.SearchResultFilteringEnumeration;
 import org.apache.ldap.server.invocation.InvocationStack;
+import org.apache.ldap.server.invocation.Invocation;
 import org.apache.ldap.server.configuration.InterceptorConfiguration;
 import org.apache.ldap.server.partition.DirectoryPartitionNexus;
 import org.apache.ldap.server.schema.ConcreteNameComponentNormalizer;
@@ -41,8 +42,8 @@
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import javax.naming.ldap.LdapContext;
 import javax.naming.ldap.Control;
+import javax.naming.ldap.LdapContext;
 import javax.naming.directory.*;
 import javax.naming.NamingException;
 import javax.naming.NamingEnumeration;
@@ -93,7 +94,7 @@
      */
     private static final SearchResultFilter SUBENTRY_FILTER = new SearchResultFilter()
     {
-        public boolean accept( LdapContext ctx, SearchResult result, SearchControls controls
)
+        public boolean accept( Invocation invocation, SearchResult result, SearchControls
controls )
         {
             Attribute objectClasses = result.getAttributes().get( "objectClass" );
 
@@ -172,11 +173,11 @@
     public NamingEnumeration list( NextInterceptor nextInterceptor, Name base ) throws NamingException
     {
         NamingEnumeration e = nextInterceptor.list( base );
-        LdapContext ctx = ( LdapContext ) InvocationStack.getInstance().peek().getCaller();
+        Invocation invocation = InvocationStack.getInstance().peek();
 
-        if ( ! isSubentryVisible( ctx ) )
+        if ( ! isSubentryVisible( invocation ) )
         {
-            return new SearchResultFilteringEnumeration( e, new SearchControls(), ctx, SUBENTRY_FILTER
);
+            return new SearchResultFilteringEnumeration( e, new SearchControls(), invocation,
SUBENTRY_FILTER );
         }
 
         return e;
@@ -187,7 +188,7 @@
             SearchControls searchCtls ) throws NamingException
     {
         NamingEnumeration e = nextInterceptor.search( base, env, filter, searchCtls );
-        LdapContext ctx = ( LdapContext ) InvocationStack.getInstance().peek().getCaller();
+        Invocation invocation = InvocationStack.getInstance().peek();
 
         // object scope searches by default return subentries
         if ( searchCtls.getSearchScope() == SearchControls.OBJECT_SCOPE )
@@ -196,9 +197,9 @@
         }
 
         // for subtree and one level scope we filter
-        if ( ! isSubentryVisible( ctx ) )
+        if ( ! isSubentryVisible( invocation ) )
         {
-            return new SearchResultFilteringEnumeration( e, searchCtls, ctx, SUBENTRY_FILTER
);
+            return new SearchResultFilteringEnumeration( e, searchCtls, invocation, SUBENTRY_FILTER
);
         }
 
         return e;
@@ -209,13 +210,13 @@
      * Checks to see if subentries for the search and list operations should be
      * made visible based on the availability of the search request control
      *
-     * @param ctx the ldap context the search operation was invoked on
+     * @param invocation
      * @return true if subentries should be visible, false otherwise
      * @throws NamingException if there are problems accessing request controls
      */
-    private boolean isSubentryVisible( LdapContext ctx ) throws NamingException
+    private boolean isSubentryVisible( Invocation invocation ) throws NamingException
     {
-        Control[] reqControls = ctx.getRequestControls();
+        Control[] reqControls = ( ( LdapContext ) invocation.getCaller() ).getRequestControls();
 
         if ( reqControls == null || reqControls.length <= 0 )
         {



Mime
View raw message