Return-Path: Delivered-To: apmail-directory-commits-archive@www.apache.org Received: (qmail 11959 invoked from network); 22 Mar 2005 09:39:14 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 22 Mar 2005 09:39:14 -0000 Received: (qmail 67495 invoked by uid 500); 22 Mar 2005 09:39:13 -0000 Delivered-To: apmail-directory-commits-archive@directory.apache.org Received: (qmail 67441 invoked by uid 500); 22 Mar 2005 09:39:13 -0000 Mailing-List: contact commits-help@directory.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@directory.apache.org Delivered-To: mailing list commits@directory.apache.org Received: (qmail 67425 invoked by uid 99); 22 Mar 2005 09:39:12 -0000 X-ASF-Spam-Status: No, hits=-9.8 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from minotaur.apache.org (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.28) with SMTP; Tue, 22 Mar 2005 01:39:11 -0800 Received: (qmail 11900 invoked by uid 65534); 22 Mar 2005 09:39:10 -0000 Message-ID: <20050322093910.11897.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Mailer: svnmailer-1.0.0-dev Date: Tue, 22 Mar 2005 09:39:10 -0000 Subject: svn commit: r158586 - in directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server: auth/ jndi/ jndi/invocation/interceptor/ To: commits@directory.apache.org From: trustin@apache.org X-Virus-Checked: Checked X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: trustin Date: Tue Mar 22 01:39:07 2005 New Revision: 158586 URL: http://svn.apache.org/viewcvs?view=3Drev&rev=3D158586 Log: * Added InterceptorContext which gives access to various internal propertie= s of service. * Modified Interceptor.init() to have InterceptorContext passed to intercep= tors. * Updated all interceptor implementations to have default constructors and = configure themselves in init(). * InterceptorChain is now Interceptor, and thus InterceptorChains can nest. * Added EnvKeys.INTERCEPTOR property to let users override the default inte= rceptor chain. Added: directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/a= pache/ldap/server/jndi/invocation/interceptor/InterceptorContext.java (wi= th props) Modified: directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/a= pache/ldap/server/auth/AuthenticatorContext.java directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/a= pache/ldap/server/auth/SimpleAuthenticator.java directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/a= pache/ldap/server/jndi/Authenticator.java directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/a= pache/ldap/server/jndi/CoreContextFactory.java directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/a= pache/ldap/server/jndi/EnvKeys.java directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/a= pache/ldap/server/jndi/JndiProvider.java directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/a= pache/ldap/server/jndi/invocation/interceptor/Authorizer.java directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/a= pache/ldap/server/jndi/invocation/interceptor/Interceptor.java directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/a= pache/ldap/server/jndi/invocation/interceptor/InterceptorChain.java directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/a= pache/ldap/server/jndi/invocation/interceptor/OperationalAttributeIntercept= or.java directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/a= pache/ldap/server/jndi/invocation/interceptor/SchemaManager.java directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/a= pache/ldap/server/jndi/invocation/interceptor/Validator.java Modified: directory/apacheds/branches/interceptor_revamp/core/src/main/java= /org/apache/ldap/server/auth/AuthenticatorContext.java URL: http://svn.apache.org/viewcvs/directory/apacheds/branches/interceptor_= revamp/core/src/main/java/org/apache/ldap/server/auth/AuthenticatorContext.= java?view=3Ddiff&r1=3D158585&r2=3D158586 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/a= pache/ldap/server/auth/AuthenticatorContext.java (original) +++ directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/a= pache/ldap/server/auth/AuthenticatorContext.java Tue Mar 22 01:39:07 2005 @@ -17,7 +17,7 @@ package org.apache.ldap.server.auth; =20 =20 -import org.apache.ldap.server.RootNexus; +import org.apache.ldap.server.PartitionNexus; =20 =20 /** @@ -30,7 +30,7 @@ { =20 /** the root nexus to all database partitions */ - private RootNexus rootNexus; + private PartitionNexus partitionNexus; /** whether or not to allow anonymous users */ private boolean allowAnonymous =3D false; =20 @@ -41,13 +41,13 @@ { } =20 - public RootNexus getRootNexus() + public PartitionNexus getPartitionNexus() { - return rootNexus; + return partitionNexus; } - public void setRootNexus( RootNexus rootNexus ) + public void setPartitionNexus( PartitionNexus rootNexus ) { - this.rootNexus =3D rootNexus; + this.partitionNexus =3D rootNexus; } =20 public boolean getAllowAnonymous() Modified: directory/apacheds/branches/interceptor_revamp/core/src/main/java= /org/apache/ldap/server/auth/SimpleAuthenticator.java URL: http://svn.apache.org/viewcvs/directory/apacheds/branches/interceptor_= revamp/core/src/main/java/org/apache/ldap/server/auth/SimpleAuthenticator.j= ava?view=3Ddiff&r1=3D158585&r2=3D158586 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/a= pache/ldap/server/auth/SimpleAuthenticator.java (original) +++ directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/a= pache/ldap/server/auth/SimpleAuthenticator.java Tue Mar 22 01:39:07 2005 @@ -17,17 +17,17 @@ package org.apache.ldap.server.auth; =20 =20 -import org.apache.ldap.server.RootNexus; -import org.apache.ldap.server.jndi.ServerContext; -import org.apache.ldap.common.exception.LdapNameNotFoundException; -import org.apache.ldap.common.exception.LdapAuthenticationException; -import org.apache.ldap.common.util.ArrayUtils; -import org.apache.ldap.common.name.LdapName; - import javax.naming.Context; import javax.naming.NamingException; -import javax.naming.directory.Attributes; import javax.naming.directory.Attribute; +import javax.naming.directory.Attributes; + +import org.apache.ldap.common.exception.LdapAuthenticationException; +import org.apache.ldap.common.exception.LdapNameNotFoundException; +import org.apache.ldap.common.name.LdapName; +import org.apache.ldap.common.util.ArrayUtils; +import org.apache.ldap.server.PartitionNexus; +import org.apache.ldap.server.jndi.ServerContext; =20 =20 /** @@ -100,7 +100,7 @@ =20 LdapName principalDn =3D new LdapName( principal ); =20 - RootNexus rootNexus =3D getAuthenticatorContext().getRootNexus(); + PartitionNexus rootNexus =3D getAuthenticatorContext().getPartitio= nNexus(); =20 Attributes userEntry =3D rootNexus.lookup( principalDn ); =20 Modified: directory/apacheds/branches/interceptor_revamp/core/src/main/java= /org/apache/ldap/server/jndi/Authenticator.java URL: http://svn.apache.org/viewcvs/directory/apacheds/branches/interceptor_= revamp/core/src/main/java/org/apache/ldap/server/jndi/Authenticator.java?vi= ew=3Ddiff&r1=3D158585&r2=3D158586 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/a= pache/ldap/server/jndi/Authenticator.java (original) +++ directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/a= pache/ldap/server/jndi/Authenticator.java Tue Mar 22 01:39:07 2005 @@ -17,12 +17,13 @@ package org.apache.ldap.server.jndi; =20 =20 +import java.lang.reflect.Constructor; import java.util.ArrayList; import java.util.Collection; +import java.util.Hashtable; import java.util.Iterator; import java.util.LinkedHashMap; import java.util.Map; -import java.util.Properties; =20 import javax.naming.Context; import javax.naming.NamingException; @@ -31,9 +32,15 @@ import org.apache.ldap.common.exception.LdapAuthenticationNotSupportedExce= ption; import org.apache.ldap.common.message.ResultCodeEnum; import org.apache.ldap.common.util.StringTools; +import org.apache.ldap.server.auth.AbstractAuthenticator; +import org.apache.ldap.server.auth.AnonymousAuthenticator; +import org.apache.ldap.server.auth.AuthenticatorConfig; +import org.apache.ldap.server.auth.AuthenticatorContext; import org.apache.ldap.server.auth.LdapPrincipal; +import org.apache.ldap.server.auth.SimpleAuthenticator; import org.apache.ldap.server.jndi.invocation.Invocation; import org.apache.ldap.server.jndi.invocation.interceptor.Interceptor; +import org.apache.ldap.server.jndi.invocation.interceptor.InterceptorConte= xt; import org.apache.ldap.server.jndi.invocation.interceptor.NextInterceptor; =20 /** @@ -63,6 +70,76 @@ { } =20 + public void init( InterceptorContext ctx ) throws NamingException + { + /* + * Create and add the Authentication service interceptor to before + * interceptor chain. + */ + boolean allowAnonymous =3D !ctx.getEnvironment().containsKey( EnvK= eys.DISABLE_ANONYMOUS ); + + // create authenticator context + AuthenticatorContext authenticatorContext =3D new AuthenticatorCon= text(); + authenticatorContext.setPartitionNexus( ctx.getRootNexus() ); + authenticatorContext.setAllowAnonymous( allowAnonymous ); + + try // initialize default authenticators + { + // create anonymous authenticator + AuthenticatorConfig authenticatorConfig =3D new AuthenticatorC= onfig(); + authenticatorConfig.setAuthenticatorName( "none" ); + authenticatorConfig.setAuthenticatorContext( authenticatorCont= ext ); + + org.apache.ldap.server.auth.Authenticator authenticator =3D ne= w AnonymousAuthenticator(); + authenticator.init( authenticatorConfig ); + this.register( authenticator ); + + // create simple authenticator + authenticatorConfig =3D new AuthenticatorConfig(); + authenticatorConfig.setAuthenticatorName( "simple" ); + authenticatorConfig.setAuthenticatorContext( authenticatorCont= ext ); + + authenticator =3D new SimpleAuthenticator(); + authenticator.init( authenticatorConfig ); + this.register( authenticator ); + } + catch ( Exception e ) + { + throw new NamingException( e.getMessage() ); + } + + AuthenticatorConfig[] configs =3D null; + configs =3D AuthenticatorConfigBuilder + .getAuthenticatorConfigs( new Hashtable( ctx.getEnvironmen= t() ) ); + + for ( int ii =3D 0; ii < configs.length; ii++ ) + { + try + { + configs[ii].setAuthenticatorContext( authenticatorContext = ); + + String authenticatorClass =3D configs[ii].getAuthenticator= Class(); + Class clazz =3D Class.forName( authenticatorClass ); + Constructor constructor =3D clazz.getConstructor( new Clas= s[] { } ); + + AbstractAuthenticator authenticator =3D ( AbstractAuthenti= cator ) constructor.newInstance( new Object[] { } ); + authenticator.init( configs[ii] ); + + this.register( authenticator ); + } + catch ( Exception e ) + { + e.printStackTrace(); + } + } + + } + =20 + public void destroy() + { + authenticators.clear(); + } + /** * Registers an Authenticator with this AuthenticatorService. Called = by each * Authenticator implementation after it has started to register for @@ -112,14 +189,6 @@ return (Collection)authenticators.get( type ); } =20 - public void init( Properties config ) - { - } - =20 - public void destroy() - { - } - public void process( NextInterceptor nextProcessor, Invocation call ) = throws NamingException { // check if we are already authenticated and if so we return making Modified: directory/apacheds/branches/interceptor_revamp/core/src/main/java= /org/apache/ldap/server/jndi/CoreContextFactory.java URL: http://svn.apache.org/viewcvs/directory/apacheds/branches/interceptor_= revamp/core/src/main/java/org/apache/ldap/server/jndi/CoreContextFactory.ja= va?view=3Ddiff&r1=3D158585&r2=3D158586 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/a= pache/ldap/server/jndi/CoreContextFactory.java (original) +++ directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/a= pache/ldap/server/jndi/CoreContextFactory.java Tue Mar 22 01:39:07 2005 @@ -44,23 +44,16 @@ import org.apache.ldap.server.ContextPartitionConfig; import org.apache.ldap.server.RootNexus; import org.apache.ldap.server.SystemPartition; -import org.apache.ldap.server.auth.AbstractAuthenticator; -import org.apache.ldap.server.auth.AnonymousAuthenticator; -import org.apache.ldap.server.auth.AuthenticatorConfig; -import org.apache.ldap.server.auth.AuthenticatorContext; -import org.apache.ldap.server.auth.SimpleAuthenticator; import org.apache.ldap.server.db.Database; import org.apache.ldap.server.db.DefaultSearchEngine; import org.apache.ldap.server.db.ExpressionEnumerator; import org.apache.ldap.server.db.ExpressionEvaluator; import org.apache.ldap.server.db.SearchEngine; import org.apache.ldap.server.db.jdbm.JdbmDatabase; -import org.apache.ldap.server.jndi.invocation.interceptor.Authorizer; -import org.apache.ldap.server.jndi.invocation.interceptor.OperationalAttri= buteInterceptor; -import org.apache.ldap.server.jndi.invocation.interceptor.SchemaManager; -import org.apache.ldap.server.jndi.invocation.interceptor.Validator; +import org.apache.ldap.server.jndi.invocation.interceptor.Interceptor; +import org.apache.ldap.server.jndi.invocation.interceptor.InterceptorChain; +import org.apache.ldap.server.jndi.invocation.interceptor.InterceptorConte= xt; import org.apache.ldap.server.schema.AttributeTypeRegistry; -import org.apache.ldap.server.schema.ConcreteNameComponentNormalizer; import org.apache.ldap.server.schema.GlobalRegistries; import org.apache.ldap.server.schema.MatchingRuleRegistry; import org.apache.ldap.server.schema.OidRegistry; @@ -497,131 +490,21 @@ // ---------------------------------------------------------------= ----- // Adding interceptors // ---------------------------------------------------------------= ----- - addDefaultInterceptors(); + Interceptor interceptor =3D (Interceptor) initialEnv.get( EnvKeys.= INTERCEPTOR ); + if( interceptor =3D=3D null ) { + // If custom interceptor is not specified, use defaule one. + interceptor =3D InterceptorChain.newDefaultChain(); + } + // FIXME interceptor config is passed incorrectly + interceptor.init( new InterceptorContext( + initialEnv, system, globalRegistries, nexus, initialEnv ) = ); + provider.setInterceptor( interceptor ); =20 // fire up the app partitions now! if ( initialEnv.get( EnvKeys.PARTITIONS ) !=3D null ) { startUpAppPartitions( wkdir ); } - } - =20 - private void addDefaultInterceptors() throws NamingException - { - addAuthenticator(); - addAuthorizer(); - addValidator(); - addSchemaManager(); - addDefaultAttributeTagger(); - } - =20 - private void addAuthenticator() throws NamingException - { - /* - * Create and add the Authentication service interceptor to before - * interceptor chain. - */ - boolean allowAnonymous =3D !initialEnv.containsKey( EnvKeys.DISABL= E_ANONYMOUS ); - Authenticator authenticationService =3D new Authenticator(); - - // create authenticator context - AuthenticatorContext authenticatorContext =3D new AuthenticatorCon= text(); - authenticatorContext.setRootNexus( nexus ); - authenticatorContext.setAllowAnonymous( allowAnonymous ); - - try // initialize default authenticators - { - // create anonymous authenticator - AuthenticatorConfig authenticatorConfig =3D new AuthenticatorC= onfig(); - authenticatorConfig.setAuthenticatorName( "none" ); - authenticatorConfig.setAuthenticatorContext( authenticatorCont= ext ); - - org.apache.ldap.server.auth.Authenticator authenticator =3D ne= w AnonymousAuthenticator(); - authenticator.init( authenticatorConfig ); - authenticationService.register( authenticator ); - - // create simple authenticator - authenticatorConfig =3D new AuthenticatorConfig(); - authenticatorConfig.setAuthenticatorName( "simple" ); - authenticatorConfig.setAuthenticatorContext( authenticatorCont= ext ); - - authenticator =3D new SimpleAuthenticator(); - authenticator.init( authenticatorConfig ); - authenticationService.register( authenticator ); - } - catch ( Exception e ) - { - throw new NamingException( e.getMessage() ); - } - - AuthenticatorConfig[] configs =3D null; - configs =3D AuthenticatorConfigBuilder - .getAuthenticatorConfigs( initialEnv ); - - for ( int ii =3D 0; ii < configs.length; ii++ ) - { - try - { - configs[ii].setAuthenticatorContext( authenticatorContext = ); - - String authenticatorClass =3D configs[ii].getAuthenticator= Class(); - Class clazz =3D Class.forName( authenticatorClass ); - Constructor constructor =3D clazz.getConstructor( new Clas= s[] { } ); - - AbstractAuthenticator authenticator =3D ( AbstractAuthenti= cator ) constructor.newInstance( new Object[] { } ); - authenticator.init( configs[ii] ); - - authenticationService.register( authenticator ); - } - catch ( Exception e ) - { - e.printStackTrace(); - } - } - =20 - provider.getInterceptorChain().addLast( "authenticator", authentic= ationService ); - } - - private void addAuthorizer() throws NamingException - { - /* - * Create and add the Authorization service interceptor to before - * interceptor chain. - */ - - AttributeTypeRegistry atr =3D globalRegistries.getAttributeTypeReg= istry(); - ConcreteNameComponentNormalizer normalizer =3D new ConcreteNameCom= ponentNormalizer( atr ); - Authorizer authorizer =3D new Authorizer( normalizer ); - provider.getInterceptorChain().addLast( "authorizer", authorizer ); - } - =20 - private void addValidator() - { - /* - * Create and add the Eve Exception service interceptor to both the - * before and onError interceptor chains. - */ - Validator validator =3D new Validator( nexus ); - provider.getInterceptorChain().addLast( "validator", validator ); - } - =20 - private void addSchemaManager() throws NamingException - { - /* - * Create and add the Eve schema service interceptor to before cha= in. - */ - SchemaManager schemaManager =3D new SchemaManager( nexus, globalRe= gistries ); - provider.getInterceptorChain().addLast( "schemaManager", schemaMan= ager ); - } - =20 - private void addDefaultAttributeTagger() - { - /* - * Create and add the Eve operational attribute managment service - * interceptor to both the before and after interceptor chains. - */ - OperationalAttributeInterceptor tagger =3D new OperationalAttribut= eInterceptor( nexus, globalRegistries ); - provider.getInterceptorChain().addLast( "defaultAttributeTagger", = tagger ); } =20 /** Modified: directory/apacheds/branches/interceptor_revamp/core/src/main/java= /org/apache/ldap/server/jndi/EnvKeys.java URL: http://svn.apache.org/viewcvs/directory/apacheds/branches/interceptor_= revamp/core/src/main/java/org/apache/ldap/server/jndi/EnvKeys.java?view=3Dd= iff&r1=3D158585&r2=3D158586 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/a= pache/ldap/server/jndi/EnvKeys.java (original) +++ directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/a= pache/ldap/server/jndi/EnvKeys.java Tue Mar 22 01:39:07 2005 @@ -52,6 +52,15 @@ /** the envprop key base to the properties of an authenticator */ public static final String AUTHENTICATOR_PROPERTIES =3D "server.authen= ticator.properties."; =20 + /** + * bootstrap property: {@link Interceptor} or {@link InterceptorChain} + * that will intercept directory operations when they are invoked. You + * don't need to specify this property if you want to use the default + * interceptor chain. If you specify this property, you might have to + * add some default interceptors in org.apache.ldap.server.jndi.in= vocation.interceptor + * package in your custom interceptor chain.=20 + */ + public static final String INTERCEPTOR =3D "server.interceptor"; =20 // -------------------------------------------------------------------= ----- // Properties for protocol/network settings Modified: directory/apacheds/branches/interceptor_revamp/core/src/main/java= /org/apache/ldap/server/jndi/JndiProvider.java URL: http://svn.apache.org/viewcvs/directory/apacheds/branches/interceptor_= revamp/core/src/main/java/org/apache/ldap/server/jndi/JndiProvider.java?vie= w=3Ddiff&r1=3D158585&r2=3D158586 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/a= pache/ldap/server/jndi/JndiProvider.java (original) +++ directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/a= pache/ldap/server/jndi/JndiProvider.java Tue Mar 22 01:39:07 2005 @@ -35,11 +35,11 @@ import org.apache.ldap.server.PartitionNexus; import org.apache.ldap.server.RootNexus; import org.apache.ldap.server.jndi.invocation.Add; -import org.apache.ldap.server.jndi.invocation.Invocation; import org.apache.ldap.server.jndi.invocation.Delete; import org.apache.ldap.server.jndi.invocation.GetMatchedDN; import org.apache.ldap.server.jndi.invocation.GetSuffix; import org.apache.ldap.server.jndi.invocation.HasEntry; +import org.apache.ldap.server.jndi.invocation.Invocation; import org.apache.ldap.server.jndi.invocation.IsSuffix; import org.apache.ldap.server.jndi.invocation.List; import org.apache.ldap.server.jndi.invocation.ListSuffixes; @@ -51,6 +51,7 @@ import org.apache.ldap.server.jndi.invocation.Move; import org.apache.ldap.server.jndi.invocation.MoveAndModifyRN; import org.apache.ldap.server.jndi.invocation.Search; +import org.apache.ldap.server.jndi.invocation.interceptor.Interceptor; import org.apache.ldap.server.jndi.invocation.interceptor.InterceptorChain; =20 =20 @@ -65,8 +66,8 @@ /** Singleton instance of this class */ private static JndiProvider s_singleton; =20 - /** The interceptor chain for this provider */ - private InterceptorChain interceptors; + /** The interceptor (or interceptor chain) for this provider */ + private Interceptor interceptor; /** RootNexus as it was given to us by the ServiceManager */ private RootNexus nexus; /** PartitionNexus proxy wrapping nexus to inject services */ @@ -98,7 +99,7 @@ =20 s_singleton =3D this; this.nexus =3D nexus; - this.interceptors =3D new InterceptorChain( nexus ); + this.interceptor =3D new InterceptorChain(); this.proxy =3D new PartitionNexusImpl(); } =20 @@ -161,20 +162,30 @@ this.nexus.close(); this.nexus =3D null; this.proxy =3D null; - this.interceptors.clear(); + this.interceptor.destroy(); + this.interceptor =3D null; this.isShutdown =3D true; s_singleton =3D null; } =20 - public InterceptorChain getInterceptorChain() + public Interceptor getInterceptor() { - return interceptors; + return interceptor; + } + + public void setInterceptor( Interceptor interceptor ) + { + if( interceptor =3D=3D null ) + { + throw new NullPointerException( "interceptor" ); + } + this.interceptor =3D interceptor; } =20 =20 public Object invoke( Invocation call ) throws NamingException { - interceptors.process( call ); + interceptor.process( null, call ); return call.getResponse(); } =20 Modified: directory/apacheds/branches/interceptor_revamp/core/src/main/java= /org/apache/ldap/server/jndi/invocation/interceptor/Authorizer.java URL: http://svn.apache.org/viewcvs/directory/apacheds/branches/interceptor_= revamp/core/src/main/java/org/apache/ldap/server/jndi/invocation/intercepto= r/Authorizer.java?view=3Ddiff&r1=3D158585&r2=3D158586 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/a= pache/ldap/server/jndi/invocation/interceptor/Authorizer.java (original) +++ directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/a= pache/ldap/server/jndi/invocation/interceptor/Authorizer.java Tue Mar 22 01= :39:07 2005 @@ -16,9 +16,6 @@ */ package org.apache.ldap.server.jndi.invocation.interceptor; =20 - -import java.util.Properties; - import javax.naming.Name; import javax.naming.NamingEnumeration; import javax.naming.NamingException; @@ -30,14 +27,14 @@ =20 import org.apache.ldap.common.exception.LdapNoPermissionException; import org.apache.ldap.common.name.DnParser; -import org.apache.ldap.common.name.NameComponentNormalizer; +import org.apache.ldap.server.BackingStore; import org.apache.ldap.server.SystemPartition; import org.apache.ldap.server.db.ResultFilteringEnumeration; import org.apache.ldap.server.db.SearchResultFilter; import org.apache.ldap.server.jndi.ServerContext; -import org.apache.ldap.server.jndi.invocation.Invocation; import org.apache.ldap.server.jndi.invocation.Delete; import org.apache.ldap.server.jndi.invocation.HasEntry; +import org.apache.ldap.server.jndi.invocation.Invocation; import org.apache.ldap.server.jndi.invocation.List; import org.apache.ldap.server.jndi.invocation.Lookup; import org.apache.ldap.server.jndi.invocation.LookupWithAttrIds; @@ -47,6 +44,8 @@ import org.apache.ldap.server.jndi.invocation.Move; import org.apache.ldap.server.jndi.invocation.MoveAndModifyRN; import org.apache.ldap.server.jndi.invocation.Search; +import org.apache.ldap.server.schema.AttributeTypeRegistry; +import org.apache.ldap.server.schema.ConcreteNameComponentNormalizer; =20 =20 /** @@ -71,23 +70,20 @@ private static final Name GROUP_BASE_DN =3D SystemPartition.getGroupsB= aseDn(); =20 /** the name parser used by this service */ - private final DnParser dnParser; + private DnParser dnParser;=20 =20 =20 /** * Creates an authorization service interceptor. - * - * @param normalizer a schema enabled name component normalizer - * @param filterService a {@link FilterService} to register filters wi= th */ - public Authorizer( NameComponentNormalizer normalizer ) - throws NamingException + public Authorizer() { - this.dnParser =3D new DnParser( normalizer ); } =20 - public void init( Properties config ) + public void init( InterceptorContext ctx ) throws NamingException { + AttributeTypeRegistry atr =3D ctx.getGlobalRegistries().getAttribu= teTypeRegistry(); + dnParser =3D new DnParser( new ConcreteNameComponentNormalizer( at= r ) ); } =20 public void destroy() Modified: directory/apacheds/branches/interceptor_revamp/core/src/main/java= /org/apache/ldap/server/jndi/invocation/interceptor/Interceptor.java URL: http://svn.apache.org/viewcvs/directory/apacheds/branches/interceptor_= revamp/core/src/main/java/org/apache/ldap/server/jndi/invocation/intercepto= r/Interceptor.java?view=3Ddiff&r1=3D158585&r2=3D158586 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/a= pache/ldap/server/jndi/invocation/interceptor/Interceptor.java (original) +++ directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/a= pache/ldap/server/jndi/invocation/interceptor/Interceptor.java Tue Mar 22 0= 1:39:07 2005 @@ -16,10 +16,9 @@ */ package org.apache.ldap.server.jndi.invocation.interceptor; =20 -import java.util.Properties; - import javax.naming.NamingException; =20 +import org.apache.ldap.server.BackingStore; import org.apache.ldap.server.jndi.invocation.Invocation; =20 /** @@ -96,10 +95,10 @@ * @param config the configuration properties for this interceptor * @throws NamingException if failed to initialize this interceptor */ - void init( Properties config ) throws NamingException; + void init( InterceptorContext context ) throws NamingException; =20 /** - * Deinitialized this interceptor. This is invoked by directory servi= ce + * Deinitializes this interceptor. This is invoked by directory servi= ce * provider when this intercepter is unloaded from interceptor chain. */ void destroy(); Modified: directory/apacheds/branches/interceptor_revamp/core/src/main/java= /org/apache/ldap/server/jndi/invocation/interceptor/InterceptorChain.java URL: http://svn.apache.org/viewcvs/directory/apacheds/branches/interceptor_= revamp/core/src/main/java/org/apache/ldap/server/jndi/invocation/intercepto= r/InterceptorChain.java?view=3Ddiff&r1=3D158585&r2=3D158586 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/a= pache/ldap/server/jndi/invocation/interceptor/InterceptorChain.java (origin= al) +++ directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/a= pache/ldap/server/jndi/invocation/interceptor/InterceptorChain.java Tue Mar= 22 01:39:07 2005 @@ -18,17 +18,20 @@ =20 import java.util.ArrayList; import java.util.HashMap; +import java.util.Iterator; import java.util.List; +import java.util.ListIterator; import java.util.Map; -import java.util.Properties; =20 import javax.naming.NamingException; =20 -import org.apache.ldap.server.BackingStore; +import org.apache.ldap.server.jndi.Authenticator; import org.apache.ldap.server.jndi.invocation.Invocation; =20 /** - * Manages the chain of {@link Interceptor}s. + * Manages the chain of {@link Interceptor}s. InterceptorChain i= s + * also an {@link Interceptor}, and thus you can create hiararchical inter= ceptor + * structure to break down complex interceptors. *

* {@link org.apache.ldap.server.jndi.JndiProvider#invoke(Invocation)} * redirects {@link Invocation}s to {@link #process(Invocation)} and @@ -38,13 +41,43 @@ * @author Trustin Lee (trustin@apache.org) * @version $Rev$, $Date$ */ -public class InterceptorChain +public class InterceptorChain implements Interceptor { + /** + * 'Preprocess chain' passes the invocation to the next interceptor + * of the parent chain after processing children. + */ + public static final ChainType PREPROCESS =3D new ChainType(); + + /** + * 'Postprocess chain' passes the invocation to the next interceptor + * of the parent chain before processing children. + */ + public static final ChainType POSTPROCESS =3D new ChainType(); + =20 + public static InterceptorChain newDefaultChain() + { + return newDefaultChain( PREPROCESS ); + } + =20 + public static InterceptorChain newDefaultChain( ChainType type ) + { + InterceptorChain chain =3D new InterceptorChain( type ); + chain.addLast( "authenticator", new Authenticator() ); + chain.addLast( "authorizer", new Authorizer() ); + chain.addLast( "validator", new Validator() ); + chain.addLast( "schemaManager", new SchemaManager() ); + chain.addLast( "operationalAttributeInterceptor", new OperationalA= ttributeInterceptor() ); + return chain; + } + =20 private final Interceptor FINAL_INTERCEPTOR =3D new Interceptor() { - public void init(Properties config) throws NamingException + private InterceptorContext ctx; + =20 + public void init(InterceptorContext context) throws NamingExceptio= n { - // unused + ctx =3D context; } =20 public void destroy() @@ -55,26 +88,103 @@ public void process(NextInterceptor nextInterceptor, Invocation ca= ll) throws NamingException { - call.execute( store ); + if( parent =3D=3D null ) + { + // execute the actual backend operation only when this cha= in + // is root. + call.execute( ctx.getRootNexus() ); + } } }; =20 - private final BackingStore store; + private InterceptorChain parent; + private final ChainType type; private final Map name2entry =3D new HashMap(); private Entry head =3D new Entry( null, null, "end", FINAL_INTERCEPTOR= ); private final Entry tail =3D head; =20 /** - * Create a new interceptor chain. + * Create a new interceptor chain whose type is {@link #PREPROCESS}. */ - public InterceptorChain( BackingStore store ) + public InterceptorChain() { - if( store =3D=3D null ) + this( PREPROCESS ); + } + =20 + /** + * Creates a new interceptor chain with the specified chain type. + */ + public InterceptorChain( ChainType type ) + { + if( type =3D=3D null ) { - throw new NullPointerException( "store" ) ; + throw new NullPointerException( "type" ); + } + + this.type =3D type; + } + =20 + /** + * Initializes all interceptors this chain contains. + */ + public synchronized void init( InterceptorContext context ) throws Nam= ingException + { + ListIterator it =3D getAll().listIterator(); + Interceptor interceptor =3D null; + try + { + while( it.hasNext() ) + { + interceptor =3D ( Interceptor ) it.next(); + interceptor.init( context ); + } + } + catch( Throwable t ) + { + while( it.hasPrevious() ) + { + Interceptor i =3D ( Interceptor ) it.previous(); + try + { + i.destroy(); + } + catch( Throwable t2 ) + { + t2.printStackTrace(); + } + } + =20 + if( t instanceof NamingException ) + { + throw ( NamingException ) t; + } + else + { + throw new InterceptorException(=20 + interceptor, null, + "Failed to initialize interceptor chain.", t ); + } + } + } + =20 + /** + * Deinitializes all interceptors this chain contains. + */ + public synchronized void destroy() + { + ListIterator it =3D getAllReversed().listIterator(); + while( it.hasNext() ) + { + Interceptor interceptor =3D ( Interceptor ) it.next(); + try + { + interceptor.destroy(); + } + catch( Throwable t ) + { + t.printStackTrace(); + } } - =20 - this.store =3D store; } =20 /** @@ -100,13 +210,13 @@ public synchronized void addFirst( String name, Interceptor interceptor ) { - checkNewName( name ); + checkAddable( name, interceptor ); =20 Entry newEntry =3D new Entry( null, head, name, interceptor ); head.prevEntry =3D newEntry; head =3D newEntry; =20 - name2entry.put( name, newEntry ); + register(name, newEntry); } =20 /** @@ -116,7 +226,7 @@ public synchronized void addLast( String name, Interceptor interceptor ) { - checkNewName( name ); + checkAddable( name, interceptor ); =20 Entry newEntry =3D new Entry( tail.prevEntry, tail, name, intercep= tor ); if( tail.prevEntry !=3D null ) @@ -129,7 +239,7 @@ } tail.prevEntry =3D newEntry; =20 - name2entry.put( name, newEntry ); + register(name, newEntry); } =20 /** @@ -141,7 +251,7 @@ Interceptor interceptor ) { Entry baseEntry =3D checkOldName( baseName ); - checkNewName( name ); + checkAddable( name, interceptor ); =20 Entry prevEntry =3D baseEntry.prevEntry; Entry newEntry =3D new Entry( prevEntry, baseEntry, name, intercep= tor ); @@ -155,7 +265,7 @@ prevEntry.nextEntry =3D newEntry; } =20 - name2entry.put( name, newEntry ); + register(name, newEntry); } =20 /** @@ -167,7 +277,7 @@ Interceptor interceptor ) { Entry baseEntry =3D checkOldName( baseName ); - checkNewName(name); + checkAddable( name, interceptor ); =20 Entry nextEntry =3D baseEntry.nextEntry; Entry newEntry =3D new Entry( baseEntry, nextEntry, name, intercep= tor ); @@ -178,7 +288,7 @@ =20 nextEntry.prevEntry.nextEntry =3D newEntry; nextEntry.prevEntry =3D newEntry; - name2entry.put( name, newEntry ); + register(name, newEntry); } =20 /** @@ -199,6 +309,13 @@ prevEntry.nextEntry =3D nextEntry; nextEntry.prevEntry =3D prevEntry; } + + name2entry.remove( name ); + Interceptor interceptor =3D entry.interceptor; + if( interceptor instanceof InterceptorChain ) + { + ( ( InterceptorChain ) interceptor ).parent =3D null; + } } =20 /** @@ -206,9 +323,20 @@ */ public synchronized void clear() { - tail.prevEntry =3D null; - tail.nextEntry =3D null; - head =3D tail; + Iterator it =3D new ArrayList( name2entry.keySet() ).iterator(); + while( it.hasNext() ) + { + this.remove( ( String ) it.next() ); + } + } + + private void register(String name, Entry newEntry) { + Interceptor interceptor =3D newEntry.interceptor; + name2entry.put( name, newEntry ); + if( interceptor instanceof InterceptorChain ) + { + ( ( InterceptorChain ) interceptor ).parent =3D this; + } } =20 /** @@ -232,13 +360,22 @@ * Checks the specified interceptor name is already taken and throws * an exception if already taken. */ - private void checkNewName( String name ) + private void checkAddable( String name, Interceptor interceptor ) { if( name2entry.containsKey( name ) ) { throw new IllegalArgumentException( "Other interceptor is using name '" + name + "'" ); } + =20 + if( interceptor instanceof InterceptorChain ) + { + if ( ( ( InterceptorChain ) interceptor ).parent !=3D null ) + { + throw new IllegalArgumentException( + "This interceptor chain has its parent already." )= ; + } + } } =20 /** @@ -246,13 +383,28 @@ *=20 * @throws NamingException if invocation failed */ - public void process( Invocation call ) throws NamingException + public void process( NextInterceptor nextInterceptor, Invocation invoc= ation ) throws NamingException { Entry head =3D this.head; try { - head.interceptor.process( - head.nextInterceptor, call ); + if( type =3D=3D PREPROCESS ) + { + head.interceptor.process( head.nextInterceptor, invocation= ); + if( nextInterceptor !=3D null ) + { + nextInterceptor.process( invocation ); + } + } + else // POSTPROCESS + { + if( nextInterceptor !=3D null ) + { + nextInterceptor.process( invocation ); + } + head.interceptor.process( head.nextInterceptor, invocation= ); + } + =20 } catch( NamingException ne ) { @@ -260,7 +412,7 @@ } catch( Throwable e ) { - throw new InterceptorException( head.interceptor, call, + throw new InterceptorException( head.interceptor, invocation, "Unexpected exception.", e ); } } @@ -349,6 +501,17 @@ } } }; + } + } + =20 + /** + * Represents how {@link InterceptorChain} interacts with + * {@link NextInterceptor}. + */ + public static class ChainType + { + private ChainType() + { } } } Added: directory/apacheds/branches/interceptor_revamp/core/src/main/java/or= g/apache/ldap/server/jndi/invocation/interceptor/InterceptorContext.java URL: http://svn.apache.org/viewcvs/directory/apacheds/branches/interceptor_= revamp/core/src/main/java/org/apache/ldap/server/jndi/invocation/intercepto= r/InterceptorContext.java?view=3Dauto&rev=3D158586 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/a= pache/ldap/server/jndi/invocation/interceptor/InterceptorContext.java (adde= d) +++ directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/a= pache/ldap/server/jndi/invocation/interceptor/InterceptorContext.java Tue M= ar 22 01:39:07 2005 @@ -0,0 +1,61 @@ +package org.apache.ldap.server.jndi.invocation.interceptor; + +import java.util.Map; + +import org.apache.ldap.server.RootNexus; +import org.apache.ldap.server.SystemPartition; +import org.apache.ldap.server.schema.GlobalRegistries; + +public class InterceptorContext { + + /** the initial context environment that fired up the backend subsyste= m */ + private final Map environment; + =20 + /** Configuration for the interceptor. */ + private final Map config; + + /** the system partition used by the context factory */ + private final SystemPartition systemPartition; + + /** the registries for system schema objects */ + private final GlobalRegistries globalRegistries; + + /** the root nexus */ + private final RootNexus rootNexus; + + public InterceptorContext( Map environment, + SystemPartition systemPartition, + GlobalRegistries globalRegistries, + RootNexus rootNexus, + Map config ) + { + this.environment =3D environment; + this.systemPartition =3D systemPartition; + this.globalRegistries =3D globalRegistries; + this.rootNexus =3D rootNexus; + this.config =3D config; + } + + public Map getEnvironment() { + return environment; + } + =20 + public Map getConfig() { + return config; + } + =20 + + public GlobalRegistries getGlobalRegistries() { + return globalRegistries; + } + =20 + + public RootNexus getRootNexus() { + return rootNexus; + } + =20 + + public SystemPartition getSystemPartition() { + return systemPartition; + } +} Propchange: directory/apacheds/branches/interceptor_revamp/core/src/main/ja= va/org/apache/ldap/server/jndi/invocation/interceptor/InterceptorContext.ja= va ---------------------------------------------------------------------------= --- svn:keywords =3D HeadURL Id LastChangedBy LastChangedDate LastChangedRe= vision Modified: directory/apacheds/branches/interceptor_revamp/core/src/main/java= /org/apache/ldap/server/jndi/invocation/interceptor/OperationalAttributeInt= erceptor.java URL: http://svn.apache.org/viewcvs/directory/apacheds/branches/interceptor_= revamp/core/src/main/java/org/apache/ldap/server/jndi/invocation/intercepto= r/OperationalAttributeInterceptor.java?view=3Ddiff&r1=3D158585&r2=3D158586 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/a= pache/ldap/server/jndi/invocation/interceptor/OperationalAttributeIntercept= or.java (original) +++ directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/a= pache/ldap/server/jndi/invocation/interceptor/OperationalAttributeIntercept= or.java Tue Mar 22 01:39:07 2005 @@ -18,7 +18,6 @@ =20 =20 import java.util.HashSet; -import java.util.Properties; =20 import javax.naming.Name; import javax.naming.NamingEnumeration; @@ -48,7 +47,6 @@ import org.apache.ldap.server.jndi.invocation.MoveAndModifyRN; import org.apache.ldap.server.jndi.invocation.Search; import org.apache.ldap.server.schema.AttributeTypeRegistry; -import org.apache.ldap.server.schema.GlobalRegistries; =20 =20 /** @@ -80,36 +78,23 @@ }; =20 /** the root nexus of the system */ - private final RootNexus nexus; - private final AttributeTypeRegistry registry; + private RootNexus nexus; + private AttributeTypeRegistry registry; =20 =20 /** * Creates the operational attribute management service interceptor. - * - * @param nexus the root nexus of the system - * @param globalRegistries the global schema object registries */ - public OperationalAttributeInterceptor( RootNexus nexus, - GlobalRegistries globalRegistr= ies ) + public OperationalAttributeInterceptor() { - this.nexus =3D nexus; - if ( this.nexus =3D=3D null ) - { - throw new NullPointerException( "the nexus cannot be null" ); - } - - if ( globalRegistries =3D=3D null ) - { - throw new NullPointerException( "the global registries cannot = be null" ); - } - this.registry =3D globalRegistries.getAttributeTypeRegistry(); } =20 - public void destroy() { + public void init( InterceptorContext ctx ) throws NamingException { + nexus =3D ctx.getRootNexus(); + registry =3D ctx.getGlobalRegistries().getAttributeTypeRegistry(); } =20 - public void init(Properties config) throws NamingException { + public void destroy() { } =20 /** Modified: directory/apacheds/branches/interceptor_revamp/core/src/main/java= /org/apache/ldap/server/jndi/invocation/interceptor/SchemaManager.java URL: http://svn.apache.org/viewcvs/directory/apacheds/branches/interceptor_= revamp/core/src/main/java/org/apache/ldap/server/jndi/invocation/intercepto= r/SchemaManager.java?view=3Ddiff&r1=3D158585&r2=3D158586 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/a= pache/ldap/server/jndi/invocation/interceptor/SchemaManager.java (original) +++ directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/a= pache/ldap/server/jndi/invocation/interceptor/SchemaManager.java Tue Mar 22= 01:39:07 2005 @@ -20,7 +20,6 @@ import java.util.Collections; import java.util.HashSet; import java.util.Iterator; -import java.util.Properties; import java.util.Set; =20 import javax.naming.NamingEnumeration; @@ -73,14 +72,14 @@ private static final String BINARY_KEY =3D "java.naming.ldap.attribute= s=2Ebinary"; =20 /** the root nexus to all database partitions */ - private final RootNexus nexus; + private RootNexus nexus; /** a binary attribute tranforming filter: String -> byte[] */ - private final BinaryAttributeFilter binaryAttributeFilter; + private BinaryAttributeFilter binaryAttributeFilter; /** the global schema object registries */ - private final GlobalRegistries globalRegistries; - private final AttributeTypeRegistry attributeRegistry; + private GlobalRegistries globalRegistries; + private AttributeTypeRegistry attributeRegistry; /** subschemaSubentry attribute's value from Root DSE */ - private final String subentryDn; + private String subentryDn; =20 =20 /** @@ -90,31 +89,20 @@ * @param globalRegistries the global schema object registries * @param filterService */ - public SchemaManager( RootNexus nexus, GlobalRegistries globalRegistri= es ) - throws NamingException + public SchemaManager() { - this.nexus =3D nexus; - if ( this.nexus =3D=3D null ) - { - throw new NullPointerException( "the nexus cannot be null" ); - } - - this.globalRegistries =3D globalRegistries; - if ( this.globalRegistries =3D=3D null ) - { - throw new NullPointerException( "the global registries cannot = be null" ); - } + } =20 + public void init( InterceptorContext ctx ) throws NamingException + { + this.nexus =3D ctx.getRootNexus(); + this.globalRegistries =3D ctx.getGlobalRegistries(); attributeRegistry =3D globalRegistries.getAttributeTypeRegistry(); binaryAttributeFilter =3D new BinaryAttributeFilter(); =20 // stuff for dealing with subentries (garbage for now) String subschemaSubentry =3D ( String ) nexus.getRootDSE().get( "s= ubschemaSubentry" ).get(); subentryDn =3D new LdapName( subschemaSubentry ).toString().toLowe= rCase(); - } - - public void init( Properties config ) - { } =20 public void destroy() Modified: directory/apacheds/branches/interceptor_revamp/core/src/main/java= /org/apache/ldap/server/jndi/invocation/interceptor/Validator.java URL: http://svn.apache.org/viewcvs/directory/apacheds/branches/interceptor_= revamp/core/src/main/java/org/apache/ldap/server/jndi/invocation/intercepto= r/Validator.java?view=3Ddiff&r1=3D158585&r2=3D158586 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/a= pache/ldap/server/jndi/invocation/interceptor/Validator.java (original) +++ directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/a= pache/ldap/server/jndi/invocation/interceptor/Validator.java Tue Mar 22 01:= 39:07 2005 @@ -17,8 +17,6 @@ package org.apache.ldap.server.jndi.invocation.interceptor; =20 =20 -import java.util.Properties; - import javax.naming.Name; import javax.naming.NamingEnumeration; import javax.naming.NamingException; @@ -31,6 +29,7 @@ import org.apache.ldap.common.exception.LdapNamingException; import org.apache.ldap.common.message.ResultCodeEnum; import org.apache.ldap.common.name.LdapName; +import org.apache.ldap.server.BackingStore; import org.apache.ldap.server.RootNexus; import org.apache.ldap.server.jndi.invocation.Add; import org.apache.ldap.server.jndi.invocation.Delete; @@ -58,21 +57,19 @@ public class Validator extends BaseInterceptor { /** the root nexus of the system */ - private RootNexus nexus =3D null; + private RootNexus nexus; =20 =20 /** * Creates an interceptor that is also the exception handling service. - * - * @param nexus the root partition nexus */ - public Validator( RootNexus nexus ) + public Validator() { - this.nexus =3D nexus; } =20 - public void init( Properties config ) + public void init( InterceptorContext ctx ) { + this.nexus =3D ctx.getRootNexus(); } =20 public void destroy()