directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r896599 [13/30] - in /directory/apacheds/trunk: ./ avl-partition/ avl-partition/src/ avl-partition/src/main/ avl-partition/src/main/java/ avl-partition/src/main/java/org/ avl-partition/src/main/java/org/apache/ avl-partition/src/main/java/o...
Date Wed, 06 Jan 2010 18:27:19 GMT
Modified: directory/apacheds/trunk/core-jndi/src/main/java/org/apache/directory/server/core/jndi/ServerContext.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-jndi/src/main/java/org/apache/directory/server/core/jndi/ServerContext.java?rev=896599&r1=896598&r2=896599&view=diff
==============================================================================
--- directory/apacheds/trunk/core-jndi/src/main/java/org/apache/directory/server/core/jndi/ServerContext.java (original)
+++ directory/apacheds/trunk/core-jndi/src/main/java/org/apache/directory/server/core/jndi/ServerContext.java Wed Jan  6 18:26:43 2010
@@ -20,12 +20,34 @@
 package org.apache.directory.server.core.jndi;
 
 
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.List;
+import java.util.Map;
+
+import javax.naming.Context;
+import javax.naming.InvalidNameException;
+import javax.naming.Name;
+import javax.naming.NameNotFoundException;
+import javax.naming.NameParser;
+import javax.naming.NamingEnumeration;
+import javax.naming.NamingException;
+import javax.naming.Reference;
+import javax.naming.Referenceable;
+import javax.naming.directory.DirContext;
+import javax.naming.directory.SearchControls;
+import javax.naming.event.EventContext;
+import javax.naming.event.NamingListener;
+import javax.naming.ldap.Control;
+import javax.naming.spi.DirStateFactory;
+import javax.naming.spi.DirectoryManager;
+
 import org.apache.directory.server.core.CoreSession;
 import org.apache.directory.server.core.DefaultCoreSession;
 import org.apache.directory.server.core.DirectoryService;
+import org.apache.directory.server.core.LdapPrincipal;
 import org.apache.directory.server.core.OperationManager;
-import org.apache.directory.server.core.authn.LdapPrincipal;
-import org.apache.directory.shared.ldap.entry.EntryAttribute;
 import org.apache.directory.server.core.entry.ClonedServerEntry;
 import org.apache.directory.server.core.entry.DefaultServerEntry;
 import org.apache.directory.server.core.entry.ServerEntry;
@@ -52,6 +74,7 @@
 import org.apache.directory.shared.ldap.constants.SchemaConstants;
 import org.apache.directory.shared.ldap.cursor.EmptyCursor;
 import org.apache.directory.shared.ldap.cursor.SingletonCursor;
+import org.apache.directory.shared.ldap.entry.EntryAttribute;
 import org.apache.directory.shared.ldap.entry.Modification;
 import org.apache.directory.shared.ldap.exception.LdapNoPermissionException;
 import org.apache.directory.shared.ldap.exception.LdapSchemaViolationException;
@@ -61,34 +84,12 @@
 import org.apache.directory.shared.ldap.filter.SearchScope;
 import org.apache.directory.shared.ldap.message.AliasDerefMode;
 import org.apache.directory.shared.ldap.message.ResultCodeEnum;
-import org.apache.directory.shared.ldap.name.AttributeTypeAndValue;
+import org.apache.directory.shared.ldap.name.AVA;
 import org.apache.directory.shared.ldap.name.LdapDN;
 import org.apache.directory.shared.ldap.name.Rdn;
 import org.apache.directory.shared.ldap.util.AttributeUtils;
 import org.apache.directory.shared.ldap.util.StringTools;
 
-import javax.naming.Context;
-import javax.naming.InvalidNameException;
-import javax.naming.Name;
-import javax.naming.NameNotFoundException;
-import javax.naming.NameParser;
-import javax.naming.NamingEnumeration;
-import javax.naming.NamingException;
-import javax.naming.Reference;
-import javax.naming.Referenceable;
-import javax.naming.directory.DirContext;
-import javax.naming.directory.SearchControls;
-import javax.naming.event.EventContext;
-import javax.naming.event.NamingListener;
-import javax.naming.ldap.Control;
-import javax.naming.spi.DirStateFactory;
-import javax.naming.spi.DirectoryManager;
-import java.io.Serializable;
-import java.util.HashMap;
-import java.util.Hashtable;
-import java.util.List;
-import java.util.Map;
-
 
 /**
  * A non-federated abstract Context implementation.
@@ -148,7 +149,6 @@
      * @throws NamingException if the environment parameters are not set 
      * correctly.
      */
-    @SuppressWarnings(value = { "unchecked" })
     protected ServerContext( DirectoryService service, Hashtable<String, Object> env ) throws Exception
     {
         this.service = service;
@@ -338,7 +338,7 @@
             
             if ( result )
             {
-                ServerEntry emptyEntry = new DefaultServerEntry( service.getRegistries(), LdapDN.EMPTY_LDAPDN ); 
+                ServerEntry emptyEntry = new DefaultServerEntry( service.getSchemaManager(), LdapDN.EMPTY_LDAPDN ); 
                 return new BaseEntryFilteringCursor( new SingletonCursor<ServerEntry>( emptyEntry ), (SearchOperationContext)opContext );
             }
             else
@@ -484,7 +484,7 @@
     /**
      * Used to encapsulate [de]marshalling of controls before and after moveAndRename operations.
      */
-    protected void doMoveAndRenameOperation( LdapDN oldDn, LdapDN parent, String newRdn, boolean delOldDn )
+    protected void doMoveAndRenameOperation( LdapDN oldDn, LdapDN parent, Rdn newRdn, boolean delOldDn )
         throws Exception
     {
         // setup the op context and populate with request controls
@@ -552,10 +552,10 @@
     /**
      * Used to encapsulate [de]marshalling of controls before and after rename operations.
      */
-    protected void doRename( LdapDN oldDn, String newRdn, boolean delOldRdn ) throws Exception
+    protected void doRename( LdapDN oldDn, Rdn newRdn, boolean delOldRdn ) throws Exception
     {
         // setup the op context and populate with request controls
-        RenameOperationContext opCtx = new RenameOperationContext( session, oldDn, new Rdn( newRdn ), delOldRdn );
+        RenameOperationContext opCtx = new RenameOperationContext( session, oldDn, newRdn, delOldRdn );
         opCtx.addRequestControls( requestControls );
 
         // Inject the referral handling into the operation context
@@ -653,7 +653,7 @@
      */
     public String getNameInNamespace() throws NamingException
     {
-        return dn.getUpName();
+        return dn.getName();
     }
 
 
@@ -807,11 +807,11 @@
 
         if ( rdn.size() == 1 )
         {
-            serverEntry.put( rdn.getUpType(), ( String ) rdn.getValue() );
+            serverEntry.put( rdn.getUpType(), ( String ) rdn.getNormValue() );
         }
         else
         {
-            for ( AttributeTypeAndValue atav : rdn )
+            for ( AVA atav : rdn )
             {
                 serverEntry.put( atav.getUpType(), atav.getNormValue().getString() );
             }
@@ -831,7 +831,7 @@
 
         // let's be sure that the Attributes is case insensitive
         ServerEntry outServerEntry = ServerEntryUtils.toServerEntry( AttributeUtils.toCaseInsensitive( res
-            .getAttributes() ), target, service.getRegistries() );
+            .getAttributes() ), target, service.getSchemaManager() );
 
         if ( outServerEntry != null )
         {
@@ -885,7 +885,7 @@
             injectRdnAttributeValues( target, serverEntry );
 
             // Serialize object into entry attributes and add it.
-            JavaLdapSupport.serialize( serverEntry, obj, service.getRegistries() );
+            JavaLdapSupport.serialize( serverEntry, obj, service.getSchemaManager() );
             try
             {
                 doAddOperation( target, serverEntry );
@@ -899,7 +899,7 @@
         {
             // Grab attributes and merge with outAttrs
             ServerEntry serverEntry = ServerEntryUtils.toServerEntry( ( ( DirContext ) obj ).getAttributes( "" ),
-                target, service.getRegistries() );
+                target, service.getSchemaManager() );
 
             if ( ( outServerEntry != null ) && ( outServerEntry.size() > 0 ) )
             {
@@ -949,13 +949,13 @@
         }
 
         // calculate parents
-        LdapDN oldBase = ( LdapDN ) oldName.clone();
-        oldBase.remove( oldName.size() - 1 );
-        LdapDN newBase = ( LdapDN ) newName.clone();
-        newBase.remove( newName.size() - 1 );
+        LdapDN oldParent = (LdapDN)oldDn.clone();
+        oldParent.remove( oldDn.size() - 1 );
+        LdapDN newParent = ( LdapDN ) newDn.clone();
+        newParent.remove( newDn.size() - 1 );
 
-        String newRdn = newName.get( newName.size() - 1 );
-        String oldRdn = oldName.get( oldName.size() - 1 );
+        Rdn oldRdn = oldDn.getRdn();
+        Rdn newRdn = newDn.getRdn();
         boolean delOldRdn = true;
 
         /*
@@ -977,7 +977,7 @@
          * a move operation.  Furthermore if the RDN in the move operation 
          * changes it is both an RDN change and a move operation.
          */
-        if ( ( oldName.size() == newName.size() ) && oldBase.equals( newBase ) )
+        if ( oldParent.equals( newParent ) )
         {
             try
             {
@@ -990,14 +990,11 @@
         }
         else
         {
-            LdapDN target = ( LdapDN ) newDn.clone();
-            target.remove( newDn.size() - 1 );
-
-            if ( newRdn.equalsIgnoreCase( oldRdn ) )
+            if ( newRdn.equals( oldRdn ) )
             {
                 try
                 {
-                    doMove( oldDn, target );
+                    doMove( oldDn, newParent );
                 }
                 catch ( Exception e )
                 {
@@ -1008,7 +1005,7 @@
             {
                 try
                 {
-                    doMoveAndRenameOperation( oldDn, target, newRdn, delOldRdn );
+                    doMoveAndRenameOperation( oldDn, newParent, newRdn, delOldRdn );
                 }
                 catch ( Exception e )
                 {

Modified: directory/apacheds/trunk/core-jndi/src/main/java/org/apache/directory/server/core/jndi/ServerDirContext.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-jndi/src/main/java/org/apache/directory/server/core/jndi/ServerDirContext.java?rev=896599&r1=896598&r2=896599&view=diff
==============================================================================
--- directory/apacheds/trunk/core-jndi/src/main/java/org/apache/directory/server/core/jndi/ServerDirContext.java (original)
+++ directory/apacheds/trunk/core-jndi/src/main/java/org/apache/directory/server/core/jndi/ServerDirContext.java Wed Jan  6 18:26:43 2010
@@ -20,9 +20,33 @@
 package org.apache.directory.server.core.jndi;
 
 
+import java.io.Serializable;
+import java.text.ParseException;
+import java.util.ArrayList;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.naming.Name;
+import javax.naming.NamingEnumeration;
+import javax.naming.NamingException;
+import javax.naming.Reference;
+import javax.naming.Referenceable;
+import javax.naming.directory.Attribute;
+import javax.naming.directory.Attributes;
+import javax.naming.directory.DirContext;
+import javax.naming.directory.InvalidSearchFilterException;
+import javax.naming.directory.ModificationItem;
+import javax.naming.directory.SearchControls;
+import javax.naming.directory.SearchResult;
+import javax.naming.event.EventDirContext;
+import javax.naming.event.NamingListener;
+import javax.naming.spi.DirStateFactory;
+import javax.naming.spi.DirectoryManager;
+
 import org.apache.directory.server.core.CoreSession;
 import org.apache.directory.server.core.DirectoryService;
-import org.apache.directory.server.core.authn.LdapPrincipal;
+import org.apache.directory.server.core.LdapPrincipal;
 import org.apache.directory.server.core.entry.ServerEntry;
 import org.apache.directory.server.core.entry.ServerEntryUtils;
 import org.apache.directory.server.core.event.DirectoryListener;
@@ -43,35 +67,12 @@
 import org.apache.directory.shared.ldap.filter.SearchScope;
 import org.apache.directory.shared.ldap.filter.SimpleNode;
 import org.apache.directory.shared.ldap.message.AliasDerefMode;
-import org.apache.directory.shared.ldap.name.AttributeTypeAndValue;
+import org.apache.directory.shared.ldap.name.AVA;
 import org.apache.directory.shared.ldap.name.LdapDN;
 import org.apache.directory.shared.ldap.name.Rdn;
 import org.apache.directory.shared.ldap.util.AttributeUtils;
 import org.apache.directory.shared.ldap.util.StringTools;
 
-import javax.naming.Name;
-import javax.naming.NamingEnumeration;
-import javax.naming.NamingException;
-import javax.naming.Reference;
-import javax.naming.Referenceable;
-import javax.naming.directory.Attribute;
-import javax.naming.directory.Attributes;
-import javax.naming.directory.DirContext;
-import javax.naming.directory.InvalidSearchFilterException;
-import javax.naming.directory.ModificationItem;
-import javax.naming.directory.SearchControls;
-import javax.naming.directory.SearchResult;
-import javax.naming.event.EventDirContext;
-import javax.naming.event.NamingListener;
-import javax.naming.spi.DirStateFactory;
-import javax.naming.spi.DirectoryManager;
-import java.io.Serializable;
-import java.text.ParseException;
-import java.util.ArrayList;
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.List;
-
 
 /**
  * The DirContext implementation for the Server Side JNDI LDAP provider.
@@ -213,7 +214,7 @@
 
         List<Modification> newMods = ServerEntryUtils.convertToServerModification( 
             modItems, 
-            getDirectoryService().getRegistries().getAttributeTypeRegistry() );
+            getDirectoryService().getSchemaManager() );
 
         try
         {
@@ -250,7 +251,7 @@
     public void modifyAttributes( Name name, ModificationItem[] mods ) throws NamingException
     {
         List<Modification> newMods = ServerEntryUtils
-            .toServerModification( mods, getDirectoryService().getRegistries().getAttributeTypeRegistry() );
+            .toServerModification( mods, getDirectoryService().getSchemaManager() );
         try
         {
             doModifyOperation( buildTarget( new LdapDN( name ) ), newMods );
@@ -270,7 +271,7 @@
     {
         List<Modification> newMods = ServerEntryUtils
             .convertToServerModification( mods, 
-                getDirectoryService().getRegistries().getAttributeTypeRegistry() );
+                getDirectoryService().getSchemaManager() );
         try
         {
             doModifyOperation( buildTarget( new LdapDN( name ) ), newMods );
@@ -314,7 +315,7 @@
         LdapDN target = buildTarget( name );
 
         ServerEntry serverEntry = ServerEntryUtils.toServerEntry( AttributeUtils.toCaseInsensitive( attrs ), target,
-            getDirectoryService().getRegistries() );
+            getDirectoryService().getSchemaManager() );
 
         // No object binding so we just add the attributes
         if ( null == obj )
@@ -334,7 +335,7 @@
         // First, use state factories to do a transformation
         DirStateFactory.Result res = DirectoryManager.getStateToBind( obj, name, this, getEnvironment(), attrs );
         ServerEntry outServerEntry = ServerEntryUtils.toServerEntry( 
-            res.getAttributes(), target, getDirectoryService().getRegistries() );
+            res.getAttributes(), target, getDirectoryService().getSchemaManager() );
 
         if ( outServerEntry != serverEntry )
         {
@@ -386,7 +387,7 @@
             }
 
             // Serialize object into entry attributes and add it.
-            JavaLdapSupport.serialize( serverEntry, obj, getDirectoryService().getRegistries() );
+            JavaLdapSupport.serialize( serverEntry, obj, getDirectoryService().getSchemaManager() );
             try
             {
                 // setup the op context
@@ -401,7 +402,7 @@
         {
             // Grab attributes and merge with outAttrs
             ServerEntry entry = ServerEntryUtils.toServerEntry( ( ( DirContext ) obj ).getAttributes( "" ), target,
-                getDirectoryService().getRegistries() );
+                getDirectoryService().getSchemaManager() );
 
             if ( ( outServerEntry != null ) && ( outServerEntry.size() > 0 ) )
             {
@@ -468,7 +469,9 @@
      */
     public DirContext createSubcontext( String name, Attributes attrs ) throws NamingException
     {
-        return createSubcontext( new LdapDN( name ), AttributeUtils.toCaseInsensitive( attrs ) );
+        LdapDN dn = new LdapDN( name );
+        Attributes attributes = AttributeUtils.toCaseInsensitive( attrs );
+        return createSubcontext( dn, attributes );
     }
 
 
@@ -492,7 +495,7 @@
         if ( rdn.size() == 1 )
         {
             String rdnAttribute = rdn.getUpType();
-            String rdnValue = ( String ) rdn.getValue();
+            String rdnValue = ( String ) rdn.getNormValue();
 
             // Add the Rdn attribute
             boolean doRdnPut = attributes.get( rdnAttribute ) == null;
@@ -508,9 +511,9 @@
         }
         else
         {
-            for ( Iterator<AttributeTypeAndValue> ii = rdn.iterator(); ii.hasNext(); /**/)
+            for ( Iterator<AVA> ii = rdn.iterator(); ii.hasNext(); /**/)
             {
-                AttributeTypeAndValue atav = ii.next();
+                AVA atav = ii.next();
 
                 // Add the Rdn attribute
                 boolean doRdnPut = attributes.get( atav.getNormType() ) == null;
@@ -530,7 +533,7 @@
         try
         {
             ServerEntry serverEntry = ServerEntryUtils.toServerEntry( attributes, 
-                target, getDirectoryService().getRegistries() );
+                target, getDirectoryService().getSchemaManager() );
             doAddOperation( target, serverEntry );
         }
         catch ( Exception e )

Modified: directory/apacheds/trunk/core-jndi/src/main/java/org/apache/directory/server/core/jndi/ServerLdapContext.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-jndi/src/main/java/org/apache/directory/server/core/jndi/ServerLdapContext.java?rev=896599&r1=896598&r2=896599&view=diff
==============================================================================
--- directory/apacheds/trunk/core-jndi/src/main/java/org/apache/directory/server/core/jndi/ServerLdapContext.java (original)
+++ directory/apacheds/trunk/core-jndi/src/main/java/org/apache/directory/server/core/jndi/ServerLdapContext.java Wed Jan  6 18:26:43 2010
@@ -30,7 +30,7 @@
 
 import org.apache.directory.server.core.CoreSession;
 import org.apache.directory.server.core.DirectoryService;
-import org.apache.directory.server.core.authn.LdapPrincipal;
+import org.apache.directory.server.core.LdapPrincipal;
 import org.apache.directory.server.core.entry.ServerBinaryValue;
 import org.apache.directory.server.core.entry.ServerStringValue;
 import org.apache.directory.server.core.interceptor.context.CompareOperationContext;
@@ -181,7 +181,7 @@
     {
         Value<?> val = null;
         
-        AttributeType attributeType = getService().getRegistries().getAttributeTypeRegistry().lookup( oid );
+        AttributeType attributeType = getService().getSchemaManager().lookupAttributeTypeRegistry( oid );
         
         // make sure we add the request controls to operation
         if ( attributeType.getSyntax().isHumanReadable() )

Modified: directory/apacheds/trunk/core-jndi/src/test/java/org/apache/directory/server/core/jndi/LdapJndiPropertiesTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-jndi/src/test/java/org/apache/directory/server/core/jndi/LdapJndiPropertiesTest.java?rev=896599&r1=896598&r2=896599&view=diff
==============================================================================
--- directory/apacheds/trunk/core-jndi/src/test/java/org/apache/directory/server/core/jndi/LdapJndiPropertiesTest.java (original)
+++ directory/apacheds/trunk/core-jndi/src/test/java/org/apache/directory/server/core/jndi/LdapJndiPropertiesTest.java Wed Jan  6 18:26:43 2010
@@ -29,9 +29,11 @@
 import org.apache.directory.shared.ldap.constants.AuthenticationLevel;
 import org.apache.directory.shared.ldap.exception.LdapConfigurationException;
 import org.apache.directory.shared.ldap.util.StringTools;
+import org.junit.Test;
 
-import junit.framework.TestCase;
-
+import static org.junit.Assert.fail;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
 
 /**
  * Tests the LdapJndiProperties.
@@ -39,8 +41,9 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$
  */
-public class LdapJndiPropertiesTest extends TestCase
+public class LdapJndiPropertiesTest
 {
+    @Test
     public void testEmptyEnv() throws Exception
     {
         try
@@ -54,6 +57,7 @@
     }
 
 
+    @Test
     public void testNullEnv() throws Exception
     {
         try
@@ -67,6 +71,7 @@
     }
 
 
+    @Test
     public void testNoAuthWithCredsEnv() throws Exception
     {
         Hashtable<String,Object> env = new Hashtable<String,Object>();
@@ -79,6 +84,7 @@
     }
 
 
+    @Test
     public void testNoAuthWithNoCredsEnv() throws Exception
     {
         Hashtable<String,Object> env = new Hashtable<String,Object>();
@@ -90,6 +96,7 @@
     }
 
 
+    @Test
     public void testAuthWithNoCredsEnv() throws Exception
     {
         Hashtable<String,Object> env = new Hashtable<String,Object>();
@@ -106,6 +113,7 @@
     }
 
 
+    @Test
     public void testAuthWithNoCredsStrong() throws Exception
     {
         Hashtable<String,Object> env = new Hashtable<String,Object>();
@@ -118,6 +126,7 @@
     }
 
 
+    @Test
     public void testAuthWithCredsStrong() throws Exception
     {
         Hashtable<String,Object> env = new Hashtable<String,Object>();

Modified: directory/apacheds/trunk/core-jndi/src/test/resources/log4j.properties
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-jndi/src/test/resources/log4j.properties?rev=896599&r1=896598&r2=896599&view=diff
==============================================================================
--- directory/apacheds/trunk/core-jndi/src/test/resources/log4j.properties (original)
+++ directory/apacheds/trunk/core-jndi/src/test/resources/log4j.properties Wed Jan  6 18:26:43 2010
@@ -14,7 +14,7 @@
 #    See the License for the specific language governing permissions and
 #    limitations under the License.
 #############################################################################
-log4j.rootCategory=ERROR, stdout
+log4j.rootCategory=OFF, stdout
 
 log4j.appender.stdout=org.apache.log4j.ConsoleAppender
 log4j.appender.stdout.layout=org.apache.log4j.PatternLayout

Propchange: directory/apacheds/trunk/core-mock/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Wed Jan  6 18:26:43 2010
@@ -0,0 +1,16 @@
+target
+.clover
+.wtpmodules
+.settings
+.deployables
+apache.org
+.metadata
+*.md5
+*.log
+*.iml
+*.ipr
+*.iws
+.project
+.classpath
+nbproject
+schema

Modified: directory/apacheds/trunk/core/pom.xml
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/pom.xml?rev=896599&r1=896598&r2=896599&view=diff
==============================================================================
--- directory/apacheds/trunk/core/pom.xml (original)
+++ directory/apacheds/trunk/core/pom.xml Wed Jan  6 18:26:43 2010
@@ -51,31 +51,31 @@
 
     <dependency>
       <groupId>org.apache.directory.server</groupId>
-      <artifactId>apacheds-xdbm-tools</artifactId>
+      <artifactId>apacheds-core-api</artifactId>
       <version>${pom.version}</version>
     </dependency>
 
     <dependency>
-      <groupId>org.apache.directory.server</groupId>
-      <artifactId>apacheds-schema-bootstrap</artifactId>
-      <version>${pom.version}</version>
+      <groupId>org.apache.directory.shared</groupId>
+      <artifactId>shared-ldap-schema</artifactId>
+      <version>${org.apache.directory.shared.version}</version>
     </dependency>
 
     <dependency>
-      <groupId>org.apache.directory.server</groupId>
-      <artifactId>apacheds-core-entry</artifactId>
-      <version>${pom.version}</version>
+      <groupId>org.apache.directory.shared</groupId>
+      <artifactId>shared-ldap-schema-manager</artifactId>
+      <version>${org.apache.directory.shared.version}</version>
     </dependency>
 
     <dependency>
       <groupId>org.apache.directory.server</groupId>
-      <artifactId>apacheds-schema-registries</artifactId>
+      <artifactId>apacheds-xdbm-tools</artifactId>
       <version>${pom.version}</version>
     </dependency>
 
     <dependency>
       <groupId>org.apache.directory.server</groupId>
-      <artifactId>apacheds-core-shared</artifactId>
+      <artifactId>apacheds-core-entry</artifactId>
       <version>${pom.version}</version>
     </dependency>
 
@@ -104,19 +104,6 @@
     </dependency>
 
     <dependency>
-      <groupId>org.apache.directory.server</groupId>
-      <artifactId>apacheds-bootstrap-extract</artifactId>
-      <version>${pom.version}</version>
-    </dependency>
-
-    <dependency>
-      <groupId>org.apache.directory.server</groupId>
-      <artifactId>apacheds-bootstrap-partition</artifactId>
-      <version>${pom.version}</version>
-      <scope>test</scope>
-    </dependency>
-
-    <dependency>
       <groupId>org.apache.directory.shared</groupId>
       <version>${org.apache.directory.shared.version}</version>
       <artifactId>shared-cursor</artifactId>

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/DefaultCoreSession.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/DefaultCoreSession.java?rev=896599&r1=896598&r2=896599&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/DefaultCoreSession.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/DefaultCoreSession.java Wed Jan  6 18:26:43 2010
@@ -29,8 +29,7 @@
 import javax.naming.ldap.Control;
 
 import org.apache.directory.server.constants.ServerDNConstants;
-import org.apache.directory.server.core.DefaultDirectoryService.LogChange;
-import org.apache.directory.server.core.authn.LdapPrincipal;
+import org.apache.directory.server.core.changelog.LogChange;
 import org.apache.directory.server.core.entry.ClonedServerEntry;
 import org.apache.directory.server.core.entry.ServerBinaryValue;
 import org.apache.directory.server.core.entry.ServerEntry;
@@ -57,8 +56,8 @@
 import org.apache.directory.shared.ldap.filter.ExprNode;
 import org.apache.directory.shared.ldap.filter.FilterParser;
 import org.apache.directory.shared.ldap.filter.SearchScope;
-import org.apache.directory.shared.ldap.message.InternalAddRequest;
 import org.apache.directory.shared.ldap.message.AliasDerefMode;
+import org.apache.directory.shared.ldap.message.InternalAddRequest;
 import org.apache.directory.shared.ldap.message.InternalCompareRequest;
 import org.apache.directory.shared.ldap.message.InternalDeleteRequest;
 import org.apache.directory.shared.ldap.message.InternalModifyDnRequest;
@@ -189,7 +188,7 @@
     {
         Value<?> val = null;
         
-        AttributeType attributeType = directoryService.getRegistries().getAttributeTypeRegistry().lookup( oid );
+        AttributeType attributeType = directoryService.getSchemaManager().lookupAttributeTypeRegistry( oid );
         
         // make sure we add the request controls to operation
         if ( attributeType.getSyntax().isHumanReadable() )
@@ -508,7 +507,7 @@
         
         for ( Modification mod:mods )
         {
-            serverModifications.add( new ServerModification( directoryService.getRegistries(), mod ) );
+            serverModifications.add( new ServerModification( directoryService.getSchemaManager(), mod ) );
         }
         
         ModifyOperationContext opContext = new ModifyOperationContext( this, dn, serverModifications );
@@ -543,7 +542,7 @@
         
         for ( Modification mod:mods )
         {
-            serverModifications.add( new ServerModification( directoryService.getRegistries(), mod ) );
+            serverModifications.add( new ServerModification( directoryService.getSchemaManager(), mod ) );
         }
 
         ModifyOperationContext opContext = new ModifyOperationContext( this, dn, serverModifications );
@@ -670,6 +669,7 @@
         opContext.setLogChange( log );
 
         OperationManager operationManager = directoryService.getOperationManager();
+        
         operationManager.rename( opContext );
     }
 

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java?rev=896599&r1=896598&r2=896599&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java Wed Jan  6 18:26:43 2010
@@ -20,9 +20,22 @@
 package org.apache.directory.server.core;
 
 
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.IOException;
+import java.io.StringReader;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.UUID;
+
+import javax.naming.NamingException;
+
 import org.apache.directory.server.constants.ServerDNConstants;
 import org.apache.directory.server.core.authn.AuthenticationInterceptor;
-import org.apache.directory.server.core.authn.LdapPrincipal;
 import org.apache.directory.server.core.authz.AciAuthorizationInterceptor;
 import org.apache.directory.server.core.authz.DefaultAuthorizationInterceptor;
 import org.apache.directory.server.core.changelog.ChangeLog;
@@ -53,33 +66,14 @@
 import org.apache.directory.server.core.partition.DefaultPartitionNexus;
 import org.apache.directory.server.core.partition.Partition;
 import org.apache.directory.server.core.partition.PartitionNexus;
-import org.apache.directory.server.core.partition.impl.btree.BTreePartition;
-import org.apache.directory.server.xdbm.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.ReferralInterceptor;
 import org.apache.directory.server.core.replication.ReplicationConfiguration;
-import org.apache.directory.server.core.schema.PartitionSchemaLoader;
+import org.apache.directory.server.core.schema.DefaultSchemaService;
 import org.apache.directory.server.core.schema.SchemaInterceptor;
-import org.apache.directory.server.core.schema.SchemaOperationControl;
-import org.apache.directory.server.core.schema.SchemaPartitionDao;
 import org.apache.directory.server.core.schema.SchemaService;
 import org.apache.directory.server.core.security.TlsKeyGenerator;
 import org.apache.directory.server.core.subtree.SubentryInterceptor;
 import org.apache.directory.server.core.trigger.TriggerInterceptor;
-import org.apache.directory.server.schema.SerializableComparator;
-import org.apache.directory.server.schema.bootstrap.ApacheSchema;
-import org.apache.directory.server.schema.bootstrap.ApachemetaSchema;
-import org.apache.directory.server.schema.bootstrap.BootstrapSchemaLoader;
-import org.apache.directory.server.schema.bootstrap.CoreSchema;
-import org.apache.directory.server.schema.bootstrap.Schema;
-import org.apache.directory.server.schema.bootstrap.SystemSchema;
-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.DefaultOidRegistry;
-import org.apache.directory.server.schema.registries.DefaultRegistries;
-import org.apache.directory.server.schema.registries.OidRegistry;
-import org.apache.directory.server.schema.registries.Registries;
 import org.apache.directory.shared.ldap.NotImplementedException;
 import org.apache.directory.shared.ldap.constants.AuthenticationLevel;
 import org.apache.directory.shared.ldap.constants.SchemaConstants;
@@ -90,15 +84,13 @@
 import org.apache.directory.shared.ldap.entry.EntryAttribute;
 import org.apache.directory.shared.ldap.entry.Modification;
 import org.apache.directory.shared.ldap.entry.client.DefaultClientEntry;
-import org.apache.directory.shared.ldap.exception.LdapNamingException;
 import org.apache.directory.shared.ldap.exception.LdapNoPermissionException;
 import org.apache.directory.shared.ldap.ldif.ChangeType;
 import org.apache.directory.shared.ldap.ldif.LdifEntry;
 import org.apache.directory.shared.ldap.ldif.LdifReader;
-import org.apache.directory.shared.ldap.message.ResultCodeEnum;
 import org.apache.directory.shared.ldap.name.LdapDN;
 import org.apache.directory.shared.ldap.name.Rdn;
-import org.apache.directory.shared.ldap.schema.AttributeType;
+import org.apache.directory.shared.ldap.schema.SchemaManager;
 import org.apache.directory.shared.ldap.schema.SchemaUtils;
 import org.apache.directory.shared.ldap.schema.normalizers.OidNormalizer;
 import org.apache.directory.shared.ldap.util.AttributeUtils;
@@ -107,20 +99,6 @@
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import javax.naming.NamingException;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.IOException;
-import java.io.StringReader;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.UUID;
-
 
 /**
  * Default implementation of {@link DirectoryService}.
@@ -132,15 +110,11 @@
 {
     /** The logger */
     private static final Logger LOG = LoggerFactory.getLogger( DefaultDirectoryService.class );
-
-    private static final String ILLEGAL_STATE_MSG = "Something has got to be severely " +
-    "wrong with the core packaging\nor the build to have " +
-    "resulted in this exception.";
     
     private SchemaService schemaService;
-
-    /** the registries for system schema objects */
-    private Registries registries;
+    
+    /** A reference on the SchemaManager */
+    private SchemaManager schemaManager;
     
     /** the root nexus */
     private DefaultPartitionNexus partitionNexus;
@@ -195,13 +169,6 @@
             "all taken into account";
 
     
-    /** A structure telling the changeLog what to do with the incoming change */
-    public enum LogChange
-    {
-        TRUE,  // The change must me stored 
-        FALSE  // The change must not be stred
-    };
-    
     /** The delay to wait between each sync on disk */
     private long syncPeriodMillis;
     
@@ -312,60 +279,27 @@
     // ------------------------------------------------------------------------
     // Constructor
     // ------------------------------------------------------------------------
+    
+    
     /**
      * Creates a new instance of the directory service.
      */
-    public DefaultDirectoryService() 
+    public DefaultDirectoryService() throws Exception
     {
         setDefaultInterceptorConfigurations();
         changeLog = new DefaultChangeLog();
         journal = new DefaultJournal();
         syncPeriodMillis = DEFAULT_SYNC_PERIOD;
-        
-        // --------------------------------------------------------------------
-        // Load the bootstrap schemas to start up the schema partition
-        // --------------------------------------------------------------------
-
-        // setup temporary loader and temp registry 
-        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() );
-        bootstrapSchemas.add( new ApacheSchema() );
-        bootstrapSchemas.add( new CoreSchema() );
-        bootstrapSchemas.add( new SystemSchema() );
-        
-        try
-        {
-            loader.loadWithDependencies( bootstrapSchemas, registries );
-        }
-        catch ( Exception e )
-        {
-            throw new IllegalStateException( ILLEGAL_STATE_MSG, e );
-        }
-
-        // run referential integrity tests
-        List<Throwable> errors = registries.checkRefInteg();
-        
-        if ( !errors.isEmpty() )
-        {
-            NamingException e = new NamingException();
-            e.setRootCause( errors.get( 0 ) );
-            throw new IllegalStateException( ILLEGAL_STATE_MSG, e );
-        }
-        
-        SerializableComparator.setRegistry( registries.getComparatorRegistry() );
-        
         csnFactory = new CsnFactory( replicaId );
+        schemaService = new DefaultSchemaService();
     }
 
 
     // ------------------------------------------------------------------------
     // C O N F I G U R A T I O N   M E T H O D S
     // ------------------------------------------------------------------------
+    
+    
     public void setInstanceId( String instanceId )
     {
         this.instanceId = instanceId;
@@ -401,13 +335,16 @@
         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 );
         }
 
@@ -645,9 +582,10 @@
     }
 
 
-    public void addPartition( Partition parition ) throws Exception
+    public void addPartition( Partition partition ) throws Exception
     {
-        partitions.add( parition );
+        partition.setSchemaManager( schemaManager );
+        partitions.add( partition );
 
         if ( ! started )
         {
@@ -655,7 +593,7 @@
         }
 
         AddContextPartitionOperationContext addPartitionCtx = 
-            new AddContextPartitionOperationContext( adminSession, parition );
+            new AddContextPartitionOperationContext( adminSession, partition );
         partitionNexus.addContextPartition( addPartitionCtx );
     }
 
@@ -882,7 +820,7 @@
                     {
                         case ChangeType.ADD_ORDINAL :
                             adminSession.add( 
-                                new DefaultServerEntry( registries, reverse.getEntry() ), true ); 
+                                new DefaultServerEntry( schemaManager, reverse.getEntry() ), true ); 
                             break;
                             
                         case ChangeType.DELETE_ORDINAL :
@@ -1024,6 +962,7 @@
         // --------------------------------------------------------------------
         // Shutdown the partition
         // --------------------------------------------------------------------
+
         partitionNexus.sync();
         partitionNexus.destroy();
         
@@ -1075,17 +1014,22 @@
     
     
     /**
-     * @return the registries
+     * @return the SchemaManager
      */
-    public Registries getRegistries()
+    public SchemaManager getSchemaManager()
     {
-        return registries;
+        return schemaManager;
     }
-
-
-    public void setRegistries( Registries registries )
+    
+    
+    /**
+     * Set the SchemaManager instance.
+     *
+     * @param schemaManager The schemaManager
+     */
+    public void setSchemaManager( SchemaManager schemaManager )
     {
-        this.registries = registries;
+        this.schemaManager = schemaManager;
     }
 
 
@@ -1101,7 +1045,7 @@
     }
 
 
-    public PartitionNexus getPartitionNexus()
+    public DefaultPartitionNexus getPartitionNexus()
     {
         return partitionNexus;
     }
@@ -1127,7 +1071,7 @@
 
     public ServerEntry newEntry( LdapDN dn ) 
     {
-        return new DefaultServerEntry( registries, dn );
+        return new DefaultServerEntry( schemaManager, dn );
     }
     
 
@@ -1150,11 +1094,11 @@
         /*
          * If the admin entry is there, then the database was already created
          */
-        if ( !partitionNexus.hasEntry( new EntryOperationContext( adminSession, PartitionNexus.getAdminName() ) ) )
+        if ( !partitionNexus.hasEntry( new EntryOperationContext( adminSession, adminDn ) ) )
         {
             firstStart = true;
 
-            ServerEntry serverEntry = new DefaultServerEntry( registries, PartitionNexus.getAdminName() );
+            ServerEntry serverEntry = new DefaultServerEntry( schemaManager, adminDn );
             
             serverEntry.put( SchemaConstants.OBJECT_CLASS_AT, 
                                 SchemaConstants.TOP_OC,
@@ -1181,7 +1125,7 @@
         // create system users area
         // -------------------------------------------------------------------
 
-        Map<String,OidNormalizer> oidsMap = registries.getAttributeTypeRegistry().getNormalizerMapping();
+        Map<String,OidNormalizer> oidsMap = schemaManager.getNormalizerMapping();
         LdapDN userDn = new LdapDN( ServerDNConstants.USERS_SYSTEM_DN );
         userDn.normalize( oidsMap );
         
@@ -1189,7 +1133,7 @@
         {
             firstStart = true;
 
-            ServerEntry serverEntry = new DefaultServerEntry( registries, userDn );
+            ServerEntry serverEntry = new DefaultServerEntry( schemaManager, userDn );
             
             serverEntry.put( SchemaConstants.OBJECT_CLASS_AT, 
                                 SchemaConstants.TOP_OC,
@@ -1215,7 +1159,7 @@
         {
             firstStart = true;
 
-            ServerEntry serverEntry = new DefaultServerEntry( registries, groupDn );
+            ServerEntry serverEntry = new DefaultServerEntry( schemaManager, groupDn );
             
             serverEntry.put( SchemaConstants.OBJECT_CLASS_AT, 
                                 SchemaConstants.TOP_OC,
@@ -1241,7 +1185,7 @@
         {
             firstStart = true;
 
-            ServerEntry serverEntry = new DefaultServerEntry( registries, name );
+            ServerEntry serverEntry = new DefaultServerEntry( schemaManager, name );
             
             serverEntry.put( SchemaConstants.OBJECT_CLASS_AT, 
                                 SchemaConstants.TOP_OC,
@@ -1291,7 +1235,7 @@
         {
             firstStart = true;
 
-            ServerEntry serverEntry = new DefaultServerEntry( registries, configurationDn );
+            ServerEntry serverEntry = new DefaultServerEntry( schemaManager, configurationDn );
             serverEntry.put( SchemaConstants.OBJECT_CLASS_AT, SchemaConstants.TOP_OC, SchemaConstants.ORGANIZATIONAL_UNIT_OC );
 
             serverEntry.put( SchemaConstants.OU_AT, "configuration" );
@@ -1314,7 +1258,7 @@
         {
             firstStart = true;
 
-            ServerEntry serverEntry = new DefaultServerEntry( registries, partitionsDn );
+            ServerEntry serverEntry = new DefaultServerEntry( schemaManager, partitionsDn );
             serverEntry.put( SchemaConstants.OBJECT_CLASS_AT, SchemaConstants.TOP_OC, SchemaConstants.ORGANIZATIONAL_UNIT_OC );
             serverEntry.put( SchemaConstants.OU_AT, "partitions" );
             serverEntry.put( SchemaConstants.CREATORS_NAME_AT, ServerDNConstants.ADMIN_SYSTEM_DN_NORMALIZED );
@@ -1336,7 +1280,7 @@
         {
             firstStart = true;
 
-            ServerEntry serverEntry = new DefaultServerEntry( registries, servicesDn );
+            ServerEntry serverEntry = new DefaultServerEntry( schemaManager, servicesDn );
             serverEntry.put( SchemaConstants.OBJECT_CLASS_AT, SchemaConstants.TOP_OC, SchemaConstants.ORGANIZATIONAL_UNIT_OC );
 
             serverEntry.put( SchemaConstants.OU_AT, "services" );
@@ -1359,7 +1303,7 @@
         {
             firstStart = true;
 
-            ServerEntry serverEntry = new DefaultServerEntry( registries, interceptorsDn );
+            ServerEntry serverEntry = new DefaultServerEntry( schemaManager, interceptorsDn );
             serverEntry.put( SchemaConstants.OBJECT_CLASS_AT, SchemaConstants.TOP_OC, SchemaConstants.ORGANIZATIONAL_UNIT_OC );
 
             serverEntry.put( SchemaConstants.OU_AT, "interceptors" );
@@ -1382,7 +1326,7 @@
         {
             firstStart = true;
 
-            ServerEntry serverEntry = new DefaultServerEntry( registries, sysPrefRootDn );
+            ServerEntry serverEntry = new DefaultServerEntry( schemaManager, sysPrefRootDn );
             serverEntry.put( SchemaConstants.OBJECT_CLASS_AT, 
                 SchemaConstants.TOP_OC, 
                 SchemaConstants.ORGANIZATIONAL_UNIT_OC,
@@ -1411,7 +1355,7 @@
         boolean needToChangeAdminPassword = false;
 
         LdapDN adminDn = new LdapDN( ServerDNConstants.ADMIN_SYSTEM_DN );
-        adminDn.normalize( registries.getAttributeTypeRegistry().getNormalizerMapping() );
+        adminDn.normalize( schemaManager.getNormalizerMapping() );
         
         ServerEntry adminEntry = partitionNexus.lookup( new LookupOperationContext( adminSession, adminDn ) );
         Object userPassword = adminEntry.get( SchemaConstants.USER_PASSWORD_AT ).get();
@@ -1448,12 +1392,11 @@
             {
                 LdifEntry ldifEntry = testEntry.clone();
                 Entry entry = ldifEntry.getEntry();
-                String dn = ldifEntry.getDn().getUpName();
+                String dn = ldifEntry.getDn().getName();
 
                 try
                 {
-                    getAdminSession().add( 
-                        new DefaultServerEntry( registries, entry ) ); 
+                    getAdminSession().add( new DefaultServerEntry( schemaManager, entry ) ); 
                 }
                 catch ( Exception e )
                 {
@@ -1480,137 +1423,26 @@
             LOG.debug( "---> Initializing the DefaultDirectoryService " );
         }
 
-        // --------------------------------------------------------------------
-        // If not present extract schema partition from jar
-        // --------------------------------------------------------------------
-
-        File schemaDirectory = new File( workingDirectory, "schema" );
-        SchemaPartitionExtractor extractor;
-        
-        if ( ! schemaDirectory.exists() )
-        {
-            try
-            {
-                extractor = new SchemaPartitionExtractor( workingDirectory );
-                extractor.extract();
-            }
-            catch ( IOException e )
-            {
-                NamingException ne = new NamingException( "Failed to extract pre-loaded schema partition." );
-                ne.setRootCause( e );
-                throw ne;
-            }
-        }
-        
-        // --------------------------------------------------------------------
-        // Initialize schema partition
-        // --------------------------------------------------------------------
-
-        JdbmPartition schemaPartition = new JdbmPartition();
-        schemaPartition.setId( "schema" );
-        schemaPartition.setCacheSize( 1000 );
-
-        DbFileListing listing;
-        
-        try 
-        {
-            listing = new DbFileListing();
-        }
-        catch( IOException e )
-        {
-            throw new LdapNamingException( "Got IOException while trying to read DBFileListing: " + e.getMessage(), 
-                ResultCodeEnum.OTHER );
-        }
-
-        Set<Index<?,ServerEntry>> indexedAttributes = new HashSet<Index<?,ServerEntry>>();
-        
-        for ( String attributeId : listing.getIndexedAttributes() )
-        {
-            indexedAttributes.add( new JdbmIndex<Object,ServerEntry>( attributeId ) );
-        }
-
-        schemaPartition.setIndexedAttributes( indexedAttributes );
-        schemaPartition.setSuffix( ServerDNConstants.OU_SCHEMA_DN );
-        schemaPartition.init( this );
+        // triggers partition to load schema fully from schema partition
+        schemaService.initialize();
+        schemaService.getSchemaPartition().initialize();
+        partitions.add( schemaService.getSchemaPartition() );
+        systemPartition.getSuffixDn().normalize( schemaManager.getNormalizerMapping() );
 
-        // --------------------------------------------------------------------
-        // Enable schemas of all indices of partition configurations 
-        // --------------------------------------------------------------------
-
-        /*
-         * We need to make sure that every attribute indexed by a partition is
-         * loaded into the registries on the next step.  So here we must enable
-         * the schemas of those attributes so they are loaded into the global
-         * registries.
-         */
-        
-        SchemaPartitionDao dao = new SchemaPartitionDao( schemaPartition, registries );
-        Map<String,Schema> schemaMap = dao.getSchemas();
-        Set<Partition> partitions = new HashSet<Partition>();
-        partitions.add( systemPartition );
-        partitions.addAll( this.partitions );
-
-        for ( Partition partition : partitions )
-        {
-            if ( partition instanceof BTreePartition )
-            {
-                JdbmPartition btpconf = ( JdbmPartition ) partition;
-                for ( Index<?,ServerEntry> index : btpconf.getIndexedAttributes() )
-                {
-                    String schemaName = null;
-                    
-                    try
-                    {
-                        // Try to retrieve the AT in the registries
-                        AttributeType at = registries.getAttributeTypeRegistry().lookup( index.getAttributeId() );
-                        schemaName = dao.findSchema( at.getOid() );
-                    }
-                    catch ( Exception e )
-                    {
-                        // It does not exists: just use the attribute ID
-                        schemaName = dao.findSchema( index.getAttributeId() );
-                    }
-                    
-                    if ( schemaName == null )
-                    {
-                        throw new NamingException( "Index on unidentified attribute: " + index.toString() );
-                    }
-
-                    Schema schema = schemaMap.get( schemaName );
-                    if ( schema.isDisabled() )
-                    {
-                        dao.enableSchema( schemaName );
-                    }
-                }
-            }
-        }
-        
-        // --------------------------------------------------------------------
-        // Initialize schema subsystem and reset registries
-        // --------------------------------------------------------------------
-        
-        PartitionSchemaLoader schemaLoader = new PartitionSchemaLoader( schemaPartition, registries );
-        Registries globalRegistries = new DefaultRegistries( "global", schemaLoader, registries.getOidRegistry() );
-        schemaLoader.loadEnabled( globalRegistries );
-        registries = globalRegistries;
-        SerializableComparator.setRegistry( globalRegistries.getComparatorRegistry() );
-
-        SchemaOperationControl schemaControl = new SchemaOperationControl( registries, schemaLoader,
-            new SchemaPartitionDao( schemaPartition, registries ) );
-
-        schemaService = new SchemaService( this, schemaPartition, schemaControl );
-
-        adminDn = new LdapDN( ServerDNConstants.ADMIN_SYSTEM_DN_NORMALIZED );
-        adminDn.normalize( registries.getAttributeTypeRegistry().getNormalizerMapping() );
+        adminDn = new LdapDN( ServerDNConstants.ADMIN_SYSTEM_DN ).normalize( schemaManager.getNormalizerMapping() );
+        adminDn.normalize( schemaManager.getNormalizerMapping() );
         adminSession = new DefaultCoreSession( new LdapPrincipal( adminDn, AuthenticationLevel.STRONG ), this );
-
-        partitionNexus = new DefaultPartitionNexus( new DefaultServerEntry( registries, LdapDN.EMPTY_LDAPDN ) );
-        partitionNexus.init( this );
-        partitionNexus.addContextPartition( new AddContextPartitionOperationContext( adminSession, schemaPartition ) );
+        
+        // @TODO - NOTE: Need to find a way to instantiate without dependency on DPN
+        partitionNexus = new DefaultPartitionNexus( new DefaultServerEntry( schemaManager, LdapDN.EMPTY_LDAPDN ) );
+        partitionNexus.setDirectoryService( this );
+        partitionNexus.initialize( );
+        //partitionNexus.addContextPartition( new AddContextPartitionOperationContext( adminSession, schemaService.getSchemaPartition() ) );
 
         // --------------------------------------------------------------------
         // Create all the bootstrap entries before initializing chain
         // --------------------------------------------------------------------
+        
         firstStart = createBootstrapEntries();
 
         interceptorChain = new InterceptorChain();
@@ -1619,13 +1451,14 @@
         // --------------------------------------------------------------------
         // Initialize the changeLog if it's enabled
         // --------------------------------------------------------------------
+        
         if ( changeLog.isEnabled() )
         {
             changeLog.init( this );
             
             if( changeLog.isExposed() && changeLog.isTagSearchSupported() )
             {
-                String clSuffix = ( ( TaggableSearchableChangeLogStore ) changeLog.getChangeLogStore() ).getPartition().getSuffix();
+                String clSuffix = ( ( TaggableSearchableChangeLogStore ) changeLog.getChangeLogStore() ).getPartition().getSuffixDn().getName();
                 partitionNexus.getRootDSE( null ).getOriginalEntry().add( SchemaConstants.CHANGELOG_CONTEXT_AT, clSuffix );
             }
         }
@@ -1729,7 +1562,7 @@
             entry.setDn( ldapDn );
             
             // TODO Let's get rid of this Attributes crap
-            ServerEntry serverEntry = new DefaultServerEntry( registries, entry );
+            ServerEntry serverEntry = new DefaultServerEntry( schemaManager, entry );
             return serverEntry;
         }
         catch ( Exception e )
@@ -1765,7 +1598,7 @@
     /**
      * {@inheritDoc}
      */
-    public void setPassordHidden( boolean passwordHidden )
+    public void setPasswordHidden( boolean passwordHidden )
     {
         this.passwordHidden = passwordHidden;
     }

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/DefaultOperationManager.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/DefaultOperationManager.java?rev=896599&r1=896598&r2=896599&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/DefaultOperationManager.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/DefaultOperationManager.java Wed Jan  6 18:26:43 2010
@@ -222,7 +222,7 @@
         {
             // Normalize the opContext DN
             LdapDN dn = opContext.getDn();
-            dn.normalize( directoryService.getRegistries().getAttributeTypeRegistry().getNormalizerMapping() );
+            dn.normalize( directoryService.getSchemaManager().getNormalizerMapping() );
 
             // We have to deal with the referral first
             directoryService.getReferralManager().lockRead();
@@ -307,7 +307,7 @@
         {
             // Normalize the opContext DN
             LdapDN dn = opContext.getDn();
-            dn.normalize( directoryService.getRegistries().getAttributeTypeRegistry().getNormalizerMapping() );
+            dn.normalize( directoryService.getSchemaManager().getNormalizerMapping() );
 
             // We have to deal with the referral first
             directoryService.getReferralManager().lockRead();
@@ -387,7 +387,7 @@
         {
             // Normalize the opContext DN
             LdapDN dn = opContext.getDn();
-            dn.normalize( directoryService.getRegistries().getAttributeTypeRegistry().getNormalizerMapping() );
+            dn.normalize( directoryService.getSchemaManager().getNormalizerMapping() );
 
             // We have to deal with the referral first
             directoryService.getReferralManager().lockRead();
@@ -632,7 +632,7 @@
         {
             // Normalize the opContext DN
             LdapDN dn = opContext.getDn();
-            dn.normalize( directoryService.getRegistries().getAttributeTypeRegistry().getNormalizerMapping() );
+            dn.normalize( directoryService.getSchemaManager().getNormalizerMapping() );
 
             // We have to deal with the referral first
             directoryService.getReferralManager().lockRead();
@@ -715,7 +715,7 @@
         {
             // Normalize the opContext DN
             LdapDN dn = opContext.getDn();
-            dn.normalize( directoryService.getRegistries().getAttributeTypeRegistry().getNormalizerMapping() );
+            dn.normalize( directoryService.getSchemaManager().getNormalizerMapping() );
 
             // We have to deal with the referral first
             directoryService.getReferralManager().lockRead();
@@ -769,7 +769,7 @@
             // Now, check the destination
             // Normalize the opContext DN
             LdapDN parentDn = opContext.getParent();
-            parentDn.normalize( directoryService.getRegistries().getAttributeTypeRegistry().getNormalizerMapping() );
+            parentDn.normalize( directoryService.getSchemaManager().getNormalizerMapping() );
 
             // If he parent DN is a referral, or has a referral ancestor, we have to issue a AffectMultipleDsas result
             // as stated by RFC 3296 Section 5.6.2
@@ -817,7 +817,7 @@
         {
             // Normalize the opContext DN
             LdapDN dn = opContext.getDn();
-            dn.normalize( directoryService.getRegistries().getAttributeTypeRegistry().getNormalizerMapping() );
+            dn.normalize( directoryService.getSchemaManager().getNormalizerMapping() );
 
             // We have to deal with the referral first
             directoryService.getReferralManager().lockRead();
@@ -871,7 +871,7 @@
             // Now, check the destination
             // Normalize the opContext DN
             LdapDN parentDn = opContext.getParent();
-            parentDn.normalize( directoryService.getRegistries().getAttributeTypeRegistry().getNormalizerMapping() );
+            parentDn.normalize( directoryService.getSchemaManager().getNormalizerMapping() );
 
             // If he parent DN is a referral, or has a referral ancestor, we have to issue a AffectMultipleDsas result
             // as stated by RFC 3296 Section 5.6.2
@@ -921,8 +921,18 @@
         {
             // Normalize the opContext DN
             LdapDN dn = opContext.getDn();
-            dn.normalize( directoryService.getRegistries().getAttributeTypeRegistry().getNormalizerMapping() );
+            dn.normalize( directoryService.getSchemaManager().getNormalizerMapping() );
 
+            // Inject the newDn into the operation context
+            // Inject the new DN into the context
+            if ( !dn.isEmpty() )
+            {
+                LdapDN newDn = (LdapDN)dn.clone();
+                newDn.remove( dn.size() - 1 );
+                newDn.add( opContext.getNewRdn() );
+                opContext.setNewDn( newDn );
+            }
+            
             // We have to deal with the referral first
             directoryService.getReferralManager().lockRead();
 
@@ -1003,7 +1013,7 @@
         {
             // Normalize the opContext DN
             LdapDN dn = opContext.getDn();
-            dn.normalize( directoryService.getRegistries().getAttributeTypeRegistry().getNormalizerMapping() );
+            dn.normalize( directoryService.getSchemaManager().getNormalizerMapping() );
 
             // We have to deal with the referral first
             directoryService.getReferralManager().lockRead();

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/ReferralManagerImpl.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/ReferralManagerImpl.java?rev=896599&r1=896598&r2=896599&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/ReferralManagerImpl.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/ReferralManagerImpl.java Wed Jan  6 18:26:43 2010
@@ -19,6 +19,7 @@
  */
 package org.apache.directory.server.core;
 
+
 import java.util.Set;
 import java.util.concurrent.locks.ReentrantReadWriteLock;
 
@@ -29,13 +30,14 @@
 import org.apache.directory.server.core.filtering.EntryFilteringCursor;
 import org.apache.directory.server.core.interceptor.context.SearchOperationContext;
 import org.apache.directory.server.core.partition.PartitionNexus;
-import org.apache.directory.shared.ldap.message.AliasDerefMode;
-import org.apache.directory.shared.ldap.name.LdapDN;
-import org.apache.directory.shared.ldap.util.tree.DnBranchNode;
 import org.apache.directory.shared.ldap.constants.SchemaConstants;
 import org.apache.directory.shared.ldap.entry.client.ClientStringValue;
 import org.apache.directory.shared.ldap.filter.EqualityNode;
 import org.apache.directory.shared.ldap.filter.ExprNode;
+import org.apache.directory.shared.ldap.message.AliasDerefMode;
+import org.apache.directory.shared.ldap.name.LdapDN;
+import org.apache.directory.shared.ldap.util.tree.DnBranchNode;
+
 
 /**
  * Implement a referral Manager, handling the requests from the LDAP protocol.
@@ -153,6 +155,7 @@
         {
             // We will store each entry's DN into the Referral tree
             LdapDN suffixDn = new LdapDN( suffix );
+            suffixDn.normalize( directoryService.getSchemaManager().getNormalizerMapping() );
             EntryFilteringCursor cursor = nexus.search( new SearchOperationContext( adminSession, suffixDn, AliasDerefMode.DEREF_ALWAYS,
                 referralFilter, searchControl ) );
             

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authn/AnonymousAuthenticator.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authn/AnonymousAuthenticator.java?rev=896599&r1=896598&r2=896599&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authn/AnonymousAuthenticator.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authn/AnonymousAuthenticator.java Wed Jan  6 18:26:43 2010
@@ -22,6 +22,7 @@
 
 import javax.naming.NamingException;
 
+import org.apache.directory.server.core.LdapPrincipal;
 import org.apache.directory.server.core.interceptor.context.BindOperationContext;
 import org.apache.directory.shared.ldap.constants.AuthenticationLevel;
 import org.apache.directory.shared.ldap.exception.LdapNoPermissionException;

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authn/AuthenticationInterceptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authn/AuthenticationInterceptor.java?rev=896599&r1=896598&r2=896599&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authn/AuthenticationInterceptor.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authn/AuthenticationInterceptor.java Wed Jan  6 18:26:43 2010
@@ -30,6 +30,7 @@
 import org.apache.directory.server.core.CoreSession;
 import org.apache.directory.server.core.DefaultCoreSession;
 import org.apache.directory.server.core.DirectoryService;
+import org.apache.directory.server.core.LdapPrincipal;
 import org.apache.directory.server.core.entry.ClonedServerEntry;
 import org.apache.directory.server.core.filtering.EntryFilteringCursor;
 import org.apache.directory.server.core.interceptor.BaseInterceptor;
@@ -59,7 +60,6 @@
 import org.apache.directory.shared.ldap.message.ResultCodeEnum;
 import org.apache.directory.shared.ldap.name.LdapDN;
 import org.apache.directory.shared.ldap.util.StringTools;
-
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -443,7 +443,7 @@
             // This is a case where the Bind request contains a DN, but no password.
             // We don't check the DN, we just return a UnwillingToPerform error
             // Cf RFC 4513, chap. 5.1.2
-            throw new LdapOperationNotSupportedException( "Cannot Bind for DN " + opContext.getDn().getUpName(), ResultCodeEnum.UNWILLING_TO_PERFORM );
+            throw new LdapOperationNotSupportedException( "Cannot Bind for DN " + opContext.getDn().getName(), ResultCodeEnum.UNWILLING_TO_PERFORM );
         }
 
         Collection<Authenticator> authenticators = getAuthenticators( level.getName() );
@@ -513,7 +513,7 @@
         }
 
         LdapDN dn = opContext.getDn();
-        String upDn = ( dn == null ? "" : dn.getUpName() );
+        String upDn = ( dn == null ? "" : dn.getName() );
         throw new LdapAuthenticationException( "Cannot authenticate user " + upDn );
     }
 }

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authn/Authenticator.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authn/Authenticator.java?rev=896599&r1=896598&r2=896599&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authn/Authenticator.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authn/Authenticator.java Wed Jan  6 18:26:43 2010
@@ -23,13 +23,14 @@
 import javax.naming.Context;
 
 import org.apache.directory.server.core.DirectoryService;
+import org.apache.directory.server.core.LdapPrincipal;
 import org.apache.directory.server.core.interceptor.context.BindOperationContext;
-import org.apache.directory.server.core.partition.PartitionNexus;
+import org.apache.directory.server.core.partition.DefaultPartitionNexus;
 import org.apache.directory.shared.ldap.name.LdapDN;
 
 
 /**
- * Authenticates users who access {@link PartitionNexus}.
+ * Authenticates users who access {@link DefaultPartitionNexus}.
  * <p>
  * {@link Authenticator}s are registered to and configured by
  * {@link AuthenticationInterceptor} interceptor.

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authn/SimpleAuthenticator.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authn/SimpleAuthenticator.java?rev=896599&r1=896598&r2=896599&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authn/SimpleAuthenticator.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authn/SimpleAuthenticator.java Wed Jan  6 18:26:43 2010
@@ -34,6 +34,7 @@
 import javax.naming.NamingException;
 
 import org.apache.commons.collections.map.LRUMap;
+import org.apache.directory.server.core.LdapPrincipal;
 import org.apache.directory.server.core.authz.AciAuthorizationInterceptor;
 import org.apache.directory.server.core.authz.DefaultAuthorizationInterceptor;
 import org.apache.directory.server.core.collective.CollectiveAttributeInterceptor;
@@ -58,7 +59,6 @@
 import org.apache.directory.shared.ldap.util.Base64;
 import org.apache.directory.shared.ldap.util.StringTools;
 import org.apache.directory.shared.ldap.util.UnixCrypt;
-
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -76,10 +76,10 @@
 public class SimpleAuthenticator extends AbstractAuthenticator
 {
     private static final Logger LOG = LoggerFactory.getLogger( SimpleAuthenticator.class );
-    
+
     /** A speedup for logger in debug mode */
     private static final boolean IS_DEBUG = LOG.isDebugEnabled();
-    
+
     /** The SHA1 hash length */
     private static final int SHA1_LENGTH = 20;
 
@@ -101,19 +101,18 @@
      * 
      * We need to be sure that frequently used passwords be always in cache, and not discarded.
      * We will use a LRU cache for this purpose. 
-     */ 
+     */
     private final LRUMap credentialCache;
-    
+
     /** Declare a default for this cache. 100 entries seems to be enough */
     private static final int DEFAULT_CACHE_SIZE = 100;
-    
+
     /**
      * Define the interceptors we should *not* go through when we will have to request the backend
      * about a userPassword.
      */
     private static final Collection<String> USERLOOKUP_BYPASS;
-    
-    
+
     static
     {
         Set<String> c = new HashSet<String>();
@@ -142,7 +141,7 @@
         credentialCache = new LRUMap( DEFAULT_CACHE_SIZE );
     }
 
-    
+
     /**
      * Creates a new instance, with an initial cache size
      * @param cacheSize the size of the credential cache
@@ -154,7 +153,6 @@
         credentialCache = new LRUMap( cacheSize > 0 ? cacheSize : DEFAULT_CACHE_SIZE );
     }
 
-    
     /**
      * A private class to store all informations about the existing
      * password found in the cache or get from the backend.
@@ -177,15 +175,16 @@
     {
         private byte[] salt;
         private LdapSecurityConstants algorithm;
-        
+
+
         private EncryptionMethod( LdapSecurityConstants algorithm, byte[] salt )
         {
             this.algorithm = algorithm;
             this.salt = salt;
         }
     }
-    
-    
+
+
     /**
      * Get the password either from cache or from backend.
      * @param principalDN The DN from which we want the password
@@ -195,21 +194,20 @@
     private LdapPrincipal getStoredPassword( BindOperationContext opContext ) throws Exception
     {
         LdapPrincipal principal = null;
-        
-        synchronized( credentialCache )
+
+        synchronized ( credentialCache )
         {
             principal = ( LdapPrincipal ) credentialCache.get( opContext.getDn().getNormName() );
         }
-        
+
         byte[] storedPassword;
-        
+
         if ( principal == null )
         {
             // Not found in the cache
             // Get the user password from the backend
             storedPassword = lookupUserPassword( opContext );
-            
-            
+
             // Deal with the special case where the user didn't enter a password
             // We will compare the empty array with the credentials. Sometime,
             // a user does not set a password. This is bad, but there is nothing
@@ -221,47 +219,57 @@
 
             // Create the new principal before storing it in the cache
             principal = new LdapPrincipal( opContext.getDn(), AuthenticationLevel.SIMPLE, storedPassword );
-            
+
             // Now, update the local cache.
-            synchronized( credentialCache )
+            synchronized ( credentialCache )
             {
                 credentialCache.put( opContext.getDn().getNormName(), principal );
             }
         }
-        
+
         return principal;
     }
 
 
     /**
+     * <p>
      * Looks up <tt>userPassword</tt> attribute of the entry whose name is the
      * value of {@link Context#SECURITY_PRINCIPAL} environment variable, and
      * authenticates a user with the plain-text password.
-     * 
+     * </p>
      * We have at least 6 algorithms to encrypt the password :
-     * - SHA
-     * - SSHA (salted SHA)
-     * - MD5
-     * - SMD5 (slated MD5)
-     * - crypt (unix crypt)
-     * - plain text, ie no encryption.
-     * 
+     * <ul>
+     * <li>- SHA</li>
+     * <li>- SSHA (salted SHA)</li>
+     * <li>- MD5</li>
+     * <li>- SMD5 (slated MD5)</li>
+     * <li>- crypt (unix crypt)</li>
+     * <li>- plain text, ie no encryption.</li>
+     * </ul>
+     * <p>
      *  If we get an encrypted password, it is prefixed by the used algorithm, between
      *  brackets : {SSHA}password ...
-     *  
+     *  </p>
      *  If the password is using SSHA, SMD5 or crypt, some 'salt' is added to the password :
-     *  - length(password) - 20, starting at 21th position for SSHA
-     *  - length(password) - 16, starting at 16th position for SMD5
-     *  - length(password) - 2, starting at 3rd position for crypt
-     *  
+     *  <ul>
+     *  <li>- length(password) - 20, starting at 21th position for SSHA</li>
+     *  <li>- length(password) - 16, starting at 16th position for SMD5</li>
+     *  <li>- length(password) - 2, starting at 3rd position for crypt</li>
+     *  </ul>
+     *  <p>
      *  For (S)SHA and (S)MD5, we have to transform the password from Base64 encoded text
      *  to a byte[] before comparing the password with the stored one.
+     *  </p>
+     *  <p>
      *  For crypt, we only have to remove the salt.
-     *  
+     *  </p>
+     *  <p>
      *  At the end, we use the digest() method for (S)SHA and (S)MD5, the crypt() method for
      *  the CRYPT algorithm and a straight comparison for PLAIN TEXT passwords.
-     *  
+     *  </p>
+     *  <p>
      *  The stored password is always using the unsalted form, and is stored as a bytes array.
+     *  </p>
      */
     public LdapPrincipal authenticate( BindOperationContext opContext ) throws Exception
     {
@@ -269,15 +277,15 @@
         {
             LOG.debug( "Authenticating {}", opContext.getDn() );
         }
-        
+
         // ---- extract password from JNDI environment
         byte[] credentials = opContext.getCredentials();
-        
+
         LdapPrincipal principal = getStoredPassword( opContext );
-        
+
         // Get the stored password, either from cache or from backend
         byte[] storedPassword = principal.getUserPassword();
-        
+
         // Short circuit for PLAIN TEXT passwords : we compare the byte array directly
         // Are the passwords equal ?
         if ( Arrays.equals( credentials, storedPassword ) )
@@ -286,28 +294,28 @@
             {
                 LOG.debug( "{} Authenticated", opContext.getDn() );
             }
-            
+
             return principal;
         }
-        
+
         // Let's see if the stored password was encrypted
         LdapSecurityConstants algorithm = findAlgorithm( storedPassword );
-        
+
         if ( algorithm != null )
         {
             EncryptionMethod encryptionMethod = new EncryptionMethod( algorithm, null );
-            
+
             // Let's get the encrypted part of the stored password
             // We should just keep the password, excluding the algorithm
             // and the salt, if any.
             // But we should also get the algorithm and salt to
             // be able to encrypt the submitted user password in the next step
             byte[] encryptedStored = splitCredentials( storedPassword, encryptionMethod );
-            
+
             // Reuse the saltedPassword informations to construct the encrypted
             // password given by the user.
             byte[] userPassword = encryptPassword( credentials, encryptionMethod );
-            
+
             // Now, compare the two passwords.
             if ( Arrays.equals( userPassword, encryptedStored ) )
             {
@@ -321,28 +329,28 @@
             else
             {
                 // Bad password ...
-                String message = "Password not correct for user '" + opContext.getDn().getUpName() + "'";
+                String message = "Password not correct for user '" + opContext.getDn().getName() + "'";
                 LOG.info( message );
-                throw new LdapAuthenticationException(message);
+                throw new LdapAuthenticationException( message );
             }
         }
         else
         {
             // Bad password ...
-            String message = "Password not correct for user '" + opContext.getDn().getUpName() + "'";
+            String message = "Password not correct for user '" + opContext.getDn().getName() + "'";
             LOG.info( message );
-            throw new LdapAuthenticationException(message);
+            throw new LdapAuthenticationException( message );
         }
     }
-    
-    
+
+
     private static void split( byte[] all, int offset, byte[] left, byte[] right )
     {
         System.arraycopy( all, offset, left, 0, left.length );
         System.arraycopy( all, offset + left.length, right, 0, right.length );
     }
 
-    
+
     /**
      * Decompose the stored password in an algorithm, an eventual salt
      * and the password itself.
@@ -357,38 +365,40 @@
     private byte[] splitCredentials( byte[] credentials, EncryptionMethod encryptionMethod )
     {
         int algoLength = encryptionMethod.algorithm.getName().length() + 2;
-        
+
         switch ( encryptionMethod.algorithm )
         {
-            case HASH_METHOD_MD5 :
-            case HASH_METHOD_SHA :
+            case HASH_METHOD_MD5:
+            case HASH_METHOD_SHA:
                 try
                 {
                     // We just have the password just after the algorithm, base64 encoded.
                     // Just decode the password and return it.
-                    return Base64.decode( new String( credentials, algoLength, credentials.length - algoLength, "UTF-8" ).toCharArray() );
+                    return Base64
+                        .decode( new String( credentials, algoLength, credentials.length - algoLength, "UTF-8" )
+                            .toCharArray() );
                 }
                 catch ( UnsupportedEncodingException uee )
                 {
                     // do nothing 
                     return credentials;
                 }
-                
-            case HASH_METHOD_SMD5 :
+
+            case HASH_METHOD_SMD5:
                 try
                 {
                     // The password is associated with a salt. Decompose it 
                     // in two parts, after having decoded the password.
                     // The salt will be stored into the EncryptionMethod structure
                     // The salt is at the end of the credentials, and is 8 bytes long
-                    byte[] passwordAndSalt = Base64.decode( new String( credentials, algoLength, credentials.length - algoLength, "UTF-8" ).
-                        toCharArray() );
-                    
+                    byte[] passwordAndSalt = Base64.decode( new String( credentials, algoLength, credentials.length
+                        - algoLength, "UTF-8" ).toCharArray() );
+
                     int saltLength = passwordAndSalt.length - MD5_LENGTH;
                     encryptionMethod.salt = new byte[saltLength];
                     byte[] password = new byte[MD5_LENGTH];
                     split( passwordAndSalt, 0, password, encryptionMethod.salt );
-                    
+
                     return password;
                 }
                 catch ( UnsupportedEncodingException uee )
@@ -396,22 +406,22 @@
                     // do nothing 
                     return credentials;
                 }
-                
-            case HASH_METHOD_SSHA :
+
+            case HASH_METHOD_SSHA:
                 try
                 {
                     // The password is associated with a salt. Decompose it 
                     // in two parts, after having decoded the password.
                     // The salt will be stored into the EncryptionMethod structure
                     // The salt is at the end of the credentials, and is 8 bytes long
-                    byte[] passwordAndSalt = Base64.decode( new String( credentials, algoLength, credentials.length - algoLength, "UTF-8" ).
-                        toCharArray() );
-                    
+                    byte[] passwordAndSalt = Base64.decode( new String( credentials, algoLength, credentials.length
+                        - algoLength, "UTF-8" ).toCharArray() );
+
                     int saltLength = passwordAndSalt.length - SHA1_LENGTH;
                     encryptionMethod.salt = new byte[saltLength];
                     byte[] password = new byte[SHA1_LENGTH];
                     split( passwordAndSalt, 0, password, encryptionMethod.salt );
-                    
+
                     return password;
                 }
                 catch ( UnsupportedEncodingException uee )
@@ -419,25 +429,25 @@
                     // do nothing 
                     return credentials;
                 }
-                
-            case HASH_METHOD_CRYPT :
+
+            case HASH_METHOD_CRYPT:
                 // The password is associated with a salt. Decompose it 
                 // in two parts, storing the salt into the EncryptionMethod structure.
                 // The salt comes first, not like for SSHA and SMD5, and is 2 bytes long
                 encryptionMethod.salt = new byte[2];
                 byte[] password = new byte[credentials.length - encryptionMethod.salt.length - algoLength];
                 split( credentials, algoLength, encryptionMethod.salt, password );
-                
+
                 return password;
-                
-            default :
+
+            default:
                 // unknown method
                 return credentials;
-                
+
         }
     }
-    
-    
+
+
     /**
      * Get the algorithm from the stored password. 
      * It can be found on the beginning of the stored password, between 
@@ -452,22 +462,22 @@
         {
             return null;
         }
-        
+
         if ( credentials[0] == '{' )
         {
             // get the algorithm
             int pos = 1;
-            
+
             while ( pos < credentials.length )
             {
                 if ( credentials[pos] == '}' )
                 {
                     break;
                 }
-                
+
                 pos++;
             }
-            
+
             if ( pos < credentials.length )
             {
                 if ( pos == 1 )
@@ -475,9 +485,9 @@
                     // We don't have an algorithm : return the credentials as is
                     return null;
                 }
-                
+
                 String algorithm = new String( credentials, 1, pos - 1 ).toLowerCase();
-                
+
                 return LdapSecurityConstants.getAlgorithm( algorithm );
             }
             else
@@ -493,7 +503,7 @@
         }
     }
 
-    
+
     /**
      * Compute the hashed password given an algorithm, the credentials and 
      * an optional salt.
@@ -528,45 +538,45 @@
         }
     }
 
-    
+
     private byte[] encryptPassword( byte[] credentials, EncryptionMethod encryptionMethod )
     {
         byte[] salt = encryptionMethod.salt;
-        
+
         switch ( encryptionMethod.algorithm )
         {
-            case HASH_METHOD_SHA :
-            case HASH_METHOD_SSHA :
+            case HASH_METHOD_SHA:
+            case HASH_METHOD_SSHA:
                 return digest( LdapSecurityConstants.HASH_METHOD_SHA, credentials, salt );
 
-            case HASH_METHOD_MD5 :
-            case HASH_METHOD_SMD5 :
+            case HASH_METHOD_MD5:
+            case HASH_METHOD_SMD5:
                 return digest( LdapSecurityConstants.HASH_METHOD_MD5, credentials, salt );
 
-            case HASH_METHOD_CRYPT :
+            case HASH_METHOD_CRYPT:
                 if ( salt == null )
                 {
                     salt = new byte[2];
                     SecureRandom sr = new SecureRandom();
                     int i1 = sr.nextInt( 64 );
                     int i2 = sr.nextInt( 64 );
-                
+
                     salt[0] = ( byte ) ( i1 < 12 ? ( i1 + '.' ) : i1 < 38 ? ( i1 + 'A' - 12 ) : ( i1 + 'a' - 38 ) );
                     salt[1] = ( byte ) ( i2 < 12 ? ( i2 + '.' ) : i2 < 38 ? ( i2 + 'A' - 12 ) : ( i2 + 'a' - 38 ) );
                 }
 
-                String saltWithCrypted = UnixCrypt.crypt( StringTools.utf8ToString( credentials ), 
-                    StringTools.utf8ToString( salt ) );
+                String saltWithCrypted = UnixCrypt.crypt( StringTools.utf8ToString( credentials ), StringTools
+                    .utf8ToString( salt ) );
                 String crypted = saltWithCrypted.substring( 2 );
-                
+
                 return StringTools.getBytesUtf8( crypted );
-                
-            default :
+
+            default:
                 return credentials;
         }
     }
 
-    
+
     /**
      * Local function which request the password from the backend
      * @param principalDn the principal to lookup
@@ -587,18 +597,17 @@
              * case where we cannot rely on the opContext to perform a new
              * sub operation.
              */
-            LookupOperationContext lookupContext = 
-                new LookupOperationContext( getDirectoryService().getAdminSession(), opContext.getDn() );
+            LookupOperationContext lookupContext = new LookupOperationContext( getDirectoryService().getAdminSession(),
+                opContext.getDn() );
             lookupContext.setByPassed( USERLOOKUP_BYPASS );
             userEntry = getDirectoryService().getOperationManager().lookup( lookupContext );
 
             if ( userEntry == null )
             {
-            LdapDN dn = opContext.getDn();
-            String upDn = ( dn == null ? "" : dn.getUpName() );
-            
-                throw new LdapAuthenticationException( "Failed to lookup user for authentication: " 
-                    + upDn );
+                LdapDN dn = opContext.getDn();
+                String upDn = ( dn == null ? "" : dn.getName() );
+
+                throw new LdapAuthenticationException( "Failed to lookup user for authentication: " + upDn );
             }
         }
         catch ( Exception cause )
@@ -626,7 +635,7 @@
         }
     }
 
-    
+
     /**
      * Get the algorithm of a password, which is stored in the form "{XYZ}...".
      * The method returns null, if the argument is not in this form. It returns
@@ -645,9 +654,7 @@
         String sPassword = StringTools.utf8ToString( password );
         int rightParen = sPassword.indexOf( '}' );
 
-        if ( ( sPassword.length() > 2 ) &&
-             ( sPassword.charAt( 0 ) == '{' ) &&
-             ( rightParen > -1 ) )
+        if ( ( sPassword.length() > 2 ) && ( sPassword.charAt( 0 ) == '{' ) && ( rightParen > -1 ) )
         {
             String algorithm = sPassword.substring( 1, rightParen );
 
@@ -655,7 +662,7 @@
             {
                 return algorithm;
             }
-            
+
             try
             {
                 MessageDigest.getInstance( algorithm );
@@ -705,7 +712,7 @@
             else
             {
                 MessageDigest digest = MessageDigest.getInstance( algorithm );
-                
+
                 // calculate hashed value of password
                 byte[] fingerPrint = digest.digest( password );
                 char[] encoded = Base64.encode( fingerPrint );
@@ -721,14 +728,14 @@
         }
     }
 
-    
+
     /**
      * Remove the principal form the cache. This is used when the user changes
      * his password.
      */
     public void invalidateCache( LdapDN bindDn )
     {
-        synchronized( credentialCache )
+        synchronized ( credentialCache )
         {
             credentialCache.remove( bindDn.getNormName() );
         }

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authn/StrongAuthenticator.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authn/StrongAuthenticator.java?rev=896599&r1=896598&r2=896599&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authn/StrongAuthenticator.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authn/StrongAuthenticator.java Wed Jan  6 18:26:43 2010
@@ -22,6 +22,7 @@
 
 import javax.naming.NamingException;
 
+import org.apache.directory.server.core.LdapPrincipal;
 import org.apache.directory.server.core.interceptor.context.BindOperationContext;
 import org.apache.directory.shared.ldap.constants.AuthenticationLevel;
 



Mime
View raw message