directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From trus...@apache.org
Subject svn commit: r189964 [1/2] - in /directory/apacheds/branches/direve-158/core: ./ src/main/java/org/apache/ldap/server/ src/main/java/org/apache/ldap/server/authn/ src/main/java/org/apache/ldap/server/configuration/ src/main/java/org/apache/ldap/server/interceptor/ src/main/java/org/apache/ldap/server/jndi/ src/main/java/org/apache/ldap/server/schema/bootstrap/ src/test/org/apache/ldap/server/authn/ src/test/org/apache/ldap/server/interceptor/ src/test/org/apache/ldap/server/jndi/ src/test/org/apache/ldap/server/prefs/ src/test/org/apache/ldap/server/schema/bootstrap/
Date Fri, 10 Jun 2005 14:22:48 GMT
Author: trustin
Date: Fri Jun 10 07:22:46 2005
New Revision: 189964

URL: http://svn.apache.org/viewcvs?rev=189964&view=rev
Log:
Propagated revamped Configurations to core

Removed:
    directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/ContextPartitionConfig.java
    directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/authn/AuthenticatorConfigBuilder.java
    directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/authn/GenericAuthenticatorConfig.java
    directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/interceptor/InterceptorConfigBuilder.java
    directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/jndi/EnvKeys.java
    directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/jndi/PartitionConfigBuilder.java
    directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/interceptor/
    directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/jndi/PartitionContextBuilderTest.java
Modified:
    directory/apacheds/branches/direve-158/core/project.xml
    directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/AbstractCoreTest.java
    directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/ApplicationPartition.java
    directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/ContextPartition.java
    directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/SystemPartition.java
    directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/authn/AbstractAuthenticator.java
    directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/authn/AnonymousAuthenticator.java
    directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/authn/AuthenticationService.java
    directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/authn/Authenticator.java
    directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/authn/AuthenticatorContext.java
    directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/authn/GenericAuthenticatorContext.java
    directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/authn/SimpleAuthenticator.java
    directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/configuration/ConfigurationUtil.java
    directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/configuration/ContextPartitionConfiguration.java
    directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/configuration/MutableContextPartitionConfiguration.java
    directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/configuration/StartupConfiguration.java
    directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/interceptor/Interceptor.java
    directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/interceptor/InterceptorChain.java
    directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/interceptor/InterceptorContext.java
    directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/jndi/CoreContextFactory.java
    directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/schema/bootstrap/BootstrapSchemaLoader.java
    directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/authn/SimpleAuthenticationTest.java
    directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/jndi/RootDSETest.java
    directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/jndi/ServiceRegistryPassthruTest.java
    directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/jndi/ShutdownTest.java
    directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/jndi/SyncTest.java
    directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/prefs/ServerSystemPreferencesTest.java
    directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/schema/bootstrap/BootstrapSchemaLoaderTest.java

Modified: directory/apacheds/branches/direve-158/core/project.xml
URL: http://svn.apache.org/viewcvs/directory/apacheds/branches/direve-158/core/project.xml?rev=189964&r1=189963&r2=189964&view=diff
==============================================================================
--- directory/apacheds/branches/direve-158/core/project.xml (original)
+++ directory/apacheds/branches/direve-158/core/project.xml Fri Jun 10 07:22:46 2005
@@ -112,7 +112,7 @@
     <dependency>
       <groupId>directory-network</groupId>
       <artifactId>mina</artifactId>
-      <version>0.7.2-SNAPSHOT</version>
+      <version>0.7.3-SNAPSHOT</version>
     </dependency>
 
     <!-- The Eve Maven Plugin -->

Modified: directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/AbstractCoreTest.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/AbstractCoreTest.java?rev=189964&r1=189963&r2=189964&view=diff
==============================================================================
--- directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/AbstractCoreTest.java (original)
+++ directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/AbstractCoreTest.java Fri Jun 10 07:22:46 2005
@@ -17,13 +17,14 @@
 package org.apache.ldap.server;
 
 
-import junit.framework.TestCase;
-import org.apache.commons.io.FileUtils;
-import org.apache.commons.lang.exception.NestableRuntimeException;
-import org.apache.ldap.common.ldif.LdifIterator;
-import org.apache.ldap.common.ldif.LdifParserImpl;
-import org.apache.ldap.common.message.LockableAttributesImpl;
-import org.apache.ldap.server.jndi.EnvKeys;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.HashSet;
+import java.util.Hashtable;
+import java.util.Set;
 
 import javax.naming.Context;
 import javax.naming.InitialContext;
@@ -31,9 +32,17 @@
 import javax.naming.directory.Attributes;
 import javax.naming.ldap.InitialLdapContext;
 import javax.naming.ldap.LdapContext;
-import java.io.*;
-import java.util.Hashtable;
-import java.util.ArrayList;
+
+import junit.framework.TestCase;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.lang.exception.NestableRuntimeException;
+import org.apache.ldap.common.ldif.LdifIterator;
+import org.apache.ldap.common.ldif.LdifParserImpl;
+import org.apache.ldap.common.message.LockableAttributesImpl;
+import org.apache.ldap.server.configuration.Configuration;
+import org.apache.ldap.server.configuration.MutableStartupConfiguration;
+import org.apache.ldap.server.configuration.ShutdownConfiguration;
 
                                                                                                             
 /**
@@ -67,15 +76,11 @@
 
     /** flag whether to delete database files for each test or not */
     protected boolean doDelete = true;
-
-    /** extra environment parameters that can be added before setUp */
-    protected Hashtable extras = new Hashtable();
-
-    /** extra environment parameters that can be added before setUp to override values */
-    protected Hashtable overrides = new Hashtable();
+    
+    protected MutableStartupConfiguration configuration = new MutableStartupConfiguration();
 
     /** A testEntries of entries as Attributes to add to the DIT for testing */
-    protected ArrayList testEntries = new ArrayList();
+    protected Set testEntries = new HashSet();
 
     /** An optional LDIF file path if set and present is read to add more test entries */
     private String ldifPath;
@@ -188,18 +193,9 @@
         // Add key for extra entries to the testEntries of extras
         // -------------------------------------------------------------------
 
-        extras.put( EnvKeys.TEST_ENTRIES, testEntries );
-        
-        if ( overrides.containsKey( EnvKeys.WKDIR ) )
-        {
-            doDelete( new File( ( String ) overrides.get( EnvKeys.WKDIR ) ) );
-        }
-        else
-        {
-            doDelete( new File( "target" + File.separator + "apacheds" ) );
-        }
-
-        setSysRoot( "uid=admin,ou=system", "secret" );
+        configuration.setTestEntries( testEntries );
+        doDelete( configuration.getWorkingDirectory() );
+        setSysRoot( "uid=admin,ou=system", "secret", configuration );
     }
 
 
@@ -232,14 +228,11 @@
      * @return the sysRoot context which is also set
      * @throws NamingException if there is a failure of any kind
      */
-    protected LdapContext setSysRoot( String user, String passwd ) throws NamingException
+    protected LdapContext setSysRoot( String user, String passwd, Configuration cfg ) throws NamingException
     {
-        Hashtable env = new Hashtable();
-
+        Hashtable env = new Hashtable( cfg.toJndiEnvironment() );
         env.put( Context.SECURITY_PRINCIPAL, user );
-
         env.put( Context.SECURITY_CREDENTIALS, passwd );
-
         return setSysRoot( env );
     }
 
@@ -255,23 +248,13 @@
      */
     protected LdapContext setSysRoot( Hashtable env ) throws NamingException
     {
-        Hashtable envFinal = new Hashtable();
-
-        envFinal.putAll( extras );
-
-        envFinal.putAll( env );
-
+        Hashtable envFinal = new Hashtable( env );
         if ( ! envFinal.containsKey( Context.PROVIDER_URL ) )
         {
             envFinal.put( Context.PROVIDER_URL, "ou=system" );
         }
 
-        envFinal.put( EnvKeys.WKDIR, "target" + File.separator + "apacheds" );
-
         envFinal.put( Context.INITIAL_CONTEXT_FACTORY, "org.apache.ldap.server.jndi.CoreContextFactory" );
-
-        envFinal.putAll( overrides );
-
         return sysRoot = new InitialLdapContext( envFinal, null );
     }
 
@@ -292,7 +275,7 @@
 
         env.put( Context.INITIAL_CONTEXT_FACTORY, "org.apache.ldap.server.jndi.CoreContextFactory" );
 
-        env.put( EnvKeys.SHUTDOWN, "" );
+        env.putAll( new ShutdownConfiguration().toJndiEnvironment() );
 
         env.put( Context.SECURITY_PRINCIPAL, "uid=admin,ou=system" );
 

Modified: directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/ApplicationPartition.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/ApplicationPartition.java?rev=189964&r1=189963&r2=189964&view=diff
==============================================================================
--- directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/ApplicationPartition.java (original)
+++ directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/ApplicationPartition.java Fri Jun 10 07:22:46 2005
@@ -37,13 +37,13 @@
      * user provided suffix distinguished name for this backend set during
      * the Avalon configuration life-cycle phase.
      */
-    private Name upSuffix = null ;
+    private Name upSuffix;
     
     /**
      * normalized suffix distinguished name for this backend set during
      * the Avalon configuration life-cycle phase.
      */
-    private Name normalizedSuffix = null ;
+    private Name normalizedSuffix;
 
 
     // ------------------------------------------------------------------------
@@ -53,22 +53,16 @@
 
     /**
      *
-     * @param upSuffix the user provided suffix without normalization
-     * @param normalizedSuffix the normalized suffix
      * @param db the database to use for this partition
      * @param searchEngine the search engine to use for this partition
      * @param indexAttributes the index attrivutes including system attributes
      * @throws NamingException on failures while creating this partition
      */
-    public ApplicationPartition( Name upSuffix, Name normalizedSuffix, Database db,
-                           SearchEngine searchEngine,
-                           AttributeType[] indexAttributes )
+    public ApplicationPartition(
+            Database db, SearchEngine searchEngine, AttributeType[] indexAttributes )
         throws NamingException
     {
         super( db, searchEngine, indexAttributes );
-
-        this.normalizedSuffix = normalizedSuffix;
-        this.upSuffix = upSuffix;
     }
 
 
@@ -77,6 +71,11 @@
     // Backend Interface Method Implementations
     // ------------------------------------------------------------------------
 
+    public void init( Name upSuffix, Name normSuffix )
+    {
+        this.upSuffix = upSuffix;
+        this.normalizedSuffix = normSuffix;
+    }
 
     /**
      * @see ContextPartition#getSuffix( boolean )

Modified: directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/ContextPartition.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/ContextPartition.java?rev=189964&r1=189963&r2=189964&view=diff
==============================================================================
--- directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/ContextPartition.java (original)
+++ directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/ContextPartition.java Fri Jun 10 07:22:46 2005
@@ -18,6 +18,7 @@
 
 
 import javax.naming.Name;
+import javax.naming.NamingException;
 
 
 /**
@@ -30,6 +31,11 @@
  */
 public interface ContextPartition extends BackingStore
 {
+    /**
+     * Initializes this partition.
+     */
+    void init( Name userProvidedSuffix, Name normalizedSuffix ) throws NamingException;
+    
     /**
      * Gets the distinguished/absolute name of the suffix for all entries
      * stored within this BackingStore.

Modified: directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/SystemPartition.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/SystemPartition.java?rev=189964&r1=189963&r2=189964&view=diff
==============================================================================
--- directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/SystemPartition.java (original)
+++ directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/SystemPartition.java Fri Jun 10 07:22:46 2005
@@ -198,6 +198,11 @@
     // B A C K E N D   M E T H O D S 
     // ------------------------------------------------------------------------
 
+    public final void init( Name upSuffix, Name normalizedSuffix )
+    {
+        // This method may not be called.
+        throw new IllegalStateException( "SystemPartition is already initialized." );
+    }
 
     /**
      * @see org.apache.ldap.server.ContextPartition#getSuffix(boolean)

Modified: directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/authn/AbstractAuthenticator.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/authn/AbstractAuthenticator.java?rev=189964&r1=189963&r2=189964&view=diff
==============================================================================
--- directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/authn/AbstractAuthenticator.java (original)
+++ directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/authn/AbstractAuthenticator.java Fri Jun 10 07:22:46 2005
@@ -17,11 +17,10 @@
 package org.apache.ldap.server.authn;
 
 
-import org.apache.ldap.server.jndi.ServerContext;
-import org.apache.ldap.common.name.LdapName;
-
 import javax.naming.NamingException;
-import java.util.Enumeration;
+
+import org.apache.ldap.common.name.LdapName;
+import org.apache.ldap.server.jndi.ServerContext;
 
 
 /**
@@ -29,14 +28,14 @@
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public abstract class AbstractAuthenticator implements Authenticator, AuthenticatorConfig
+public abstract class AbstractAuthenticator implements Authenticator
 {
 
     /** authenticator config */
-    public AuthenticatorConfig authenticatorConfig;
+    private AuthenticatorContext ctx;
 
     /** authenticator type */
-    public String authenticatorType;
+    private String authenticatorType;
 
 
     /**
@@ -44,7 +43,7 @@
      *
      * @param type authenticator's type
      */
-    public AbstractAuthenticator( String type )
+    protected AbstractAuthenticator( String type )
     {
         this.authenticatorType = type;
     }
@@ -53,9 +52,9 @@
     /**
      * Returns a reference to the AuthenticatorContext in which this authenticator is running.
      */
-    public AuthenticatorContext getAuthenticatorContext()
+    public AuthenticatorContext getContext()
     {
-        return authenticatorConfig.getAuthenticatorContext();
+        return ctx;
     }
 
 
@@ -69,23 +68,13 @@
 
 
     /**
-     * Return this authenticator's AuthenticatorConfig object.
-     */
-    public AuthenticatorConfig getAuthenticatorConfig()
-    {
-        return authenticatorConfig;
-    }
-
-
-    /**
      * Called by the server to indicate to an authenticator that the authenticator
      * is being placed into service.
      */
-    public void init( AuthenticatorConfig authenticatorConfig ) throws NamingException
+    public final void init( AuthenticatorContext ctx ) throws NamingException
     {
-        this.authenticatorConfig = authenticatorConfig;
-
-        init();
+        this.ctx = ctx;
+        doInit();
     }
 
 
@@ -93,9 +82,7 @@
      * A convenience method which can be overridden so that there's no need to
      * call super.init( authenticatorConfig ).
      */
-    public void init() throws NamingException
-    {
-    }
+    protected abstract void doInit();
 
 
     /**
@@ -105,33 +92,6 @@
 
 
     /**
-     * Returns the name of this authenticator instance.
-     */
-    public String getAuthenticatorName()
-    {
-        return authenticatorConfig.getAuthenticatorName();
-    }
-
-
-    /**
-     * Returns a String containing the value of the named initialization parameter, or null if the parameter does not exist.
-     */
-    public String getInitParameter( String name )
-    {
-        return authenticatorConfig.getInitParameter( name );
-    }
-
-
-    /**
-     * Returns the names of the servlet's initialization parameters as an Enumeration of String objects, or an empty Enumeration if the servlet has no initialization parameters.
-     */
-    public Enumeration getInitParameterNames()
-    {
-        return authenticatorConfig.getInitParameterNames();
-    }
-
-
-    /**
      * Allows a means to create an LDAP principal without exposing LdapPrincipal creation
      * to the rest of the world.
      *
@@ -142,9 +102,6 @@
     protected LdapPrincipal createLdapPrincipal( String dn ) throws NamingException
     {
         LdapName principalDn = new LdapName( dn );
-
         return new LdapPrincipal( principalDn );
     }
-
-
 }

Modified: directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/authn/AnonymousAuthenticator.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/authn/AnonymousAuthenticator.java?rev=189964&r1=189963&r2=189964&view=diff
==============================================================================
--- directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/authn/AnonymousAuthenticator.java (original)
+++ directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/authn/AnonymousAuthenticator.java Fri Jun 10 07:22:46 2005
@@ -28,11 +28,14 @@
  */
 public class AnonymousAuthenticator extends AbstractAuthenticator
 {
-    public AnonymousAuthenticator( )
+    public AnonymousAuthenticator()
     {
         super( "none" );
     }
 
+    protected void doInit()
+    {
+    }
 
     /**
      * This will be called when the authentication is set to "none" on the client.
@@ -40,7 +43,7 @@
      */
     public LdapPrincipal authenticate( ServerContext ctx ) throws NamingException
     {
-        if ( getAuthenticatorContext().getAllowAnonymous() )
+        if ( getContext().getRootConfiguration().isAllowAnonymousAccess() )
         {
             return LdapPrincipal.ANONYMOUS ;
         }

Modified: directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/authn/AuthenticationService.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/authn/AuthenticationService.java?rev=189964&r1=189963&r2=189964&view=diff
==============================================================================
--- directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/authn/AuthenticationService.java (original)
+++ directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/authn/AuthenticationService.java Fri Jun 10 07:22:46 2005
@@ -17,23 +17,27 @@
 package org.apache.ldap.server.authn;
 
 
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import javax.naming.Context;
+import javax.naming.NamingException;
+
 import org.apache.ldap.common.exception.LdapAuthenticationException;
 import org.apache.ldap.common.exception.LdapAuthenticationNotSupportedException;
 import org.apache.ldap.common.message.ResultCodeEnum;
 import org.apache.ldap.common.util.StringTools;
+import org.apache.ldap.server.configuration.AuthenticatorConfiguration;
 import org.apache.ldap.server.interceptor.Interceptor;
 import org.apache.ldap.server.interceptor.InterceptorContext;
 import org.apache.ldap.server.interceptor.NextInterceptor;
 import org.apache.ldap.server.invocation.Invocation;
-import org.apache.ldap.server.jndi.EnvKeys;
 import org.apache.ldap.server.jndi.ServerContext;
 import org.apache.ldap.server.jndi.ServerLdapContext;
 
-import javax.naming.Context;
-import javax.naming.NamingException;
-import java.lang.reflect.Constructor;
-import java.util.*;
-
 
 /**
  * An {@link Interceptor} that authenticates users.
@@ -52,7 +56,7 @@
     private static final String CREDS = Context.SECURITY_CREDENTIALS;
 
     /** authenticators **/
-    public Map authenticators = new LinkedHashMap();
+    public Map authenticators = new HashMap();
 
 
     /**
@@ -64,82 +68,27 @@
 
     public void init( InterceptorContext ctx ) throws NamingException
     {
-        /*
-         * Create and add the Authentication service interceptor to before
-         * interceptor chain.
-         */
-        boolean allowAnonymous = !ctx.getEnvironment().containsKey( EnvKeys.DISABLE_ANONYMOUS );
-
-        // create authenticator context
-
-        GenericAuthenticatorContext authenticatorContext = new GenericAuthenticatorContext();
-
-        authenticatorContext.setPartitionNexus( ctx.getRootNexus() );
-
-        authenticatorContext.setAllowAnonymous( allowAnonymous );
-
-        try // initialize default authenticators
-        {
-            // create anonymous authenticator
-
-            GenericAuthenticatorConfig authenticatorConfig = new GenericAuthenticatorConfig();
-
-            authenticatorConfig.setAuthenticatorName( "none" );
-
-            authenticatorConfig.setAuthenticatorContext( authenticatorContext );
-
-            org.apache.ldap.server.authn.Authenticator authenticator = new AnonymousAuthenticator();
-
-            authenticator.init( authenticatorConfig );
-
-            this.register( authenticator );
-
-            // create simple authenticator
-            authenticatorConfig = new GenericAuthenticatorConfig();
-
-            authenticatorConfig.setAuthenticatorName( "simple" );
-
-            authenticatorConfig.setAuthenticatorContext( authenticatorContext );
-
-            authenticator = new SimpleAuthenticator();
-
-            authenticator.init( authenticatorConfig );
-
-            this.register( authenticator );
-        }
-        catch ( Exception e )
-        {
-            throw new NamingException( e.getMessage() );
-        }
-
-        GenericAuthenticatorConfig[] configs = null;
-
-        configs = AuthenticatorConfigBuilder.getAuthenticatorConfigs( new Hashtable( ctx.getEnvironment() ) );
-
-        for ( int ii = 0; ii < configs.length; ii++ )
+        // Register all authenticators
+        Iterator i = ctx.getConfiguration().getAuthenticatorConfigurations().iterator();
+        while( i.hasNext() )
         {
-            try
-            {
-                configs[ii].setAuthenticatorContext( authenticatorContext );
-
-                String authenticatorClass = configs[ii].getAuthenticatorClass();
-
-                Class clazz = Class.forName( authenticatorClass );
-
-                Constructor constructor = clazz.getConstructor( new Class[] { } );
-
-                AbstractAuthenticator authenticator = ( AbstractAuthenticator ) constructor.newInstance( new Object[] { } );
-
-                authenticator.init( configs[ii] );
-
-                this.register( authenticator );
+            try {
+                AuthenticatorConfiguration cfg = ( AuthenticatorConfiguration ) i.next();
+                
+                // Create context
+                AuthenticatorContext authenticatorContext =
+                    new GenericAuthenticatorContext( ctx.getConfiguration(), cfg, ctx.getRootNexus() );
+    
+                cfg.getAuthenticator().init( authenticatorContext );
+                
+                this.register( cfg.getAuthenticator() );
             }
             catch ( Exception e )
             {
-                e.printStackTrace();
+                throw ( NamingException ) new NamingException(
+                        "Failed to register authenticator." ).initCause( e );
             }
         }
-
     }
     
     public void destroy()
@@ -155,7 +104,7 @@
      * @param authenticator AuthenticationService component to register with this
      * AuthenticatorService.
      */
-    public void register( org.apache.ldap.server.authn.Authenticator authenticator )
+    public void register( Authenticator authenticator )
     {
         Collection authenticatorList = getAuthenticators( authenticator.getAuthenticatorType() );
 

Modified: directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/authn/Authenticator.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/authn/Authenticator.java?rev=189964&r1=189963&r2=189964&view=diff
==============================================================================
--- directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/authn/Authenticator.java (original)
+++ directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/authn/Authenticator.java Fri Jun 10 07:22:46 2005
@@ -36,24 +36,17 @@
  */
 public interface Authenticator
 {
-    public AuthenticatorConfig getAuthenticatorConfig();
-
     public String getAuthenticatorType();
+    
+    public AuthenticatorContext getContext();
 
     /**
      * Called by the authenticator container to indicate that the authenticator is being placed into service.
-     *
-     * @param authenticatorConfig
-     * @throws NamingException
      */
-    public void init( AuthenticatorConfig authenticatorConfig ) throws NamingException;
+    public void init( AuthenticatorContext ctx ) throws NamingException;
 
     /**
      * Perform the authentication operation and return the authorization id if successfull.
-     *
-     * @param ctx
-     * @return the authorization id
-     * @throws NamingException
      */
     public LdapPrincipal authenticate( ServerContext ctx ) throws NamingException;
 }

Modified: directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/authn/AuthenticatorContext.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/authn/AuthenticatorContext.java?rev=189964&r1=189963&r2=189964&view=diff
==============================================================================
--- directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/authn/AuthenticatorContext.java (original)
+++ directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/authn/AuthenticatorContext.java Fri Jun 10 07:22:46 2005
@@ -18,6 +18,8 @@
 
 
 import org.apache.ldap.server.PartitionNexus;
+import org.apache.ldap.server.configuration.AuthenticatorConfiguration;
+import org.apache.ldap.server.configuration.StartupConfiguration;
 
 
 /**
@@ -30,14 +32,18 @@
  */
 public interface AuthenticatorContext
 {
+    /**
+     * Returns root configuration.
+     */
+    public StartupConfiguration getRootConfiguration();
 
     /**
-     * Returns a reference to the PartitionNexus.
+     * Returns configuration of the {@link Authenticator}.
      */
-    public PartitionNexus getPartitionNexus();
+    public AuthenticatorConfiguration getConfiguration();
 
     /**
-     * Returns the value of server.disable.anonymous JNDI Property.
+     * Returns {@link PartitionNexus}.
      */
-    public boolean getAllowAnonymous();
+    public PartitionNexus getPartitionNexus();
 }

Modified: directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/authn/GenericAuthenticatorContext.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/authn/GenericAuthenticatorContext.java?rev=189964&r1=189963&r2=189964&view=diff
==============================================================================
--- directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/authn/GenericAuthenticatorContext.java (original)
+++ directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/authn/GenericAuthenticatorContext.java Fri Jun 10 07:22:46 2005
@@ -18,6 +18,8 @@
 
 
 import org.apache.ldap.server.PartitionNexus;
+import org.apache.ldap.server.configuration.AuthenticatorConfiguration;
+import org.apache.ldap.server.configuration.StartupConfiguration;
 
 
 /**
@@ -28,36 +30,40 @@
  */
 public class GenericAuthenticatorContext implements AuthenticatorContext
 {
-
+    private StartupConfiguration rootConfiguration;
+    private AuthenticatorConfiguration configuration;
     /** the root nexus to all database partitions */
     private PartitionNexus partitionNexus;
-    /** whether or not to allow anonymous users */
-    private boolean allowAnonymous = false;
 
     /**
      * Create a new AuthenticatorContext.
      */
-    public GenericAuthenticatorContext()
-    {
-    }
-
-    public PartitionNexus getPartitionNexus()
+    public GenericAuthenticatorContext(
+            StartupConfiguration rootConfiguration,
+            AuthenticatorConfiguration configuration,
+            PartitionNexus partitionNexus )
     {
-        return partitionNexus;
+        assert rootConfiguration != null;
+        assert configuration != null;
+        assert partitionNexus != null;
+
+        this.rootConfiguration = rootConfiguration;
+        this.configuration = configuration;
+        this.partitionNexus = partitionNexus;
     }
-    public void setPartitionNexus( PartitionNexus rootNexus )
+    
+    public StartupConfiguration getRootConfiguration()
     {
-        this.partitionNexus = rootNexus;
+        return rootConfiguration;
     }
-
-    public boolean getAllowAnonymous()
+    
+    public AuthenticatorConfiguration getConfiguration()
     {
-        return allowAnonymous;
+        return configuration;
     }
 
-    public void setAllowAnonymous( boolean allowAnonymous )
+    public PartitionNexus getPartitionNexus()
     {
-        this.allowAnonymous = allowAnonymous;
+        return partitionNexus;
     }
-
 }

Modified: directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/authn/SimpleAuthenticator.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/authn/SimpleAuthenticator.java?rev=189964&r1=189963&r2=189964&view=diff
==============================================================================
--- directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/authn/SimpleAuthenticator.java (original)
+++ directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/authn/SimpleAuthenticator.java Fri Jun 10 07:22:46 2005
@@ -47,7 +47,10 @@
         super( "simple" );
     }
 
-
+    protected void doInit()
+    {
+    }
+    
     /**
      * Uses the userPassword field of the user to authenticate.
      *
@@ -90,7 +93,7 @@
 
         LdapName principalDn = new LdapName( principal );
 
-        PartitionNexus rootNexus = getAuthenticatorContext().getPartitionNexus();
+        PartitionNexus rootNexus = getContext().getPartitionNexus();
 
         Attributes userEntry = rootNexus.lookup( principalDn );
 

Modified: directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/configuration/ConfigurationUtil.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/configuration/ConfigurationUtil.java?rev=189964&r1=189963&r2=189964&view=diff
==============================================================================
--- directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/configuration/ConfigurationUtil.java (original)
+++ directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/configuration/ConfigurationUtil.java Fri Jun 10 07:22:46 2005
@@ -49,7 +49,7 @@
                         "Invalid element type: " + e.getClass() +
                         " (expected " + type );
             }
-            set.add( e );
+            newSet.add( e );
         }
         return newSet;
     }

Modified: directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/configuration/ContextPartitionConfiguration.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/configuration/ContextPartitionConfiguration.java?rev=189964&r1=189963&r2=189964&view=diff
==============================================================================
--- directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/configuration/ContextPartitionConfiguration.java (original)
+++ directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/configuration/ContextPartitionConfiguration.java Fri Jun 10 07:22:46 2005
@@ -40,7 +40,7 @@
     private String name;
     private String suffix;
     private Set indexedAttributes = new HashSet(); // Set<String>
-    private Attributes rootEntry = new BasicAttributes();
+    private Attributes contextEntry = new BasicAttributes();
     private ContextPartition contextPartition;
     
     /**
@@ -86,19 +86,22 @@
         return contextPartition;
     }
     
+    /**
+     * Set this to null if you want to use {@link org.apache.ldap.server.ApplicationPartition}.
+     */
     protected void setContextPartition( ContextPartition partition )
     {
         this.contextPartition = partition;
     }
     
-    public Attributes getRootEntry()
+    public Attributes getContextEntry()
     {
-        return ( Attributes ) rootEntry.clone();
+        return ( Attributes ) contextEntry.clone();
     }
     
-    protected void setRootEntry( Attributes rootEntry )
+    protected void setContextEntry( Attributes rootEntry )
     {
-        this.rootEntry = ( Attributes ) rootEntry.clone();
+        this.contextEntry = ( Attributes ) rootEntry.clone();
     }
     
     public String getSuffix()
@@ -128,11 +131,6 @@
         if( getSuffix() == null )
         {
             throw new ConfigurationException( "Suffix is not specified." );
-        }
-        
-        if( getContextPartition() == null )
-        {
-            throw new ConfigurationException( "Partition is not specified." );
         }
     }
 }

Modified: directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/configuration/MutableContextPartitionConfiguration.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/configuration/MutableContextPartitionConfiguration.java?rev=189964&r1=189963&r2=189964&view=diff
==============================================================================
--- directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/configuration/MutableContextPartitionConfiguration.java (original)
+++ directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/configuration/MutableContextPartitionConfiguration.java Fri Jun 10 07:22:46 2005
@@ -50,9 +50,9 @@
         super.setContextPartition( partition );
     }
 
-    public void setRootEntry( Attributes rootEntry )
+    public void setContextEntry( Attributes rootEntry )
     {
-        super.setRootEntry( rootEntry );
+        super.setContextEntry( rootEntry );
     }
 
     public void setSuffix( String suffix )

Modified: directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/configuration/StartupConfiguration.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/configuration/StartupConfiguration.java?rev=189964&r1=189963&r2=189964&view=diff
==============================================================================
--- directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/configuration/StartupConfiguration.java (original)
+++ directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/configuration/StartupConfiguration.java Fri Jun 10 07:22:46 2005
@@ -25,6 +25,7 @@
 
 import javax.naming.directory.Attributes;
 
+import org.apache.ldap.server.authn.AnonymousAuthenticator;
 import org.apache.ldap.server.authn.SimpleAuthenticator;
 import org.apache.ldap.server.interceptor.InterceptorChain;
 import org.apache.ldap.server.schema.bootstrap.ApacheSchema;
@@ -57,7 +58,7 @@
     protected boolean enableKerberos;
     
     protected Set bootstrapSchemas; // Set<BootstrapSchema>
-    protected Set contextPartitionConfigurations; // Set<ContextPartitionConfiguration>
+    protected Set contextPartitionConfigurations = new HashSet(); // Set<ContextPartitionConfiguration>
     protected Set testEntries = new HashSet(); // Set<Attributes>
     
     protected StartupConfiguration()
@@ -67,7 +68,16 @@
         // Set default authenticator configurations
         set = new HashSet();
         
-        MutableAuthenticatorConfiguration authCfg = new MutableAuthenticatorConfiguration();
+        MutableAuthenticatorConfiguration authCfg;
+
+        // Anonymous
+        authCfg = new MutableAuthenticatorConfiguration();
+        authCfg.setName( "Anonymous" );
+        authCfg.setAuthenticator( new AnonymousAuthenticator() );
+        set.add( authCfg );
+
+        // Simple
+        authCfg = new MutableAuthenticatorConfiguration();
         authCfg.setName( "Simple" );
         authCfg.setAuthenticator( new SimpleAuthenticator() );
         set.add( authCfg );
@@ -310,10 +320,5 @@
     public void validate()
     {
         setWorkingDirectory( workingDirectory );
-        
-        if( contextPartitionConfigurations == null || contextPartitionConfigurations.size() == 0 )
-        {
-            throw new ConfigurationException( "ContextPartitionConfiguration is not specified." );
-        }
     }
 }

Modified: directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/interceptor/Interceptor.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/interceptor/Interceptor.java?rev=189964&r1=189963&r2=189964&view=diff
==============================================================================
--- directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/interceptor/Interceptor.java (original)
+++ directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/interceptor/Interceptor.java Fri Jun 10 07:22:46 2005
@@ -17,11 +17,12 @@
 package org.apache.ldap.server.interceptor;
 
 
+import javax.naming.NamingException;
+
 import org.apache.ldap.server.BackingStore;
+import org.apache.ldap.server.configuration.StartupConfiguration;
 import org.apache.ldap.server.invocation.Invocation;
 
-import javax.naming.NamingException;
-
 
 /**
  * Filters any directory operations.  You can filter any {@link Invocation}
@@ -83,8 +84,7 @@
  * <p/>
  * <h2>Overriding Default Interceptor Settings</h2>
  * <p/>
- * See {@link org.apache.ldap.server.jndi.EnvKeys#INTERCEPTORS} and
- * {@link InterceptorChain#newDefaultChain()}.
+ * See {@link StartupConfiguration} and {@link InterceptorChain#newDefaultChain()}.
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$, $Date$

Modified: directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/interceptor/InterceptorChain.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/interceptor/InterceptorChain.java?rev=189964&r1=189963&r2=189964&view=diff
==============================================================================
--- directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/interceptor/InterceptorChain.java (original)
+++ directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/interceptor/InterceptorChain.java Fri Jun 10 07:22:46 2005
@@ -17,16 +17,23 @@
 package org.apache.ldap.server.interceptor;
 
 
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.IdentityHashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.Map;
+
+import javax.naming.NamingException;
+
 import org.apache.ldap.server.authn.AuthenticationService;
-import org.apache.ldap.server.invocation.Invocation;
 import org.apache.ldap.server.authz.AuthorizationService;
-import org.apache.ldap.server.schema.SchemaService;
-import org.apache.ldap.server.operational.OperationalAttributeService;
 import org.apache.ldap.server.exception.ExceptionService;
+import org.apache.ldap.server.invocation.Invocation;
 import org.apache.ldap.server.normalization.NormalizationService;
-
-import javax.naming.NamingException;
-import java.util.*;
+import org.apache.ldap.server.operational.OperationalAttributeService;
+import org.apache.ldap.server.schema.SchemaService;
 
 
 /**
@@ -165,15 +172,7 @@
             while ( it.hasNext() )
             {
                 interceptor = ( Interceptor ) it.next();
-
-                String name = getName( interceptor );
-
-                Map config = InterceptorConfigBuilder.build( ctx.getConfig(), ( name == null ) ? "" : name );
-
-                InterceptorContext newCtx = new InterceptorContext( ctx.getEnvironment(),
-                        ctx.getSystemPartition(), ctx.getGlobalRegistries(), ctx.getRootNexus(), config );
-
-                interceptor.init( newCtx );
+                interceptor.init( ctx );
             }
         }
         catch ( Throwable t )
@@ -242,19 +241,6 @@
         }
 
         return e.interceptor;
-    }
-
-
-    private String getName( Interceptor interceptor )
-    {
-        Entry e = ( Entry ) interceptor2entry.get( interceptor );
-
-        if ( e == null )
-        {
-            return null;
-        }
-
-        return e.name;
     }
 
 

Modified: directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/interceptor/InterceptorContext.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/interceptor/InterceptorContext.java?rev=189964&r1=189963&r2=189964&view=diff
==============================================================================
--- directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/interceptor/InterceptorContext.java (original)
+++ directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/interceptor/InterceptorContext.java Fri Jun 10 07:22:46 2005
@@ -3,10 +3,9 @@
 
 import org.apache.ldap.server.RootNexus;
 import org.apache.ldap.server.SystemPartition;
+import org.apache.ldap.server.configuration.StartupConfiguration;
 import org.apache.ldap.server.schema.GlobalRegistries;
 
-import java.util.Map;
-
 
 /**
  * @todo doc me
@@ -17,14 +16,9 @@
 {
 
     /**
-     * the initial context environment that fired up the backend subsystem
+     * the configuration
      */
-    private final Map environment;
-
-    /**
-     * Configuration for the interceptor.
-     */
-    private final Map config;
+    private final StartupConfiguration configuration;
 
     /**
      * the system partition used by the context factory
@@ -42,33 +36,24 @@
     private final RootNexus rootNexus;
 
 
-    public InterceptorContext( Map environment,
+    public InterceptorContext( StartupConfiguration configuration,
                                SystemPartition systemPartition,
                                GlobalRegistries globalRegistries,
-                               RootNexus rootNexus,
-                               Map config )
+                               RootNexus rootNexus )
     {
-        this.environment = environment;
+        this.configuration = configuration;
 
         this.systemPartition = systemPartition;
 
         this.globalRegistries = globalRegistries;
 
         this.rootNexus = rootNexus;
-
-        this.config = config;
-    }
-
-
-    public Map getEnvironment()
-    {
-        return environment;
     }
 
 
-    public Map getConfig()
+    public StartupConfiguration getConfiguration()
     {
-        return config;
+        return configuration;
     }
 
 

Modified: directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/jndi/CoreContextFactory.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/jndi/CoreContextFactory.java?rev=189964&r1=189963&r2=189964&view=diff
==============================================================================
--- directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/jndi/CoreContextFactory.java (original)
+++ directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/jndi/CoreContextFactory.java Fri Jun 10 07:22:46 2005
@@ -17,40 +17,55 @@
 package org.apache.ldap.server.jndi;
 
 
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.naming.Context;
+import javax.naming.Name;
+import javax.naming.NamingException;
+import javax.naming.directory.Attribute;
+import javax.naming.directory.Attributes;
+import javax.naming.spi.InitialContextFactory;
+
 import org.apache.ldap.common.exception.LdapAuthenticationNotSupportedException;
 import org.apache.ldap.common.exception.LdapConfigurationException;
 import org.apache.ldap.common.exception.LdapNoPermissionException;
 import org.apache.ldap.common.message.LockableAttributesImpl;
 import org.apache.ldap.common.message.ResultCodeEnum;
-import org.apache.ldap.common.name.LdapName;
 import org.apache.ldap.common.name.DnParser;
+import org.apache.ldap.common.name.LdapName;
 import org.apache.ldap.common.name.NameComponentNormalizer;
 import org.apache.ldap.common.schema.AttributeType;
 import org.apache.ldap.common.schema.Normalizer;
 import org.apache.ldap.common.util.DateUtils;
-import org.apache.ldap.common.util.StringTools;
-import org.apache.ldap.server.*;
-import org.apache.ldap.server.db.*;
+import org.apache.ldap.server.ApplicationPartition;
+import org.apache.ldap.server.ContextPartition;
+import org.apache.ldap.server.RootNexus;
+import org.apache.ldap.server.SystemPartition;
+import org.apache.ldap.server.configuration.Configuration;
+import org.apache.ldap.server.configuration.ContextPartitionConfiguration;
+import org.apache.ldap.server.configuration.ShutdownConfiguration;
+import org.apache.ldap.server.configuration.StartupConfiguration;
+import org.apache.ldap.server.configuration.SyncConfiguration;
+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.interceptor.InterceptorChain;
-import org.apache.ldap.server.interceptor.InterceptorConfigBuilder;
 import org.apache.ldap.server.interceptor.InterceptorContext;
-import org.apache.ldap.server.schema.*;
+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;
 import org.apache.ldap.server.schema.bootstrap.BootstrapRegistries;
 import org.apache.ldap.server.schema.bootstrap.BootstrapSchemaLoader;
 
-import javax.naming.Context;
-import javax.naming.Name;
-import javax.naming.NamingException;
-import javax.naming.directory.Attributes;
-import javax.naming.directory.Attribute;
-import javax.naming.spi.InitialContextFactory;
-import java.io.File;
-import java.lang.reflect.Constructor;
-import java.util.ArrayList;
-import java.util.Hashtable;
-import java.util.List;
-
 
 /**
  * A server-side provider implementation of a InitialContextFactory.  Can be
@@ -90,20 +105,6 @@
     /** shorthand reference to the admin principal distinguished name */
     protected static final Name ADMIN_NAME = SystemPartition.getAdminDn();
 
-    /** default path to working directory if WKDIR_ENV property is not set */
-    public static final String DEFAULT_WKDIR = "server-work";
-
-    /** default schema classes for the SCHEMAS_ENV property if not set */
-    protected static final String[] DEFAULT_SCHEMAS = new String[]
-    {
-        "org.apache.ldap.server.schema.bootstrap.CoreSchema",
-        "org.apache.ldap.server.schema.bootstrap.CosineSchema",
-        "org.apache.ldap.server.schema.bootstrap.ApacheSchema",
-        "org.apache.ldap.server.schema.bootstrap.InetorgpersonSchema",
-        "org.apache.ldap.server.schema.bootstrap.JavaSchema",
-        "org.apache.ldap.server.schema.bootstrap.SystemSchema"
-    };
-
     // ------------------------------------------------------------------------
     // Members
     // ------------------------------------------------------------------------
@@ -113,6 +114,9 @@
 
     /** the initial context environment that fired up the backend subsystem */
     protected Hashtable initialEnv;
+    
+    /** the configuration */
+    protected StartupConfiguration configuration;
 
     /** the system partition used by the context factory */
     protected SystemPartition system;
@@ -149,11 +153,11 @@
 
     public Context getInitialContext( Hashtable env ) throws NamingException
     {
-        env = ( Hashtable ) env.clone();
-
-        Context ctx = null;
 
-        if ( env.containsKey( EnvKeys.SHUTDOWN ) )
+        Configuration cfg = Configuration.toConfiguration( env );
+        
+        Context ctx;
+        if( cfg instanceof ShutdownConfiguration )
         {
             if ( this.provider == null )
             {
@@ -163,6 +167,7 @@
             try
             {
                 this.provider.shutdown();
+                return new DeadContext();
             }
             catch ( Throwable t )
             {
@@ -170,22 +175,23 @@
             }
             finally
             {
-                ctx = new DeadContext();
-
                 provider = null;
-
                 initialEnv = null;
+                configuration = null;
             }
-
-            return ctx;
         }
-
-        if ( env.containsKey( EnvKeys.SYNC ) )
+        else if( cfg instanceof SyncConfiguration )
         {
+            if ( this.provider == null )
+            {
+                return new DeadContext();
+            }
+            
             provider.sync();
-
             return provider.getLdapContext( env );
         }
+        
+        StartupConfiguration startupCfg = ( StartupConfiguration ) cfg;
 
         checkSecuritySettings( env );
 
@@ -199,15 +205,15 @@
         {
             // we need to check this here instead of in AuthenticationService
             // because otherwise we are going to start up the system incorrectly
-            if ( isAnonymous( env ) && env.containsKey( EnvKeys.DISABLE_ANONYMOUS ) )
+            if ( isAnonymous( env ) && !startupCfg.isAllowAnonymousAccess() )
             {
-                throw new LdapNoPermissionException( "cannot bind as anonymous "
-                        + "on startup while disabling anonymous binds w/ property: "
-                        + EnvKeys.DISABLE_ANONYMOUS );
+                throw new LdapNoPermissionException(
+                        "ApacheDS is configured to disallow anonymous access" );
             }
 
+            startupCfg.validate();
             this.initialEnv = env;
-
+            this.configuration = startupCfg;
             initialize();
 
             createMode = createBootstrapEntries();
@@ -218,34 +224,21 @@
              * entries at startup due to a chicken and egg like problem.  The value
              * of this property is a list of attributes to be added.
              */
-
-            if ( createMode && env.containsKey( EnvKeys.TEST_ENTRIES ) )
-            {
-                ArrayList list = ( ArrayList ) initialEnv.get( EnvKeys.TEST_ENTRIES );
-
-                if ( list != null )
-                {
-                    for ( int ii = 0; ii < list.size(); ii++ )
-                    {
-                        Attributes attributes = ( Attributes ) list.get( ii );
-
-                        attributes.put( "creatorsName", ADMIN );
-
-                        attributes.put( "createTimestamp", DateUtils.getGeneralizedTime() );
-
-                        Attribute dn = attributes.remove( "dn" );
-
-                        AttributeTypeRegistry registry = globalRegistries.getAttributeTypeRegistry();
-
-                        NameComponentNormalizer ncn = new ConcreteNameComponentNormalizer( registry );
-
-                        DnParser parser = new DnParser( ncn );
-
-                        Name ndn = parser.parse( ( String ) dn.get() );
-                        
-                        nexus.add( ( String ) dn.get(), ndn, attributes );
-                    }
-                }
+            
+            Iterator i = configuration.getTestEntries().iterator();
+            while( i.hasNext() )
+            {
+                Attributes entry = ( Attributes ) i.next();
+                entry.put( "creatorsName", ADMIN );
+                entry.put( "createTimestamp", DateUtils.getGeneralizedTime() );
+                
+                Attribute dn = entry.remove( "dn" );
+                AttributeTypeRegistry registry = globalRegistries.getAttributeTypeRegistry();
+                NameComponentNormalizer ncn = new ConcreteNameComponentNormalizer( registry );
+                DnParser parser = new DnParser( ncn );
+                Name ndn = parser.parse( ( String ) dn.get() );
+                
+                nexus.add( ( String ) dn.get(), ndn, entry );
             }
         }
 
@@ -502,24 +495,7 @@
         BootstrapRegistries bootstrapRegistries = new BootstrapRegistries();
 
         BootstrapSchemaLoader loader = new BootstrapSchemaLoader();
-
-        String[] schemas = DEFAULT_SCHEMAS;
-
-        if ( initialEnv.containsKey( EnvKeys.SCHEMAS ) )
-        {
-            String schemaList = ( String ) initialEnv.get( EnvKeys.SCHEMAS );
-
-            schemaList = StringTools.deepTrim( schemaList );
-
-            schemas = schemaList.split( " " );
-
-            for ( int ii = 0; ii < schemas.length; ii++ )
-            {
-                schemas[ii] = schemas[ii].trim();
-            }
-        }
-
-        loader.load( schemas, bootstrapRegistries );
+        loader.load( configuration.getBootstrapSchemas(), bootstrapRegistries );
 
         List errors = bootstrapRegistries.checkRefInteg();
 
@@ -536,34 +512,13 @@
         // Fire up the system partition
         // --------------------------------------------------------------------
 
-        String wkdir = DEFAULT_WKDIR;
-
-        if ( initialEnv.containsKey( EnvKeys.WKDIR ) )
-        {
-            wkdir = ( ( String ) initialEnv.get( EnvKeys.WKDIR ) ).trim();
-        }
-
-        File wkdirFile = new File( wkdir );
-
-        if ( wkdirFile.isAbsolute() )
-        {
-            if ( !wkdirFile.exists() )
-            {
-                throw new NamingException( "working directory " + wkdir + " does not exist" );
-            }
-        }
-        else
-        {
-            File current = new File( "." );
-
-            mkdirs( current.getAbsolutePath(), wkdir );
-        }
+        File workDir = configuration.getWorkingDirectory();
 
         LdapName suffix = new LdapName();
 
         suffix.add( SystemPartition.SUFFIX );
 
-        Database db = new JdbmDatabase( suffix, suffix, wkdir );
+        Database db = new JdbmDatabase( suffix, suffix, workDir.getPath() );
 
         AttributeTypeRegistry attributeTypeRegistry;
 
@@ -586,109 +541,76 @@
         AttributeType[] attributes = new AttributeType[]
         {
             attributeTypeRegistry.lookup( SystemPartition.ALIAS_OID ),
-
             attributeTypeRegistry.lookup( SystemPartition.EXISTANCE_OID ),
-
             attributeTypeRegistry.lookup( SystemPartition.HIERARCHY_OID ),
-
             attributeTypeRegistry.lookup( SystemPartition.NDN_OID ),
-
             attributeTypeRegistry.lookup( SystemPartition.ONEALIAS_OID ),
-
             attributeTypeRegistry.lookup( SystemPartition.SUBALIAS_OID ),
-
             attributeTypeRegistry.lookup( SystemPartition.UPDN_OID )
         };
 
         system = new SystemPartition( db, eng, attributes );
-
         globalRegistries = new GlobalRegistries( system, bootstrapRegistries );
-
         nexus = new RootNexus( system, new LockableAttributesImpl() );
-
         provider = new JndiProvider( nexus );
 
         // --------------------------------------------------------------------
         // Adding interceptors
         // --------------------------------------------------------------------
-        InterceptorChain interceptor = ( InterceptorChain ) initialEnv.get( EnvKeys.INTERCEPTORS );
-
-        if( interceptor == null )
-        {
-            // If custom interceptor is not specified, use defaule one.
-
-            interceptor = InterceptorChain.newDefaultChain();
-        }
-
-        interceptor.init( new InterceptorContext( initialEnv, system, globalRegistries, nexus,
-                InterceptorConfigBuilder.build( initialEnv, EnvKeys.INTERCEPTORS ) ) );
+        InterceptorChain interceptor = configuration.getInterceptors();
+        interceptor.init( new InterceptorContext( configuration, system, globalRegistries, nexus ) );
 
         provider.setInterceptor( interceptor );
 
         // fire up the app partitions now!
-        if ( initialEnv.get( EnvKeys.PARTITIONS ) != null )
-        {
-            startUpAppPartitions( wkdir );
-        }
+        startUpAppPartitions();
     }
 
     /**
      * Starts up all the application partitions that will be attached to naming contexts in the system.  Partition
      * database files are created within a subdirectory immediately under the Eve working directory base.
      *
-     * @param eveWkdir the base Eve working directory
      * @throws javax.naming.NamingException if there are problems creating and starting these new application
      *                                      partitions
      */
-    protected void startUpAppPartitions( String eveWkdir ) throws NamingException
+    protected void startUpAppPartitions() throws NamingException
     {
         OidRegistry oidRegistry = globalRegistries.getOidRegistry();
-
         AttributeTypeRegistry attributeTypeRegistry;
-
         attributeTypeRegistry = globalRegistries.getAttributeTypeRegistry();
-
         MatchingRuleRegistry reg = globalRegistries.getMatchingRuleRegistry();
 
-        // start getting all the parameters from the initial environment
-        ContextPartitionConfig[] configs = null;
-
-        configs = PartitionConfigBuilder.getContextPartitionConfigs( initialEnv );
+        File workDir = configuration.getWorkingDirectory();
 
-        for ( int ii = 0; ii < configs.length; ii++ )
+        Iterator i = configuration.getContextPartitionConfigurations().iterator();
+        while( i.hasNext() )
         {
+            ContextPartitionConfiguration cfg = ( ContextPartitionConfiguration ) i.next();
+            
             // ----------------------------------------------------------------
             // create working directory under eve directory for app partition
             // ----------------------------------------------------------------
 
-            String wkdir = eveWkdir + File.separator + configs[ii].getId();
-
-            mkdirs( eveWkdir, configs[ii].getId() );
+            File partitionWorkDir = new File( workDir.getPath() + File.separator + cfg.getName() );
+            partitionWorkDir.mkdirs();
 
             // ----------------------------------------------------------------
             // create the database/store
             // ----------------------------------------------------------------
 
-            Name upSuffix = new LdapName( configs[ii].getSuffix() );
-
+            Name upSuffix = new LdapName( cfg.getSuffix() );
             Normalizer dnNorm = reg.lookup( "distinguishedNameMatch" ) .getNormalizer();
-
-            Name normSuffix = new LdapName( ( String ) dnNorm.normalize( configs[ii].getSuffix() ) );
-
-            Database db = new JdbmDatabase( upSuffix, normSuffix, wkdir );
+            Name normSuffix = new LdapName( ( String ) dnNorm.normalize( cfg.getSuffix() ) );
+            Database db = new JdbmDatabase( upSuffix, normSuffix, partitionWorkDir.getPath() );
 
             // ----------------------------------------------------------------
             // create the search engine using db, enumerators and evaluators
             // ----------------------------------------------------------------
 
             ExpressionEvaluator evaluator;
-
             evaluator = new ExpressionEvaluator( db, oidRegistry, attributeTypeRegistry );
-
             ExpressionEnumerator enumerator;
-
             enumerator = new ExpressionEnumerator( db, attributeTypeRegistry, evaluator );
-
             SearchEngine eng = new DefaultSearchEngine( db, evaluator, enumerator );
 
             // ----------------------------------------------------------------
@@ -696,29 +618,24 @@
             // ----------------------------------------------------------------
 
             ArrayList attributeTypeList = new ArrayList();
-
             attributeTypeList.add( attributeTypeRegistry.lookup( SystemPartition.ALIAS_OID ) );
-
             attributeTypeList.add( attributeTypeRegistry.lookup( SystemPartition.EXISTANCE_OID ) );
-
             attributeTypeList.add( attributeTypeRegistry.lookup( SystemPartition.HIERARCHY_OID ) );
-
             attributeTypeList.add( attributeTypeRegistry.lookup( SystemPartition.NDN_OID ) );
-
             attributeTypeList.add( attributeTypeRegistry.lookup( SystemPartition.ONEALIAS_OID ) );
-
             attributeTypeList.add( attributeTypeRegistry.lookup( SystemPartition.SUBALIAS_OID ) );
-
             attributeTypeList.add( attributeTypeRegistry.lookup( SystemPartition.UPDN_OID ) );
 
             // ----------------------------------------------------------------
             // if user indices are specified add those attribute types as well
             // ----------------------------------------------------------------
 
-            for ( int jj = 0; jj < configs[ii].getIndices().length; jj++ )
+            Iterator j = cfg.getIndexedAttributes().iterator();
+            while( j.hasNext() )
             {
+                String attribute = ( String ) j.next();
                 attributeTypeList.add( attributeTypeRegistry
-                        .lookup( configs[ii].getIndices()[jj] ) );
+                        .lookup( attribute ) );
             }
 
             // ----------------------------------------------------------------
@@ -728,79 +645,31 @@
             AttributeType[] indexTypes = ( AttributeType[] ) attributeTypeList
                     .toArray( new AttributeType[attributeTypeList.size()] );
 
-            String partitionClass = configs[ii].getPartitionClass();
-
-            String properties = configs[ii].getProperties();
+            ContextPartition partition = cfg.getContextPartition();
 
-            ContextPartition partition = null;
-
-            if ( partitionClass == null )
+            if ( partition == null )
             {
                 // If custom partition is not defined, use the ApplicationPartion.
-                partition = new ApplicationPartition( upSuffix, normSuffix, db, eng, indexTypes );
-
-            }
-            else
-            {
-                // If custom partition is defined, instantiate it.
-                try
-                {
-                    Class clazz = Class.forName( partitionClass );
-
-                    Constructor constructor = clazz.getConstructor(
-                            new Class[] { Name.class, Name.class, String.class } );
-
-                    partition = ( ContextPartition ) constructor.newInstance(
-                            new Object[] { upSuffix, normSuffix, properties } );
-                }
-                catch ( Exception e )
-                {
-                    e.printStackTrace();
-                }
+                partition = new ApplicationPartition( db, eng, indexTypes );
             }
 
-            if ( partition != null ) 
-            { 
+            // Initialize the partition
+            try
+            {
+                partition.init( upSuffix, normSuffix );
                 nexus.register( partition );
             }
+            catch ( Exception e )
+            {
+                throw ( NamingException ) new NamingException(
+                        "Failed to initialize custom partition." ).initCause( e );
+            }
 
             // ----------------------------------------------------------------
             // add the nexus context entry
             // ----------------------------------------------------------------
 
-            partition.add( configs[ii].getSuffix(), normSuffix, configs[ii].getAttributes() );
+            partition.add( cfg.getSuffix(), normSuffix, cfg.getContextEntry() );
         }
-    }
-
-
-    /**
-     * Recursively creates a bunch of directories from a base down to a path.
-     *
-     * @param base the base directory to start at
-     * @param path the path to recursively create if we have to
-     * @return true if the target directory has been created or exists, false if we fail along the way somewhere
-     */
-    protected boolean mkdirs( String base, String path )
-    {
-        String[] comps = path.split( "/" );
-
-        File file = new File( base );
-
-        if ( !file.exists() )
-        {
-            file.mkdirs();
-        }
-
-        for ( int ii = 0; ii < comps.length; ii++ )
-        {
-            file = new File( file, comps[ii] );
-
-            if ( !file.exists() )
-            {
-                file.mkdirs();
-            }
-        }
-
-        return file.exists();
     }
 }

Modified: directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/schema/bootstrap/BootstrapSchemaLoader.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/schema/bootstrap/BootstrapSchemaLoader.java?rev=189964&r1=189963&r2=189964&view=diff
==============================================================================
--- directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/schema/bootstrap/BootstrapSchemaLoader.java (original)
+++ directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/schema/bootstrap/BootstrapSchemaLoader.java Fri Jun 10 07:22:46 2005
@@ -17,13 +17,40 @@
 package org.apache.ldap.server.schema.bootstrap;
 
 
-import org.apache.ldap.common.schema.*;
-import org.apache.ldap.server.jndi.ServerDirObjectFactory;
-import org.apache.ldap.server.jndi.ServerDirStateFactory;
-import org.apache.ldap.server.schema.*;
+import java.util.Collection;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Stack;
 
 import javax.naming.NamingException;
-import java.util.*;
+
+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.Normalizer;
+import org.apache.ldap.common.schema.ObjectClass;
+import org.apache.ldap.common.schema.Syntax;
+import org.apache.ldap.common.schema.SyntaxChecker;
+import org.apache.ldap.server.jndi.ServerDirObjectFactory;
+import org.apache.ldap.server.jndi.ServerDirStateFactory;
+import org.apache.ldap.server.schema.AttributeTypeRegistry;
+import org.apache.ldap.server.schema.ComparatorRegistry;
+import org.apache.ldap.server.schema.DITContentRuleRegistry;
+import org.apache.ldap.server.schema.DITStructureRuleRegistry;
+import org.apache.ldap.server.schema.MatchingRuleRegistry;
+import org.apache.ldap.server.schema.MatchingRuleUseRegistry;
+import org.apache.ldap.server.schema.NameFormRegistry;
+import org.apache.ldap.server.schema.NormalizerRegistry;
+import org.apache.ldap.server.schema.ObjectClassRegistry;
+import org.apache.ldap.server.schema.ObjectFactoryRegistry;
+import org.apache.ldap.server.schema.StateFactoryRegistry;
+import org.apache.ldap.server.schema.SyntaxCheckerRegistry;
+import org.apache.ldap.server.schema.SyntaxRegistry;
 
 
 /**
@@ -66,39 +93,30 @@
      * Loads a set of schemas by loading and running all producers for each
      * dependent schema first.
      *
-     * @param schemaClasses the full qualified class names of the schema classes
+     * @param bootstrapSchemas Collection of {@link BootstrapSchema}s to load
      * @param registries the registries to fill with producer created objects
      * @throws NamingException if there are any failures during this process
      */
-    public final void load( String[] schemaClasses, BootstrapRegistries registries )
+    public final void load( Collection bootstrapSchemas, BootstrapRegistries registries )
         throws NamingException
     {
-        BootstrapSchema[] schemas = new BootstrapSchema[schemaClasses.length];
+        BootstrapSchema[] schemas = new BootstrapSchema[ bootstrapSchemas.size() ];
+        schemas = ( BootstrapSchema[] ) bootstrapSchemas.toArray( schemas );
         HashMap loaded = new HashMap();
         HashMap notLoaded = new HashMap();
 
-
         for ( int ii = 0; ii < schemas.length; ii++ )
         {
-            try
-            {
-                Class schemaClass = Class.forName( schemaClasses[ii] );
-                schemas[ii] = ( BootstrapSchema ) schemaClass.newInstance();
-                notLoaded.put( schemas[ii].getSchemaName(), schemas[ii] );
-            }
-            catch ( Exception e )
-            {
-                String msg = "problem loading/creating " + schemaClasses[ii];
-                NamingException ne = new NamingException( msg );
-                ne.setRootCause( e );
-                throw ne;
-            }
+            notLoaded.put( schemas[ii].getSchemaName(), schemas[ii] );
         }
-
-        // kick it off by loading system which will never depend on anything
-        BootstrapSchema schema = ( BootstrapSchema ) notLoaded.get( "system" );
+        
+        BootstrapSchema schema;
+        
+        // Create system schema and kick it off by loading system which
+        // will never depend on anything.
+        schema = new SystemSchema();
         load( schema, registries );
-        notLoaded.remove( "system" );
+        notLoaded.remove( schema.getSchemaName() ); // Remove if user specified it.
         loaded.put( schema.getSchemaName(), schema );
 
         Iterator list = notLoaded.values().iterator();

Modified: directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/authn/SimpleAuthenticationTest.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/authn/SimpleAuthenticationTest.java?rev=189964&r1=189963&r2=189964&view=diff
==============================================================================
--- directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/authn/SimpleAuthenticationTest.java (original)
+++ directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/authn/SimpleAuthenticationTest.java Fri Jun 10 07:22:46 2005
@@ -17,22 +17,25 @@
 package org.apache.ldap.server.authn;
 
 
-import org.apache.ldap.common.exception.LdapConfigurationException;
-import org.apache.ldap.common.exception.LdapNoPermissionException;
-import org.apache.ldap.common.util.ArrayUtils;
-import org.apache.ldap.server.AbstractCoreTest;
-import org.apache.ldap.server.jndi.EnvKeys;
-import org.apache.mina.util.AvailablePortFinder;
+import java.io.File;
+import java.io.IOException;
+import java.util.Hashtable;
 
-import javax.naming.*;
+import javax.naming.ConfigurationException;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
 import javax.naming.directory.Attribute;
 import javax.naming.directory.Attributes;
 import javax.naming.directory.DirContext;
 import javax.naming.directory.InitialDirContext;
 import javax.naming.ldap.InitialLdapContext;
-import java.io.File;
-import java.io.IOException;
-import java.util.Hashtable;
+
+import org.apache.ldap.common.exception.LdapConfigurationException;
+import org.apache.ldap.common.exception.LdapNoPermissionException;
+import org.apache.ldap.common.util.ArrayUtils;
+import org.apache.ldap.server.AbstractCoreTest;
+import org.apache.mina.util.AvailablePortFinder;
 
 
 /**
@@ -182,11 +185,9 @@
         doDelete( new File( "target" + File.separator + "eve" ) );
         Hashtable env = new Hashtable();
         env.put( Context.SECURITY_AUTHENTICATION, "none" );
-        env.put( EnvKeys.DISABLE_ANONYMOUS, "true" );
-
-        int port = AvailablePortFinder.getNextAvailable( 1024 );
-
-        env.put( EnvKeys.LDAP_PORT, String.valueOf( port ) );
+        
+        configuration.setAllowAnonymousAccess( false );
+        configuration.setLdapPort( AvailablePortFinder.getNextAvailable( 1024 ) );
 
         try
         {
@@ -200,7 +201,7 @@
         // ok this should start up the system now as admin
         Hashtable anonymous = new Hashtable();
 
-        anonymous.put( EnvKeys.LDAP_PORT, String.valueOf( port ) );
+        configuration.setLdapPort( AvailablePortFinder.getNextAvailable( 1024 ) );
 
         InitialLdapContext ctx = ( InitialLdapContext ) setSysRoot( anonymous );
         assertNotNull( ctx );

Modified: directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/jndi/RootDSETest.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/jndi/RootDSETest.java?rev=189964&r1=189963&r2=189964&view=diff
==============================================================================
--- directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/jndi/RootDSETest.java (original)
+++ directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/jndi/RootDSETest.java Fri Jun 10 07:22:46 2005
@@ -17,9 +17,9 @@
 package org.apache.ldap.server.jndi;
 
 
-import junit.framework.TestCase;
-import org.apache.commons.io.FileUtils;
-import org.apache.ldap.common.exception.LdapNoPermissionException;
+import java.io.File;
+import java.io.IOException;
+import java.util.Hashtable;
 
 import javax.naming.Context;
 import javax.naming.InitialContext;
@@ -27,9 +27,13 @@
 import javax.naming.directory.Attributes;
 import javax.naming.directory.DirContext;
 import javax.naming.directory.ModificationItem;
-import java.io.File;
-import java.io.IOException;
-import java.util.Hashtable;
+
+import junit.framework.TestCase;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.ldap.common.exception.LdapNoPermissionException;
+import org.apache.ldap.server.configuration.MutableStartupConfiguration;
+import org.apache.ldap.server.configuration.ShutdownConfiguration;
 
 
 /**
@@ -90,7 +94,7 @@
 
         env.put( Context.INITIAL_CONTEXT_FACTORY, "org.apache.ldap.server.jndi.CoreContextFactory" );
 
-        env.put( EnvKeys.SHUTDOWN, "" );
+        env.putAll( new ShutdownConfiguration().toJndiEnvironment() );
 
         env.put( Context.SECURITY_PRINCIPAL, "uid=admin,ou=system" );
 
@@ -108,20 +112,16 @@
      */
     public void testGetInitialContext() throws NamingException
     {
-        Hashtable env = new Hashtable();
-
-        env.put( EnvKeys.WKDIR, "target/server" );
+        MutableStartupConfiguration cfg = new MutableStartupConfiguration();
+        cfg.setWorkingDirectory( new File( "target" + File.separator + "server" ) );
 
+        Hashtable env = new Hashtable( cfg.toJndiEnvironment() );
         env.put( Context.PROVIDER_URL, "" );
-
         env.put( Context.SECURITY_PRINCIPAL, "uid=admin,ou=system" );
-
         env.put( Context.SECURITY_CREDENTIALS, "secret" );
-
         env.put( Context.INITIAL_CONTEXT_FACTORY, CoreContextFactory.class.getName() );
 
         InitialContext initCtx = new InitialContext( env );
-
         assertNotNull( initCtx );
     }
 
@@ -134,16 +134,13 @@
      */
     public void testGetInitialContextLookupAttributes() throws NamingException
     {
-        Hashtable env = new Hashtable();
-
-        env.put( EnvKeys.WKDIR, "target/server" );
+        MutableStartupConfiguration cfg = new MutableStartupConfiguration();
+        cfg.setWorkingDirectory( new File( "target" + File.separator + "server" ) );
 
+        Hashtable env = new Hashtable( cfg.toJndiEnvironment() );
         env.put( Context.PROVIDER_URL, "" );
-
         env.put( Context.SECURITY_PRINCIPAL, "uid=admin,ou=system" );
-
         env.put( Context.SECURITY_CREDENTIALS, "secret" );
-
         env.put( Context.INITIAL_CONTEXT_FACTORY, CoreContextFactory.class.getName() );
 
         InitialContext initCtx = new InitialContext( env );
@@ -167,16 +164,13 @@
      */
     public void testGetInitialContextLookupAttributesByName() throws NamingException
     {
-        Hashtable env = new Hashtable();
-
-        env.put( EnvKeys.WKDIR, "target/server" );
+        MutableStartupConfiguration cfg = new MutableStartupConfiguration();
+        cfg.setWorkingDirectory( new File( "target" + File.separator + "server" ) );
 
+        Hashtable env = new Hashtable( cfg.toJndiEnvironment() );
         env.put( Context.PROVIDER_URL, "" );
-
         env.put( Context.SECURITY_PRINCIPAL, "uid=admin,ou=system" );
-
         env.put( Context.SECURITY_CREDENTIALS, "secret" );
-
         env.put( Context.INITIAL_CONTEXT_FACTORY, CoreContextFactory.class.getName() );
 
         InitialContext initCtx = new InitialContext( env );
@@ -202,16 +196,13 @@
      */
     public void testDelete() throws NamingException
     {
-        Hashtable env = new Hashtable();
-
-        env.put( EnvKeys.WKDIR, "target/server" );
+        MutableStartupConfiguration cfg = new MutableStartupConfiguration();
+        cfg.setWorkingDirectory( new File( "target" + File.separator + "server" ) );
 
+        Hashtable env = new Hashtable( cfg.toJndiEnvironment() );
         env.put( Context.PROVIDER_URL, "" );
-
         env.put( Context.SECURITY_PRINCIPAL, "uid=admin,ou=system" );
-
         env.put( Context.SECURITY_CREDENTIALS, "secret" );
-
         env.put( Context.INITIAL_CONTEXT_FACTORY, CoreContextFactory.class.getName() );
 
         InitialContext initCtx = new InitialContext( env );
@@ -244,16 +235,13 @@
      */
     public void testRename() throws NamingException
     {
-        Hashtable env = new Hashtable();
-
-        env.put( EnvKeys.WKDIR, "target/server" );
+        MutableStartupConfiguration cfg = new MutableStartupConfiguration();
+        cfg.setWorkingDirectory( new File( "target" + File.separator + "server" ) );
 
+        Hashtable env = new Hashtable( cfg.toJndiEnvironment() );
         env.put( Context.PROVIDER_URL, "" );
-
         env.put( Context.SECURITY_PRINCIPAL, "uid=admin,ou=system" );
-
         env.put( Context.SECURITY_CREDENTIALS, "secret" );
-
         env.put( Context.INITIAL_CONTEXT_FACTORY, CoreContextFactory.class.getName() );
 
         InitialContext initCtx = new InitialContext( env );
@@ -286,10 +274,10 @@
      */
     public void testModify() throws NamingException
     {
-        Hashtable env = new Hashtable();
-
-        env.put( EnvKeys.WKDIR, "target/server" );
+        MutableStartupConfiguration cfg = new MutableStartupConfiguration();
+        cfg.setWorkingDirectory( new File( "target" + File.separator + "server" ) );
 
+        Hashtable env = new Hashtable( cfg.toJndiEnvironment() );
         env.put( Context.PROVIDER_URL, "" );
 
         env.put( Context.SECURITY_PRINCIPAL, "uid=admin,ou=system" );
@@ -328,10 +316,10 @@
      */
     public void testModify2() throws NamingException
     {
-        Hashtable env = new Hashtable();
-
-        env.put( EnvKeys.WKDIR, "target/server" );
+        MutableStartupConfiguration cfg = new MutableStartupConfiguration();
+        cfg.setWorkingDirectory( new File( "target" + File.separator + "server" ) );
 
+        Hashtable env = new Hashtable( cfg.toJndiEnvironment() );
         env.put( Context.PROVIDER_URL, "" );
 
         env.put( Context.SECURITY_PRINCIPAL, "uid=admin,ou=system" );

Modified: directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/jndi/ServiceRegistryPassthruTest.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/jndi/ServiceRegistryPassthruTest.java?rev=189964&r1=189963&r2=189964&view=diff
==============================================================================
--- directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/jndi/ServiceRegistryPassthruTest.java (original)
+++ directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/jndi/ServiceRegistryPassthruTest.java Fri Jun 10 07:22:46 2005
@@ -35,10 +35,11 @@
 
     protected void setUp() throws Exception
     {
+        registry = new SimpleServiceRegistry();
+
         if ( getName().equals( "testUsePassthru" ) )
         {
-            registry = new SimpleServiceRegistry();
-            super.extras.put( EnvKeys.PASSTHRU, registry );
+            configuration.setMinaServiceRegistry( registry );
         }
 
         super.setUp();
@@ -48,18 +49,18 @@
     protected void tearDown() throws Exception
     {
         super.tearDown();
-        registry = null;
+        registry.unbindAll();
     }
 
 
     public void testUsePassthru() throws Exception
     {
-        assertTrue( sysRoot.getEnvironment().containsKey( EnvKeys.PASSTHRU ) );
+        assertEquals( 1, registry.getAllServices().size() );
     }
 
 
     public void testDoNotUsePassthru() throws Exception
     {
-        assertFalse( sysRoot.getEnvironment().containsKey( EnvKeys.PASSTHRU ) );
+        assertEquals( 0, registry.getAllServices().size() );
     }
 }

Modified: directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/jndi/ShutdownTest.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/jndi/ShutdownTest.java?rev=189964&r1=189963&r2=189964&view=diff
==============================================================================
--- directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/jndi/ShutdownTest.java (original)
+++ directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/jndi/ShutdownTest.java Fri Jun 10 07:22:46 2005
@@ -18,6 +18,7 @@
 
 
 import org.apache.ldap.server.AbstractCoreTest;
+import org.apache.ldap.server.configuration.ShutdownConfiguration;
 
 
 /**
@@ -43,17 +44,7 @@
      */
     public void testShutdownNonNullContext() throws Exception
     {
-        overrides.put( EnvKeys.SHUTDOWN, "true" );
-
-        try
-        {
-            setSysRoot( "uid=admin,ou=system", "secret" );
-        }
-        finally
-        {
-            overrides.remove( EnvKeys.SHUTDOWN );
-        }
-
+        setSysRoot( "uid=admin,ou=system", "secret", new ShutdownConfiguration() );
         assertNotNull( sysRoot );
     }
 
@@ -65,20 +56,13 @@
      */
     public void testShutdownRestart() throws Exception
     {
-        overrides.put( EnvKeys.SHUTDOWN, "true" );
-
-        try
-        {
-            setSysRoot( "uid=admin,ou=system", "secret" );
-        }
-        finally
-        {
-            overrides.remove( EnvKeys.SHUTDOWN );
-        }
-
+        setSysRoot( "uid=admin,ou=system", "secret", new ShutdownConfiguration() );
         assertNotNull( sysRoot );
 
         // restart the system now
-        setSysRoot( "uid=admin,ou=system", "secret" );
+        setSysRoot( "uid=admin,ou=system", "secret", configuration );
+        
+        // Shutdown again (tearDown is overriden)
+        setSysRoot( "uid=admin,ou=system", "secret", new ShutdownConfiguration() );
     }
 }

Modified: directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/jndi/SyncTest.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/jndi/SyncTest.java?rev=189964&r1=189963&r2=189964&view=diff
==============================================================================
--- directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/jndi/SyncTest.java (original)
+++ directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/jndi/SyncTest.java Fri Jun 10 07:22:46 2005
@@ -17,10 +17,11 @@
 package org.apache.ldap.server.jndi;
 
 
-import org.apache.ldap.server.AbstractCoreTest;
-
 import javax.naming.directory.Attributes;
 
+import org.apache.ldap.server.AbstractCoreTest;
+import org.apache.ldap.server.configuration.SyncConfiguration;
+
 
 /**
  * Tests the sync operation on the JNDI provider.
@@ -38,8 +39,7 @@
      */
     public void testSyncNoException() throws Exception
     {
-        overrides.put( EnvKeys.SYNC, "true" );
-        sysRoot = setSysRoot( "uid=admin,ou=system", "secret" );
+        sysRoot = setSysRoot( "uid=admin,ou=system", "secret", new SyncConfiguration() );
         assertNotNull( sysRoot );
     }
 
@@ -52,8 +52,7 @@
      */
     public void testPostSyncLookup() throws Exception
     {
-        overrides.put( EnvKeys.SYNC, "true" );
-        sysRoot = setSysRoot( "uid=admin,ou=system", "secret" );
+        sysRoot = setSysRoot( "uid=admin,ou=system", "secret", new SyncConfiguration() );
         Attributes users = sysRoot.getAttributes( "ou=users" );
 
         // assert making sure the entry is ok



Mime
View raw message