merging in from trunks

git-svn-id: https://svn.apache.org/repos/asf/directory/apacheds/branches/milestones@1079045 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/core-api/src/main/java/org/apache/directory/server/core/LdapPrincipal.java b/core-api/src/main/java/org/apache/directory/server/core/LdapPrincipal.java
index be70b19..55557a8 100644
--- a/core-api/src/main/java/org/apache/directory/server/core/LdapPrincipal.java
+++ b/core-api/src/main/java/org/apache/directory/server/core/LdapPrincipal.java
@@ -20,17 +20,12 @@
 package org.apache.directory.server.core;
 
 
-import java.io.Externalizable;
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
 import java.security.Principal;
 
 import org.apache.directory.server.i18n.I18n;
 import org.apache.directory.shared.ldap.model.constants.AuthenticationLevel;
 import org.apache.directory.shared.ldap.model.exception.LdapInvalidDnException;
 import org.apache.directory.shared.ldap.model.name.Dn;
-import org.apache.directory.shared.ldap.model.name.DnSerializer;
 import org.apache.directory.shared.ldap.model.schema.SchemaManager;
 import org.apache.directory.shared.util.Strings;
 
@@ -41,7 +36,7 @@
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public final class LdapPrincipal implements Principal, Cloneable, Externalizable
+public final class LdapPrincipal implements Principal, Cloneable
 {
     private static final long serialVersionUID = 3906650782395676720L;
 
@@ -126,24 +121,12 @@
 
 
     /**
-     * Gets a reference to the distinguished name of this
-     * principal as a {@link org.apache.directory.shared.ldap.model.name.Dn}.
-     *
-     * @return the distinguished name of the principal as a {@link org.apache.directory.shared.ldap.model.name.Dn}
-     */
-    public Dn getDNRef()
-    {
-        return dn;
-    }
-
-
-    /**
      * Gets a cloned copy of the normalized distinguished name of this
      * principal as a {@link org.apache.directory.shared.ldap.model.name.Dn}.
      *
      * @return the cloned distinguished name of the principal as a {@link org.apache.directory.shared.ldap.model.name.Dn}
      */
-    public Dn getDN()
+    public Dn getDn()
     {
         return dn;
     }
@@ -200,65 +183,6 @@
     
     
     /**
-     * @see Externalizable#readExternal(ObjectInput)
-     * 
-     * @param in The stream from which the LdapPrincipal is read
-     * @throws IOException If the stream can't be read
-     * @throws ClassNotFoundException If the LdapPrincipal can't be created 
-     */
-    public void readExternal( ObjectInput in ) throws IOException , ClassNotFoundException
-    {
-        // Read the name
-        try
-        {
-            dn = DnSerializer.deserialize( schemaManager, in );
-        }
-        catch ( LdapInvalidDnException lide )
-        {
-            throw new IOException( lide.getMessage() );
-        }
-        
-        // read the authentication level
-        int level = in.readInt();
-        
-        authenticationLevel = AuthenticationLevel.getLevel( level );
-    }
-
-
-    /**
-     * Note: The password won't be written !
-     * 
-     * @see Externalizable#readExternal(ObjectInput)
-     *
-     * @param out The stream in which the LdapPrincipal will be serialized. 
-     *
-     * @throws IOException If the serialization fail
-     */
-    public void writeExternal( ObjectOutput out ) throws IOException
-    {
-        // Write the name
-        if ( dn == null )
-        {
-            DnSerializer.serialize( Dn.EMPTY_DN, out );
-        }
-        else
-        {
-            DnSerializer.serialize( dn, out );
-        }
-        
-        // write the authentication level
-        if ( authenticationLevel == null )
-        {
-            out.writeInt( AuthenticationLevel.NONE.getLevel() );
-        }
-        else
-        {
-            out.writeInt( authenticationLevel.getLevel() );
-        }
-    }
-
-
-    /**
      * @return the schemaManager
      */
     public SchemaManager getSchemaManager()
diff --git a/core-api/src/main/java/org/apache/directory/server/core/LdapPrincipalSerializer.java b/core-api/src/main/java/org/apache/directory/server/core/LdapPrincipalSerializer.java
index acfda22..82878af 100644
--- a/core-api/src/main/java/org/apache/directory/server/core/LdapPrincipalSerializer.java
+++ b/core-api/src/main/java/org/apache/directory/server/core/LdapPrincipalSerializer.java
@@ -52,8 +52,8 @@
     /**
      * Serializes a LdapPrincipal instance.
      * 
-     * @param principal The LsapPrincipal instance to serialize
-     * @param out The stream into which we will write teh serialized instance
+     * @param principal The LdapPrincipal instance to serialize
+     * @param out The stream into which we will write the serialized instance
      * @throws IOException If the stream can't be written
      */
     public static void serialize( LdapPrincipal principal, ObjectOutput out ) throws IOException
@@ -62,13 +62,13 @@
         out.writeInt( principal.getAuthenticationLevel().getLevel() );
         
         // The principal's DN
-        if ( principal.getDN() == null )
+        if ( principal.getDn() == null )
         {
             DnSerializer.serialize( Dn.EMPTY_DN, out );
         }
         else
         {
-            DnSerializer.serialize( principal.getDN(), out );
+            DnSerializer.serialize( principal.getDn(), out );
         }
     }
     
@@ -77,8 +77,8 @@
      * Deserializes a LdapPrincipal instance.
      * 
      * @param schemaManager The SchemaManager (can be null)
-     * @param in The input stream from which the Rdn is read
-     * @return a deserialized Rdn
+     * @param in The input stream from which the LdapPrincipal is read
+     * @return a deserialized LdapPrincipal
      * @throws IOException If the stream can't be read
      */
     public static LdapPrincipal deserialize( SchemaManager schemaManager, ObjectInput in )
diff --git a/core-api/src/main/java/org/apache/directory/server/core/changelog/ChangeLogEvent.java b/core-api/src/main/java/org/apache/directory/server/core/changelog/ChangeLogEvent.java
index 1d80aee..cb9b1ac 100644
--- a/core-api/src/main/java/org/apache/directory/server/core/changelog/ChangeLogEvent.java
+++ b/core-api/src/main/java/org/apache/directory/server/core/changelog/ChangeLogEvent.java
@@ -20,17 +20,12 @@
 package org.apache.directory.server.core.changelog;
 
 
-import java.io.Externalizable;
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
 import java.util.ArrayList;
 import java.util.List;
 
 import org.apache.directory.server.core.LdapPrincipal;
 import org.apache.directory.shared.ldap.model.entry.EntryAttribute;
 import org.apache.directory.shared.ldap.model.ldif.LdifEntry;
-import org.apache.directory.shared.util.Unicode;
 
 
 /**
@@ -38,25 +33,22 @@
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class ChangeLogEvent implements Externalizable
+public class ChangeLogEvent
 {
-    private static final long serialVersionUID = 1L;
+    /** */
     private String zuluTime;
+    
+    /** The committer */
+    private LdapPrincipal committer;
+    
+    /** The revision number for this event */
     private long revision;
+    
+    /** The modification */
     private LdifEntry forwardLdif;
     
     /** The revert changes. Can contain more than one single change */
     private List<LdifEntry> reverseLdifs;
-    private LdapPrincipal committer;
-
-
-    /**
-     * Creates a new instance of ChangeLogEvent, used during the deserialization
-     * process
-     */
-    public ChangeLogEvent()
-    {
-    }
 
 
     /**
@@ -152,112 +144,6 @@
     }
 
 
-    /**
-     * @see Externalizable#readExternal(ObjectInput)
-     * 
-     * @param in The stream from which the ChangeOlgEvent is read
-     * @throws IOException If the stream can't be read
-     * @throws ClassNotFoundException If the ChangeLogEvent can't be created 
-     */
-    public void readExternal( ObjectInput in ) throws IOException , ClassNotFoundException
-    {
-        // Read the committer
-        committer = (LdapPrincipal)in.readObject();
-        
-        // Read the revision
-        revision = in.readLong();
-        
-        // Read the time
-        boolean hasZuluTime = in.readBoolean();
-        
-        if ( hasZuluTime )
-        {
-            zuluTime = Unicode.readUTF(in);
-        }
-        
-        // Read the forward LDIF
-        boolean hasForwardLdif = in.readBoolean();
-        
-        if ( hasForwardLdif )
-        {
-            forwardLdif = (LdifEntry)in.readObject();
-        }
-        
-        // Read the reverse LDIF number
-        int nbReverseLdif = in.readInt();
-        
-        if ( nbReverseLdif > 0 )
-        {
-            // Read each reverse ldif
-            reverseLdifs = new ArrayList<LdifEntry>(nbReverseLdif);
-            
-            for ( int i = 0; i < nbReverseLdif; i++ )
-            {
-                reverseLdifs.add( (LdifEntry)in.readObject() ); 
-            }
-        }
-    }
-
-
-    /**
-     * @see Externalizable#readExternal(ObjectInput)
-     *
-     * @param out The stream in which the ChangeLogEvent will be serialized. 
-     *
-     * @throws IOException If the serialization fail
-     */
-    public void writeExternal( ObjectOutput out ) throws IOException
-    {
-        // Write the committer
-        out.writeObject( committer );
-        
-        // write the revision
-        out.writeLong( revision );
-        
-        // write the time
-        
-        if ( zuluTime != null )
-        {
-            out.writeBoolean( true );
-            Unicode.writeUTF(out, zuluTime);
-        }
-        else
-        {
-            out.writeBoolean( false );
-        }
-        
-        // write the forward LDIF
-        if ( forwardLdif != null )
-        {
-            out.writeBoolean( true );
-            out.writeObject( forwardLdif );
-        }
-        else
-        {
-            out.writeBoolean( false );
-        }
-        
-        // write the reverse LDIF
-        if ( reverseLdifs != null )
-        {
-            out.writeInt( reverseLdifs.size() );
-            
-            // write each reverse
-            for ( LdifEntry reverseLdif:reverseLdifs )
-            {
-                out.writeObject( reverseLdif );
-            }
-        }
-        else
-        {
-            out.writeBoolean( false );
-        }
-        
-        // and flush the result
-        out.flush();
-    }
-
-
     @Override
     public String toString()
     {
diff --git a/core-api/src/main/java/org/apache/directory/server/core/changelog/ChangeLogEventSerializer.java b/core-api/src/main/java/org/apache/directory/server/core/changelog/ChangeLogEventSerializer.java
new file mode 100644
index 0000000..19f6d4c
--- /dev/null
+++ b/core-api/src/main/java/org/apache/directory/server/core/changelog/ChangeLogEventSerializer.java
@@ -0,0 +1,125 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.server.core.changelog;
+
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.directory.server.core.LdapPrincipal;
+import org.apache.directory.server.core.LdapPrincipalSerializer;
+import org.apache.directory.shared.ldap.model.exception.LdapInvalidDnException;
+import org.apache.directory.shared.ldap.model.ldif.LdifEntry;
+import org.apache.directory.shared.ldap.model.ldif.LdifEntrySerializer;
+import org.apache.directory.shared.ldap.model.schema.SchemaManager;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * A helper class which serialize and deserialize a ChangeLogEvent.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public final class ChangeLogEventSerializer
+{
+    /** The LoggerFactory used by this class */
+    protected static final Logger LOG = LoggerFactory.getLogger( ChangeLogEventSerializer.class );
+
+    /**
+     * Private constructor.
+     */
+    private ChangeLogEventSerializer()
+    {
+    }
+
+    
+    /**
+     * Serializes a ChangeLogEvent instance.
+     * 
+     * @param principal The ChangeLogEvent instance to serialize
+     * @param out The stream into which we will write the serialized instance
+     * @throws IOException If the stream can't be written
+     */
+    public static void serialize( ChangeLogEvent event, ObjectOutput out ) throws IOException
+    {
+        // The date the change has been created, "yyyyMMddHHmmss'Z'" 
+        out.writeUTF( event.getZuluTime() );
+        
+        // The committer's Principal
+        LdapPrincipalSerializer.serialize( event.getCommitterPrincipal(), out );
+        
+        // The revision
+        out.writeLong( event.getRevision() );
+        
+        // The forward LDIF
+        LdifEntrySerializer.serialize( event.getForwardLdif(), out );
+        
+        // The reverse LDIFs number
+        int nbReverses = event.getReverseLdifs().size();
+        out.writeInt( nbReverses );
+        
+        for ( LdifEntry reverseLdif : event.getReverseLdifs() )
+        {
+            LdifEntrySerializer.serialize( reverseLdif, out );
+        }
+    }
+    
+    
+    /**
+     * Deserializes a ChangeLogEvent instance.
+     * 
+     * @param schemaManager The SchemaManager (can be null)
+     * @param in The input stream from which the ChengaLogEvent is read
+     * @return a deserialized ChangeLogEvent
+     * @throws IOException If the stream can't be read
+     */
+    public static ChangeLogEvent deserialize( SchemaManager schemaManager, ObjectInput in )
+        throws IOException, LdapInvalidDnException
+    {
+        // The date the change has been created, "yyyyMMddHHmmss'Z'" 
+        String zuluTime = in.readUTF();
+        
+        // The committer's Principal
+        LdapPrincipal committerPrincipal = LdapPrincipalSerializer.deserialize( schemaManager, in );
+        
+        // The revision
+        long revision = in.readLong();
+        
+        // The forward LDIF
+        LdifEntry forwardEntry = LdifEntrySerializer.deserialize( schemaManager, in );
+        
+        // The reverse LDIFs number
+        int nbReverses = in.readInt();
+        
+        List<LdifEntry> reverses = new ArrayList<LdifEntry>( nbReverses );
+        
+        for ( int i = 0; i < nbReverses; i++ )
+        {
+            LdifEntry reverseEntry = LdifEntrySerializer.deserialize( schemaManager, in );
+            reverses.add( reverseEntry );
+        }
+        
+        ChangeLogEvent changeLogEvent = new ChangeLogEvent( revision, zuluTime, committerPrincipal, forwardEntry, reverses );
+
+        return changeLogEvent;
+    }
+}
diff --git a/core-api/src/main/java/org/apache/directory/server/core/interceptor/context/UnbindOperationContext.java b/core-api/src/main/java/org/apache/directory/server/core/interceptor/context/UnbindOperationContext.java
index 603c11b..9194e5c 100644
--- a/core-api/src/main/java/org/apache/directory/server/core/interceptor/context/UnbindOperationContext.java
+++ b/core-api/src/main/java/org/apache/directory/server/core/interceptor/context/UnbindOperationContext.java
@@ -38,13 +38,13 @@
      */
     public UnbindOperationContext( CoreSession session )
     {
-        super( session, session.getEffectivePrincipal().getDN() );
+        super( session, session.getEffectivePrincipal().getDn() );
     }
     
 
     public UnbindOperationContext( CoreSession session, UnbindRequest unbindRequest )
     {
-        super( session, session.getEffectivePrincipal().getDN() );
+        super( session, session.getEffectivePrincipal().getDn() );
         this.setRequestControls( unbindRequest.getControls() );
     }
 
diff --git a/core-api/src/main/java/org/apache/directory/server/core/schema/SchemaPartitionDao.java b/core-api/src/main/java/org/apache/directory/server/core/schema/SchemaPartitionDao.java
index 3902ed9..ed6f924 100644
--- a/core-api/src/main/java/org/apache/directory/server/core/schema/SchemaPartitionDao.java
+++ b/core-api/src/main/java/org/apache/directory/server/core/schema/SchemaPartitionDao.java
@@ -1,3 +1,22 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ *
+ */
 package org.apache.directory.server.core.schema;
 
 
diff --git a/core-api/src/main/java/org/apache/directory/server/core/schema/SchemaService.java b/core-api/src/main/java/org/apache/directory/server/core/schema/SchemaService.java
index 50d2c54..23b8df1 100644
--- a/core-api/src/main/java/org/apache/directory/server/core/schema/SchemaService.java
+++ b/core-api/src/main/java/org/apache/directory/server/core/schema/SchemaService.java
@@ -1,3 +1,22 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ *
+ */
 package org.apache.directory.server.core.schema;
 
 
diff --git a/core-api/src/main/resources/directory-cacheservice.xml b/core-api/src/main/resources/directory-cacheservice.xml
index 82e7f06..f73f17a 100644
--- a/core-api/src/main/resources/directory-cacheservice.xml
+++ b/core-api/src/main/resources/directory-cacheservice.xml
@@ -1,4 +1,22 @@
 <?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License.  You may obtain a copy of the License at
+  
+  http://www.apache.org/licenses/LICENSE-2.0
+  
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied.  See the License for the
+  specific language governing permissions and limitations
+  under the License.
+-->
 <ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 	xsi:noNamespaceSchemaLocation="ehcache.xsd" updateCheck="false"
 	monitoring="autodetect" dynamicConfig="true">
diff --git a/core-integ/src/test/java/org/apache/directory/server/core/authz/AddAuthorizationIT.java b/core-integ/src/test/java/org/apache/directory/server/core/authz/AddAuthorizationIT.java
index 70c3cfd..104eefa 100644
--- a/core-integ/src/test/java/org/apache/directory/server/core/authz/AddAuthorizationIT.java
+++ b/core-integ/src/test/java/org/apache/directory/server/core/authz/AddAuthorizationIT.java
@@ -39,7 +39,6 @@
 import org.apache.directory.shared.ldap.model.name.Dn;
 import org.junit.After;
 import org.junit.Before;
-import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 
@@ -188,7 +187,6 @@
      * @throws Exception if the test encounters an error
      */
     @Test
-    @Ignore
     public void testGrantAddByName() throws Exception
     {
         // create the non-admin user
@@ -227,7 +225,6 @@
      * @throws Exception if the test encounters an error
      */
     @Test
-    @Ignore
     public void testGrantAddBySubtree() throws Exception
     {
         // create the non-admin user
@@ -269,7 +266,6 @@
      * @throws Exception if the test encounters an error
      */
     @Test
-    @Ignore
     public void testGrantAddAllUsers() throws Exception
     {
         // create the non-admin user
diff --git a/core-jndi/src/main/java/org/apache/directory/server/core/jndi/JavaLdapSupport.java b/core-jndi/src/main/java/org/apache/directory/server/core/jndi/JavaLdapSupport.java
index 2d03021..ec61846 100644
--- a/core-jndi/src/main/java/org/apache/directory/server/core/jndi/JavaLdapSupport.java
+++ b/core-jndi/src/main/java/org/apache/directory/server/core/jndi/JavaLdapSupport.java
@@ -101,6 +101,7 @@
         {
             byte[] data = ( byte[] ) serverEntry.get( JSERIALDATA_ATTR ).getBytes();
             in = new ObjectInputStream( new ByteArrayInputStream( data ) );
+            
             return in.readObject();
         }
         catch ( Exception e )
diff --git a/core/src/main/java/org/apache/directory/server/core/DefaultCoreSession.java b/core/src/main/java/org/apache/directory/server/core/DefaultCoreSession.java
index 5a964c2..f85531d 100644
--- a/core/src/main/java/org/apache/directory/server/core/DefaultCoreSession.java
+++ b/core/src/main/java/org/apache/directory/server/core/DefaultCoreSession.java
@@ -816,7 +816,7 @@
 
     public boolean isAnonymous()
     {
-        return getEffectivePrincipal().getDNRef().isEmpty();
+        return getEffectivePrincipal().getDn().isEmpty();
     }
 
 
diff --git a/core/src/main/java/org/apache/directory/server/core/authn/AuthenticationInterceptor.java b/core/src/main/java/org/apache/directory/server/core/authn/AuthenticationInterceptor.java
index e8bc039..20a50ea 100644
--- a/core/src/main/java/org/apache/directory/server/core/authn/AuthenticationInterceptor.java
+++ b/core/src/main/java/org/apache/directory/server/core/authn/AuthenticationInterceptor.java
@@ -512,7 +512,7 @@
         PasswordPolicyConfiguration policyConfig = directoryService.getPwdPolicy( modifyContext.getOriginalEntry() );
         
         boolean isPPolicyReqCtrlPresent = modifyContext.hasRequestControl( PasswordPolicy.OID );
-        Dn userDn = modifyContext.getSession().getAuthenticatedPrincipal().getDN();
+        Dn userDn = modifyContext.getSession().getAuthenticatedPrincipal().getDn();
 
         PwdModDetailsHolder pwdModDetails = null;
         if ( policyConfig.isPwdSafeModify() || pwdResetSet.contains( userDn ) || ( policyConfig.getPwdMinAge() > 0 ) )
@@ -1380,7 +1380,7 @@
         {
             CoreSession session = opContext.getSession();
 
-            Dn userDn = session.getAuthenticatedPrincipal().getDN();
+            Dn userDn = session.getAuthenticatedPrincipal().getDn();
 
             if ( pwdResetSet.contains( userDn ) )
             {
diff --git a/core/src/main/java/org/apache/directory/server/core/authz/AciAuthorizationInterceptor.java b/core/src/main/java/org/apache/directory/server/core/authz/AciAuthorizationInterceptor.java
index 1c2185a..d5f8d58 100644
--- a/core/src/main/java/org/apache/directory/server/core/authz/AciAuthorizationInterceptor.java
+++ b/core/src/main/java/org/apache/directory/server/core/authz/AciAuthorizationInterceptor.java
@@ -304,7 +304,7 @@
 
     private void protectCriticalEntries( Dn dn ) throws LdapException
     {
-        Dn principalDn = getPrincipal().getDNRef();
+        Dn principalDn = getPrincipal().getDn();
 
         if ( dn.isEmpty() )
         {
@@ -508,7 +508,7 @@
 
         // Access the principal requesting the operation, and bypass checks if it is the admin
         LdapPrincipal principal = addContext.getSession().getEffectivePrincipal();
-        Dn principalDn = principal.getDN();
+        Dn principalDn = principal.getDn();
 
         Entry serverEntry = addContext.getEntry();
 
@@ -605,7 +605,7 @@
 
         Dn dn = deleteContext.getDn();
         LdapPrincipal principal = session.getEffectivePrincipal();
-        Dn principalDn = principal.getDN();
+        Dn principalDn = principal.getDn();
 
         Entry entry = deleteContext.getEntry();
 
@@ -656,7 +656,7 @@
         Entry entry = modifyContext.getEntry();
 
         LdapPrincipal principal = modifyContext.getSession().getEffectivePrincipal();
-        Dn principalDn = principal.getDN();
+        Dn principalDn = principal.getDn();
 
         // bypass authz code if we are disabled
         if ( !modifyContext.getSession().getDirectoryService().isAccessControlEnabled() )
@@ -824,7 +824,7 @@
 
         // TODO - eventually replace this with a check on session.isAnAdministrator()
         LdapPrincipal principal = hasEntryContext.getSession().getEffectivePrincipal();
-        Dn principalDn = principal.getDN();
+        Dn principalDn = principal.getDn();
 
         if ( isPrincipalAnAdministrator( principalDn ) )
         {
@@ -880,7 +880,7 @@
         }
 
         LdapPrincipal principal = lookupContext.getSession().getEffectivePrincipal();
-        Dn userName = principal.getDN();
+        Dn userName = principal.getDn();
         Set<Dn> userGroups = groupCache.getGroups( userName.getNormName() );
         Collection<ACITuple> tuples = new HashSet<ACITuple>();
         addPerscriptiveAciTuples( lookupContext, tuples, dn, entry );
@@ -931,7 +931,7 @@
         DirectoryService directoryService = session.getDirectoryService();
 
         LdapPrincipal principal = session.getEffectivePrincipal();
-        Dn principalDn = principal.getDN();
+        Dn principalDn = principal.getDn();
 
         if ( !principalDn.isNormalized() )
         {
@@ -964,7 +964,7 @@
         }
 
         LdapPrincipal principal = renameContext.getSession().getEffectivePrincipal();
-        Dn principalDn = principal.getDN();
+        Dn principalDn = principal.getDn();
         Dn newName = renameContext.getNewDn();
 
         // bypass authz code if we are disabled
@@ -1019,7 +1019,7 @@
         Entry entry = moveAndRenameContext.getOriginalEntry();
 
         LdapPrincipal principal = moveAndRenameContext.getSession().getEffectivePrincipal();
-        Dn principalDn = principal.getDN();
+        Dn principalDn = principal.getDn();
         Dn newDn = moveAndRenameContext.getNewDn();
 
         // bypass authz code if we are disabled
@@ -1116,7 +1116,7 @@
         Dn newDn = moveContext.getNewDn();
 
         LdapPrincipal principal = moveContext.getSession().getEffectivePrincipal();
-        Dn principalDn = principal.getDN();
+        Dn principalDn = principal.getDn();
 
         // bypass authz code if we are disabled
         if ( !moveContext.getSession().getDirectoryService().isAccessControlEnabled() )
@@ -1202,7 +1202,7 @@
         LdapPrincipal user = listContext.getSession().getEffectivePrincipal();
         EntryFilteringCursor cursor = next.list( listContext );
 
-        if ( isPrincipalAnAdministrator( user.getDNRef() )
+        if ( isPrincipalAnAdministrator( user.getDn() )
             || !listContext.getSession().getDirectoryService().isAccessControlEnabled() )
         {
             return cursor;
@@ -1217,7 +1217,7 @@
     public EntryFilteringCursor search( NextInterceptor next, SearchOperationContext searchContext ) throws LdapException
     {
         LdapPrincipal user = searchContext.getSession().getEffectivePrincipal();
-        Dn principalDn = user.getDN();
+        Dn principalDn = user.getDn();
         EntryFilteringCursor cursor = next.search( searchContext );
 
         boolean isSubschemaSubentryLookup = subschemaSubentryDn.equals( searchContext.getDn().getNormName() );
@@ -1256,7 +1256,7 @@
         Entry entry = compareContext.getOriginalEntry();
 
         LdapPrincipal principal = session.getEffectivePrincipal();
-        Dn principalDn = principal.getDN();
+        Dn principalDn = principal.getDn();
 
         if ( isPrincipalAnAdministrator( principalDn ) || !session.getDirectoryService().isAccessControlEnabled() )
         {
@@ -1313,7 +1313,7 @@
          */
 
         LdapPrincipal principal = opContext.getSession().getEffectivePrincipal();
-        Dn userDn = principal.getDN();
+        Dn userDn = principal.getDn();
         Set<Dn> userGroups = groupCache.getGroups( userDn.getNormName() );
         Collection<ACITuple> tuples = new HashSet<ACITuple>();
         addPerscriptiveAciTuples( opContext, tuples, normName, clonedEntry );
diff --git a/core/src/main/java/org/apache/directory/server/core/authz/DefaultAuthorizationInterceptor.java b/core/src/main/java/org/apache/directory/server/core/authz/DefaultAuthorizationInterceptor.java
index ab25833..27fbbb4 100644
--- a/core/src/main/java/org/apache/directory/server/core/authz/DefaultAuthorizationInterceptor.java
+++ b/core/src/main/java/org/apache/directory/server/core/authz/DefaultAuthorizationInterceptor.java
@@ -166,7 +166,7 @@
             throw new LdapNoPermissionException( msg );
         }
 
-        Dn principalDn = getPrincipal().getDNRef();
+        Dn principalDn = getPrincipal().getDn();
 
         if ( dn.equals( ADMIN_SYSTEM_DN ) )
         {
@@ -242,7 +242,7 @@
 
     private void protectModifyAlterations( Dn dn ) throws LdapException
     {
-        Dn principalDn = getPrincipal().getDN();
+        Dn principalDn = getPrincipal().getDn();
 
         if ( dn.isEmpty() )
         {
@@ -334,7 +334,7 @@
 
     private void protectDnAlterations( Dn dn ) throws LdapException
     {
-        Dn principalDn = getPrincipal().getDN();
+        Dn principalDn = getPrincipal().getDn();
 
         if ( dn.isEmpty() )
         {
@@ -383,7 +383,7 @@
             return entry;
         }
 
-        protectLookUp( session.getEffectivePrincipal().getDNRef(), lookupContext.getDn() );
+        protectLookUp( session.getEffectivePrincipal().getDn(), lookupContext.getDn() );
 
         return entry;
     }
@@ -484,7 +484,7 @@
     @SuppressWarnings("PMD.CollapsibleIfStatements")
     private boolean isSearchable( OperationContext opContext, ClonedServerEntry result ) throws Exception
     {
-        Dn principalDn = opContext.getSession().getEffectivePrincipal().getDN();
+        Dn principalDn = opContext.getSession().getEffectivePrincipal().getDn();
         Dn dn = result.getDn();
 
         if ( !dn.isNormalized() )
diff --git a/core/src/main/java/org/apache/directory/server/core/changelog/MemoryChangeLogStore.java b/core/src/main/java/org/apache/directory/server/core/changelog/MemoryChangeLogStore.java
index 3634385..87d65ff 100644
--- a/core/src/main/java/org/apache/directory/server/core/changelog/MemoryChangeLogStore.java
+++ b/core/src/main/java/org/apache/directory/server/core/changelog/MemoryChangeLogStore.java
@@ -348,7 +348,7 @@
 
                 for ( int i = 0; i < size; i++ )
                 {
-                    ChangeLogEvent event = ( ChangeLogEvent ) in.readObject();
+                    ChangeLogEvent event = ChangeLogEventSerializer.deserialize( directoryService.getSchemaManager(), in );
                     event.getCommitterPrincipal().setSchemaManager( directoryService.getSchemaManager() );
                     changeLogEvents.add( event );
                 }
@@ -412,7 +412,7 @@
             
             for ( ChangeLogEvent event : events )
             {
-                out.writeObject( event );
+                ChangeLogEventSerializer.serialize( event, out  );
             }
 
             out.flush();
diff --git a/core/src/main/java/org/apache/directory/server/core/operational/OperationalAttributeInterceptor.java b/core/src/main/java/org/apache/directory/server/core/operational/OperationalAttributeInterceptor.java
index cd1eac1..1ca560f 100644
--- a/core/src/main/java/org/apache/directory/server/core/operational/OperationalAttributeInterceptor.java
+++ b/core/src/main/java/org/apache/directory/server/core/operational/OperationalAttributeInterceptor.java
@@ -237,7 +237,7 @@
         // otherwise, inject those values into the list of modifications
         List<Modification> mods = modifyContext.getModItems();
 
-        boolean isAdmin = modifyContext.getSession().getAuthenticatedPrincipal().getDN().equals( adminDn );
+        boolean isAdmin = modifyContext.getSession().getAuthenticatedPrincipal().getDn().equals( adminDn );
 
         boolean modifierAtPresent = false;
         boolean modifiedTimeAtPresent = false;
diff --git a/core/src/main/java/org/apache/directory/server/core/trigger/SimpleTriggerExecutionAuthorizer.java b/core/src/main/java/org/apache/directory/server/core/trigger/SimpleTriggerExecutionAuthorizer.java
index cc8248a..9edbc36 100644
--- a/core/src/main/java/org/apache/directory/server/core/trigger/SimpleTriggerExecutionAuthorizer.java
+++ b/core/src/main/java/org/apache/directory/server/core/trigger/SimpleTriggerExecutionAuthorizer.java
@@ -44,7 +44,7 @@
     
     public boolean hasPermission( OperationContext opContext ) throws LdapException
     {
-        Dn principalName = opContext.getSession().getEffectivePrincipal().getDN();
-        return principalName.equals( opContext.getSession().getDirectoryService().getAdminSession().getAuthenticatedPrincipal().getDN() );
+        Dn principalName = opContext.getSession().getEffectivePrincipal().getDn();
+        return principalName.equals( opContext.getSession().getDirectoryService().getAdminSession().getAuthenticatedPrincipal().getDn() );
     }
 }
diff --git a/core/src/test/java/org/apache/directory/server/core/authn/LdapPrincipalTest.java b/core/src/test/java/org/apache/directory/server/core/authn/LdapPrincipalTest.java
index 14cac2e..08fe266 100644
--- a/core/src/test/java/org/apache/directory/server/core/authn/LdapPrincipalTest.java
+++ b/core/src/test/java/org/apache/directory/server/core/authn/LdapPrincipalTest.java
@@ -27,6 +27,12 @@
 import java.io.ObjectOutputStream;
 
 import org.apache.directory.server.core.LdapPrincipal;
+import org.apache.directory.server.core.LdapPrincipalSerializer;
+import org.apache.directory.shared.ldap.model.constants.AuthenticationLevel;
+import org.apache.directory.shared.ldap.model.name.Dn;
+import org.apache.directory.shared.ldap.model.schema.SchemaManager;
+import org.apache.directory.shared.ldap.schemamanager.impl.DefaultSchemaManager;
+import org.junit.BeforeClass;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 
@@ -44,6 +50,16 @@
 @Concurrency()
 public class LdapPrincipalTest
 {
+    /** The schema manager instance */
+    private static SchemaManager schemaManager;
+
+    @BeforeClass
+    public static void setUp() throws Exception
+    {
+        schemaManager = new DefaultSchemaManager();
+    }
+
+
     /**
      * Test the serialization of an empty LdapPrincipal
      */
@@ -55,12 +71,36 @@
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         ObjectOutputStream out = new ObjectOutputStream( baos );
 
-        out.writeObject( principal );
+        LdapPrincipalSerializer.serialize( principal, out );
+        out.flush();
 
         byte[] data = baos.toByteArray();
         ObjectInputStream in = new ObjectInputStream( new ByteArrayInputStream( data ) );
 
-        LdapPrincipal readPrincipal = (LdapPrincipal)in.readObject();
+        LdapPrincipal readPrincipal = LdapPrincipalSerializer.deserialize( null, in );
+        assertEquals( principal.getAuthenticationLevel(), readPrincipal.getAuthenticationLevel() );
+        assertEquals( principal.getName(), readPrincipal.getName() );
+    }
+    
+    
+    /**
+     * Test the serialization of an empty LdapPrincipal
+     */
+    @Test
+    public void testStaticSerializeLdapPrincipalWithSchemaManager() throws Exception
+    {
+        LdapPrincipal principal = new LdapPrincipal( schemaManager, new Dn( schemaManager, "uid=admin,ou=system" ), AuthenticationLevel.STRONG );
+
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        ObjectOutputStream out = new ObjectOutputStream( baos );
+
+        LdapPrincipalSerializer.serialize( principal, out );
+        out.flush();
+
+        byte[] data = baos.toByteArray();
+        ObjectInputStream in = new ObjectInputStream( new ByteArrayInputStream( data ) );
+
+        LdapPrincipal readPrincipal = LdapPrincipalSerializer.deserialize( null, in );
         assertEquals( principal.getAuthenticationLevel(), readPrincipal.getAuthenticationLevel() );
         assertEquals( principal.getName(), readPrincipal.getName() );
     }
diff --git a/core/src/test/java/org/apache/directory/server/core/changelog/MemoryChangeLogStoreTest.java b/core/src/test/java/org/apache/directory/server/core/changelog/MemoryChangeLogStoreTest.java
index 7a747e3..329287a 100644
--- a/core/src/test/java/org/apache/directory/server/core/changelog/MemoryChangeLogStoreTest.java
+++ b/core/src/test/java/org/apache/directory/server/core/changelog/MemoryChangeLogStoreTest.java
@@ -125,12 +125,12 @@
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         ObjectOutputStream out = new ObjectOutputStream( baos );
 
-        out.writeObject( event );
+        ChangeLogEventSerializer.serialize( event, out );
         
         byte[] data = baos.toByteArray();
         ObjectInputStream in = new ObjectInputStream( new ByteArrayInputStream( data ) );
         
-        ChangeLogEvent read = (ChangeLogEvent)in.readObject(); 
+        ChangeLogEvent read = ChangeLogEventSerializer.deserialize( schemaManager, in ); 
         
         // The read event should not be equal to the written event, as
         // the principal's password has not been stored
@@ -140,7 +140,7 @@
         
         assertEquals( principal.getAuthenticationLevel(), readPrincipal.getAuthenticationLevel() );
         assertEquals( principal.getName(), readPrincipal.getName() );
-        assertEquals( principal.getDN(), readPrincipal.getDN() );
+        assertEquals( principal.getDn(), readPrincipal.getDn() );
         assertNull( readPrincipal.getUserPassword() );
         
         assertEquals( zuluTime, read.getZuluTime() );
diff --git a/http-directory-bridge/pom.xml b/http-directory-bridge/pom.xml
index 1629278..cff47f6 100644
--- a/http-directory-bridge/pom.xml
+++ b/http-directory-bridge/pom.xml
@@ -1,3 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License.  You may obtain a copy of the License at
+  
+  http://www.apache.org/licenses/LICENSE-2.0
+  
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied.  See the License for the
+  specific language governing permissions and limitations
+  under the License.
+-->
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
   <modelVersion>4.0.0</modelVersion>
diff --git a/installers-maven-plugin/pom.xml b/installers-maven-plugin/pom.xml
index e0db19d..0b1d82f 100644
--- a/installers-maven-plugin/pom.xml
+++ b/installers-maven-plugin/pom.xml
@@ -60,7 +60,42 @@
     </dependency>
   </dependencies>
 
-  <build>
+  <build><pluginManagement>
+      <plugins>
+        <plugin>
+          <groupId>org.apache.rat</groupId>
+          <artifactId>apache-rat-plugin</artifactId>
+          <configuration>
+            <excludeSubProjects>false</excludeSubProjects>
+            <excludes>
+              <!-- MAVEN_DEFAULT_EXCLUDES -->
+              <exclude>**/target/**/*</exclude>
+              <exclude>**/cobertura.ser</exclude>
+              <!-- ECLIPSE_DEFAULT_EXCLUDES -->
+              <exclude>**/.classpath</exclude>
+              <exclude>**/.project</exclude>
+              <exclude>**/.settings/**/*</exclude>
+              <!-- IDEA_DEFAULT_EXCLUDES -->
+              <exclude>**/*.iml</exclude>
+              <exclude>**/*.ipr</exclude>
+              <exclude>**/*.iws</exclude>
+              <!-- MANIFEST_MF_EXCLUDES -->
+              <exclude>**/MANIFEST.MF</exclude>
+              <!-- Missing license header in dependency reduced pom, see http://jira.codehaus.org/browse/MSHADE-48 -->
+              <exclude>**/dependency-reduced-pom.xml</exclude>
+              <!-- LDIF_FILES_EXCLUDES -->
+              <exclude>**/*.ldif</exclude>
+              <!-- INSTALLERS_FILES_EXCLUDES -->
+              <exclude>src/main/resources/org/apache/directory/server/installers/deb/control</exclude>
+              <exclude>src/main/resources/org/apache/directory/server/installers/macosxpkg/License.rtf</exclude>
+              <exclude>src/main/resources/org/apache/directory/server/installers/solarispkg/pkginfo</exclude>
+              <exclude>src/main/resources/org/apache/directory/server/installers/solarispkg/Prototype</exclude>
+            </excludes>
+          </configuration>
+         </plugin>
+      </plugins>
+    </pluginManagement>
+    
     <plugins>
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
diff --git a/installers/settings-hudson.xml b/installers/settings-hudson.xml
index 93ab7e4..01a2ab9 100644
--- a/installers/settings-hudson.xml
+++ b/installers/settings-hudson.xml
@@ -1,3 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License.  You may obtain a copy of the License at
+  
+  http://www.apache.org/licenses/LICENSE-2.0
+  
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied.  See the License for the
+  specific language governing permissions and limitations
+  under the License.
+-->
 <settings>
   <!-- These settings are used on Hudson OSX slave to build installers -->
   <profiles>
diff --git a/jdbm/pom.xml b/jdbm/pom.xml
index ef4c04f..9b5cde6 100644
--- a/jdbm/pom.xml
+++ b/jdbm/pom.xml
@@ -42,4 +42,21 @@
       <artifactId>apacheds-i18n</artifactId>
     </dependency>
   </dependencies>
+  
+  <build>
+    <pluginManagement>
+      <plugins>
+        <plugin>
+          <groupId>org.apache.rat</groupId>
+          <artifactId>apache-rat-plugin</artifactId>
+          <configuration>
+            <excludeSubProjects>false</excludeSubProjects>
+            <excludes>
+              <exclude>**/*</exclude>
+            </excludes>
+          </configuration>
+         </plugin>
+      </plugins>
+    </pluginManagement>
+  </build>
 </project>
diff --git a/kerberos-test/src/test/resources/krb5.conf b/kerberos-test/src/test/resources/krb5.conf
index caa72b9..f8dbeab 100644
--- a/kerberos-test/src/test/resources/krb5.conf
+++ b/kerberos-test/src/test/resources/krb5.conf
@@ -1,3 +1,19 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+# 
+# http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
 [libdefaults]
 	default_realm = EXAMPLE.COM
 
diff --git a/osgi/src/main/filtered-resources/features.xml b/osgi/src/main/filtered-resources/features.xml
index c5da26e..7f61df9 100644
--- a/osgi/src/main/filtered-resources/features.xml
+++ b/osgi/src/main/filtered-resources/features.xml
@@ -1,23 +1,23 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!--
-
-      Licensed to the Apache Software Foundation (ASF) under one or more
-      contributor license agreements.  See the NOTICE file distributed with
-      this work for additional information regarding copyright ownership.
-      The ASF licenses this file to You under the Apache License, Version 2.0
-      (the "License"); you may not use this file except in compliance with
-      the License.  You may obtain a copy of the License at
-
-         http///www.apache.org/licenses/LICENSE-2.0
-
-      Unless required by applicable law or agreed to in writing, software
-      distributed under the License is distributed on an "AS IS" BASIS,
-      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-      See the License for the specific language governing permissions and
-      limitations under the License.
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License.  You may obtain a copy of the License at
+  
+  http://www.apache.org/licenses/LICENSE-2.0
+  
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied.  See the License for the
+  specific language governing permissions and limitations
+  under the License.
 -->
 
-
     <!--
     Install with:
     features/addUrl mvn:org.apache.directory.server/apacheds-osgi/${apache.directory.version}/xml/features
diff --git a/osgi/src/main/resources/apacheds.xsd b/osgi/src/main/resources/apacheds.xsd
index 7340d25..6efd651 100644
--- a/osgi/src/main/resources/apacheds.xsd
+++ b/osgi/src/main/resources/apacheds.xsd
@@ -1,4 +1,22 @@
 <?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License.  You may obtain a copy of the License at
+  
+  http://www.apache.org/licenses/LICENSE-2.0
+  
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied.  See the License for the
+  specific language governing permissions and limitations
+  under the License.
+-->
 <xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema' elementFormDefault='qualified'
            targetNamespace='http://apacheds.org/config/core'
            xmlns:directory='http://apacheds.org/config/core'
diff --git a/pom.xml b/pom.xml
index 13a3569..ade776d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -24,7 +24,7 @@
   <parent>
     <groupId>org.apache.directory.project</groupId>
     <artifactId>project</artifactId>
-    <version>20</version>
+    <version>21</version>
   </parent>
 
   <groupId>org.apache.directory.server</groupId>
@@ -62,8 +62,8 @@
     <commons.net.version>2.2</commons.net.version>
     <commons.pool.version>1.5.5</commons.pool.version>
     <derby.version>10.7.1.1</derby.version>
-    <dnsjava.version>2.1.0</dnsjava.version>
-    <ehcache.version>2.3.2</ehcache.version>
+    <dnsjava.version>2.1.1</dnsjava.version>
+    <ehcache.version>2.4.0</ehcache.version>
     <jetty.version>6.1.14</jetty.version>
     <jug.asl.version>2.0.0.RC1</jug.asl.version>
     <junit.version>4.8.2</junit.version>
@@ -156,6 +156,51 @@
   </profiles>
 
   <build>
+    <pluginManagement>
+      <plugins>
+        <plugin>
+          <groupId>org.apache.rat</groupId>
+          <artifactId>apache-rat-plugin</artifactId>
+          <configuration>
+            <excludeSubProjects>false</excludeSubProjects>
+            <excludes>
+              <!-- MAVEN_DEFAULT_EXCLUDES -->
+              <exclude>**/target/**/*</exclude>
+              <exclude>**/cobertura.ser</exclude>
+              <!-- ECLIPSE_DEFAULT_EXCLUDES -->
+              <exclude>**/.classpath</exclude>
+              <exclude>**/.project</exclude>
+              <exclude>**/.settings/**/*</exclude>
+              <!-- IDEA_DEFAULT_EXCLUDES -->
+              <exclude>**/*.iml</exclude>
+              <exclude>**/*.ipr</exclude>
+              <exclude>**/*.iws</exclude>
+              <!-- MANIFEST_MF_EXCLUDES -->
+              <exclude>**/MANIFEST.MF</exclude>
+              <!-- Missing license header in dependency reduced pom, see http://jira.codehaus.org/browse/MSHADE-48 -->
+              <exclude>**/dependency-reduced-pom.xml</exclude>
+              <!-- LDIF_FILES_EXCLUDES -->
+              <exclude>**/*.ldif</exclude>
+              <!-- PDU_FILES_EXCLUDES -->
+              <exclude>**/*.pdu</exclude>
+              <!-- JDBM_FILES_EXCLUDES -->
+              <exclude>jdbm/**/*</exclude>
+              <!-- INSTALLERS_FILES_EXCLUDES -->
+              <exclude>installers-maven-plugin/src/main/resources/org/apache/directory/server/installers/deb/control</exclude>
+              <exclude>installers-maven-plugin/src/main/resources/org/apache/directory/server/installers/macosxpkg/License.rtf</exclude>
+              <exclude>installers-maven-plugin/src/main/resources/org/apache/directory/server/installers/solarispkg/pkginfo</exclude>
+              <exclude>installers-maven-plugin/src/main/resources/org/apache/directory/server/installers/solarispkg/Prototype</exclude>
+              <!-- OSGI_FILES_EXCLUDES -->
+              <exclude>osgi/src/main/resources/META-INF/spring.handlers</exclude>
+              <exclude>osgi/src/main/resources/META-INF/spring.schemas</exclude>
+              <!-- LOG_FILES_EXCLUDES -->
+              <exclude>**/*.log</exclude>
+            </excludes>
+          </configuration>
+         </plugin>
+      </plugins>
+    </pluginManagement>
+    
     <plugins>
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
@@ -223,28 +268,6 @@
               </reportSets>
             </plugin>
             <plugin>
-              <groupId>org.apache.rat</groupId>
-              <artifactId>apache-rat-plugin</artifactId>
-              <configuration>
-                <excludeSubProjects>false</excludeSubProjects>
-                <excludes>
-                  <!-- MAVEN_DEFAULT_EXCLUDES -->
-                  <exclude>**/target/**/*</exclude>
-                  <exclude>**/cobertura.ser</exclude>
-                  <!-- ECLIPSE_DEFAULT_EXCLUDES -->
-                  <exclude>**/.classpath</exclude>
-                  <exclude>**/.project</exclude>
-                  <exclude>**/.settings/**/*</exclude>
-                  <!-- IDEA_DEFAULT_EXCLUDES -->
-                  <exclude>**/*.iml</exclude>
-                  <exclude>**/*.ipr</exclude>
-                  <exclude>**/*.iws</exclude>
-                  <!-- MANIFEST_MF_EXCLUDES -->
-                  <exclude>**/MANIFEST.MF</exclude>
-                </excludes>
-              </configuration>
-            </plugin>
-            <plugin>
               <groupId>org.codehaus.mojo</groupId>
               <artifactId>versions-maven-plugin</artifactId>
               <reportSets>
diff --git a/protocol-kerberos/src/test/resources/org/apache/directory/server/kerberos/kdc/krb5.conf b/protocol-kerberos/src/test/resources/org/apache/directory/server/kerberos/kdc/krb5.conf
index caa72b9..f8dbeab 100644
--- a/protocol-kerberos/src/test/resources/org/apache/directory/server/kerberos/kdc/krb5.conf
+++ b/protocol-kerberos/src/test/resources/org/apache/directory/server/kerberos/kdc/krb5.conf
@@ -1,3 +1,19 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+# 
+# http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
 [libdefaults]
 	default_realm = EXAMPLE.COM
 
diff --git a/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapServer.java b/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapServer.java
index 6705fe2..563273f 100644
--- a/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapServer.java
+++ b/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapServer.java
@@ -186,7 +186,7 @@
     private LdapRequestHandler<BindRequest> bindHandler;
     private LdapRequestHandler<CompareRequest> compareHandler;
     private LdapRequestHandler<DeleteRequest> deleteHandler;
-    private ExtendedHandler<ExtendedRequest<ExtendedResponse>, ExtendedResponse> extendedHandler;
+    private ExtendedHandler extendedHandler;
     private LdapRequestHandler<ModifyRequest> modifyHandler;
     private LdapRequestHandler<ModifyDnRequest> modifyDnHandler;
     private LdapRequestHandler<SearchRequest> searchHandler;
@@ -285,7 +285,7 @@
 
         if ( getExtendedHandler() == null )
         {
-            setExtendedHandler( new ExtendedHandler<ExtendedRequest<ExtendedResponse>, ExtendedResponse>() );
+            setExtendedHandler( new ExtendedHandler() );
         }
 
         if ( getModifyHandler() == null )
@@ -771,7 +771,7 @@
      * request handler
      * @return the exnteded operation handler
      */
-    public ExtendedOperationHandler<? extends ExtendedRequest<? extends ExtendedResponse>,? extends ExtendedResponse> 
+    public ExtendedOperationHandler<ExtendedRequest<ExtendedResponse>,ExtendedResponse> 
         getExtendedOperationHandler( String oid )
     {
         for ( ExtendedOperationHandler<ExtendedRequest<ExtendedResponse>, ExtendedResponse> h : extendedOperationHandlers )
@@ -1136,7 +1136,7 @@
      * @param extendedHandler The ExtendedRequest handler
      */
     @SuppressWarnings({ "unchecked", "rawtypes" })
-    public void setExtendedHandler( ExtendedHandler<ExtendedRequest<ExtendedResponse>, ExtendedResponse> extendedHandler )
+    public void setExtendedHandler( ExtendedHandler extendedHandler )
     {
         this.handler.removeReceivedMessageHandler( ExtendedRequest.class );
         this.extendedHandler = extendedHandler;
diff --git a/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/BindHandler.java b/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/BindHandler.java
index 1c19da3..27e6b18 100644
--- a/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/BindHandler.java
+++ b/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/BindHandler.java
@@ -310,7 +310,7 @@
                 {
                     DirectoryService ds = ldapSession.getLdapServer().getDirectoryService();
                     String saslMechanism = bindRequest.getSaslMechanism();
-                    CoreSession userSession = ds.getSession( ldapPrincipal.getDN(), ldapPrincipal.getUserPassword(),
+                    CoreSession userSession = ds.getSession( ldapPrincipal.getDn(), ldapPrincipal.getUserPassword(),
                         saslMechanism, null );
 
                     // Set the user session into the ldap session 
diff --git a/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/ExtendedHandler.java b/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/ExtendedHandler.java
index 31bf6a2..3e14f79 100644
--- a/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/ExtendedHandler.java
+++ b/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/ExtendedHandler.java
@@ -34,13 +34,11 @@
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class ExtendedHandler<Q extends ExtendedRequest<R>, R extends ExtendedResponse> extends LdapRequestHandler<Q>
+public class ExtendedHandler extends LdapRequestHandler<ExtendedRequest<ExtendedResponse>>
 {
-    public void handle( LdapSession session, Q req ) throws Exception
+    public void handle( LdapSession session, ExtendedRequest<ExtendedResponse> req ) throws Exception
     {
-        @SuppressWarnings("unchecked")
-        ExtendedOperationHandler<Q, R> handler = 
-            ( ExtendedOperationHandler<Q, R> ) getLdapServer().getExtendedOperationHandler( req.getRequestName() );
+        ExtendedOperationHandler<ExtendedRequest<ExtendedResponse>, ExtendedResponse> handler = getLdapServer().getExtendedOperationHandler( req.getRequestName() );
 
         if ( handler == null )
         {
diff --git a/service/ApacheDS.launch b/service/ApacheDS.launch
index 74551fc..0e6a052 100644
--- a/service/ApacheDS.launch
+++ b/service/ApacheDS.launch
@@ -1,4 +1,22 @@
 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License.  You may obtain a copy of the License at
+  
+  http://www.apache.org/licenses/LICENSE-2.0
+  
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied.  See the License for the
+  specific language governing permissions and limitations
+  under the License.
+-->
 <launchConfiguration type="org.eclipse.jdt.launching.localJavaApplication">
 <listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
 <listEntry value="/apacheds-service/src/main/java/org/apache/directory/server/UberjarMain.java"/>
diff --git a/test-framework/pom.xml b/test-framework/pom.xml
index b26aa1f..83d81eb 100644
--- a/test-framework/pom.xml
+++ b/test-framework/pom.xml
@@ -1,3 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License.  You may obtain a copy of the License at
+  
+  http://www.apache.org/licenses/LICENSE-2.0
+  
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied.  See the License for the
+  specific language governing permissions and limitations
+  under the License.
+-->
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
   <modelVersion>4.0.0</modelVersion>
diff --git a/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/AbstractStore.java b/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/AbstractStore.java
index dcac71c..53f4983 100644
--- a/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/AbstractStore.java
+++ b/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/AbstractStore.java
@@ -28,6 +28,7 @@
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
+import java.util.concurrent.atomic.AtomicBoolean;
 
 import org.apache.directory.server.constants.ApacheSchemaConstants;
 import org.apache.directory.server.core.entry.ClonedServerEntry;
@@ -83,7 +84,7 @@
     protected URI partitionPath;
 
     /** true if we sync disks on every write operation */
-    protected boolean isSyncOnWrite = true;
+    protected AtomicBoolean isSyncOnWrite = new AtomicBoolean( true );
 
     /** The store cache size */
     protected int cacheSize = DEFAULT_CACHE_SIZE;
@@ -187,13 +188,13 @@
     public void setSyncOnWrite( boolean isSyncOnWrite )
     {
         protect( "syncOnWrite" );
-        this.isSyncOnWrite = isSyncOnWrite;
+        this.isSyncOnWrite.set( isSyncOnWrite );
     }
 
 
     public boolean isSyncOnWrite()
     {
-        return isSyncOnWrite;
+        return isSyncOnWrite.get();
     }
 
 
@@ -1012,7 +1013,7 @@
 
         master.put( id, entry );
 
-        if ( isSyncOnWrite )
+        if ( isSyncOnWrite.get() )
         {
             sync();
         }
@@ -1059,7 +1060,7 @@
         updateCsnIndex( entry, id );
         master.put( id, entry );
 
-        if ( isSyncOnWrite )
+        if ( isSyncOnWrite.get() )
         {
             sync();
         }
@@ -1100,7 +1101,7 @@
         updateCsnIndex( entry, id );
         master.put( id, entry );
 
-        if ( isSyncOnWrite )
+        if ( isSyncOnWrite.get() )
         {
             sync();
         }
@@ -1156,7 +1157,7 @@
 
         master.delete( id );
 
-        if ( isSyncOnWrite )
+        if ( isSyncOnWrite.get() )
         {
             sync();
         }
@@ -1287,7 +1288,7 @@
 
         master.put( id, entry );
 
-        if ( isSyncOnWrite )
+        if ( isSyncOnWrite.get() )
         {
             sync();
         }
@@ -1347,7 +1348,7 @@
         rename( oldDn, newRdn, deleteOldRdn, modifiedEntry );
         moveAndRename( oldDn, oldId, newSuperiorDn, newRdn, modifiedEntry );
 
-        if ( isSyncOnWrite )
+        if ( isSyncOnWrite.get() )
         {
             sync();
         }
@@ -1447,7 +1448,7 @@
             master.put( entryId, modifiedEntry );
         }
 
-        if ( isSyncOnWrite )
+        if ( isSyncOnWrite.get() )
         {
             sync();
         }
diff --git a/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/ParentIdAndRdn.java b/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/ParentIdAndRdn.java
index 4206b63..e037f69 100644
--- a/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/ParentIdAndRdn.java
+++ b/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/ParentIdAndRdn.java
@@ -27,7 +27,9 @@
 import java.util.Arrays;
 import java.util.List;
 
+import org.apache.directory.shared.ldap.model.exception.LdapInvalidDnException;
 import org.apache.directory.shared.ldap.model.name.Rdn;
+import org.apache.directory.shared.ldap.model.name.RdnSerializer;
 
 
 /**
@@ -189,7 +191,7 @@
 
         for ( Rdn rdn : rdns )
         {
-            rdn.writeExternal( out );
+            RdnSerializer.serialize( rdn, out );
         }
     }
 
@@ -203,9 +205,14 @@
         
         for ( int i = 0; i < size; i++ )
         {
-            Rdn rdn = new Rdn();
-            rdn.readExternal( in );
-            rdns[i] = rdn;
+            try
+            {
+                rdns[i] = RdnSerializer.deserialize( null, in );
+            }
+            catch ( LdapInvalidDnException lide )
+            {
+                throw new IOException( lide.getMessage() );
+            }
         }
     }