You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by ak...@apache.org on 2007/10/06 08:48:45 UTC
svn commit: r582462 [2/10] - in /directory: apacheds/branches/bigbang/
apacheds/branches/bigbang/core-unit/src/main/java/org/apache/directory/server/core/unit/
apacheds/branches/bigbang/core-unit/src/test/java/org/apache/directory/server/core/
apacheds...
Modified: directory/apacheds/branches/bigbang/core-unit/src/test/java/org/apache/directory/server/core/jndi/ShutdownITest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core-unit/src/test/java/org/apache/directory/server/core/jndi/ShutdownITest.java?rev=582462&r1=582461&r2=582462&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core-unit/src/test/java/org/apache/directory/server/core/jndi/ShutdownITest.java (original)
+++ directory/apacheds/branches/bigbang/core-unit/src/test/java/org/apache/directory/server/core/jndi/ShutdownITest.java Fri Oct 5 23:48:35 2007
@@ -20,8 +20,6 @@
package org.apache.directory.server.core.jndi;
-import org.apache.directory.server.core.configuration.ShutdownConfiguration;
-import org.apache.directory.server.core.configuration.SyncConfiguration;
import org.apache.directory.server.core.unit.AbstractAdminTestCase;
@@ -48,34 +46,22 @@
*/
public void testShutdownNonNullContext() throws Exception
{
- // for some reason if we don't synch first windows blows chuncks when
- // attempting to delete the db files - perhaps this buys more time rather
- // because there is less to sync when shutting down so shutdown happens
- // faster before the doDelete method is called. Regardless this does
- // deserve some investigation at some point after the bigbang cleanup.
- setContextRoots( "uid=admin,ou=system", "secret", new SyncConfiguration() );
- setContextRoots( "uid=admin,ou=system", "secret", new ShutdownConfiguration() );
+ service.shutdown();
assertNotNull( sysRoot );
- doDelete( configuration.getWorkingDirectory() );
+ doDelete( service.getWorkingDirectory() );
}
- /**
- *
- *
- * @throws Exception
- */
public void testShutdownRestart() throws Exception
{
- setContextRoots( "uid=admin,ou=system", "secret", new SyncConfiguration() );
- setContextRoots( "uid=admin,ou=system", "secret", new ShutdownConfiguration() );
+ service.shutdown();
assertNotNull( sysRoot );
// restart the system now
- setContextRoots( "uid=admin,ou=system", "secret", configuration );
+ setContextRoots( "uid=admin,ou=system", "secret" );
// (tearDown is overriden)
super.tearDown();
- doDelete( configuration.getWorkingDirectory() );
+ doDelete( service.getWorkingDirectory() );
}
}
Modified: directory/apacheds/branches/bigbang/core-unit/src/test/java/org/apache/directory/server/core/jndi/SyncITest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core-unit/src/test/java/org/apache/directory/server/core/jndi/SyncITest.java?rev=582462&r1=582461&r2=582462&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core-unit/src/test/java/org/apache/directory/server/core/jndi/SyncITest.java (original)
+++ directory/apacheds/branches/bigbang/core-unit/src/test/java/org/apache/directory/server/core/jndi/SyncITest.java Fri Oct 5 23:48:35 2007
@@ -22,7 +22,6 @@
import javax.naming.directory.Attributes;
-import org.apache.directory.server.core.configuration.SyncConfiguration;
import org.apache.directory.server.core.unit.AbstractAdminTestCase;
@@ -42,7 +41,7 @@
*/
public void testSyncNoException() throws Exception
{
- setContextRoots( "uid=admin,ou=system", "secret", new SyncConfiguration() );
+ service.sync();
assertNotNull( sysRoot );
}
@@ -55,8 +54,7 @@
*/
public void testPostSyncLookup() throws Exception
{
- setContextRoots( "uid=admin,ou=system", "secret", new SyncConfiguration() );
-
+ service.sync();
Attributes users = sysRoot.getAttributes( "ou=users" );
// assert making sure the entry is ok
Modified: directory/apacheds/branches/bigbang/core-unit/src/test/java/org/apache/directory/server/core/prefs/ServerPreferencesFactoryITest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core-unit/src/test/java/org/apache/directory/server/core/prefs/ServerPreferencesFactoryITest.java?rev=582462&r1=582461&r2=582462&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core-unit/src/test/java/org/apache/directory/server/core/prefs/ServerPreferencesFactoryITest.java (original)
+++ directory/apacheds/branches/bigbang/core-unit/src/test/java/org/apache/directory/server/core/prefs/ServerPreferencesFactoryITest.java Fri Oct 5 23:48:35 2007
@@ -36,7 +36,7 @@
{
public void testSystemRoot()
{
- ServerPreferencesFactory factory = new ServerPreferencesFactory();
+ ServerPreferencesFactory factory = new ServerPreferencesFactory( service );
Preferences prefs = factory.systemRoot();
assertNotNull( prefs );
Modified: directory/apacheds/branches/bigbang/core-unit/src/test/java/org/apache/directory/server/core/prefs/ServerSystemPreferencesITest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core-unit/src/test/java/org/apache/directory/server/core/prefs/ServerSystemPreferencesITest.java?rev=582462&r1=582461&r2=582462&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core-unit/src/test/java/org/apache/directory/server/core/prefs/ServerSystemPreferencesITest.java (original)
+++ directory/apacheds/branches/bigbang/core-unit/src/test/java/org/apache/directory/server/core/prefs/ServerSystemPreferencesITest.java Fri Oct 5 23:48:35 2007
@@ -41,7 +41,7 @@
public void setUp() throws Exception
{
super.setUp();
- prefs = new ServerSystemPreferences();
+ prefs = new ServerSystemPreferences( service );
}
Copied: directory/apacheds/branches/bigbang/core-unit/src/test/java/org/apache/directory/server/core/schema/ObjectClassCreateITest.java (from r581137, directory/apacheds/branches/bigbang/core-unit/src/test/java/org/apache/directory/server/core/schema/ObjectClassCreateTest.java)
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core-unit/src/test/java/org/apache/directory/server/core/schema/ObjectClassCreateITest.java?p2=directory/apacheds/branches/bigbang/core-unit/src/test/java/org/apache/directory/server/core/schema/ObjectClassCreateITest.java&p1=directory/apacheds/branches/bigbang/core-unit/src/test/java/org/apache/directory/server/core/schema/ObjectClassCreateTest.java&r1=581137&r2=582462&rev=582462&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core-unit/src/test/java/org/apache/directory/server/core/schema/ObjectClassCreateTest.java (original)
+++ directory/apacheds/branches/bigbang/core-unit/src/test/java/org/apache/directory/server/core/schema/ObjectClassCreateITest.java Fri Oct 5 23:48:35 2007
@@ -29,7 +29,7 @@
import org.apache.directory.server.core.unit.AbstractAdminTestCase;
import org.apache.directory.shared.ldap.name.LdapDN;
-public class ObjectClassCreateTest extends AbstractAdminTestCase
+public class ObjectClassCreateITest extends AbstractAdminTestCase
{
private String testOID =
"1.3.6.1.4.1.18060.0.4.0.3.1.555555.5555.5555555";
Propchange: directory/apacheds/branches/bigbang/core-unit/src/test/java/org/apache/directory/server/core/schema/ObjectClassCreateITest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: directory/apacheds/branches/bigbang/core-unit/src/test/java/org/apache/directory/server/core/schema/SubschemaSubentryITest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core-unit/src/test/java/org/apache/directory/server/core/schema/SubschemaSubentryITest.java?rev=582462&r1=582461&r2=582462&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core-unit/src/test/java/org/apache/directory/server/core/schema/SubschemaSubentryITest.java (original)
+++ directory/apacheds/branches/bigbang/core-unit/src/test/java/org/apache/directory/server/core/schema/SubschemaSubentryITest.java Fri Oct 5 23:48:35 2007
@@ -20,29 +20,9 @@
package org.apache.directory.server.core.schema;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Hashtable;
-import java.util.List;
-import java.util.TimeZone;
-
-import javax.naming.Context;
-import javax.naming.NamingEnumeration;
-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.directory.SearchControls;
-import javax.naming.directory.SearchResult;
-
import jdbm.helper.IntegerComparator;
-
-import org.apache.directory.server.core.configuration.Configuration;
-import org.apache.directory.server.core.configuration.StartupConfiguration;
+import org.apache.directory.server.core.DefaultDirectoryService;
+import org.apache.directory.server.core.DirectoryService;
import org.apache.directory.server.core.unit.AbstractAdminTestCase;
import org.apache.directory.shared.ldap.exception.LdapNameAlreadyBoundException;
import org.apache.directory.shared.ldap.exception.LdapOperationNotSupportedException;
@@ -53,25 +33,20 @@
import org.apache.directory.shared.ldap.name.LdapDN;
import org.apache.directory.shared.ldap.schema.AttributeType;
import org.apache.directory.shared.ldap.schema.DeepTrimNormalizer;
-import org.apache.directory.shared.ldap.schema.syntax.AcceptAllSyntaxChecker;
-import org.apache.directory.shared.ldap.schema.syntax.AttributeTypeDescription;
-import org.apache.directory.shared.ldap.schema.syntax.ComparatorDescription;
-import org.apache.directory.shared.ldap.schema.syntax.LdapSyntaxDescription;
-import org.apache.directory.shared.ldap.schema.syntax.MatchingRuleDescription;
-import org.apache.directory.shared.ldap.schema.syntax.NormalizerDescription;
-import org.apache.directory.shared.ldap.schema.syntax.ObjectClassDescription;
-import org.apache.directory.shared.ldap.schema.syntax.SyntaxChecker;
-import org.apache.directory.shared.ldap.schema.syntax.SyntaxCheckerDescription;
-import org.apache.directory.shared.ldap.schema.syntax.parser.AttributeTypeDescriptionSchemaParser;
-import org.apache.directory.shared.ldap.schema.syntax.parser.ComparatorDescriptionSchemaParser;
-import org.apache.directory.shared.ldap.schema.syntax.parser.LdapSyntaxDescriptionSchemaParser;
-import org.apache.directory.shared.ldap.schema.syntax.parser.MatchingRuleDescriptionSchemaParser;
-import org.apache.directory.shared.ldap.schema.syntax.parser.NormalizerDescriptionSchemaParser;
-import org.apache.directory.shared.ldap.schema.syntax.parser.ObjectClassDescriptionSchemaParser;
-import org.apache.directory.shared.ldap.schema.syntax.parser.SyntaxCheckerDescriptionSchemaParser;
+import org.apache.directory.shared.ldap.schema.syntax.*;
+import org.apache.directory.shared.ldap.schema.syntax.parser.*;
import org.apache.directory.shared.ldap.util.Base64;
import org.apache.directory.shared.ldap.util.DateUtils;
+import javax.naming.Context;
+import javax.naming.NamingEnumeration;
+import javax.naming.NamingException;
+import javax.naming.directory.*;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.*;
+
/**
* An integration test class for performing various operations on the
@@ -1825,7 +1800,7 @@
env.put( Context.SECURITY_AUTHENTICATION, "simple" );
env.put( Context.SECURITY_CREDENTIALS, "secret" );
env.put( Context.SECURITY_PRINCIPAL, "cn=bogus user,ou=system" );
- env.put( Configuration.JNDI_KEY, new StartupConfiguration() );
+ env.put( DirectoryService.JNDI_KEY, service );
InitialDirContext ctx = new InitialDirContext( env );
// now let's add another attribute type definition to the schema but
Modified: directory/apacheds/branches/bigbang/core/pom.xml
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/pom.xml?rev=582462&r1=582461&r2=582462&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core/pom.xml (original)
+++ directory/apacheds/branches/bigbang/core/pom.xml Fri Oct 5 23:48:35 2007
@@ -94,12 +94,6 @@
<version>${pom.version}</version>
<scope>test</scope>
</dependency>
-
- <dependency>
- <groupId>org.apache.directory.server</groupId>
- <artifactId>apacheds-kerberos-shared</artifactId>
- <version>${pom.version}</version>
- </dependency>
</dependencies>
<build>
Modified: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java?rev=582462&r1=582461&r2=582462&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java (original)
+++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java Fri Oct 5 23:48:35 2007
@@ -20,19 +20,20 @@
package org.apache.directory.server.core;
+import org.apache.directory.server.core.authn.AuthenticationService;
+import org.apache.directory.server.core.authn.LdapPrincipal;
import org.apache.directory.server.core.authz.AuthorizationService;
-import org.apache.directory.server.core.configuration.Configuration;
-import org.apache.directory.server.core.configuration.ConfigurationException;
-import org.apache.directory.server.core.configuration.StartupConfiguration;
+import org.apache.directory.server.core.authz.DefaultAuthorizationService;
+import org.apache.directory.server.core.collective.CollectiveAttributeService;
+import org.apache.directory.server.core.event.EventService;
+import org.apache.directory.server.core.exception.ExceptionService;
import org.apache.directory.server.core.interceptor.Interceptor;
import org.apache.directory.server.core.interceptor.InterceptorChain;
-import org.apache.directory.server.core.interceptor.context.AddContextPartitionOperationContext;
-import org.apache.directory.server.core.interceptor.context.AddOperationContext;
-import org.apache.directory.server.core.interceptor.context.EntryOperationContext;
-import org.apache.directory.server.core.interceptor.context.LookupOperationContext;
-import org.apache.directory.server.core.jndi.AbstractContextFactory;
+import org.apache.directory.server.core.interceptor.context.*;
import org.apache.directory.server.core.jndi.DeadContext;
import org.apache.directory.server.core.jndi.ServerLdapContext;
+import org.apache.directory.server.core.normalization.NormalizationService;
+import org.apache.directory.server.core.operational.OperationalAttributeService;
import org.apache.directory.server.core.partition.DefaultPartitionNexus;
import org.apache.directory.server.core.partition.Partition;
import org.apache.directory.server.core.partition.PartitionNexus;
@@ -40,14 +41,19 @@
import org.apache.directory.server.core.partition.impl.btree.Index;
import org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmIndex;
import org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmPartition;
+import org.apache.directory.server.core.referral.ReferralService;
import org.apache.directory.server.core.schema.PartitionSchemaLoader;
import org.apache.directory.server.core.schema.SchemaManager;
import org.apache.directory.server.core.schema.SchemaPartitionDao;
+import org.apache.directory.server.core.schema.SchemaService;
+import org.apache.directory.server.core.subtree.SubentryService;
+import org.apache.directory.server.core.trigger.TriggerService;
import org.apache.directory.server.schema.SerializableComparator;
import org.apache.directory.server.schema.bootstrap.*;
import org.apache.directory.server.schema.bootstrap.partition.DbFileListing;
import org.apache.directory.server.schema.bootstrap.partition.SchemaPartitionExtractor;
import org.apache.directory.server.schema.registries.*;
+import org.apache.directory.shared.ldap.aci.AuthenticationLevel;
import org.apache.directory.shared.ldap.constants.JndiPropertyConstants;
import org.apache.directory.shared.ldap.constants.SchemaConstants;
import org.apache.directory.shared.ldap.constants.ServerDNConstants;
@@ -81,23 +87,16 @@
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
-class DefaultDirectoryService extends DirectoryService
+public class DefaultDirectoryService extends DirectoryService
{
- private static final Logger log = LoggerFactory.getLogger( DefaultDirectoryService.class );
+ private static final Logger LOG = LoggerFactory.getLogger( DefaultDirectoryService.class );
private static final String BINARY_KEY = JndiPropertyConstants.JNDI_LDAP_ATTRIBUTES_BINARY;
- private final DirectoryServiceConfiguration configuration = new DefaultDirectoryServiceConfiguration( this );
-
- private DirectoryServiceListener serviceListener;
-
private SchemaManager schemaManager;
/** the initial context environment that fired up the backend subsystem */
private Hashtable<String, Object> environment;
- /** the configuration */
- private StartupConfiguration startupConfiguration;
-
/** the registries for system schema objects */
private Registries registries;
@@ -111,7 +110,7 @@
private InterceptorChain interceptorChain;
/** whether or not this instance has been shutdown */
- private boolean started = false;
+ private boolean started;
// ------------------------------------------------------------------------
@@ -122,13 +121,10 @@
/**
* Creates a new instance.
*/
- public DefaultDirectoryService( String instanceId )
+ public DefaultDirectoryService()
{
- if ( instanceId == null )
- {
- throw new NullPointerException( "instanceId" );
- }
- this.instanceId = instanceId;
+ environment = new Hashtable<String,Object>();
+ setDefaultInterceptorConfigurations();
}
@@ -137,26 +133,315 @@
// ------------------------------------------------------------------------
-// public static final int MAX_THREADS_DEFAULT = 32;
-// public static final int MAX_SIZE_LIMIT_DEFAULT = 100;
-// public static final int MAX_TIME_LIMIT_DEFAULT = 10000;
-//
+ public static final int MAX_SIZE_LIMIT_DEFAULT = 100;
+ public static final int MAX_TIME_LIMIT_DEFAULT = 10000;
+
private String instanceId;
-// private File workingDirectory = new File( "server-work" );
-// private boolean exitVmOnShutdown = true; // allow by default
-// private boolean shutdownHookEnabled = true; // allow by default
-// private boolean allowAnonymousAccess = true; // allow by default
-// private boolean accessControlEnabled; // off by default
-// private boolean denormalizeOpAttrsEnabled; // off by default
-// private int maxThreads = MAX_THREADS_DEFAULT; // set to default value
-// private int maxSizeLimit = MAX_SIZE_LIMIT_DEFAULT; // set to default value
-// private int maxTimeLimit = MAX_TIME_LIMIT_DEFAULT; // set to default value (milliseconds)
-// private List<Interceptor> interceptors;
-// private Partition systemPartition;
-// private Set<? extends Partition> partitions = new HashSet<Partition>();
-// private List<? extends Entry> testEntries = new ArrayList<Entry>(); // List<Attributes>
+ private File workingDirectory = new File( "server-work" );
+ private boolean exitVmOnShutdown = true; // allow by default
+ private boolean shutdownHookEnabled = true; // allow by default
+ private boolean allowAnonymousAccess = true; // allow by default
+ private boolean accessControlEnabled; // off by default
+ private boolean denormalizeOpAttrsEnabled; // off by default
+ private int maxSizeLimit = MAX_SIZE_LIMIT_DEFAULT; // set to default value
+ private int maxTimeLimit = MAX_TIME_LIMIT_DEFAULT; // set to default value (milliseconds)
+ private List<Interceptor> interceptors;
+ private Partition systemPartition;
+ private Set<Partition> partitions = new HashSet<Partition>();
+ private List<? extends Entry> testEntries = new ArrayList<Entry>(); // List<Attributes>
+
+
+
+ public void setInstanceId( String instanceId )
+ {
+ this.instanceId = instanceId;
+ }
+ public String getInstanceId()
+ {
+ return instanceId;
+ }
+
+
+ /**
+ * Gets the {@link Partition}s used by this DirectoryService.
+ *
+ * @return the set of partitions used
+ */
+ public Set<? extends Partition> getPartitions()
+ {
+ Set<Partition> cloned = new HashSet<Partition>();
+ cloned.addAll( partitions );
+ return cloned;
+ }
+
+
+ /**
+ * Sets {@link Partition}s used by this DirectoryService.
+ *
+ * @param partitions the partitions to used
+ */
+ public void setPartitions( Set<? extends Partition> partitions )
+ {
+ Set<Partition> cloned = new HashSet<Partition>();
+ cloned.addAll( partitions );
+ Set<String> names = new HashSet<String>();
+ for ( Partition partition : cloned )
+ {
+ String id = partition.getId();
+ if ( names.contains( id ) )
+ {
+ LOG.warn( "Encountered duplicate partition {} identifier.", id );
+ }
+ names.add( id );
+ }
+
+ this.partitions = cloned;
+ }
+
+
+ /**
+ * Returns <tt>true</tt> if access control checks are enabled.
+ *
+ * @return true if access control checks are enabled, false otherwise
+ */
+ public boolean isAccessControlEnabled()
+ {
+ return accessControlEnabled;
+ }
+
+
+ /**
+ * Sets whether to enable basic access control checks or not.
+ *
+ * @param accessControlEnabled true to enable access control checks, false otherwise
+ */
+ public void setAccessControlEnabled( boolean accessControlEnabled )
+ {
+ this.accessControlEnabled = accessControlEnabled;
+ }
+
+
+ /**
+ * Returns <tt>true</tt> if anonymous access is allowed on entries besides the RootDSE.
+ * If the access control subsystem is enabled then access to some entries may not be
+ * allowed even when full anonymous access is enabled.
+ *
+ * @return true if anonymous access is allowed on entries besides the RootDSE, false
+ * if anonymous access is allowed to all entries.
+ */
+ public boolean isAllowAnonymousAccess()
+ {
+ return allowAnonymousAccess;
+ }
+
+
+ /**
+ * Sets whether to allow anonymous access to entries other than the RootDSE. If the
+ * access control subsystem is enabled then access to some entries may not be allowed
+ * even when full anonymous access is enabled.
+ *
+ * @param enableAnonymousAccess true to enable anonymous access, false to disable it
+ */
+ public void setAllowAnonymousAccess( boolean enableAnonymousAccess )
+ {
+ this.allowAnonymousAccess = enableAnonymousAccess;
+ }
+
+
+ /**
+ * Returns interceptors in the server.
+ *
+ * @return the interceptors in the server.
+ */
+ public List<Interceptor> getInterceptors()
+ {
+ List<Interceptor> cloned = new ArrayList<Interceptor>();
+ cloned.addAll( interceptors );
+ return cloned;
+ }
+
+
+ /**
+ * Sets the interceptors in the server.
+ *
+ * @param interceptors the interceptors to be used in the server.
+ */
+ public void setInterceptors( List<Interceptor> interceptors )
+ {
+ Set<String> names = new HashSet<String>();
+ for ( Interceptor interceptor : interceptors )
+ {
+ String name = interceptor.getName();
+ if ( names.contains( name ) )
+ {
+ LOG.warn( "Encountered duplicate definitions for {} interceptor", interceptor.getName() );
+ }
+ names.add( name );
+ }
+
+ this.interceptors = interceptors;
+ }
+
+
+ /**
+ * Returns test directory entries({@link Entry}) to be loaded while
+ * bootstrapping.
+ *
+ * @return test entries to load during bootstrapping
+ */
+ public List<Entry> getTestEntries()
+ {
+ List<Entry> cloned = new ArrayList<Entry>();
+ cloned.addAll( testEntries );
+ return cloned;
+ }
+
+
+ /**
+ * Sets test directory entries({@link Attributes}) to be loaded while
+ * bootstrapping.
+ *
+ * @param testEntries the test entries to load while bootstrapping
+ */
+ public void setTestEntries( List<? extends Entry> testEntries )
+ {
+ //noinspection MismatchedQueryAndUpdateOfCollection
+ List<Entry> cloned = new ArrayList<Entry>();
+ cloned.addAll( testEntries );
+ this.testEntries = testEntries;
+ }
+
+
+ /**
+ * Returns working directory (counterpart of <tt>var/lib</tt>) where partitions are
+ * stored by default.
+ *
+ * @return the directory where partition's are stored.
+ */
+ public File getWorkingDirectory()
+ {
+ return workingDirectory;
+ }
+
+
+ /**
+ * Sets working directory (counterpart of <tt>var/lib</tt>) where partitions are stored
+ * by default.
+ *
+ * @param workingDirectory the directory where the server's partitions are stored by default.
+ */
+ public void setWorkingDirectory( File workingDirectory )
+ {
+ this.workingDirectory = workingDirectory;
+ }
+
+
+ public void validate()
+ {
+ setWorkingDirectory( workingDirectory );
+ }
+
+
+ public void setShutdownHookEnabled( boolean shutdownHookEnabled )
+ {
+ this.shutdownHookEnabled = shutdownHookEnabled;
+ }
+
+
+ public boolean isShutdownHookEnabled()
+ {
+ return shutdownHookEnabled;
+ }
+
+
+ public void setExitVmOnShutdown( boolean exitVmOnShutdown )
+ {
+ this.exitVmOnShutdown = exitVmOnShutdown;
+ }
+
+
+ public boolean isExitVmOnShutdown()
+ {
+ return exitVmOnShutdown;
+ }
+
+
+ public void setMaxSizeLimit( int maxSizeLimit )
+ {
+ this.maxSizeLimit = maxSizeLimit;
+ }
+
+
+ public int getMaxSizeLimit()
+ {
+ return maxSizeLimit;
+ }
+
+
+ public void setMaxTimeLimit( int maxTimeLimit )
+ {
+ this.maxTimeLimit = maxTimeLimit;
+ }
+
+
+ public int getMaxTimeLimit()
+ {
+ return maxTimeLimit;
+ }
+
+ public void setSystemPartition( Partition systemPartition )
+ {
+ this.systemPartition = systemPartition;
+ }
+
+
+ public Partition getSystemPartition()
+ {
+ return systemPartition;
+ }
+
+
+ public boolean isDenormalizeOpAttrsEnabled()
+ {
+ return denormalizeOpAttrsEnabled;
+ }
+
+
+ public void setDenormalizeOpAttrsEnabled( boolean denormalizeOpAttrsEnabled )
+ {
+ this.denormalizeOpAttrsEnabled = denormalizeOpAttrsEnabled;
+ }
+
+
+ public void addPartition( Partition parition ) throws NamingException
+ {
+ partitions.add( parition );
+
+ if ( ! started )
+ {
+ return;
+ }
+
+ AddContextPartitionOperationContext addPartitionCtx = new AddContextPartitionOperationContext( parition );
+ partitionNexus.addContextPartition( addPartitionCtx );
+ }
+
+
+ public void removePartition( Partition partition ) throws NamingException
+ {
+ partitions.remove( partition );
+
+ if ( ! started )
+ {
+ return;
+ }
+
+ RemoveContextPartitionOperationContext removePartitionCtx =
+ new RemoveContextPartitionOperationContext( partition.getSuffixDn() );
+ partitionNexus.removeContextPartition( removePartitionCtx );
+ }
// ------------------------------------------------------------------------
@@ -164,6 +449,28 @@
// ------------------------------------------------------------------------
+ private void setDefaultInterceptorConfigurations()
+ {
+ // Set default interceptor chains
+ List<Interceptor> list = new ArrayList<Interceptor>();
+
+ list.add( new NormalizationService() );
+ list.add( new AuthenticationService() );
+ list.add( new ReferralService() );
+ list.add( new AuthorizationService() );
+ list.add( new DefaultAuthorizationService() );
+ list.add( new ExceptionService() );
+ list.add( new OperationalAttributeService() );
+ list.add( new SchemaService() );
+ list.add( new SubentryService() );
+ list.add( new CollectiveAttributeService() );
+ list.add( new EventService() );
+ list.add( new TriggerService() );
+
+ setInterceptors( list );
+ }
+
+
public Context getJndiContext( String rootDN ) throws NamingException
{
return this.getJndiContext( null, null, null, "none", rootDN );
@@ -180,7 +487,8 @@
return new DeadContext();
}
- Hashtable<String, Object> environment = getEnvironment();
+ //noinspection unchecked
+ Hashtable<String, Object> environment = ( Hashtable<String, Object> ) getEnvironment().clone();
environment.remove( Context.SECURITY_PRINCIPAL );
environment.remove( Context.SECURITY_CREDENTIALS );
environment.remove( Context.SECURITY_AUTHENTICATION );
@@ -205,24 +513,20 @@
rootDN = "";
}
environment.put( Context.PROVIDER_URL, rootDN );
-
+ environment.put( DirectoryService.JNDI_KEY, this );
+
return new ServerLdapContext( this, environment );
}
- @SuppressWarnings("unchecked")
- public synchronized void startup( DirectoryServiceListener listener, Hashtable env ) throws NamingException
+ public synchronized void startup() throws NamingException
{
if ( started )
{
return;
}
- Hashtable<String,Object> envCopy = ( Hashtable ) env.clone();
-
- StartupConfiguration cfg = ( StartupConfiguration ) Configuration.toConfiguration( env );
-
- if ( cfg.isShutdownHookEnabled() )
+ if ( shutdownHookEnabled )
{
Runtime.getRuntime().addShutdownHook( new Thread( new Runnable()
{
@@ -234,50 +538,29 @@
}
catch ( NamingException e )
{
- log.warn( "Failed to shut down the directory service: "
+ LOG.warn( "Failed to shut down the directory service: "
+ DefaultDirectoryService.this.instanceId, e );
}
}
}, "ApacheDS Shutdown Hook (" + instanceId + ')' ) );
- log.info( "ApacheDS shutdown hook has been registered with the runtime." );
+ LOG.info( "ApacheDS shutdown hook has been registered with the runtime." );
}
- else if ( log.isWarnEnabled() )
+ else if ( LOG.isWarnEnabled() )
{
- log.warn( "ApacheDS shutdown hook has NOT been registered with the runtime."
+ LOG.warn( "ApacheDS shutdown hook has NOT been registered with the runtime."
+ " This default setting for standalone operation has been overriden." );
}
- envCopy.put( Context.PROVIDER_URL, "" );
-
- try
- {
- cfg.validate();
- }
- catch ( ConfigurationException e )
- {
- NamingException ne = new LdapConfigurationException( "Invalid configuration." );
- ne.initCause( e );
- throw ne;
- }
-
- this.environment = envCopy;
- this.startupConfiguration = cfg;
-
- listener.beforeStartup( this );
-
initialize();
firstStart = createBootstrapEntries();
showSecurityWarnings();
- this.serviceListener = listener;
started = true;
- if ( !startupConfiguration.getTestEntries().isEmpty() )
+ if ( !testEntries.isEmpty() )
{
- createTestEntries( env );
+ createTestEntries();
}
-
- listener.afterStartup( this );
}
@@ -288,15 +571,7 @@
return;
}
- serviceListener.beforeSync( this );
- try
- {
- this.partitionNexus.sync();
- }
- finally
- {
- serviceListener.afterSync( this );
- }
+ this.partitionNexus.sync();
}
@@ -307,33 +582,12 @@
return;
}
- serviceListener.beforeShutdown( this );
- try
- {
- this.partitionNexus.sync();
- this.partitionNexus.destroy();
- this.interceptorChain.destroy();
- this.started = false;
- }
- finally
- {
- serviceListener.afterShutdown( this );
- environment = null;
- interceptorChain = null;
- startupConfiguration = null;
- }
- }
-
-
- public String getInstanceId()
- {
- return instanceId;
- }
-
-
- public DirectoryServiceConfiguration getConfiguration()
- {
- return configuration;
+ this.partitionNexus.sync();
+ this.partitionNexus.destroy();
+ this.interceptorChain.destroy();
+ this.started = false;
+ setDefaultInterceptorConfigurations();
+ this.environment = new Hashtable<String,Object>();
}
@@ -344,21 +598,21 @@
}
- public DirectoryServiceListener getServiceListener()
+ public void setEnvironment( Hashtable<String, Object> environment )
{
- return serviceListener;
+ this.environment = environment;
}
- public StartupConfiguration getStartupConfiguration()
+ public Registries getRegistries()
{
- return startupConfiguration;
+ return registries;
}
- public Registries getRegistries()
+ public void setRegistries( Registries registries )
{
- return registries;
+ this.registries = registries;
}
@@ -390,6 +644,9 @@
* Checks to make sure security environment parameters are set correctly.
*
* @throws javax.naming.NamingException if the security settings are not correctly configured.
+ * @param authentication the mechanism for authentication
+ * @param credential the password
+ * @param principal the distinguished name of the principal
*/
private void checkSecuritySettings( String principal, byte[] credential, String authentication )
throws NamingException
@@ -449,7 +706,7 @@
+ " property is set" );
}
- if ( !startupConfiguration.isAllowAnonymousAccess() )
+ if ( !allowAnonymousAccess )
{
throw new LdapNoPermissionException( "Anonymous access disabled." );
}
@@ -470,7 +727,8 @@
* start of the server. Otherwise if all entries exist, meaning none
* had to be created, then we are not starting for the first time.
*
- * @throws javax.naming.NamingException
+ * @return true if the bootstrap entries had to be created, false otherwise
+ * @throws javax.naming.NamingException if entries cannot be created
*/
private boolean createBootstrapEntries() throws NamingException
{
@@ -512,7 +770,7 @@
// create system users area
// -------------------------------------------------------------------
- Map<String,OidNormalizer> oidsMap = configuration.getRegistries().getAttributeTypeRegistry().getNormalizerMapping();
+ Map<String,OidNormalizer> oidsMap = registries.getAttributeTypeRegistry().getNormalizerMapping();
LdapDN userDn = new LdapDN( "ou=users,ou=system" );
userDn.normalize( oidsMap );
@@ -584,13 +842,13 @@
if ( authzInterceptor == null )
{
- log.error( "The Authorization service is null : this is not allowed" );
+ LOG.error( "The Authorization service is null : this is not allowed" );
throw new NamingException( "The Authorization service is null" );
}
if ( !( authzInterceptor instanceof AuthorizationService) )
{
- log.error( "The Authorization service is not set correctly : '{}' is an incorect interceptor",
+ LOG.error( "The Authorization service is not set correctly : '{}' is an incorect interceptor",
authzInterceptor.getClass().getName() );
throw new NamingException( "The Authorization service is incorrectly set" );
@@ -728,6 +986,7 @@
/**
* Displays security warning messages if any possible secutiry issue is found.
+ * @throws NamingException if there are failures parsing and accessing internal structures
*/
private void showSecurityWarnings() throws NamingException
{
@@ -735,7 +994,7 @@
boolean needToChangeAdminPassword = false;
LdapDN adminDn = new LdapDN( PartitionNexus.ADMIN_PRINCIPAL );
- adminDn.normalize( configuration.getRegistries().getAttributeTypeRegistry().getNormalizerMapping() );
+ adminDn.normalize( registries.getAttributeTypeRegistry().getNormalizerMapping() );
Attributes adminEntry = partitionNexus.lookup( new LookupOperationContext( adminDn ) );
Object userPassword = adminEntry.get( SchemaConstants.USER_PASSWORD_AT ).get();
@@ -751,46 +1010,45 @@
if ( needToChangeAdminPassword )
{
- log.warn( "You didn't change the admin password of directory service " + "instance '" + instanceId + "'. "
+ LOG.warn( "You didn't change the admin password of directory service " + "instance '" + instanceId + "'. "
+ "Please update the admin password as soon as possible " + "to prevent a possible security breach." );
}
}
- private void createTestEntries( Hashtable<String,Object> env ) throws NamingException
+ /**
+ * @todo need to re-enable this after removing JNDI and creating means to pump
+ * requests into the core to add entries.
+ *
+ * @throws NamingException if the creation of test entries fails.
+ */
+ private void createTestEntries() throws NamingException
{
- String principal = AbstractContextFactory.getPrincipal( env );
- byte[] credential = AbstractContextFactory.getCredential( env );
- String authentication = AbstractContextFactory.getAuthentication( env );
-
- LdapDN principalDn = new LdapDN( principal );
-
- ServerLdapContext ctx = ( ServerLdapContext )
- getJndiContext( principalDn, principal, credential, authentication, "" );
-
- Iterator<Entry> i = startupConfiguration.getTestEntries().iterator();
-
- while ( i.hasNext() )
- {
- try
- {
- Entry entry = i.next().clone();
- Attributes attributes = entry.getAttributes();
- String dn = entry.getDn();
-
- try
- {
- ctx.createSubcontext( dn, attributes );
- }
- catch ( Exception e )
- {
- log.warn( dn + " test entry already exists.", e );
- }
- }
- catch ( CloneNotSupportedException cnse )
- {
- log.warn( "Cannot clone the entry ", cnse );
- }
+ LdapPrincipal principal = new LdapPrincipal( new LdapDN( PartitionNexus.ADMIN_PRINCIPAL ),
+ AuthenticationLevel.SIMPLE );
+ ServerLdapContext ctx = new ServerLdapContext( this, principal, new LdapDN() );
+
+ for ( Entry testEntry : testEntries )
+ {
+ try
+ {
+ Entry entry = testEntry.clone();
+ Attributes attributes = entry.getAttributes();
+ String dn = entry.getDn();
+
+ try
+ {
+ ctx.createSubcontext( dn, attributes );
+ }
+ catch ( Exception e )
+ {
+ LOG.warn( dn + " test entry already exists.", e );
+ }
+ }
+ catch ( CloneNotSupportedException cnse )
+ {
+ LOG.warn( "Cannot clone the entry ", cnse );
+ }
}
}
@@ -802,9 +1060,9 @@
*/
private void initialize() throws NamingException
{
- if ( log.isDebugEnabled() )
+ if ( LOG.isDebugEnabled() )
{
- log.debug( "---> Initializing the DefaultDirectoryService " );
+ LOG.debug( "---> Initializing the DefaultDirectoryService " );
}
// --------------------------------------------------------------------
@@ -815,7 +1073,7 @@
BootstrapSchemaLoader loader = new BootstrapSchemaLoader();
OidRegistry oidRegistry = new DefaultOidRegistry();
registries = new DefaultRegistries( "bootstrap", loader, oidRegistry );
-
+
// load essential bootstrap schemas
Set<Schema> bootstrapSchemas = new HashSet<Schema>();
bootstrapSchemas.add( new ApachemetaSchema() );
@@ -839,13 +1097,13 @@
// If not present extract schema partition from jar
// --------------------------------------------------------------------
- File schemaDirectory = new File( startupConfiguration.getWorkingDirectory(), "schema" );
- SchemaPartitionExtractor extractor = null;
+ File schemaDirectory = new File( workingDirectory, "schema" );
+ SchemaPartitionExtractor extractor;
if ( ! schemaDirectory.exists() )
{
try
{
- extractor = new SchemaPartitionExtractor( startupConfiguration.getWorkingDirectory() );
+ extractor = new SchemaPartitionExtractor( workingDirectory );
extractor.extract();
}
catch ( IOException e )
@@ -864,7 +1122,7 @@
schemaPartition.setId( "schema" );
schemaPartition.setCacheSize( 1000 );
- DbFileListing listing = null;
+ DbFileListing listing;
try
{
listing = new DbFileListing();
@@ -889,7 +1147,7 @@
entry.get( SchemaConstants.OBJECT_CLASS_AT ).add( SchemaConstants.ORGANIZATIONAL_UNIT_OC );
entry.put( SchemaConstants.OU_AT, "schema" );
schemaPartition.setContextEntry( entry );
- schemaPartition.init( configuration );
+ schemaPartition.init( this );
// --------------------------------------------------------------------
// Enable schemas of all indices of partition configurations
@@ -905,22 +1163,20 @@
SchemaPartitionDao dao = new SchemaPartitionDao( schemaPartition, registries );
Map<String,Schema> schemaMap = dao.getSchemas();
Set<Partition> partitions = new HashSet<Partition>();
- partitions.add( startupConfiguration.getSystemPartition() );
- partitions.addAll( startupConfiguration.getPartitions() );
+ partitions.add( systemPartition );
+ partitions.addAll( this.partitions );
for ( Partition partition : partitions )
{
if ( partition instanceof BTreePartition )
{
JdbmPartition btpconf = ( JdbmPartition ) partition;
- Iterator<Index> indices = btpconf.getIndexedAttributes().iterator();
- while ( indices.hasNext() )
+ for ( Index index : btpconf.getIndexedAttributes() )
{
- Index indexedAttr = indices.next();
- String schemaName = dao.findSchema( indexedAttr.getAttributeId() );
+ String schemaName = dao.findSchema( index.getAttributeId() );
if ( schemaName == null )
{
- throw new NamingException( "Index on unidentified attribute: " + indexedAttr.toString() );
+ throw new NamingException( "Index on unidentified attribute: " + index.toString() );
}
Schema schema = schemaMap.get( schemaName );
@@ -945,17 +1201,17 @@
Set<String> binaries = new HashSet<String>();
if ( this.environment.containsKey( BINARY_KEY ) )
{
- if ( log.isInfoEnabled() )
+ if ( LOG.isInfoEnabled() )
{
- log.info( "Startup environment contains " + BINARY_KEY );
+ LOG.info( "Startup environment contains " + BINARY_KEY );
}
String binaryIds = ( String ) this.environment.get( BINARY_KEY );
if ( binaryIds == null )
{
- if ( log.isWarnEnabled() )
+ if ( LOG.isWarnEnabled() )
{
- log.warn( BINARY_KEY + " in startup environment contains null value. "
+ LOG.warn( BINARY_KEY + " in startup environment contains null value. "
+ "Using only schema info to set binary attributeTypes." );
}
}
@@ -965,15 +1221,15 @@
{
String[] binaryArray = binaryIds.split( " " );
- for ( int i = 0; i < binaryArray.length; i++ )
+ for ( String aBinaryArray : binaryArray )
{
- binaries.add( StringTools.lowerCaseAscii( StringTools.trim( binaryArray[i] ) ) );
+ binaries.add( StringTools.lowerCaseAscii( StringTools.trim( aBinaryArray ) ) );
}
}
- if ( log.isInfoEnabled() )
+ if ( LOG.isInfoEnabled() )
{
- log.info( "Setting binaries to union of schema defined binaries and those provided in "
+ LOG.info( "Setting binaries to union of schema defined binaries and those provided in "
+ BINARY_KEY );
}
}
@@ -996,30 +1252,30 @@
// add the lowercased name for the names for the attributeType
String[] names = type.getNames();
-
- for ( int ii = 0; ii < names.length; ii++ )
+
+ for ( String name : names )
{
- binaries.add( StringTools.lowerCaseAscii( StringTools.trim( names[ii] ) ) );
+ binaries.add( StringTools.lowerCaseAscii( StringTools.trim( name ) ) );
}
}
}
this.environment.put( BINARY_KEY, binaries );
- if ( log.isDebugEnabled() )
+ if ( LOG.isDebugEnabled() )
{
- log.debug( "binary ids used: " + binaries );
+ LOG.debug( "binary ids used: " + binaries );
}
partitionNexus = new DefaultPartitionNexus( new AttributesImpl() );
- partitionNexus.init( configuration );
+ partitionNexus.init( this );
partitionNexus.addContextPartition( new AddContextPartitionOperationContext( schemaPartition ) );
interceptorChain = new InterceptorChain();
- interceptorChain.init( configuration );
+ interceptorChain.init( this );
- if ( log.isDebugEnabled() )
+ if ( LOG.isDebugEnabled() )
{
- log.debug( "<--- DefaultDirectoryService initialized" );
+ LOG.debug( "<--- DefaultDirectoryService initialized" );
}
}
@@ -1027,5 +1283,11 @@
public SchemaManager getSchemaManager()
{
return schemaManager;
+ }
+
+
+ public void setSchemaManager( SchemaManager schemaManager )
+ {
+ this.schemaManager = schemaManager;
}
}
Modified: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/DirectoryService.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/DirectoryService.java?rev=582462&r1=582461&r2=582462&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/DirectoryService.java (original)
+++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/DirectoryService.java Fri Oct 5 23:48:35 2007
@@ -20,21 +20,24 @@
package org.apache.directory.server.core;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Hashtable;
-import java.util.Map;
-import java.util.Set;
-
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-
-import org.apache.directory.server.core.configuration.Configuration;
+import org.apache.directory.server.core.interceptor.Interceptor;
+import org.apache.directory.server.core.interceptor.InterceptorChain;
import org.apache.directory.server.core.jndi.AbstractContextFactory;
import org.apache.directory.server.core.partition.Partition;
+import org.apache.directory.server.core.partition.PartitionNexus;
+import org.apache.directory.server.core.schema.SchemaManager;
+import org.apache.directory.server.schema.registries.Registries;
+import org.apache.directory.shared.ldap.ldif.Entry;
import org.apache.directory.shared.ldap.name.LdapDN;
+import javax.naming.Context;
+import javax.naming.NamingException;
+import javax.naming.directory.Attributes;
+import java.io.File;
+import java.util.Hashtable;
+import java.util.List;
+import java.util.Set;
+
/**
* Provides JNDI service to {@link AbstractContextFactory}.
@@ -44,55 +47,35 @@
*/
public abstract class DirectoryService
{
- private static final Map<String, DirectoryService> instances = new HashMap<String, DirectoryService>();
+ public static final String JNDI_KEY = DirectoryService.class.getName();
+ public abstract Hashtable<String,Object> getEnvironment();
- /**
- * Returns the default instance. This method is identical with calling
- * <tt>getInstance( Configuration.DEFAULT_INSTANCE_ID )</tt>.
- */
- public static DirectoryService getInstance()
- {
- return getInstance( Configuration.DEFAULT_INSTANCE_ID );
- }
+ public abstract void setEnvironment( Hashtable<String,Object> environment );
+ public abstract PartitionNexus getPartitionNexus();
- /**
- * Returns {@link DirectoryService} with the specified instance ID.
- */
- public synchronized static DirectoryService getInstance( String instanceId )
- {
- instanceId = instanceId.trim();
- DirectoryService service = instances.get( instanceId );
- if ( service == null )
- {
- service = new DefaultDirectoryService( instanceId );
- instances.put( instanceId, service );
- }
+ public abstract InterceptorChain getInterceptorChain();
- return service;
- }
+ public abstract void addPartition( Partition partition ) throws NamingException;
+
+ public abstract void removePartition( Partition partition ) throws NamingException;
+ public abstract Registries getRegistries();
- /**
- * Returns all instances of instantiated {@link DirectoryService}.
- */
- public synchronized static Set<DirectoryService> getAllInstances()
- {
- return new HashSet<DirectoryService>( instances.values() );
- }
+ public abstract void setRegistries( Registries registries );
+
+ public abstract SchemaManager getSchemaManager();
+
+ public abstract void setSchemaManager( SchemaManager schemaManager );
/**
* Starts up this service.
*
- * @param listener a listener that listens to the lifecycle of this service
- * @param environment JNDI {@link InitialContext} environment
- *
* @throws NamingException if failed to start up
*/
- public abstract void startup( DirectoryServiceListener listener, Hashtable<String,Object> environment )
- throws NamingException;
+ public abstract void startup() throws NamingException;
/**
@@ -112,17 +95,12 @@
/**
* Returns <tt>true</tt> if this service is started.
+ * @return true if the service has started, false otherwise
*/
public abstract boolean isStarted();
/**
- * Returns the configuration of this service.
- */
- public abstract DirectoryServiceConfiguration getConfiguration();
-
-
- /**
* Returns an anonymous JNDI {@link Context} with the specified <tt>baseName</tt>
* @throws NamingException if failed to create a context
*/
@@ -141,4 +119,154 @@
*/
public abstract Context getJndiContext( LdapDN principalDn, String principal, byte[] credential,
String authentication, String baseName ) throws NamingException;
+
+
+ public abstract void setInstanceId( String instanceId );
+
+
+ public abstract String getInstanceId();
+
+
+ /**
+ * Gets the {@link Partition}s used by this DirectoryService.
+ *
+ * @return the set of partitions used
+ */
+ public abstract Set<? extends Partition> getPartitions();
+
+
+ /**
+ * Sets {@link Partition}s used by this DirectoryService.
+ *
+ * @param partitions the partitions to used
+ */
+ public abstract void setPartitions( Set<? extends Partition> partitions );
+
+
+ /**
+ * Returns <tt>true</tt> if access control checks are enabled.
+ *
+ * @return true if access control checks are enabled, false otherwise
+ */
+ public abstract boolean isAccessControlEnabled();
+
+
+ /**
+ * Sets whether to enable basic access control checks or not.
+ *
+ * @param accessControlEnabled true to enable access control checks, false otherwise
+ */
+ public abstract void setAccessControlEnabled( boolean accessControlEnabled );
+
+
+ /**
+ * Returns <tt>true</tt> if anonymous access is allowed on entries besides the RootDSE.
+ * If the access control subsystem is enabled then access to some entries may not be
+ * allowed even when full anonymous access is enabled.
+ *
+ * @return true if anonymous access is allowed on entries besides the RootDSE, false
+ * if anonymous access is allowed to all entries.
+ */
+ public abstract boolean isAllowAnonymousAccess();
+
+
+ /**
+ * Sets whether to allow anonymous access to entries other than the RootDSE. If the
+ * access control subsystem is enabled then access to some entries may not be allowed
+ * even when full anonymous access is enabled.
+ *
+ * @param enableAnonymousAccess true to enable anonymous access, false to disable it
+ */
+ public abstract void setAllowAnonymousAccess( boolean enableAnonymousAccess );
+
+
+ /**
+ * Returns interceptors in the server.
+ *
+ * @return the interceptors in the server.
+ */
+ public abstract List<Interceptor> getInterceptors();
+
+
+ /**
+ * Sets the interceptors in the server.
+ *
+ * @param interceptors the interceptors to be used in the server.
+ */
+ public abstract void setInterceptors( List<Interceptor> interceptors );
+
+
+ /**
+ * Returns test directory entries({@link Entry}) to be loaded while
+ * bootstrapping.
+ *
+ * @return test entries to load during bootstrapping
+ */
+ public abstract List<Entry> getTestEntries();
+
+
+ /**
+ * Sets test directory entries({@link Attributes}) to be loaded while
+ * bootstrapping.
+ *
+ * @param testEntries the test entries to load while bootstrapping
+ */
+ public abstract void setTestEntries( List<? extends Entry> testEntries );
+
+
+ /**
+ * Returns working directory (counterpart of <tt>var/lib</tt>) where partitions are
+ * stored by default.
+ *
+ * @return the directory where partition's are stored.
+ */
+ public abstract File getWorkingDirectory();
+
+
+ /**
+ * Sets working directory (counterpart of <tt>var/lib</tt>) where partitions are stored
+ * by default.
+ *
+ * @param workingDirectory the directory where the server's partitions are stored by default.
+ */
+ public abstract void setWorkingDirectory( File workingDirectory );
+
+
+ public abstract void validate();
+
+
+ public abstract void setShutdownHookEnabled( boolean shutdownHookEnabled );
+
+
+ public abstract boolean isShutdownHookEnabled();
+
+
+ public abstract void setExitVmOnShutdown( boolean exitVmOnShutdown );
+
+
+ public abstract boolean isExitVmOnShutdown();
+
+
+ public abstract void setMaxSizeLimit( int maxSizeLimit );
+
+
+ public abstract int getMaxSizeLimit();
+
+
+ public abstract void setMaxTimeLimit( int maxTimeLimit );
+
+
+ public abstract int getMaxTimeLimit();
+
+
+ public abstract void setSystemPartition( Partition systemPartition );
+
+
+ public abstract Partition getSystemPartition();
+
+
+ public abstract boolean isDenormalizeOpAttrsEnabled();
+
+
+ public abstract void setDenormalizeOpAttrsEnabled( boolean denormalizeOpAttrsEnabled );
}
Modified: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/authn/AbstractAuthenticator.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/authn/AbstractAuthenticator.java?rev=582462&r1=582461&r2=582462&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/authn/AbstractAuthenticator.java (original)
+++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/authn/AbstractAuthenticator.java Fri Oct 5 23:48:35 2007
@@ -20,14 +20,12 @@
package org.apache.directory.server.core.authn;
-import javax.naming.NamingException;
-import javax.naming.spi.InitialContextFactory;
-
-import org.apache.directory.server.core.DirectoryServiceConfiguration;
+import org.apache.directory.server.core.DirectoryService;
import org.apache.directory.server.core.jndi.ServerContext;
-import org.apache.directory.shared.ldap.aci.AuthenticationLevel;
import org.apache.directory.shared.ldap.name.LdapDN;
+import javax.naming.NamingException;
+
/**
* Base class for all Authenticators.
@@ -37,7 +35,7 @@
*/
public abstract class AbstractAuthenticator implements Authenticator
{
- private DirectoryServiceConfiguration factoryCfg;
+ private DirectoryService directoryService;
/** authenticator type */
private final String authenticatorType;
@@ -55,13 +53,14 @@
/**
- * Returns {@link DirectoryServiceConfiguration} of {@link InitialContextFactory}
- * which initialized this authenticator.
+ * Returns {@link DirectoryService} for this authenticator.
+ * @return the directory service core
*/
- public DirectoryServiceConfiguration getFactoryConfiguration()
+ public DirectoryService getDirectoryService()
{
- return factoryCfg;
+ return directoryService;
}
+
public String getAuthenticatorType()
{
@@ -70,14 +69,14 @@
/**
- * Initializes default properties (<tt>factoryConfiguration</tt> and
- * <tt>configuration</tt>, and calls {@link #doInit()} method.
+ * Initializes (<tt>directoryService</tt> and and calls {@link #doInit()} method.
* Please put your initialization code into {@link #doInit()}.
+ * @param directoryService the directory core for this authenticator
+ * @throws NamingException if there is a problem starting up the authenticator
*/
- public final void init( DirectoryServiceConfiguration factoryCfg )
- throws NamingException
+ public final void init( DirectoryService directoryService ) throws NamingException
{
- this.factoryCfg = factoryCfg;
+ this.directoryService = directoryService;
doInit();
}
@@ -103,7 +102,7 @@
}
finally
{
- this.factoryCfg = null;
+ this.directoryService = null;
}
}
Modified: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/authn/AnonymousAuthenticator.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/authn/AnonymousAuthenticator.java?rev=582462&r1=582461&r2=582462&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/authn/AnonymousAuthenticator.java (original)
+++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/authn/AnonymousAuthenticator.java Fri Oct 5 23:48:35 2007
@@ -50,7 +50,7 @@
*/
public LdapPrincipal authenticate( LdapDN bindDn, ServerContext ctx ) throws NamingException
{
- if ( getFactoryConfiguration().getStartupConfiguration().isAllowAnonymousAccess() )
+ if ( super.getDirectoryService().isAllowAnonymousAccess() )
{
return LdapPrincipal.ANONYMOUS;
}
Modified: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/authn/AuthenticationService.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/authn/AuthenticationService.java?rev=582462&r1=582461&r2=582462&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/authn/AuthenticationService.java (original)
+++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/authn/AuthenticationService.java Fri Oct 5 23:48:35 2007
@@ -20,40 +20,11 @@
package org.apache.directory.server.core.authn;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import javax.naming.Context;
-import javax.naming.NamingEnumeration;
-import javax.naming.NamingException;
-import javax.naming.directory.Attributes;
-import javax.naming.directory.SearchResult;
-
-import org.apache.directory.server.core.DirectoryServiceConfiguration;
+import org.apache.directory.server.core.DirectoryService;
import org.apache.directory.server.core.interceptor.BaseInterceptor;
import org.apache.directory.server.core.interceptor.Interceptor;
import org.apache.directory.server.core.interceptor.NextInterceptor;
-import org.apache.directory.server.core.interceptor.context.AddOperationContext;
-import org.apache.directory.server.core.interceptor.context.BindOperationContext;
-import org.apache.directory.server.core.interceptor.context.DeleteOperationContext;
-import org.apache.directory.server.core.interceptor.context.EntryOperationContext;
-import org.apache.directory.server.core.interceptor.context.GetMatchedNameOperationContext;
-import org.apache.directory.server.core.interceptor.context.GetRootDSEOperationContext;
-import org.apache.directory.server.core.interceptor.context.GetSuffixOperationContext;
-import org.apache.directory.server.core.interceptor.context.ListOperationContext;
-import org.apache.directory.server.core.interceptor.context.ListSuffixOperationContext;
-import org.apache.directory.server.core.interceptor.context.LookupOperationContext;
-import org.apache.directory.server.core.interceptor.context.ModifyOperationContext;
-import org.apache.directory.server.core.interceptor.context.MoveAndRenameOperationContext;
-import org.apache.directory.server.core.interceptor.context.MoveOperationContext;
-import org.apache.directory.server.core.interceptor.context.RenameOperationContext;
-import org.apache.directory.server.core.interceptor.context.SearchOperationContext;
+import org.apache.directory.server.core.interceptor.context.*;
import org.apache.directory.server.core.invocation.InvocationStack;
import org.apache.directory.server.core.jndi.LdapJndiProperties;
import org.apache.directory.server.core.jndi.ServerContext;
@@ -65,6 +36,13 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import javax.naming.Context;
+import javax.naming.NamingEnumeration;
+import javax.naming.NamingException;
+import javax.naming.directory.Attributes;
+import javax.naming.directory.SearchResult;
+import java.util.*;
+
/**
* An {@link Interceptor} that authenticates users.
@@ -75,12 +53,12 @@
*/
public class AuthenticationService extends BaseInterceptor
{
- private static final Logger log = LoggerFactory.getLogger( AuthenticationService.class );
+ private static final Logger LOG = LoggerFactory.getLogger( AuthenticationService.class );
/**
* Speedup for logs
*/
- private static final boolean IS_DEBUG = log.isDebugEnabled();
+ private static final boolean IS_DEBUG = LOG.isDebugEnabled();
private Set<Authenticator> authenticators;
private final Map<String, Collection<Authenticator>> authenticatorsMapByType = new HashMap<String, Collection<Authenticator>>();
@@ -95,7 +73,7 @@
/**
* Registers and initializes all {@link Authenticator}s to this service.
*/
- public void init( DirectoryServiceConfiguration factoryCfg ) throws NamingException
+ public void init( DirectoryService directoryService ) throws NamingException
{
if ( authenticators == null )
@@ -105,7 +83,7 @@
// Register all authenticators
for ( Authenticator authenticator : authenticators )
{
- register( authenticator, factoryCfg );
+ register( authenticator, directoryService );
}
}
@@ -153,12 +131,12 @@
* this service.
*
* @param authenticator Authenticator to initialize and register by type
- * @param factoryConfig configuration info to supply to the Authenticator during initialization
+ * @param directoryService configuration info to supply to the Authenticator during initialization
* @throws javax.naming.NamingException if initialization fails.
*/
- private void register( Authenticator authenticator, DirectoryServiceConfiguration factoryConfig ) throws NamingException
+ private void register( Authenticator authenticator, DirectoryService directoryService ) throws NamingException
{
- authenticator.init( factoryConfig );
+ authenticator.init( directoryService );
Collection<Authenticator> authenticatorList = getAuthenticators( authenticator.getAuthenticatorType() );
@@ -196,7 +174,7 @@
{
if ( IS_DEBUG )
{
- log.debug( "Adding the entry " +
+ LOG.debug( "Adding the entry " +
AttributeUtils.toString( opContext.getEntry() ) +
" for DN = '" + opContext.getDn().getUpName() + "'" );
}
@@ -210,7 +188,7 @@
{
if ( IS_DEBUG )
{
- log.debug( "Deleting name = '" + opContext.getDn().getUpName() + "'" );
+ LOG.debug( "Deleting name = '" + opContext.getDn().getUpName() + "'" );
}
checkAuthenticated( MessageTypeEnum.DEL_REQUEST );
@@ -223,7 +201,7 @@
{
if ( IS_DEBUG )
{
- log.debug( "Matching name = '" + opContext.getDn().getUpName() + "'" );
+ LOG.debug( "Matching name = '" + opContext.getDn().getUpName() + "'" );
}
checkAuthenticated();
@@ -235,7 +213,7 @@
{
if ( IS_DEBUG )
{
- log.debug( "Getting root DSE" );
+ LOG.debug( "Getting root DSE" );
}
checkAuthenticated();
@@ -247,7 +225,7 @@
{
if ( IS_DEBUG )
{
- log.debug( "Getting suffix for name = '" + opContext.getDn().getUpName() + "'" );
+ LOG.debug( "Getting suffix for name = '" + opContext.getDn().getUpName() + "'" );
}
checkAuthenticated();
@@ -259,7 +237,7 @@
{
if ( IS_DEBUG )
{
- log.debug( "Testing if entry name = '" + opContext.getDn().getUpName() + "' exists" );
+ LOG.debug( "Testing if entry name = '" + opContext.getDn().getUpName() + "' exists" );
}
checkAuthenticated();
@@ -271,7 +249,7 @@
{
if ( IS_DEBUG )
{
- log.debug( "Listing base = '" + opContext.getDn().getUpName() + "'" );
+ LOG.debug( "Listing base = '" + opContext.getDn().getUpName() + "'" );
}
checkAuthenticated();
@@ -283,7 +261,7 @@
{
if ( IS_DEBUG )
{
- log.debug( "Listing suffixes" );
+ LOG.debug( "Listing suffixes" );
}
checkAuthenticated();
@@ -300,10 +278,10 @@
if ( ( attrIds != null ) && ( attrIds.size() != 0 ) )
{
String attrs = StringTools.listToString( attrIds );
- log.debug( "Lookup name = '" + opContext.getDn().getUpName() + "', attributes = " + attrs );
+ LOG.debug( "Lookup name = '" + opContext.getDn().getUpName() + "', attributes = " + attrs );
} else
{
- log.debug( "Lookup name = '" + opContext.getDn().getUpName() + "', no attributes " );
+ LOG.debug( "Lookup name = '" + opContext.getDn().getUpName() + "', no attributes " );
}
}
@@ -330,7 +308,7 @@
{
if ( IS_DEBUG )
{
- log.debug( opContext.toString() );
+ LOG.debug( opContext.toString() );
}
checkAuthenticated( MessageTypeEnum.MODIFY_REQUEST );
@@ -343,7 +321,7 @@
{
if ( IS_DEBUG )
{
- log.debug( "Modifying name = '" + opContext.getDn().getUpName() + "', new RDN = '" +
+ LOG.debug( "Modifying name = '" + opContext.getDn().getUpName() + "', new RDN = '" +
opContext.getNewRdn() + "', " +
"oldRDN = '" + opContext.getDelOldDn() + "'" );
}
@@ -359,7 +337,7 @@
{
if ( IS_DEBUG )
{
- log.debug( "Moving name = '" + opContext.getDn().getUpName() + "' to name = '" +
+ LOG.debug( "Moving name = '" + opContext.getDn().getUpName() + "' to name = '" +
opContext.getParent() + "', new RDN = '" +
opContext.getNewRdn() + "', oldRDN = '" +
opContext.getDelOldDn() + "'" );
@@ -375,7 +353,7 @@
{
if ( IS_DEBUG )
{
- log.debug( "Moving name = '" + opContext.getDn().getUpName() + " to name = '" +
+ LOG.debug( "Moving name = '" + opContext.getDn().getUpName() + " to name = '" +
opContext.getParent().getUpName() + "'" );
}
@@ -389,7 +367,7 @@
{
if ( IS_DEBUG )
{
- log.debug( "Search for base = '" + opContext.getDn().getUpName() + "'" );
+ LOG.debug( "Search for base = '" + opContext.getDn().getUpName() + "'" );
}
checkAuthenticated( MessageTypeEnum.SEARCH_REQUEST );
@@ -405,7 +383,7 @@
}
catch ( IllegalStateException ise )
{
- log.error( "Attempted operation {} by unauthenticated caller.", operation.name() );
+ LOG.error( "Attempted operation {} by unauthenticated caller.", operation.name() );
throw new IllegalStateException( "Attempted operation by unauthenticated caller." );
}
@@ -438,7 +416,7 @@
if ( IS_DEBUG )
{
- log.debug( "Bind operation. bindDn: " + bindUpDn );
+ LOG.debug( "Bind operation. bindDn: " + bindUpDn );
}
// check if we are already authenticated and if so we return making
@@ -447,7 +425,7 @@
if ( IS_DEBUG )
{
- log.debug( "bind: principal: " + ctx.getPrincipal() );
+ LOG.debug( "bind: principal: " + ctx.getPrincipal() );
}
if ( ctx.getPrincipal() != null )
@@ -475,12 +453,12 @@
if ( authenticators == null )
{
- log.debug( "No authenticators found, delegating bind to the nexus." );
+ LOG.debug( "No authenticators found, delegating bind to the nexus." );
// as a last resort try binding via the nexus
next.bind( opContext );
- log.debug( "Nexus succeeded on bind operation." );
+ LOG.debug( "Nexus succeeded on bind operation." );
// bind succeeded if we got this far
ctx.setPrincipal( new TrustedPrincipalWrapper( new LdapPrincipal( normBindDn, LdapJndiProperties
@@ -511,24 +489,24 @@
catch ( LdapAuthenticationException e )
{
// authentication failed, try the next authenticator
- if ( log.isInfoEnabled() )
+ if ( LOG.isInfoEnabled() )
{
- log.info( "Authenticator " + authenticator.getClass() + " failed to authenticate " + bindUpDn );
+ LOG.info( "Authenticator " + authenticator.getClass() + " failed to authenticate " + bindUpDn );
}
}
catch ( Exception e )
{
// Log other exceptions than LdapAuthenticationException
- if ( log.isWarnEnabled() )
+ if ( LOG.isWarnEnabled() )
{
- log.warn( "Unexpected exception from " + authenticator.getClass() + " for principal " + bindUpDn, e );
+ LOG.warn( "Unexpected exception from " + authenticator.getClass() + " for principal " + bindUpDn, e );
}
}
}
- if ( log.isInfoEnabled() )
+ if ( LOG.isInfoEnabled() )
{
- log.info( "Cannot bind to the server " );
+ LOG.info( "Cannot bind to the server " );
}
throw new LdapAuthenticationException();
Modified: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/authn/Authenticator.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/authn/Authenticator.java?rev=582462&r1=582461&r2=582462&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/authn/Authenticator.java (original)
+++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/authn/Authenticator.java Fri Oct 5 23:48:35 2007
@@ -20,14 +20,14 @@
package org.apache.directory.server.core.authn;
-import javax.naming.Context;
-import javax.naming.NamingException;
-
-import org.apache.directory.server.core.DirectoryServiceConfiguration;
+import org.apache.directory.server.core.DirectoryService;
import org.apache.directory.server.core.jndi.ServerContext;
import org.apache.directory.server.core.partition.PartitionNexus;
import org.apache.directory.shared.ldap.name.LdapDN;
+import javax.naming.Context;
+import javax.naming.NamingException;
+
/**
* Authenticates users who access {@link PartitionNexus}.
@@ -36,7 +36,7 @@
* {@link AuthenticationService} interceptor.
* <p>
* {@link AuthenticationService} authenticates users by calling
- * {@link #authenticate(ServerContext)}, and then {@link Authenticator}
+ * {@link #authenticate(LdapDN,ServerContext)}, and then {@link Authenticator}
* checks JNDI {@link Context} environment properties
* ({@link Context#SECURITY_PRINCIPAL} and {@link Context#SECURITY_CREDENTIALS})
* of current {@link Context}.
@@ -58,7 +58,7 @@
* Called by {@link AuthenticationService} to indicate that this
* authenticator is being placed into service.
*/
- public void init( DirectoryServiceConfiguration factoryCfg ) throws NamingException;
+ public void init( DirectoryService directoryService ) throws NamingException;
/**
Modified: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/authn/LdapPrincipal.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/authn/LdapPrincipal.java?rev=582462&r1=582461&r2=582462&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/authn/LdapPrincipal.java (original)
+++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/authn/LdapPrincipal.java Fri Oct 5 23:48:35 2007
@@ -62,7 +62,7 @@
* @param name the normalized distinguished name of the principal
* @param authenticationLevel
*/
- LdapPrincipal( LdapDN name, AuthenticationLevel authenticationLevel )
+ public LdapPrincipal( LdapDN name, AuthenticationLevel authenticationLevel )
{
this.name = name;
this.authenticationLevel = authenticationLevel;
@@ -78,7 +78,7 @@
* @param authenticationLevel
* @param userPassword The user password
*/
- LdapPrincipal( LdapDN name, AuthenticationLevel authenticationLevel, byte[] userPassword )
+ public LdapPrincipal( LdapDN name, AuthenticationLevel authenticationLevel, byte[] userPassword )
{
this.name = name;
this.authenticationLevel = authenticationLevel;
Modified: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/authn/SimpleAuthenticator.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/authn/SimpleAuthenticator.java?rev=582462&r1=582461&r2=582462&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/authn/SimpleAuthenticator.java (original)
+++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/authn/SimpleAuthenticator.java Fri Oct 5 23:48:35 2007
@@ -36,7 +36,6 @@
import javax.naming.directory.Attributes;
import org.apache.commons.collections.map.LRUMap;
-import org.apache.directory.server.core.configuration.StartupConfiguration;
import org.apache.directory.server.core.interceptor.context.LookupOperationContext;
import org.apache.directory.server.core.invocation.Invocation;
import org.apache.directory.server.core.invocation.InvocationStack;