You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by tr...@apache.org on 2005/03/20 05:50:24 UTC

svn commit: r158301 - in directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server/jndi: call/ call/interceptor/ ibs/

Author: trustin
Date: Sat Mar 19 20:50:21 2005
New Revision: 158301

URL: http://svn.apache.org/viewcvs?view=rev&rev=158301
Log:
Converted SchemaService into SchemaManager

Added:
    directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server/jndi/call/interceptor/SchemaManager.java   (with props)
Removed:
    directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server/jndi/ibs/SchemaService.java
Modified:
    directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server/jndi/call/Call.java
    directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server/jndi/call/interceptor/Authenticatior.java
    directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server/jndi/call/interceptor/Authorizer.java
    directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server/jndi/call/interceptor/BaseInterceptor.java
    directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server/jndi/call/interceptor/DefaultAttributeTagger.java
    directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server/jndi/call/interceptor/Interceptor.java
    directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server/jndi/call/interceptor/InterceptorChain.java
    directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server/jndi/call/interceptor/InterceptorException.java
    directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server/jndi/call/interceptor/NextInterceptor.java

Modified: directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server/jndi/call/Call.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server/jndi/call/Call.java?view=diff&r1=158300&r2=158301
==============================================================================
--- directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server/jndi/call/Call.java (original)
+++ directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server/jndi/call/Call.java Sat Mar 19 20:50:21 2005
@@ -2,13 +2,24 @@
 
 import java.util.Stack;
 
+import javax.naming.NamingException;
+
+import org.apache.ldap.server.BackingStore;
+
 public abstract class Call {
 
-    private Object response;
-    private Stack contextStack;
+    protected final BackingStore store;
+    protected Object response;
+    protected Stack contextStack;
 
-    protected Call()
+    protected Call( BackingStore store )
     {
+        if( store == null )
+        {
+            throw new NullPointerException( "store" );
+        }
+
+        this.store = store;
     }
     
     /**
@@ -49,4 +60,11 @@
     {
         this.contextStack = contextStack;
     }
+    
+    public void execute() throws NamingException
+    {
+        setResponse( doExecute() );
+    }
+    
+    protected abstract Object doExecute() throws NamingException;
 }

Modified: directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server/jndi/call/interceptor/Authenticatior.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server/jndi/call/interceptor/Authenticatior.java?view=diff&r1=158300&r2=158301
==============================================================================
--- directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server/jndi/call/interceptor/Authenticatior.java (original)
+++ directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server/jndi/call/interceptor/Authenticatior.java Sat Mar 19 20:50:21 2005
@@ -85,7 +85,7 @@
     /**
      * Unregisters an Authenticator with this AuthenticatorService.  Called for each
      * registered Authenticator right before it is to be stopped.  This prevents
-     * protocol server requests from reaching the Backend and effectively puts
+     * protocol server calls from reaching the Backend and effectively puts
      * the ContextPartition's naming context offline.
      *
      * @param authenticator Authenticator component to unregister with this
@@ -120,11 +120,11 @@
     {
     }
 
-    public void process( NextInterceptor nextProcessor, Call request ) throws NamingException
+    public void process( NextInterceptor nextProcessor, Call call ) throws NamingException
     {
         // check if we are already authenticated and if so we return making
         // sure first that the credentials are not exposed within context
-        ServerContext ctx = ( ServerLdapContext ) request.getContextStack().peek();
+        ServerContext ctx = ( ServerLdapContext ) call.getContextStack().peek();
         if ( ctx.getPrincipal() != null )
         {
             if ( ctx.getEnvironment().containsKey( CREDS ) )
@@ -132,7 +132,7 @@
                 ctx.removeFromEnvironment( CREDS );
             }
 
-            nextProcessor.process(request);
+            nextProcessor.process(call);
         }
 
         String authList = ( String ) ctx.getEnvironment().get( AUTH_TYPE );
@@ -186,7 +186,7 @@
 
                 // remove creds so there is no security risk
                 ctx.removeFromEnvironment( CREDS );
-                nextProcessor.process(request);
+                nextProcessor.process(call);
                 return;
             }
             catch ( LdapAuthenticationException e )

Modified: directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server/jndi/call/interceptor/Authorizer.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server/jndi/call/interceptor/Authorizer.java?view=diff&r1=158300&r2=158301
==============================================================================
--- directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server/jndi/call/interceptor/Authorizer.java (original)
+++ directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server/jndi/call/interceptor/Authorizer.java Sat Mar 19 20:50:21 2005
@@ -92,10 +92,10 @@
     //    Lookup, search and list operations need to be handled using a filter
     // and so we need access to the filter service.
 
-    protected void process( NextInterceptor nextProcessor, Delete request ) throws NamingException
+    protected void process( NextInterceptor nextProcessor, Delete call ) throws NamingException
     {
-        Name name = request.getName();
-        Name principalDn = getPrincipal( request ).getDn();
+        Name name = call.getName();
+        Name principalDn = getPrincipal( call ).getDn();
 
         if ( name.toString().equals( "" ) )
         {
@@ -129,7 +129,7 @@
             throw new LdapNoPermissionException( msg );
         }
         
-        nextProcessor.process( request );
+        nextProcessor.process( call );
     }
 
 
@@ -141,9 +141,9 @@
      *
      * @see org.apache.ldap.server.jndi.BaseInterceptor#hasEntry(Name)
      */
-    protected void process( NextInterceptor nextProcessor, HasEntry request ) throws NamingException
+    protected void process( NextInterceptor nextProcessor, HasEntry call ) throws NamingException
     {
-        super.process( nextProcessor, request );
+        super.process( nextProcessor, call );
     }
 
 
@@ -160,10 +160,10 @@
      *
      * @see BaseInterceptor#modify(Name, int, Attributes)
      */
-    protected void process( NextInterceptor nextProcessor, Modify request ) throws NamingException
+    protected void process( NextInterceptor nextProcessor, Modify call ) throws NamingException
     {
-        protectModifyAlterations( request, request.getName() );
-        nextProcessor.process( request );
+        protectModifyAlterations( call, call.getName() );
+        nextProcessor.process( call );
     }
 
 
@@ -175,16 +175,16 @@
      *
      * @see BaseInterceptor#modify(Name, ModificationItem[])
      */
-    protected void process( NextInterceptor nextProcessor, ModifyMany request ) throws NamingException
+    protected void process( NextInterceptor nextProcessor, ModifyMany call ) throws NamingException
     {
-        protectModifyAlterations( request, request.getName() );
-        nextProcessor.process( request );
+        protectModifyAlterations( call, call.getName() );
+        nextProcessor.process( call );
     }
 
 
-    private void protectModifyAlterations( Call request, Name dn ) throws LdapNoPermissionException
+    private void protectModifyAlterations( Call call, Name dn ) throws LdapNoPermissionException
     {
-        Name principalDn = getPrincipal( request ).getDn();
+        Name principalDn = getPrincipal( call ).getDn();
 
         if ( dn.toString().equals( "" ) )
         {
@@ -232,30 +232,30 @@
     // ------------------------------------------------------------------------
 
 
-    protected void process( NextInterceptor nextProcessor, ModifyRN request ) throws NamingException
+    protected void process( NextInterceptor nextProcessor, ModifyRN call ) throws NamingException
     {
-        protectDnAlterations( request, request.getName() );
-        nextProcessor.process( request );
+        protectDnAlterations( call, call.getName() );
+        nextProcessor.process( call );
     }
 
 
-    protected void process( NextInterceptor nextProcessor, Move request ) throws NamingException
+    protected void process( NextInterceptor nextProcessor, Move call ) throws NamingException
     {
-        protectDnAlterations( request, request.getName() );
-        nextProcessor.process( request );
+        protectDnAlterations( call, call.getName() );
+        nextProcessor.process( call );
     }
 
 
-    protected void process( NextInterceptor nextProcessor, MoveAndModifyRN request ) throws NamingException
+    protected void process( NextInterceptor nextProcessor, MoveAndModifyRN call ) throws NamingException
     {
-        protectDnAlterations( request, request.getName() );
-        nextProcessor.process( request );
+        protectDnAlterations( call, call.getName() );
+        nextProcessor.process( call );
     }
 
 
-    private void protectDnAlterations( Call request, Name dn ) throws LdapNoPermissionException
+    private void protectDnAlterations( Call call, Name dn ) throws LdapNoPermissionException
     {
-        Name principalDn = getPrincipal( request ).getDn();
+        Name principalDn = getPrincipal( call ).getDn();
 
         if ( dn.toString().equals( "" ) )
         {
@@ -290,34 +290,34 @@
         }
     }
     
-    protected void process(NextInterceptor nextProcessor, Lookup request) throws NamingException {
-        super.process(nextProcessor, request);
+    protected void process(NextInterceptor nextProcessor, Lookup call) throws NamingException {
+        super.process(nextProcessor, call);
         
-        Attributes attributes = ( Attributes ) request.getResponse();
+        Attributes attributes = ( Attributes ) call.getResponse();
         if( attributes == null )
         {
             return;
         }
 
         Attributes retval = ( Attributes ) attributes.clone();
-        LdapContext ctx = ( LdapContext ) request.getContextStack().peek();
-        protectLookUp( ctx, request.getName() );
-        request.setResponse( retval );
+        LdapContext ctx = ( LdapContext ) call.getContextStack().peek();
+        protectLookUp( ctx, call.getName() );
+        call.setResponse( retval );
     }
 
-    protected void process(NextInterceptor nextProcessor, LookupWithAttrIds request) throws NamingException {
-        super.process(nextProcessor, request);
+    protected void process(NextInterceptor nextProcessor, LookupWithAttrIds call) throws NamingException {
+        super.process(nextProcessor, call);
         
-        Attributes attributes = ( Attributes ) request.getResponse();
+        Attributes attributes = ( Attributes ) call.getResponse();
         if( attributes == null )
         {
             return;
         }
 
         Attributes retval = ( Attributes ) attributes.clone();
-        LdapContext ctx = ( LdapContext ) request.getContextStack().peek();
-        protectLookUp( ctx, request.getName() );
-        request.setResponse( retval );
+        LdapContext ctx = ( LdapContext ) call.getContextStack().peek();
+        protectLookUp( ctx, call.getName() );
+        call.setResponse( retval );
     }
     
     private void protectLookUp( LdapContext ctx, Name dn ) throws NamingException
@@ -370,10 +370,10 @@
         }
     }
     
-    protected void process(NextInterceptor nextProcessor, Search request) throws NamingException {
-        super.process(nextProcessor, request);
+    protected void process(NextInterceptor nextProcessor, Search call) throws NamingException {
+        super.process(nextProcessor, call);
         
-        SearchControls searchControls = request.getSearchControls();
+        SearchControls searchControls = call.getSearchControls();
         if ( searchControls.getReturningAttributes() != null )
         {
             return;
@@ -381,8 +381,8 @@
 
         NamingEnumeration e ;
         ResultFilteringEnumeration retval;
-        LdapContext ctx = ( LdapContext ) request.getContextStack().peek();
-        e = ( NamingEnumeration ) request.getResponse();
+        LdapContext ctx = ( LdapContext ) call.getContextStack().peek();
+        e = ( NamingEnumeration ) call.getResponse();
         retval = new ResultFilteringEnumeration( e, searchControls, ctx,
             new SearchResultFilter()
             {
@@ -394,7 +394,7 @@
                 }
             } );
 
-        request.setResponse( retval );
+        call.setResponse( retval );
     }
 
     private boolean isSearchable( LdapContext ctx, SearchResult result )

Modified: directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server/jndi/call/interceptor/BaseInterceptor.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server/jndi/call/interceptor/BaseInterceptor.java?view=diff&r1=158300&r2=158301
==============================================================================
--- directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server/jndi/call/interceptor/BaseInterceptor.java (original)
+++ directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server/jndi/call/interceptor/BaseInterceptor.java Sat Mar 19 20:50:21 2005
@@ -67,13 +67,13 @@
 public abstract class BaseInterceptor implements Interceptor
 {
     /**
-     * Gets the request's current context's Principal.
+     * Gets the call's current context's Principal.
      * 
      * @return the principal making the call
      */
-    public static LdapPrincipal getPrincipal( Call request )
+    public static LdapPrincipal getPrincipal( Call call )
     {
-        ServerContext ctx = ( ServerContext ) request.getContextStack().peek();
+        ServerContext ctx = ( ServerContext ) call.getContextStack().peek();
         return ctx.getPrincipal();
     }
 
@@ -90,76 +90,76 @@
      * analog method that does the work of the Interceptor for that Invocation
      * method.
      */
-    public void process( NextInterceptor nextProcessor, Call request )
+    public void process( NextInterceptor nextInterceptor, Call call )
             throws NamingException
     {
-        if( request instanceof Add )
+        if( call instanceof Add )
         {
-            process( nextProcessor, ( Add ) request );
+            process( nextInterceptor, ( Add ) call );
         }
-        else if( request instanceof Delete )
+        else if( call instanceof Delete )
         {
-            process( nextProcessor, ( Delete ) request );
+            process( nextInterceptor, ( Delete ) call );
         }
-        else if( request instanceof GetMatchedDN )
+        else if( call instanceof GetMatchedDN )
         {
-            process( nextProcessor, ( GetMatchedDN ) request );
+            process( nextInterceptor, ( GetMatchedDN ) call );
         }
-        else if( request instanceof GetSuffix )
+        else if( call instanceof GetSuffix )
         {
-            process( nextProcessor, ( GetSuffix ) request );
+            process( nextInterceptor, ( GetSuffix ) call );
         }
-        else if( request instanceof HasEntry )
+        else if( call instanceof HasEntry )
         {
-            process( nextProcessor, ( HasEntry ) request );
+            process( nextInterceptor, ( HasEntry ) call );
         }
-        else if( request instanceof IsSuffix )
+        else if( call instanceof IsSuffix )
         {
-            process( nextProcessor, ( IsSuffix ) request );
+            process( nextInterceptor, ( IsSuffix ) call );
         }
-        else if( request instanceof List )
+        else if( call instanceof List )
         {
-            process( nextProcessor, ( List ) request );
+            process( nextInterceptor, ( List ) call );
         }
-        else if( request instanceof ListSuffixes )
+        else if( call instanceof ListSuffixes )
         {
-            process( nextProcessor, ( ListSuffixes ) request );
+            process( nextInterceptor, ( ListSuffixes ) call );
         }
-        else if( request instanceof Lookup )
+        else if( call instanceof Lookup )
         {
-            process( nextProcessor, ( Lookup ) request );
+            process( nextInterceptor, ( Lookup ) call );
         }
-        else if( request instanceof LookupWithAttrIds )
+        else if( call instanceof LookupWithAttrIds )
         {
-            process( nextProcessor, ( LookupWithAttrIds ) request );
+            process( nextInterceptor, ( LookupWithAttrIds ) call );
         }
-        else if( request instanceof Modify )
+        else if( call instanceof Modify )
         {
-            process( nextProcessor, ( Modify ) request );
+            process( nextInterceptor, ( Modify ) call );
         }
-        else if( request instanceof ModifyMany )
+        else if( call instanceof ModifyMany )
         {
-            process( nextProcessor, ( ModifyMany ) request );
+            process( nextInterceptor, ( ModifyMany ) call );
         }
-        else if( request instanceof ModifyRN )
+        else if( call instanceof ModifyRN )
         {
-            process( nextProcessor, ( ModifyRN ) request );
+            process( nextInterceptor, ( ModifyRN ) call );
         }
-        else if( request instanceof Move )
+        else if( call instanceof Move )
         {
-            process( nextProcessor, ( Move ) request );
+            process( nextInterceptor, ( Move ) call );
         }
-        else if( request instanceof MoveAndModifyRN )
+        else if( call instanceof MoveAndModifyRN )
         {
-            process( nextProcessor, ( MoveAndModifyRN ) request );
+            process( nextInterceptor, ( MoveAndModifyRN ) call );
         }
-        else if( request instanceof Search )
+        else if( call instanceof Search )
         {
-            process( nextProcessor, ( Search ) request );
+            process( nextInterceptor, ( Search ) call );
         }
         else {
             throw new IllegalArgumentException(
-                    "Unknown request type: " + request.getClass() );
+                    "Unknown call type: " + call.getClass() );
         }
     }
 
@@ -167,99 +167,99 @@
     // Invocation Analogs
     // ------------------------------------------------------------------------
 
-    protected void process( NextInterceptor nextProcessor, Add request )
+    protected void process( NextInterceptor nextInterceptor, Add call )
             throws NamingException
     {
-        nextProcessor.process( request );
+        nextInterceptor.process( call );
     }
 
-    protected void process( NextInterceptor nextProcessor, Delete request ) 
+    protected void process( NextInterceptor nextInterceptor, Delete call ) 
             throws NamingException
     {
-        nextProcessor.process( request );
+        nextInterceptor.process( call );
     }
 
-    protected void process( NextInterceptor nextProcessor, GetMatchedDN request ) 
+    protected void process( NextInterceptor nextInterceptor, GetMatchedDN call ) 
             throws NamingException
     {
-        nextProcessor.process( request );
+        nextInterceptor.process( call );
     }
 
-    protected void process( NextInterceptor nextProcessor, GetSuffix request ) 
+    protected void process( NextInterceptor nextInterceptor, GetSuffix call ) 
             throws NamingException
     {
-        nextProcessor.process( request );
+        nextInterceptor.process( call );
     }
 
-    protected void process( NextInterceptor nextProcessor, HasEntry request ) 
+    protected void process( NextInterceptor nextInterceptor, HasEntry call ) 
             throws NamingException
     {
-        nextProcessor.process( request );
+        nextInterceptor.process( call );
     }
 
-    protected void process( NextInterceptor nextProcessor, IsSuffix request ) 
+    protected void process( NextInterceptor nextInterceptor, IsSuffix call ) 
             throws NamingException
     {
-        nextProcessor.process( request );
+        nextInterceptor.process( call );
     }
 
-    protected void process( NextInterceptor nextProcessor, List request ) 
+    protected void process( NextInterceptor nextInterceptor, List call ) 
             throws NamingException
     {
-        nextProcessor.process( request );
+        nextInterceptor.process( call );
     }
 
-    protected void process( NextInterceptor nextProcessor, ListSuffixes request ) 
+    protected void process( NextInterceptor nextInterceptor, ListSuffixes call ) 
             throws NamingException
     {
-        nextProcessor.process( request );
+        nextInterceptor.process( call );
     }
 
-    protected void process( NextInterceptor nextProcessor, Lookup request ) 
+    protected void process( NextInterceptor nextInterceptor, Lookup call ) 
             throws NamingException
     {
-        nextProcessor.process( request );
+        nextInterceptor.process( call );
     }
 
-    protected void process( NextInterceptor nextProcessor, LookupWithAttrIds request ) 
+    protected void process( NextInterceptor nextInterceptor, LookupWithAttrIds call ) 
             throws NamingException
     {
-        nextProcessor.process( request );
+        nextInterceptor.process( call );
     }
 
-    protected void process( NextInterceptor nextProcessor, Modify request ) 
+    protected void process( NextInterceptor nextInterceptor, Modify call ) 
             throws NamingException
     {
-        nextProcessor.process( request );
+        nextInterceptor.process( call );
     }
 
-    protected void process( NextInterceptor nextProcessor, ModifyMany request ) 
+    protected void process( NextInterceptor nextInterceptor, ModifyMany call ) 
             throws NamingException
     {
-        nextProcessor.process( request );
+        nextInterceptor.process( call );
     }
 
-    protected void process( NextInterceptor nextProcessor, ModifyRN request ) 
+    protected void process( NextInterceptor nextInterceptor, ModifyRN call ) 
             throws NamingException
     {
-        nextProcessor.process( request );
+        nextInterceptor.process( call );
     }
 
-    protected void process( NextInterceptor nextProcessor, Move request ) 
+    protected void process( NextInterceptor nextInterceptor, Move call ) 
             throws NamingException
     {
-        nextProcessor.process( request );
+        nextInterceptor.process( call );
     }
 
-    protected void process( NextInterceptor nextProcessor, MoveAndModifyRN request ) 
+    protected void process( NextInterceptor nextInterceptor, MoveAndModifyRN call ) 
             throws NamingException
     {
-        nextProcessor.process( request );
+        nextInterceptor.process( call );
     }
 
-    protected void process( NextInterceptor nextProcessor, Search request ) 
+    protected void process( NextInterceptor nextInterceptor, Search call ) 
             throws NamingException
     {
-        nextProcessor.process( request );
+        nextInterceptor.process( call );
     }
 }

Modified: directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server/jndi/call/interceptor/DefaultAttributeTagger.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server/jndi/call/interceptor/DefaultAttributeTagger.java?view=diff&r1=158300&r2=158301
==============================================================================
--- directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server/jndi/call/interceptor/DefaultAttributeTagger.java (original)
+++ directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server/jndi/call/interceptor/DefaultAttributeTagger.java Sat Mar 19 20:50:21 2005
@@ -112,10 +112,10 @@
      *
      * @see BaseInterceptor#add(String, Name, Attributes)
      */
-    protected void process( NextInterceptor nextInterceptor, Add request ) throws NamingException
+    protected void process( NextInterceptor nextInterceptor, Add call ) throws NamingException
     {
-        String principal = getPrincipal( request ).getName();
-        Attributes entry = request.getAttributes();
+        String principal = getPrincipal( call ).getName();
+        Attributes entry = call.getAttributes();
 
         BasicAttribute attribute = new BasicAttribute( "creatorsName" );
         attribute.add( principal );
@@ -125,128 +125,128 @@
         attribute.add( DateUtils.getGeneralizedTime() );
         entry.put( attribute );
         
-        nextInterceptor.process( request );
+        nextInterceptor.process( call );
     }
 
 
-    protected void process( NextInterceptor nextInterceptor, Modify request ) throws NamingException
+    protected void process( NextInterceptor nextInterceptor, Modify call ) throws NamingException
     {
-        nextInterceptor.process( request );
+        nextInterceptor.process( call );
         
         // add operational attributes after call in case the operation fails
         Attributes attributes = new BasicAttributes();
         BasicAttribute attribute = new BasicAttribute( "modifiersName" );
-        attribute.add( getPrincipal( request ).getName() );
+        attribute.add( getPrincipal( call ).getName() );
         attributes.put( attribute );
 
         attribute = new BasicAttribute( "modifyTimestamp" );
         attribute.add( DateUtils.getGeneralizedTime() );
         attributes.put( attribute );
 
-        nexus.modify( request.getName(), DirContext.REPLACE_ATTRIBUTE, attributes );
+        nexus.modify( call.getName(), DirContext.REPLACE_ATTRIBUTE, attributes );
     }
 
 
-    protected void process( NextInterceptor nextInterceptor, ModifyMany request ) throws NamingException
+    protected void process( NextInterceptor nextInterceptor, ModifyMany call ) throws NamingException
     {
-        nextInterceptor.process( request );
+        nextInterceptor.process( call );
 
         // add operational attributes after call in case the operation fails
         Attributes attributes = new BasicAttributes();
         BasicAttribute attribute = new BasicAttribute( "modifiersName" );
-        attribute.add( getPrincipal( request ).getName() );
+        attribute.add( getPrincipal( call ).getName() );
         attributes.put( attribute );
 
         attribute = new BasicAttribute( "modifyTimestamp" );
         attribute.add( DateUtils.getGeneralizedTime() );
         attributes.put( attribute );
 
-        nexus.modify( request.getName(), DirContext.REPLACE_ATTRIBUTE, attributes );
+        nexus.modify( call.getName(), DirContext.REPLACE_ATTRIBUTE, attributes );
     }
 
 
-    protected void process( NextInterceptor nextInterceptor, ModifyRN request ) throws NamingException
+    protected void process( NextInterceptor nextInterceptor, ModifyRN call ) throws NamingException
     {
-        nextInterceptor.process( request );
+        nextInterceptor.process( call );
         
         // add operational attributes after call in case the operation fails
         Attributes attributes = new BasicAttributes();
         BasicAttribute attribute = new BasicAttribute( "modifiersName" );
-        attribute.add( getPrincipal( request ).getName() );
+        attribute.add( getPrincipal( call ).getName() );
         attributes.put( attribute );
 
         attribute = new BasicAttribute( "modifyTimestamp" );
         attribute.add( DateUtils.getGeneralizedTime() );
         attributes.put( attribute );
 
-        Name newDn = request.getName().getSuffix( 1 ).add( request.getNewRelativeName() );
+        Name newDn = call.getName().getSuffix( 1 ).add( call.getNewRelativeName() );
         nexus.modify( newDn, DirContext.REPLACE_ATTRIBUTE, attributes );
     }
 
 
-    protected void process( NextInterceptor nextInterceptor, Move request ) throws NamingException
+    protected void process( NextInterceptor nextInterceptor, Move call ) throws NamingException
     {
-        nextInterceptor.process( request );
+        nextInterceptor.process( call );
 
         // add operational attributes after call in case the operation fails
         Attributes attributes = new BasicAttributes();
         BasicAttribute attribute = new BasicAttribute( "modifiersName" );
-        attribute.add( getPrincipal( request ).getName() );
+        attribute.add( getPrincipal( call ).getName() );
         attributes.put( attribute );
 
         attribute = new BasicAttribute( "modifyTimestamp" );
         attribute.add( DateUtils.getGeneralizedTime() );
         attributes.put( attribute );
 
-        nexus.modify( request.getNewParentName(), DirContext.REPLACE_ATTRIBUTE, attributes );
+        nexus.modify( call.getNewParentName(), DirContext.REPLACE_ATTRIBUTE, attributes );
     }
 
 
-    protected void process( NextInterceptor nextInterceptor, MoveAndModifyRN request ) throws NamingException
+    protected void process( NextInterceptor nextInterceptor, MoveAndModifyRN call ) throws NamingException
     {
-        nextInterceptor.process( request );
+        nextInterceptor.process( call );
 
         // add operational attributes after call in case the operation fails
         Attributes attributes = new BasicAttributes();
         BasicAttribute attribute = new BasicAttribute( "modifiersName" );
-        attribute.add( getPrincipal( request ).getName() );
+        attribute.add( getPrincipal( call ).getName() );
         attributes.put( attribute );
 
         attribute = new BasicAttribute( "modifyTimestamp" );
         attribute.add( DateUtils.getGeneralizedTime() );
         attributes.put( attribute );
 
-        nexus.modify( request.getNewParentName(), DirContext.REPLACE_ATTRIBUTE, attributes );
+        nexus.modify( call.getNewParentName(), DirContext.REPLACE_ATTRIBUTE, attributes );
     }
 
 
-    protected void process(NextInterceptor nextInterceptor, Lookup request) throws NamingException {
-        nextInterceptor.process( request );
+    protected void process(NextInterceptor nextInterceptor, Lookup call) throws NamingException {
+        nextInterceptor.process( call );
         
-        Attributes attributes = ( Attributes ) request.getResponse();
+        Attributes attributes = ( Attributes ) call.getResponse();
         Attributes retval = ( Attributes ) attributes.clone();
         filter( retval );
-        request.setResponse( retval );
+        call.setResponse( retval );
     }
 
-    protected void process(NextInterceptor nextInterceptor, LookupWithAttrIds request) throws NamingException {
-        nextInterceptor.process( request );
+    protected void process(NextInterceptor nextInterceptor, LookupWithAttrIds call) throws NamingException {
+        nextInterceptor.process( call );
         
-        Attributes attributes = ( Attributes ) request.getResponse();
+        Attributes attributes = ( Attributes ) call.getResponse();
         if ( attributes == null )
         {
             return;
         }
 
         Attributes retval = ( Attributes ) attributes.clone();
-        filter( request.getName(), retval, request.getAttributeIds() );
-        request.setResponse( retval );
+        filter( call.getName(), retval, call.getAttributeIds() );
+        call.setResponse( retval );
     }
 
-    protected void process(NextInterceptor nextInterceptor, Search request) throws NamingException {
-        nextInterceptor.process( request );
+    protected void process(NextInterceptor nextInterceptor, Search call) throws NamingException {
+        nextInterceptor.process( call );
         
-        SearchControls searchControls = request.getSearchControls();
+        SearchControls searchControls = call.getSearchControls();
         if ( searchControls.getReturningAttributes() != null )
         {
             return;
@@ -254,10 +254,10 @@
 
         NamingEnumeration e ;
         ResultFilteringEnumeration retval;
-        LdapContext ctx = ( LdapContext ) request.getContextStack().peek();
-        e = ( NamingEnumeration ) request.getResponse();
+        LdapContext ctx = ( LdapContext ) call.getContextStack().peek();
+        e = ( NamingEnumeration ) call.getResponse();
         retval = new ResultFilteringEnumeration( e, searchControls, ctx, SEARCH_FILTER );
-        request.setResponse( retval );
+        call.setResponse( retval );
     }
 
     /**

Modified: directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server/jndi/call/interceptor/Interceptor.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server/jndi/call/interceptor/Interceptor.java?view=diff&r1=158300&r2=158301
==============================================================================
--- directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server/jndi/call/interceptor/Interceptor.java (original)
+++ directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server/jndi/call/interceptor/Interceptor.java Sat Mar 19 20:50:21 2005
@@ -56,6 +56,6 @@
      * @param invocation the invocation to process
      * @throws NamingException on failures while handling the invocation
      */
-    void process( NextInterceptor nextProcessor, Call request )
+    void process( NextInterceptor nextProcessor, Call call )
             throws NamingException;
 }

Modified: directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server/jndi/call/interceptor/InterceptorChain.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server/jndi/call/interceptor/InterceptorChain.java?view=diff&r1=158300&r2=158301
==============================================================================
--- directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server/jndi/call/interceptor/InterceptorChain.java (original)
+++ directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server/jndi/call/interceptor/InterceptorChain.java Sat Mar 19 20:50:21 2005
@@ -34,7 +34,7 @@
             // do nothing
         }
 
-        public void process(NextInterceptor nextProcessor, Call request)
+        public void process(NextInterceptor nextProcessor, Call call)
                 throws NamingException
         {
             // do nothing
@@ -199,13 +199,13 @@
      * Start invocation chain with the specified invocation.
      * @throws NamingException if invocation failed
      */
-    public void process( Call request ) throws NamingException
+    public void process( Call call ) throws NamingException
     {
         Entry head = this.head;
         try
         {
             head.processor.process(
-                    head.nextProcessor, request );
+                    head.nextProcessor, call );
         }
         catch( NamingException ne )
         {
@@ -213,7 +213,7 @@
         }
         catch( Throwable e )
         {
-            throw new InterceptorException( head.processor, request,
+            throw new InterceptorException( head.processor, call,
                                             "Unexpected exception.", e );
         }
     }
@@ -280,13 +280,13 @@
             this.processor = processor;
             this.nextProcessor = new NextInterceptor()
             {
-                public void process(Call request)
+                public void process(Call call)
                         throws NamingException {
                     Interceptor processor = Entry.this.nextEntry.processor;
                     try
                     {
                         processor.process(
-                                Entry.this.nextEntry.nextProcessor, request );
+                                Entry.this.nextEntry.nextProcessor, call );
                     }
                     catch( NamingException ne )
                     {
@@ -294,7 +294,7 @@
                     }
                     catch( Throwable e )
                     {
-                        throw new InterceptorException( processor, request,
+                        throw new InterceptorException( processor, call,
                                                              "Unexpected exception.", e );
                     }
                 }

Modified: directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server/jndi/call/interceptor/InterceptorException.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server/jndi/call/interceptor/InterceptorException.java?view=diff&r1=158300&r2=158301
==============================================================================
--- directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server/jndi/call/interceptor/InterceptorException.java (original)
+++ directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server/jndi/call/interceptor/InterceptorException.java Sat Mar 19 20:50:21 2005
@@ -36,7 +36,7 @@
     private static final long serialVersionUID = 3258690996517746233L;
 
     /** The Invokation the Interceptor failed on */
-    private final Call request;
+    private final Call call;
     /** The Interceptor causing the failure */
     private final Interceptor requestProcessor;
 
@@ -50,7 +50,7 @@
     public InterceptorException( Interceptor requestProcessor, Call request )
     {
         super( ResultCodeEnum.OTHER );
-        this.request = request;
+        this.call = request;
         this.requestProcessor = requestProcessor;
     }
 
@@ -66,7 +66,7 @@
                                       Call request, String explanation )
     {
         super( explanation, ResultCodeEnum.OTHER );
-        this.request = request;
+        this.call = request;
         this.requestProcessor = requestProcessor;
     }
 
@@ -107,9 +107,9 @@
      *
      * @return the invovation object this exception is associated with
      */
-    public Call getRequest()
+    public Call getCall()
     {
-        return request;
+        return call;
     }
 
 

Modified: directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server/jndi/call/interceptor/NextInterceptor.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server/jndi/call/interceptor/NextInterceptor.java?view=diff&r1=158300&r2=158301
==============================================================================
--- directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server/jndi/call/interceptor/NextInterceptor.java (original)
+++ directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server/jndi/call/interceptor/NextInterceptor.java Sat Mar 19 20:50:21 2005
@@ -5,5 +5,5 @@
 import org.apache.ldap.server.jndi.call.Call;
 
 public interface NextInterceptor {
-    void process( Call request ) throws NamingException;
+    void process( Call call ) throws NamingException;
 }

Added: directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server/jndi/call/interceptor/SchemaManager.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server/jndi/call/interceptor/SchemaManager.java?view=auto&rev=158301
==============================================================================
--- directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server/jndi/call/interceptor/SchemaManager.java (added)
+++ directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server/jndi/call/interceptor/SchemaManager.java Sat Mar 19 20:50:21 2005
@@ -0,0 +1,437 @@
+/*
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed 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.ldap.server.jndi.call.interceptor;
+
+
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Properties;
+import java.util.Set;
+
+import javax.naming.NamingEnumeration;
+import javax.naming.NamingException;
+import javax.naming.directory.Attribute;
+import javax.naming.directory.Attributes;
+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.filter.PresenceNode;
+import org.apache.ldap.common.filter.SimpleNode;
+import org.apache.ldap.common.message.LockableAttributeImpl;
+import org.apache.ldap.common.message.LockableAttributesImpl;
+import org.apache.ldap.common.name.LdapName;
+import org.apache.ldap.common.schema.AttributeType;
+import org.apache.ldap.common.schema.DITContentRule;
+import org.apache.ldap.common.schema.DITStructureRule;
+import org.apache.ldap.common.schema.MatchingRule;
+import org.apache.ldap.common.schema.MatchingRuleUse;
+import org.apache.ldap.common.schema.NameForm;
+import org.apache.ldap.common.schema.ObjectClass;
+import org.apache.ldap.common.schema.SchemaUtils;
+import org.apache.ldap.common.schema.Syntax;
+import org.apache.ldap.common.util.SingletonEnumeration;
+import org.apache.ldap.server.RootNexus;
+import org.apache.ldap.server.db.ResultFilteringEnumeration;
+import org.apache.ldap.server.db.SearchResultFilter;
+import org.apache.ldap.server.jndi.ServerLdapContext;
+import org.apache.ldap.server.jndi.call.Lookup;
+import org.apache.ldap.server.jndi.call.LookupWithAttrIds;
+import org.apache.ldap.server.jndi.call.Search;
+import org.apache.ldap.server.schema.AttributeTypeRegistry;
+import org.apache.ldap.server.schema.GlobalRegistries;
+
+
+/**
+ * A schema management and enforcement interceptor service.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class SchemaManager extends BaseInterceptor
+{
+    private static final String BINARY_KEY = "java.naming.ldap.attributes.binary";
+
+    /** the root nexus to all database partitions */
+    private final RootNexus nexus;
+    /** a binary attribute tranforming filter: String -> byte[] */
+    private final BinaryAttributeFilter binaryAttributeFilter;
+    /** the global schema object registries */
+    private final GlobalRegistries globalRegistries;
+    private final AttributeTypeRegistry attributeRegistry;
+    /** subschemaSubentry attribute's value from Root DSE */
+    private final String subentryDn;
+
+
+    /**
+     * Creates a schema service interceptor.
+     *
+     * @param nexus the root nexus to access all database partitions
+     * @param globalRegistries the global schema object registries
+     * @param filterService
+     */
+    public SchemaManager( RootNexus nexus, GlobalRegistries globalRegistries )
+            throws NamingException
+    {
+        this.nexus = nexus;
+        if ( this.nexus == null )
+        {
+            throw new NullPointerException( "the nexus cannot be null" );
+        }
+
+        this.globalRegistries = globalRegistries;
+        if ( this.globalRegistries == null )
+        {
+            throw new NullPointerException( "the global registries cannot be null" );
+        }
+
+        attributeRegistry = globalRegistries.getAttributeTypeRegistry();
+        binaryAttributeFilter = new BinaryAttributeFilter();
+
+        // stuff for dealing with subentries (garbage for now)
+        String subschemaSubentry = ( String ) nexus.getRootDSE().get( "subschemaSubentry" ).get();
+        subentryDn = new LdapName( subschemaSubentry ).toString().toLowerCase();
+    }
+
+    public void init( Properties config )
+    {
+    }
+    
+    public void destroy()
+    {
+    }
+
+    protected void process( NextInterceptor nextInterceptor, Search call ) throws NamingException
+    {
+        // check to make sure the DN searched for is a subentry
+        if ( ! subentryDn.equals( call.getBaseName().toString() ) )
+        {
+            nextInterceptor.process( call );
+            return;
+        }
+
+        boolean bypass = false;
+        SearchControls searchControls = call.getSearchControls();
+        ExprNode filter = call.getExpressionNode();
+        if ( searchControls.getSearchScope() == SearchControls.OBJECT_SCOPE &&
+             filter instanceof SimpleNode )
+        {
+            SimpleNode node = ( SimpleNode ) filter;
+
+            if ( node.getAttribute().equalsIgnoreCase( "objectClass" ) &&
+                 node.getValue().equalsIgnoreCase( "subschema" ) &&
+                 node.getAssertionType() == SimpleNode.EQUALITY
+               )
+            {
+                // call.setBypass( true );
+                Attributes attrs = getSubschemaEntry( searchControls.getReturningAttributes() );
+                SearchResult result = new SearchResult( call.getBaseName().toString(), null, attrs );
+                SingletonEnumeration e = new SingletonEnumeration( result );
+                call.setResponse( e );
+                bypass = true;
+            }
+        }
+        else if ( searchControls.getSearchScope() == SearchControls.OBJECT_SCOPE &&
+                 filter instanceof PresenceNode )
+        {
+            PresenceNode node = ( PresenceNode ) filter;
+
+            if ( node.getAttribute().equalsIgnoreCase( "objectClass" ) )
+            {
+                // call.setBypass( true );
+                Attributes attrs = getSubschemaEntry( searchControls.getReturningAttributes() );
+                SearchResult result = new SearchResult( call.getBaseName().toString(), null, attrs );
+                SingletonEnumeration e = new SingletonEnumeration( result );
+                call.setResponse( e );
+                bypass = true;
+            }
+        }
+
+        if( !bypass )
+        {
+            nextInterceptor.process( call );
+        }
+        
+        if ( searchControls.getReturningAttributes() != null )
+        {
+            return;
+        }
+
+        NamingEnumeration e ;
+        ResultFilteringEnumeration retval;
+        LdapContext ctx = ( LdapContext ) call.getContextStack().peek();
+        e = ( NamingEnumeration ) call.getResponse();
+        retval = new ResultFilteringEnumeration( e, searchControls, ctx, binaryAttributeFilter );
+        call.setResponse( retval );
+    }
+
+
+    private Attributes getSubschemaEntry( String[] ids ) throws NamingException
+    {
+        if ( ids == null )
+        {
+            return new LockableAttributesImpl();
+        }
+
+        HashSet set = new HashSet( ids.length );
+        LockableAttributesImpl attrs = new LockableAttributesImpl();
+        LockableAttributeImpl attr = null;
+
+        for ( int ii = 0; ii < ids.length; ii++ )
+        {
+            set.add( ids[ii].toLowerCase() );
+        }
+
+
+        if ( set.contains( "objectclasses" ) )
+        {
+            attr = new LockableAttributeImpl( attrs, "objectClasses" );
+            Iterator list = globalRegistries.getObjectClassRegistry().list();
+            while ( list.hasNext() )
+            {
+                ObjectClass oc = ( ObjectClass ) list.next();
+                attr.add( SchemaUtils.render( oc ).toString() );
+            }
+            attrs.put( attr );
+        }
+
+        if ( set.contains( "attributetypes" ) )
+        {
+            attr = new LockableAttributeImpl( attrs, "attributeTypes" );
+            Iterator list = globalRegistries.getAttributeTypeRegistry().list();
+            while ( list.hasNext() )
+            {
+                AttributeType at = ( AttributeType ) list.next();
+                attr.add( SchemaUtils.render( at ).toString() );
+            }
+            attrs.put( attr );
+        }
+
+        if ( set.contains( "matchingrules" ) )
+        {
+            attr = new LockableAttributeImpl( attrs, "matchingRules" );
+            Iterator list = globalRegistries.getMatchingRuleRegistry().list();
+            while ( list.hasNext() )
+            {
+                MatchingRule mr = ( MatchingRule ) list.next();
+                attr.add( SchemaUtils.render( mr ).toString() );
+            }
+            attrs.put( attr );
+        }
+
+        if ( set.contains( "matchingruleuse" ) )
+        {
+            attr = new LockableAttributeImpl( attrs, "matchingRuleUse" );
+            Iterator list = globalRegistries.getMatchingRuleUseRegistry().list();
+            while ( list.hasNext() )
+            {
+                MatchingRuleUse mru = ( MatchingRuleUse ) list.next();
+                attr.add( SchemaUtils.render( mru ).toString() );
+            }
+            attrs.put( attr );
+        }
+
+        if ( set.contains( "ldapsyntaxes" ) )
+        {
+            attr = new LockableAttributeImpl( attrs, "ldapSyntaxes" );
+            Iterator list = globalRegistries.getSyntaxRegistry().list();
+            while ( list.hasNext() )
+            {
+                Syntax syntax = ( Syntax ) list.next();
+                attr.add( SchemaUtils.render( syntax ).toString() );
+            }
+            attrs.put( attr );
+        }
+
+        if ( set.contains( "ditcontentrules" ) )
+        {
+            attr = new LockableAttributeImpl( attrs, "dITContentRules" );
+            Iterator list = globalRegistries.getDitContentRuleRegistry().list();
+            while ( list.hasNext() )
+            {
+                DITContentRule dcr = ( DITContentRule ) list.next();
+                attr.add( SchemaUtils.render( dcr ).toString() );
+            }
+            attrs.put( attr );
+        }
+
+        if ( set.contains( "ditstructurerules" ) )
+        {
+            attr = new LockableAttributeImpl( attrs, "dITStructureRules" );
+            Iterator list = globalRegistries.getDitStructureRuleRegistry().list();
+            while ( list.hasNext() )
+            {
+                DITStructureRule dsr = ( DITStructureRule ) list.next();
+                attr.add( SchemaUtils.render( dsr ).toString() );
+            }
+            attrs.put( attr );
+        }
+
+        if ( set.contains( "nameforms" ) )
+        {
+            attr = new LockableAttributeImpl( attrs, "nameForms" );
+            Iterator list = globalRegistries.getNameFormRegistry().list();
+            while ( list.hasNext() )
+            {
+                NameForm nf = ( NameForm ) list.next();
+                attr.add( SchemaUtils.render( nf ).toString() );
+            }
+            attrs.put( attr );
+        }
+
+        // add the objectClass attribute
+        attr = new LockableAttributeImpl( attrs, "objectClass" );
+        attr.add( "top" );
+        attr.add( "subschema" );
+        attrs.put( attr );
+
+        // add the cn attribute as required for the RDN
+        attrs.put( "cn", "schema" );
+
+        return attrs;
+    }
+
+    protected void process(NextInterceptor nextInterceptor, Lookup call) throws NamingException {
+        nextInterceptor.process( call );
+        
+        ServerLdapContext ctx = ( ServerLdapContext ) call.getContextStack().peek();
+        Attributes attributes = ( Attributes ) call.getResponse();
+        Attributes retval = ( Attributes ) attributes.clone();
+        doFilter( ctx, retval );
+        call.setResponse( retval );
+    }
+
+    protected void process(NextInterceptor nextInterceptor, LookupWithAttrIds call) throws NamingException {
+        nextInterceptor.process( call );
+
+        ServerLdapContext ctx = ( ServerLdapContext ) call.getContextStack().peek();
+        Attributes attributes = ( Attributes ) call.getResponse();
+        if ( attributes == null )
+        {
+            return;
+        }
+
+        Attributes retval = ( Attributes ) attributes.clone();
+        doFilter( ctx, retval );
+        call.setResponse( retval );
+    }
+
+    private void doFilter( LdapContext ctx, 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 );
+        
+        if ( binaryIds == null )
+        {
+            binaries = Collections.EMPTY_SET;
+        }
+        else
+        {
+            String[] binaryArray = binaryIds.split( " " );
+            
+            binaries = new HashSet( binaryArray.length );
+            
+            for ( int ii = 0; ii < binaryArray.length; ii++ )
+            {
+                AttributeType type = attributeRegistry.lookup( binaryArray[ii] );
+                
+                binaries.add( type );
+            }
+        }
+        
+        /*
+         * start converting values of attributes to byte[]s which are not
+         * human readable and those that are in the binaries set
+         */
+        NamingEnumeration list = entry.getIDs();
+        
+        while ( list.hasMore() )
+        {
+            String id = ( String ) list.next();
+            
+            AttributeType type = null;
+            
+            boolean asBinary = false;
+            
+            if ( attributeRegistry.hasAttributeType( id ) )
+            {
+                type = attributeRegistry.lookup( id );
+            }
+            
+            if ( type != null )
+            {
+                asBinary = ! type.getSyntax().isHumanReadible();
+                
+                asBinary = asBinary || binaries.contains( type );
+            }
+            
+            if ( asBinary )
+            {
+                Attribute attribute = entry.get( id );
+                
+                Attribute binary = new LockableAttributeImpl( id );
+                
+                for ( int ii = 0; ii < attribute.size(); ii++ )
+                {
+                    Object value = attribute.get( ii );
+                    
+                    if ( value instanceof String )
+                    {
+                        binary.add( ii, ( ( String ) value ).getBytes() );
+                    }
+                    else
+                    {
+                        binary.add( ii, value );
+                    }
+                }
+                
+                entry.remove( id );
+                
+                entry.put( binary );
+            }
+        }
+    }
+
+    /**
+     * A special filter over entry attributes which replaces Attribute String
+     * values with their respective byte[] representations using schema
+     * information and the value held in the JNDI environment property:
+     * <code>java.naming.ldap.attributes.binary</code>.
+     *
+     * @see <a href=
+     * "http://java.sun.com/j2se/1.4.2/docs/guide/jndi/jndi-ldap-gl.html#binary">
+     * java.naming.ldap.attributes.binary</a>
+     */
+    private class BinaryAttributeFilter implements SearchResultFilter
+    {
+        public BinaryAttributeFilter( )
+        {
+        }
+
+        public boolean accept( LdapContext ctx, SearchResult result, SearchControls controls ) throws NamingException
+        {
+            doFilter( ctx, result.getAttributes() );
+            return true;
+        }
+    }
+}

Propchange: directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server/jndi/call/interceptor/SchemaManager.java
------------------------------------------------------------------------------
    svn:keywords = HeadURL Id LastChangedBy LastChangedDate LastChangedRevision