directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r582462 [7/10] - in /directory: apacheds/branches/bigbang/ apacheds/branches/bigbang/core-unit/src/main/java/org/apache/directory/server/core/unit/ apacheds/branches/bigbang/core-unit/src/test/java/org/apache/directory/server/core/ apacheds...
Date Sat, 06 Oct 2007 06:48:45 GMT
Modified: directory/apacheds/branches/bigbang/mitosis/src/main/java/org/apache/directory/mitosis/service/protocol/handler/ReplicationClientContextHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/mitosis/src/main/java/org/apache/directory/mitosis/service/protocol/handler/ReplicationClientContextHandler.java?rev=582462&r1=582461&r2=582462&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/mitosis/src/main/java/org/apache/directory/mitosis/service/protocol/handler/ReplicationClientContextHandler.java (original)
+++ directory/apacheds/branches/bigbang/mitosis/src/main/java/org/apache/directory/mitosis/service/protocol/handler/ReplicationClientContextHandler.java Fri Oct  5 23:48:35 2007
@@ -21,7 +21,6 @@
 
 
 import java.net.InetSocketAddress;
-import java.util.Iterator;
 import java.util.Map;
 
 import javax.naming.NamingEnumeration;
@@ -186,9 +185,9 @@
     /**
      * A helper to write a message and schedule that message for expiration.
      *
-     * @param ctx
-     * @param message
-     * @return
+     * @param ctx the replication context
+     * @param message the message to replicate
+     * @return the write future to block on this replication message transmission
      */
     public WriteFuture writeTimeLimitedMessage( ReplicationContext ctx, Object message )
     {
@@ -219,14 +218,12 @@
             return;
         }
 
-        Iterator i = ctx.getConfiguration().getPeerReplicas().iterator();
-        while ( i.hasNext() )
+        for ( Replica replica : ctx.getConfiguration().getPeerReplicas() )
         {
-            Replica replica = ( Replica ) i.next();
             if ( replica.getId().equals( message.getReplicaId() ) )
             {
                 if ( replica.getAddress().getAddress().equals(
-                    ( ( InetSocketAddress ) ctx.getSession().getRemoteAddress() ).getAddress() ) )
+                        ( ( InetSocketAddress ) ctx.getSession().getRemoteAddress() ).getAddress() ) )
                 {
                     ctx.setPeer( replica );
                     ctx.setState( State.READY );
@@ -235,7 +232,7 @@
                 else
                 {
                     SessionLog.warn( ctx.getSession(), "Peer address mismatches: "
-                        + ctx.getSession().getRemoteAddress() + " (expected: " + replica.getAddress() );
+                            + ctx.getSession().getRemoteAddress() + " (expected: " + replica.getAddress() );
                     ctx.getSession().close();
                     return;
                 }
@@ -336,7 +333,7 @@
 
     private void sendAllEntries( ReplicationContext ctx ) throws NamingException
     {
-        Attributes rootDSE = ctx.getServiceConfiguration().getPartitionNexus().getRootDSE( null );
+        Attributes rootDSE = ctx.getDirectoryService().getPartitionNexus().getRootDSE( null );
 
         Attribute namingContextsAttr = rootDSE.get( "namingContexts" );
         if ( namingContextsAttr == null || namingContextsAttr.size() == 0 )
@@ -364,7 +361,7 @@
 
             SessionLog.info( ctx.getSession(), "Sending entries under '" + contextName + '\'' );
 
-            Map<String, OidNormalizer> mapping = ctx.getServiceConfiguration().getRegistries().getAttributeTypeRegistry()
+            Map<String, OidNormalizer> mapping = ctx.getDirectoryService().getRegistries().getAttributeTypeRegistry()
                 .getNormalizerMapping();
             contextName.normalize( mapping );
             sendAllEntries( ctx, contextName );
@@ -377,9 +374,9 @@
         // Retrieve all subtree including the base entry
         SearchControls ctrl = new SearchControls();
         ctrl.setSearchScope( SearchControls.SUBTREE_SCOPE );
-        NamingEnumeration e = ctx.getServiceConfiguration().getPartitionNexus().search( 
+        NamingEnumeration e = ctx.getDirectoryService().getPartitionNexus().search(
             new SearchOperationContext( contextName,
-            ctx.getServiceConfiguration().getEnvironment(),
+            ctx.getDirectoryService().getEnvironment(),
             new PresenceNode( SchemaConstants.OBJECT_CLASS_AT_OID ), ctrl ) );
 
         try
@@ -397,7 +394,7 @@
                 }
 
                 // Get entryCSN of the entry.  Skip if entryCSN value is invalid. 
-                CSN csn = null;
+                CSN csn;
                 try
                 {
                     csn = new DefaultCSN( String.valueOf( entryCSNAttr.get() ) );
@@ -410,8 +407,8 @@
 
                 // Convert the entry into AddEntryOperation log.
                 LdapDN dn = new LdapDN( sr.getName() );
-                dn.normalize( ctx.getServiceConfiguration().getRegistries()
-                    .getAttributeTypeRegistry().getNormalizerMapping() );
+                dn.normalize( ctx.getDirectoryService().getRegistries()
+                        .getAttributeTypeRegistry().getNormalizerMapping() );
                 Operation op = new AddEntryOperation( csn, dn, attrs );
 
                 // Send a LogEntry message for the entry.
@@ -428,16 +425,14 @@
     @SuppressWarnings("unchecked")
     private void sendReplicationLogs( ReplicationContext ctx, CSNVector myPV, CSNVector yourUV )
     {
-        Iterator i = myPV.getReplicaIds().iterator();
-        while ( i.hasNext() )
+        for ( ReplicaId replicaId : myPV.getReplicaIds() )
         {
-            ReplicaId replicaId = ( ReplicaId ) i.next();
             CSN myCSN = myPV.getCSN( replicaId );
             CSN yourCSN = yourUV.getCSN( replicaId );
             if ( yourCSN != null && ( myCSN == null || yourCSN.compareTo( myCSN ) < 0 ) )
             {
                 SessionLog.warn( ctx.getSession(), "Remote update vector (" + yourUV
-                    + ") is out-of-date.  Full replication is required." );
+                        + ") is out-of-date.  Full replication is required." );
                 ctx.getSession().close();
                 return;
             }

Modified: directory/apacheds/branches/bigbang/mitosis/src/main/java/org/apache/directory/mitosis/service/protocol/handler/ReplicationProtocolHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/mitosis/src/main/java/org/apache/directory/mitosis/service/protocol/handler/ReplicationProtocolHandler.java?rev=582462&r1=582461&r2=582462&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/mitosis/src/main/java/org/apache/directory/mitosis/service/protocol/handler/ReplicationProtocolHandler.java (original)
+++ directory/apacheds/branches/bigbang/mitosis/src/main/java/org/apache/directory/mitosis/service/protocol/handler/ReplicationProtocolHandler.java Fri Oct  5 23:48:35 2007
@@ -21,10 +21,10 @@
 
 
 import org.apache.directory.mitosis.configuration.ReplicationConfiguration;
+import org.apache.directory.mitosis.service.DefaultReplicationContext;
 import org.apache.directory.mitosis.service.ReplicationContext;
 import org.apache.directory.mitosis.service.ReplicationService;
-import org.apache.directory.mitosis.service.DefaultReplicationContext;
-import org.apache.directory.server.core.DirectoryServiceConfiguration;
+import org.apache.directory.server.core.DirectoryService;
 import org.apache.mina.common.IdleStatus;
 import org.apache.mina.common.IoHandler;
 import org.apache.mina.common.IoSession;
@@ -42,7 +42,7 @@
 
     private final ReplicationService service;
     private final ReplicationConfiguration configuration;
-    private final DirectoryServiceConfiguration serviceCfg;
+    private final DirectoryService directoryService;
     private final ReplicationContextHandler contextHandler;
 
 
@@ -53,7 +53,7 @@
 
         this.service = service;
         this.configuration = service.getConfiguration();
-        this.serviceCfg = service.getFactoryConfiguration();
+        this.directoryService = service.getDirectoryService();
         this.contextHandler = contextHandler;
     }
 
@@ -70,7 +70,8 @@
 
     public void sessionCreated( IoSession session ) throws Exception
     {
-        session.setAttribute( CONTEXT, new DefaultReplicationContext( service, serviceCfg, configuration, session ) );
+        session.setAttribute( CONTEXT,
+                new DefaultReplicationContext( service, directoryService, configuration, session ) );
     }
 
 

Modified: directory/apacheds/branches/bigbang/mitosis/src/main/java/org/apache/directory/mitosis/service/protocol/handler/ReplicationServerContextHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/mitosis/src/main/java/org/apache/directory/mitosis/service/protocol/handler/ReplicationServerContextHandler.java?rev=582462&r1=582461&r2=582462&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/mitosis/src/main/java/org/apache/directory/mitosis/service/protocol/handler/ReplicationServerContextHandler.java (original)
+++ directory/apacheds/branches/bigbang/mitosis/src/main/java/org/apache/directory/mitosis/service/protocol/handler/ReplicationServerContextHandler.java Fri Oct  5 23:48:35 2007
@@ -21,7 +21,6 @@
 
 
 import java.net.InetSocketAddress;
-import java.util.Iterator;
 
 import org.apache.directory.mitosis.common.CSNVector;
 import org.apache.directory.mitosis.common.Replica;
@@ -53,7 +52,7 @@
  */
 public class ReplicationServerContextHandler implements ReplicationContextHandler
 {
-    private Replica replicaInTransaction = null;
+    private Replica replicaInTransaction;
 
 
     public void contextBegin( ReplicationContext ctx ) throws Exception
@@ -136,19 +135,17 @@
 
     private void onLogin( ReplicationContext ctx, LoginMessage message )
     {
-        Iterator i = ctx.getConfiguration().getPeerReplicas().iterator();
-        while ( i.hasNext() )
+        for ( Replica replica : ctx.getConfiguration().getPeerReplicas() )
         {
-            Replica replica = ( Replica ) i.next();
             if ( replica.getId().equals( message.getReplicaId() ) )
             {
                 if ( replica.getAddress().getAddress().equals(
-                    ( ( InetSocketAddress ) ctx.getSession().getRemoteAddress() ).getAddress() ) )
+                        ( ( InetSocketAddress ) ctx.getSession().getRemoteAddress() ).getAddress() ) )
                 {
                     ctx.getSession()
-                        .write(
-                            new LoginAckMessage( message.getSequence(), Constants.OK, ctx.getConfiguration()
-                                .getReplicaId() ) );
+                            .write(
+                                    new LoginAckMessage( message.getSequence(), Constants.OK, ctx.getConfiguration()
+                                            .getReplicaId() ) );
                     ctx.setPeer( replica );
                     ctx.setState( State.READY );
 
@@ -159,10 +156,10 @@
                 else
                 {
                     SessionLog.warn( ctx.getSession(), "Peer address mismatches: "
-                        + ctx.getSession().getRemoteAddress() + " (expected: " + replica.getAddress() );
+                            + ctx.getSession().getRemoteAddress() + " (expected: " + replica.getAddress() );
                     ctx.getSession().write(
-                        new LoginAckMessage( message.getSequence(), Constants.NOT_OK, ctx.getConfiguration()
-                            .getReplicaId() ) );
+                            new LoginAckMessage( message.getSequence(), Constants.NOT_OK, ctx.getConfiguration()
+                                    .getReplicaId() ) );
                     ctx.getSession().close();
                     return;
                 }
@@ -190,9 +187,8 @@
         LogEntryAckMessage ack = null;
         try
         {
-            op.execute( ctx.getServiceConfiguration().getPartitionNexus(), 
-                ctx.getConfiguration().getStore(),
-                ctx.getServiceConfiguration().getRegistries().getAttributeTypeRegistry() );
+            op.execute( ctx.getDirectoryService().getPartitionNexus(), ctx.getConfiguration().getStore(),
+                ctx.getDirectoryService().getRegistries().getAttributeTypeRegistry() );
             ack = new LogEntryAckMessage( message.getSequence(), Constants.OK );
         }
         catch ( Exception e )

Modified: directory/apacheds/branches/bigbang/mitosis/src/main/java/org/apache/directory/mitosis/store/ReplicationStore.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/mitosis/src/main/java/org/apache/directory/mitosis/store/ReplicationStore.java?rev=582462&r1=582461&r2=582462&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/mitosis/src/main/java/org/apache/directory/mitosis/store/ReplicationStore.java (original)
+++ directory/apacheds/branches/bigbang/mitosis/src/main/java/org/apache/directory/mitosis/store/ReplicationStore.java Fri Oct  5 23:48:35 2007
@@ -20,20 +20,15 @@
 package org.apache.directory.mitosis.store;
 
 
-import java.util.Set;
-
-import javax.naming.Name;
-
-import org.apache.directory.mitosis.common.CSN;
-import org.apache.directory.mitosis.common.CSNVector;
-import org.apache.directory.mitosis.common.Replica;
-import org.apache.directory.mitosis.common.ReplicaId;
-import org.apache.directory.mitosis.common.UUID;
+import org.apache.directory.mitosis.common.*;
 import org.apache.directory.mitosis.configuration.ReplicationConfiguration;
 import org.apache.directory.mitosis.operation.Operation;
-import org.apache.directory.server.core.DirectoryServiceConfiguration;
+import org.apache.directory.server.core.DirectoryService;
 import org.apache.directory.shared.ldap.name.LdapDN;
 
+import javax.naming.Name;
+import java.util.Set;
+
 /**
  * Provides an abstract storage that stores data required to perform
  * replication, such as {@link UUID}-{@link LdapDN} mapping and
@@ -48,7 +43,7 @@
     /**
      * Opens this storage.
      */
-    void open( DirectoryServiceConfiguration serviceCfg, ReplicationConfiguration cfg );
+    void open( DirectoryService directoryService, ReplicationConfiguration cfg );
 
     /**
      * Closes this storage and releases the resources allocated when it's

Modified: directory/apacheds/branches/bigbang/mitosis/src/main/java/org/apache/directory/mitosis/store/derby/DerbyReplicationStore.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/mitosis/src/main/java/org/apache/directory/mitosis/store/derby/DerbyReplicationStore.java?rev=582462&r1=582461&r2=582462&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/mitosis/src/main/java/org/apache/directory/mitosis/store/derby/DerbyReplicationStore.java (original)
+++ directory/apacheds/branches/bigbang/mitosis/src/main/java/org/apache/directory/mitosis/store/derby/DerbyReplicationStore.java Fri Oct  5 23:48:35 2007
@@ -20,40 +20,30 @@
 package org.apache.directory.mitosis.store.derby;
 
 
-import java.io.File;
-import java.sql.Connection;
-import java.sql.DriverManager;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Statement;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-
-import javax.naming.Name;
-import javax.naming.ldap.LdapName;
-
 import org.apache.commons.dbcp.BasicDataSource;
-import org.apache.directory.server.core.DirectoryServiceConfiguration;
-import org.apache.directory.mitosis.common.CSN;
-import org.apache.directory.mitosis.common.CSNVector;
-import org.apache.directory.mitosis.common.ReplicaId;
-import org.apache.directory.mitosis.common.DefaultCSN;
-import org.apache.directory.mitosis.common.UUID;
+import org.apache.directory.mitosis.common.*;
 import org.apache.directory.mitosis.configuration.ReplicationConfiguration;
 import org.apache.directory.mitosis.operation.Operation;
 import org.apache.directory.mitosis.operation.OperationCodec;
 import org.apache.directory.mitosis.store.ReplicationLogIterator;
 import org.apache.directory.mitosis.store.ReplicationStore;
 import org.apache.directory.mitosis.store.ReplicationStoreException;
+import org.apache.directory.server.core.DirectoryService;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import javax.naming.Name;
+import javax.naming.ldap.LdapName;
+import java.io.File;
+import java.sql.*;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
 
 public class DerbyReplicationStore implements ReplicationStore
 {
-    private static final Logger log = LoggerFactory.getLogger( DerbyReplicationStore.class );
+    private static final Logger LOG = LoggerFactory.getLogger( DerbyReplicationStore.class );
 
     private static final String DEFAULT_TABLE_PREFIX = "REPLICATION_";
     private static final String KEY_REPLICA_ID = "replicaId";
@@ -68,7 +58,7 @@
     private String metadataTableName;
     private String uuidTableName;
     private String logTableName;
-    private Set<ReplicaId> knownReplicaIds;
+    private final Set<ReplicaId> knownReplicaIds = new HashSet<ReplicaId>();
     private final Object knownReplicaIdsLock = new Object();
     private final OperationCodec operationCodec = new OperationCodec();
 
@@ -96,12 +86,12 @@
     }
 
 
-    public void open( DirectoryServiceConfiguration serviceCfg, ReplicationConfiguration cfg )
+    public void open( DirectoryService directoryService, ReplicationConfiguration cfg )
     {
         replicaId = cfg.getReplicaId();
 
         // Calculate DB URI
-        dbURI = DB_URI_PREFIX + serviceCfg.getStartupConfiguration().getWorkingDirectory().getPath() + File.separator
+        dbURI = DB_URI_PREFIX + directoryService.getWorkingDirectory().getPath() + File.separator
             + "replication";
 
         // Create database if not exists.
@@ -249,7 +239,6 @@
             // Get known replica IDs.
             ps = con.prepareStatement( "SELECT DISTINCT CSN_REPLICA_ID FROM " + logTableName );
             rs = ps.executeQuery();
-            knownReplicaIds = new HashSet<ReplicaId>();
             while ( rs.next() )
             {
                 knownReplicaIds.add( new ReplicaId( rs.getString( 1 ) ) );
@@ -278,7 +267,7 @@
         }
         catch ( SQLException e )
         {
-            log.warn( "Failed to close the dataSource.", e );
+            LOG.warn( "Failed to close the dataSource.", e );
         }
         dataSource = null;
         replicaId = null;
@@ -384,6 +373,8 @@
             }
             catch ( SQLException e1 )
             {
+                LOG.error( "Exception while rolling back attempt to put a UUID {} for dn {}",
+                        uuid.toString(), dn.toString() );
             }
 
             throw new ReplicationStoreException( e );
@@ -468,9 +459,8 @@
         {
             synchronized ( knownReplicaIdsLock )
             {
-                Set<ReplicaId> newKnownReplicaIds = new HashSet<ReplicaId>( knownReplicaIds );
-                newKnownReplicaIds.add( csn.getReplicaId() );
-                knownReplicaIds = newKnownReplicaIds;
+                knownReplicaIds.clear();
+                knownReplicaIds.add( csn.getReplicaId() );
             }
         }
     }
@@ -478,9 +468,9 @@
 
     public ReplicationLogIterator getLogs( CSNVector updateVector, boolean inclusive )
     {
-        Connection con = null;
-        PreparedStatement ps = null;
-        ResultSet rs = null;
+        Connection con;
+        PreparedStatement ps;
+        ResultSet rs;
 
         updateVector = getNormalizedUpdateVector( updateVector );
 
@@ -492,8 +482,8 @@
             buf.append( "WHERE " );
             for ( int i = updateVector.size();; )
             {
-                buf.append( "( CSN_REPLICA_ID = ? AND (CSN_TIMESTAMP = ? AND CSN_OP_SEQ >" + ( inclusive ? "=" : "" )
-                    + " ? OR CSN_TIMESTAMP > ?) ) " );
+                buf.append( "( CSN_REPLICA_ID = ? AND (CSN_TIMESTAMP = ? AND CSN_OP_SEQ >" )
+                        .append( inclusive ? "=" : "" ).append( " ? OR CSN_TIMESTAMP > ?) ) " );
                 i--;
                 if ( i == 0 )
                 {
@@ -547,10 +537,9 @@
         CSNVector newUV = new CSNVector();
         synchronized ( knownReplicaIds )
         {
-            Iterator<ReplicaId> i = knownReplicaIds.iterator();
-            while ( i.hasNext() )
+            for ( ReplicaId knownReplicaId : knownReplicaIds )
             {
-                newUV.setCSN( new DefaultCSN( 0, i.next(), 0 ) );
+                newUV.setCSN( new DefaultCSN( 0, knownReplicaId, 0 ) );
             }
         }
 
@@ -561,9 +550,9 @@
 
     public ReplicationLogIterator getLogs( CSN fromCSN, boolean inclusive )
     {
-        Connection con = null;
-        PreparedStatement ps = null;
-        ResultSet rs = null;
+        Connection con;
+        PreparedStatement ps;
+        ResultSet rs;
 
         try
         {
@@ -710,10 +699,8 @@
             ps = con.prepareStatement( "SELECT CSN_TIMESTAMP, CSN_OP_SEQ FROM " + logTableName
                 + " WHERE CSN_REPLICA_ID=? ORDER BY CSN_TIMESTAMP " + ORDER + ", CSN_OP_SEQ " + ORDER );
 
-            Iterator<ReplicaId> it = knownReplicaIds.iterator();
-            while ( it.hasNext() )
+            for ( ReplicaId replicaId : knownReplicaIds )
             {
-                ReplicaId replicaId = it.next();
                 ps.setString( 1, replicaId.getId() );
                 rs = ps.executeQuery();
                 if ( rs.next() )

Modified: directory/apacheds/branches/bigbang/mitosis/src/test/java/org/apache/directory/mitosis/service/AbstractReplicationServiceTestCase.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/mitosis/src/test/java/org/apache/directory/mitosis/service/AbstractReplicationServiceTestCase.java?rev=582462&r1=582461&r2=582462&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/mitosis/src/test/java/org/apache/directory/mitosis/service/AbstractReplicationServiceTestCase.java (original)
+++ directory/apacheds/branches/bigbang/mitosis/src/test/java/org/apache/directory/mitosis/service/AbstractReplicationServiceTestCase.java Fri Oct  5 23:48:35 2007
@@ -20,42 +20,38 @@
 
 package org.apache.directory.mitosis.service;
 
-import java.io.File;
-import java.net.InetSocketAddress;
-import java.util.HashMap;
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Random;
-
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.ldap.InitialLdapContext;
-import javax.naming.ldap.LdapContext;
-
 import junit.framework.TestCase;
-
 import org.apache.commons.io.FileUtils;
 import org.apache.directory.mitosis.common.Replica;
 import org.apache.directory.mitosis.common.ReplicaId;
 import org.apache.directory.mitosis.configuration.ReplicationConfiguration;
+import org.apache.directory.server.core.DefaultDirectoryService;
 import org.apache.directory.server.core.DirectoryService;
 import org.apache.directory.server.core.interceptor.Interceptor;
-import org.apache.directory.server.core.configuration.MutableStartupConfiguration;
-import org.apache.directory.server.core.configuration.ShutdownConfiguration;
 import org.apache.directory.server.core.jndi.CoreContextFactory;
 import org.apache.mina.util.AvailablePortFinder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.naming.Context;
+import javax.naming.ldap.InitialLdapContext;
+import javax.naming.ldap.LdapContext;
+import java.io.File;
+import java.net.InetSocketAddress;
+import java.util.*;
+
 
 /**
- * TODO AbstractReplicationServiceTestCase.
+ * An abstract base class for replication tests.
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$, $Date$
  */
 public abstract class AbstractReplicationServiceTestCase extends TestCase
 {
+    private static final Logger LOG = LoggerFactory.getLogger( AbstractReplicationServiceTestCase.class );
     protected Map<String, LdapContext> contexts = new HashMap<String, LdapContext>();
+    protected Map<String, DirectoryService> services = new HashMap<String, DirectoryService>();
     protected Map<String, ReplicationService> replicationServices = new HashMap<String, ReplicationService>();
 
     protected void setUp() throws Exception
@@ -89,46 +85,46 @@
                 + File.separator + "mitosis-"
                 + Long.toHexString( random.nextLong() );
 
-        for( int i = 0; i < replicas.length; i++ )
+        for ( Replica replica : replicas )
         {
-            Replica replica = replicas[ i ];
-            String replicaId = replicas[ i ].getId().getId();
-            MutableStartupConfiguration ldapCfg = new MutableStartupConfiguration(
-                    replicaId );
+            String replicaId = replica.getId().getId();
+            DirectoryService service = new DefaultDirectoryService();
+            service.setInstanceId( replicaId );
 
             File workDir = new File( homeDirectory + File.separator
-                    + ldapCfg.getInstanceId() );
+                    + service.getInstanceId() );
 
-            ldapCfg.setShutdownHookEnabled( false );
-            ldapCfg.setWorkingDirectory( workDir );
+            service.setShutdownHookEnabled( false );
+            service.setWorkingDirectory( workDir );
 
-            List<Interceptor> interceptors = ldapCfg.getInterceptors();
+            List<Interceptor> interceptors = service.getInterceptors();
 
             ReplicationConfiguration replicationCfg = new ReplicationConfiguration();
             replicationCfg.setReplicaId( replica.getId() );
             // Disable automatic replication to prevent unexpected behavior
-            replicationCfg.setReplicationInterval(0);
+            replicationCfg.setReplicationInterval( 0 );
             replicationCfg.setServerPort( replica.getAddress().getPort() );
-            for( int j = 0; j < replicas.length; j++ )
+            for ( Replica replica1 : replicas )
             {
-                if( replicas[ j ] != replica )
+                if ( replica1 != replica )
                 {
-                    replicationCfg.addPeerReplica( replicas[ j ] );
+                    replicationCfg.addPeerReplica( replica1 );
                 }
             }
 
             ReplicationService replicationService = new ReplicationService();
-            replicationService.setConfiguration(replicationCfg);
-            interceptors.add(replicationService);
+            replicationService.setConfiguration( replicationCfg );
+            interceptors.add( replicationService );
 
-            ldapCfg.setInterceptors( interceptors );
+            service.setInterceptors( interceptors );
 
-            if( workDir.exists() )
+            if ( workDir.exists() )
             {
                 FileUtils.deleteDirectory( workDir );
             }
 
-            Hashtable env = new Hashtable( ldapCfg.toJndiEnvironment() );
+            Hashtable env = new Hashtable();
+            env.put( DirectoryService.JNDI_KEY, service );
             env.put( Context.SECURITY_PRINCIPAL, "uid=admin,ou=system" );
             env.put( Context.SECURITY_CREDENTIALS, "secret" );
             env.put( Context.SECURITY_AUTHENTICATION, "simple" );
@@ -139,13 +135,14 @@
             // Initialize the server instance.
             LdapContext context = new InitialLdapContext( env, null );
             contexts.put( replicaId, context );
+            services.put( replicaId, service );
             replicationServices.put( replicaId, replicationService );
         }
 
         // Ensure all replicas have had a chance to connect to each other since the last one started.
-        for( Iterator<ReplicationService> i = replicationServices.values().iterator(); i.hasNext(); )
+        for ( ReplicationService replicationService : replicationServices.values() )
         {
-            i.next().interruptConnectors();
+            replicationService.interruptConnectors();
         }
         Thread.sleep( 5000 );
     }
@@ -164,27 +161,19 @@
     @SuppressWarnings("unchecked")
     protected void destroyAllReplicas() throws Exception
     {
-        for( Iterator<String> i = contexts.keySet().iterator(); i.hasNext(); )
+        for( Iterator<DirectoryService> i = services.values().iterator(); i.hasNext(); )
         {
-            String replicaId = i.next();
-            File workDir = DirectoryService.getInstance( replicaId )
-                    .getConfiguration().getStartupConfiguration()
-                    .getWorkingDirectory();
+            DirectoryService replica = i.next();
+            File workDir = replica.getWorkingDirectory();
 
-            Hashtable env = new Hashtable();
-            env.put( Context.PROVIDER_URL, "ou=system" );
-            env.put( Context.INITIAL_CONTEXT_FACTORY, CoreContextFactory.class
-                    .getName() );
-            env.putAll( new ShutdownConfiguration( replicaId )
-                    .toJndiEnvironment() );
-            env.put( Context.SECURITY_PRINCIPAL, "uid=admin,ou=system" );
-            env.put( Context.SECURITY_CREDENTIALS, "secret" );
             try
             {
-                new InitialContext( env );
+                replica.shutdown();
             }
             catch( Exception e )
             {
+                LOG.error( "Encountered error while shutting down replica {}", replica.getInstanceId(), e );
+                throw e;
             }
 
             try

Modified: directory/apacheds/branches/bigbang/mitosis/src/test/java/org/apache/directory/mitosis/store/derby/DerbyReplicationStoreTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/mitosis/src/test/java/org/apache/directory/mitosis/store/derby/DerbyReplicationStoreTest.java?rev=582462&r1=582461&r2=582462&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/mitosis/src/test/java/org/apache/directory/mitosis/store/derby/DerbyReplicationStoreTest.java (original)
+++ directory/apacheds/branches/bigbang/mitosis/src/test/java/org/apache/directory/mitosis/store/derby/DerbyReplicationStoreTest.java Fri Oct  5 23:48:35 2007
@@ -18,60 +18,32 @@
  *  
  */
 package org.apache.directory.mitosis.store.derby;
- 
 
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-
-import javax.naming.Name;
-import javax.naming.ldap.LdapName;
 
 import junit.framework.Assert;
 import junit.framework.TestCase;
-
 import org.apache.commons.io.FileUtils;
-import org.apache.directory.server.core.DirectoryService;
-import org.apache.directory.server.core.DirectoryServiceConfiguration;
-import org.apache.directory.server.core.DirectoryServiceListener;
-import org.apache.directory.server.core.configuration.MutableStartupConfiguration;
-import org.apache.directory.server.core.configuration.StartupConfiguration;
-import org.apache.directory.server.core.interceptor.InterceptorChain;
-import org.apache.directory.server.core.partition.PartitionNexus;
-import org.apache.directory.server.core.schema.SchemaManager;
-import org.apache.directory.server.schema.registries.Registries;
-import org.apache.directory.shared.ldap.message.AttributeImpl;
-import org.apache.directory.shared.ldap.message.AttributesImpl;
-import org.apache.directory.shared.ldap.name.LdapDN;
-import org.apache.directory.mitosis.common.CSN;
-import org.apache.directory.mitosis.common.CSNFactory;
-import org.apache.directory.mitosis.common.CSNVector;
-import org.apache.directory.mitosis.common.ReplicaId;
-import org.apache.directory.mitosis.common.DefaultCSN;
-import org.apache.directory.mitosis.common.DefaultCSNFactory;
-import org.apache.directory.mitosis.common.DefaultUUIDFactory;
+import org.apache.directory.mitosis.common.*;
 import org.apache.directory.mitosis.common.UUID;
-import org.apache.directory.mitosis.common.UUIDFactory;
 import org.apache.directory.mitosis.configuration.ReplicationConfiguration;
-import org.apache.directory.mitosis.operation.AddAttributeOperation;
-import org.apache.directory.mitosis.operation.AddEntryOperation;
-import org.apache.directory.mitosis.operation.CompositeOperation;
-import org.apache.directory.mitosis.operation.DeleteAttributeOperation;
-import org.apache.directory.mitosis.operation.Operation;
-import org.apache.directory.mitosis.operation.ReplaceAttributeOperation;
+import org.apache.directory.mitosis.operation.*;
 import org.apache.directory.mitosis.store.ReplicationLogIterator;
 import org.apache.directory.mitosis.store.ReplicationStoreException;
-import org.apache.directory.mitosis.store.derby.DerbyReplicationStore;
+import org.apache.directory.server.core.DefaultDirectoryService;
+import org.apache.directory.shared.ldap.message.AttributeImpl;
+import org.apache.directory.shared.ldap.message.AttributesImpl;
+import org.apache.directory.shared.ldap.name.LdapDN;
+
+import javax.naming.Name;
+import javax.naming.ldap.LdapName;
+import java.io.File;
+import java.io.IOException;
+import java.util.*;
 
 
 public class DerbyReplicationStoreTest extends TestCase
 {
-    private static final ReplicaId REPLICA_ID = new ReplicaId( "TEST_REPLICA" );
+    private static final ReplicaId TEST_REPLICA_ID = new ReplicaId( "TEST_REPLICA" );
     private static final ReplicaId OTHER_REPLICA_ID = new ReplicaId( "OTHER_REPLICA" );
     private static final ReplicaId OTHER_REPLICA_ID_2 = new ReplicaId( "OTHER_REPLICA_2" );
     private static final File DB_PATH = new File( "target/testDB" );
@@ -86,7 +58,7 @@
     public void setUp() throws Exception
     {
         dropDatabase();
-        startupDatabase( REPLICA_ID );
+        startupDatabase( TEST_REPLICA_ID );
         initStopWatch();
     }
 
@@ -100,7 +72,7 @@
         // Open store
         store = new DerbyReplicationStore();
         store.setTablePrefix( "TEST_" );
-        store.open( new DirectoryServiceConfigurationImpl(), cfg );
+        store.open( new DefaultDirectoryService(), cfg );
     }
 
 
@@ -113,6 +85,7 @@
 
     private void dropDatabase() throws IOException
     {
+        FileUtils.deleteDirectory( new File( new DefaultDirectoryService().getWorkingDirectory().getPath(), "replication" ) );
         FileUtils.deleteDirectory( DB_PATH );
         File logFile = new File( "derby.log" );
         if ( !logFile.delete() )
@@ -149,8 +122,9 @@
         }
         catch ( ReplicationStoreException e )
         {
+            assertNotNull( e );
         }
-        startupDatabase( REPLICA_ID );
+        startupDatabase( TEST_REPLICA_ID );
     }
 
 
@@ -170,10 +144,10 @@
     {
         ReplicationLogIterator it;
 
-        it = store.getLogs( csnFactory.newInstance( REPLICA_ID ), true );
+        it = store.getLogs( csnFactory.newInstance( TEST_REPLICA_ID ), true );
         Assert.assertFalse( it.next() );
         it.close();
-        it = store.getLogs( csnFactory.newInstance( REPLICA_ID ), false );
+        it = store.getLogs( csnFactory.newInstance( TEST_REPLICA_ID ), false );
         Assert.assertFalse( it.next() );
         it.close();
         it = store.getLogs( csnFactory.newInstance( OTHER_REPLICA_ID ), true );
@@ -189,7 +163,7 @@
 
     private void subTestWriteLog() throws Exception
     {
-        CSN csn = csnFactory.newInstance( REPLICA_ID );
+        CSN csn = csnFactory.newInstance( TEST_REPLICA_ID );
         CompositeOperation op1 = new CompositeOperation( csn );
         op1.add( new AddEntryOperation( csn, new LdapDN( "ou=a" ), new AttributesImpl( true ) ) );
         op1.add( new AddAttributeOperation( csn, new LdapDN( "ou=a" ), new AttributeImpl( "id", "valie" ) ) );
@@ -210,7 +184,7 @@
         testGetLogs( csn, op2 );
 
         Assert.assertEquals( 2, store.getLogSize() );
-        Assert.assertEquals( 1, store.getLogSize( REPLICA_ID ) );
+        Assert.assertEquals( 1, store.getLogSize( TEST_REPLICA_ID ) );
         Assert.assertEquals( 1, store.getLogSize( OTHER_REPLICA_ID ) );
 
         // Test getLogs(CSNVector, true)
@@ -259,14 +233,14 @@
         CSN csn;
         ReplicationLogIterator it;
 
-        it = store.getLogs( new DefaultCSN( 0, REPLICA_ID, 0 ), false );
+        it = store.getLogs( new DefaultCSN( 0, TEST_REPLICA_ID, 0 ), false );
         it.next();
         csn = it.getOperation().getCSN();
         it.close();
 
         Assert.assertEquals( 0, store.removeLogs( csn, false ) );
         Assert.assertEquals( 1, store.removeLogs( csn, true ) );
-        Assert.assertEquals( 0, store.getLogSize( REPLICA_ID ) );
+        Assert.assertEquals( 0, store.getLogSize( TEST_REPLICA_ID ) );
 
         it = store.getLogs( new DefaultCSN( 0, OTHER_REPLICA_ID, 0 ), false );
         Assert.assertTrue( it.next() );
@@ -283,8 +257,8 @@
 
     private void subTestVectors() throws Exception
     {
-        CSN csnA = new DefaultCSN( 0, REPLICA_ID, 0 );
-        CSN csnB = new DefaultCSN( 1, REPLICA_ID, 0 );
+        CSN csnA = new DefaultCSN( 0, TEST_REPLICA_ID, 0 );
+        CSN csnB = new DefaultCSN( 1, TEST_REPLICA_ID, 0 );
         CSN csnC = new DefaultCSN( 0, OTHER_REPLICA_ID_2, 0 );
         CSN csnD = new DefaultCSN( 0, OTHER_REPLICA_ID_2, 1 );
         store.putLog( new Operation( csnA ) );
@@ -293,7 +267,7 @@
         store.putLog( new Operation( csnD ) );
 
         Set<ReplicaId> expectedKnownReplicaIds = new HashSet<ReplicaId>();
-        expectedKnownReplicaIds.add( REPLICA_ID );
+        expectedKnownReplicaIds.add( TEST_REPLICA_ID );
         expectedKnownReplicaIds.add( OTHER_REPLICA_ID );
         expectedKnownReplicaIds.add( OTHER_REPLICA_ID_2 );
 
@@ -378,69 +352,5 @@
     private static void assertEquals( Operation expected, Operation actual )
     {
         Assert.assertEquals( expected.toString(), actual.toString() );
-    }
-
-    private static class DirectoryServiceConfigurationImpl implements DirectoryServiceConfiguration
-    {
-        public DirectoryService getService()
-        {
-            return null;
-        }
-
-
-        public String getInstanceId()
-        {
-            return null;
-        }
-
-
-        public Hashtable getEnvironment()
-        {
-            return null;
-        }
-
-
-        public StartupConfiguration getStartupConfiguration()
-        {
-            MutableStartupConfiguration cfg = new MutableStartupConfiguration();
-            cfg.setWorkingDirectory( DB_PATH );
-            return cfg;
-        }
-
-
-        public Registries getRegistries()
-        {
-            return null;
-        }
-
-
-        public PartitionNexus getPartitionNexus()
-        {
-            return null;
-        }
-
-
-        public InterceptorChain getInterceptorChain()
-        {
-            return null;
-        }
-
-
-        public boolean isFirstStart()
-        {
-            return false;
-        }
-
-
-        public DirectoryServiceListener getServiceListener()
-        {
-            return null;
-        }
-
-
-        public SchemaManager getSchemaManager()
-        {
-            return null;
-        }
     }
 }

Modified: directory/apacheds/branches/bigbang/pom.xml
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/pom.xml?rev=582462&r1=582461&r2=582462&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/pom.xml (original)
+++ directory/apacheds/branches/bigbang/pom.xml Fri Oct  5 23:48:35 2007
@@ -345,6 +345,7 @@
     <module>server-jndi</module>
     <module>kerberos-shared</module>
     <!--module>kerberos-unit</module-->
+    <module>interceptor-kerberos</module>
     <module>mitosis</module>
     <module>server-replication</module>
     <module>apacheds-xbean-spring</module>

Modified: directory/apacheds/branches/bigbang/protocol-dns/pom.xml
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/protocol-dns/pom.xml?rev=582462&r1=582461&r2=582462&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/protocol-dns/pom.xml (original)
+++ directory/apacheds/branches/bigbang/protocol-dns/pom.xml Fri Oct  5 23:48:35 2007
@@ -39,6 +39,13 @@
       <artifactId>mina-core</artifactId>
     </dependency>
 
+
+    <dependency>
+      <groupId>org.apache.directory.server</groupId>
+      <artifactId>apacheds-core</artifactId>
+      <version>${pom.version}</version>
+    </dependency>
+
     <dependency>
       <groupId>org.apache.directory.server</groupId>
       <artifactId>apacheds-protocol-shared</artifactId>

Modified: directory/apacheds/branches/bigbang/protocol-dns/src/main/java/org/apache/directory/server/dns/store/jndi/JndiRecordStoreImpl.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/protocol-dns/src/main/java/org/apache/directory/server/dns/store/jndi/JndiRecordStoreImpl.java?rev=582462&r1=582461&r2=582462&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/protocol-dns/src/main/java/org/apache/directory/server/dns/store/jndi/JndiRecordStoreImpl.java (original)
+++ directory/apacheds/branches/bigbang/protocol-dns/src/main/java/org/apache/directory/server/dns/store/jndi/JndiRecordStoreImpl.java Fri Oct  5 23:48:35 2007
@@ -20,16 +20,15 @@
 package org.apache.directory.server.dns.store.jndi;
 
 
-import java.util.Set;
-
-import javax.naming.spi.InitialContextFactory;
-
+import org.apache.directory.server.core.DirectoryService;
 import org.apache.directory.server.dns.DnsConfiguration;
 import org.apache.directory.server.dns.DnsException;
 import org.apache.directory.server.dns.messages.QuestionRecord;
 import org.apache.directory.server.dns.messages.ResourceRecord;
 import org.apache.directory.server.dns.store.RecordStore;
 
+import java.util.Set;
+
 
 /**
  * A JNDI-backed implementation of the RecordStore interface.  This RecordStore uses
@@ -44,7 +43,7 @@
     /** a handle on the configuration */
     private DnsConfiguration config;
     /** a handle on the provider factory */
-    private InitialContextFactory factory;
+    private DirectoryService directoryService;
     /** a handle on the searchh strategy */
     private SearchStrategy strategy;
 
@@ -53,12 +52,12 @@
      * Creates a new instance of JndiRecordStoreImpl.
      *
      * @param config
-     * @param factory
+     * @param directoryService
      */
-    public JndiRecordStoreImpl( DnsConfiguration config, InitialContextFactory factory )
+    public JndiRecordStoreImpl( DnsConfiguration config, DirectoryService directoryService )
     {
         this.config = config;
-        this.factory = factory;
+        this.directoryService = directoryService;
 
         strategy = getSearchStrategy();
     }
@@ -75,10 +74,10 @@
         if ( config.getCatalogBaseDn() != null )
         {
             // build catalog from factory
-            return new MultiBaseSearch( config, factory );
+            return new MultiBaseSearch( config, directoryService );
         }
 
         // use config for catalog baseDN
-        return new SingleBaseSearch( config, factory );
+        return new SingleBaseSearch( config, directoryService );
     }
 }

Modified: directory/apacheds/branches/bigbang/protocol-dns/src/main/java/org/apache/directory/server/dns/store/jndi/MultiBaseSearch.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/protocol-dns/src/main/java/org/apache/directory/server/dns/store/jndi/MultiBaseSearch.java?rev=582462&r1=582461&r2=582462&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/protocol-dns/src/main/java/org/apache/directory/server/dns/store/jndi/MultiBaseSearch.java (original)
+++ directory/apacheds/branches/bigbang/protocol-dns/src/main/java/org/apache/directory/server/dns/store/jndi/MultiBaseSearch.java Fri Oct  5 23:48:35 2007
@@ -21,15 +21,7 @@
 package org.apache.directory.server.dns.store.jndi;
 
 
-import java.util.Hashtable;
-import java.util.Map;
-import java.util.Set;
-
-import javax.naming.Context;
-import javax.naming.NamingException;
-import javax.naming.directory.DirContext;
-import javax.naming.spi.InitialContextFactory;
-
+import org.apache.directory.server.core.DirectoryService;
 import org.apache.directory.server.dns.DnsConfiguration;
 import org.apache.directory.server.dns.DnsException;
 import org.apache.directory.server.dns.messages.QuestionRecord;
@@ -44,6 +36,14 @@
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import javax.naming.Context;
+import javax.naming.NamingException;
+import javax.naming.directory.DirContext;
+import javax.naming.directory.InitialDirContext;
+import java.util.Hashtable;
+import java.util.Map;
+import java.util.Set;
+
 
 /**
  * A JNDI-backed search strategy implementation.  This search strategy builds a catalog
@@ -55,31 +55,29 @@
  */
 public class MultiBaseSearch implements SearchStrategy
 {
-    /** the log for this class */
-    private static final Logger log = LoggerFactory.getLogger( MultiBaseSearch.class );
+    /** the LOG for this class */
+    private static final Logger LOG = LoggerFactory.getLogger( MultiBaseSearch.class );
 
-    private InitialContextFactory factory;
     private Hashtable<String, Object> env = new Hashtable<String, Object>();
-
     private Catalog catalog;
 
 
-    MultiBaseSearch( DnsConfiguration config, InitialContextFactory factory )
+    MultiBaseSearch( DnsConfiguration config, DirectoryService directoryService )
     {
-        this.factory = factory;
-
         env.put( Context.INITIAL_CONTEXT_FACTORY, config.getInitialContextFactory() );
         env.put( Context.PROVIDER_URL, config.getCatalogBaseDn() );
+        env.put( DirectoryService.JNDI_KEY, directoryService );
 
         try
         {
-            DirContext ctx = ( DirContext ) factory.getInitialContext( env );
+            DirContext ctx = new InitialDirContext( env );
+            //noinspection unchecked
             catalog = new DnsCatalog( ( Map<String, Object> ) execute( ctx, new GetCatalog() ) );
         }
         catch ( Exception e )
         {
-            log.error( e.getMessage(), e );
-            String message = "Failed to get catalog context " + ( String ) env.get( Context.PROVIDER_URL );
+            LOG.error( e.getMessage(), e );
+            String message = "Failed to get catalog context " + env.get( Context.PROVIDER_URL );
             throw new ServiceConfigurationException( message, e );
         }
     }
@@ -87,28 +85,30 @@
 
     public Set<ResourceRecord> getRecords( QuestionRecord question ) throws DnsException
     {
-        env.put( Context.PROVIDER_URL, catalog.getBaseDn( question.getDomainName() ) );
+        Hashtable<String, Object> cloned = new Hashtable<String, Object>();
+        cloned.putAll( env );
+        cloned.put( Context.PROVIDER_URL, catalog.getBaseDn( question.getDomainName() ) );
 
         try
         {
-            DirContext ctx = ( DirContext ) factory.getInitialContext( env );
+            DirContext ctx = new InitialDirContext( cloned );
             return execute( ctx, new GetRecords( question ) );
         }
         catch ( LdapNameNotFoundException lnnfe )
         {
-            log.debug( "Name for DNS record search does not exist.", lnnfe );
+            LOG.debug( "Name for DNS record search does not exist.", lnnfe );
 
             throw new DnsException( ResponseCode.NAME_ERROR );
         }
         catch ( NamingException ne )
         {
-            log.error( ne.getMessage(), ne );
-            String message = "Failed to get initial context " + ( String ) env.get( Context.PROVIDER_URL );
+            LOG.error( ne.getMessage(), ne );
+            String message = "Failed to get initial context " + env.get( Context.PROVIDER_URL );
             throw new ServiceConfigurationException( message, ne );
         }
         catch ( Exception e )
         {
-            log.debug( "Unexpected error retrieving DNS records.", e );
+            LOG.debug( "Unexpected error retrieving DNS records.", e );
             throw new DnsException( ResponseCode.SERVER_FAILURE );
         }
 

Modified: directory/apacheds/branches/bigbang/protocol-dns/src/main/java/org/apache/directory/server/dns/store/jndi/SingleBaseSearch.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/protocol-dns/src/main/java/org/apache/directory/server/dns/store/jndi/SingleBaseSearch.java?rev=582462&r1=582461&r2=582462&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/protocol-dns/src/main/java/org/apache/directory/server/dns/store/jndi/SingleBaseSearch.java (original)
+++ directory/apacheds/branches/bigbang/protocol-dns/src/main/java/org/apache/directory/server/dns/store/jndi/SingleBaseSearch.java Fri Oct  5 23:48:35 2007
@@ -21,14 +21,7 @@
 package org.apache.directory.server.dns.store.jndi;
 
 
-import java.util.Hashtable;
-import java.util.Set;
-
-import javax.naming.Context;
-import javax.naming.NamingException;
-import javax.naming.directory.DirContext;
-import javax.naming.spi.InitialContextFactory;
-
+import org.apache.directory.server.core.DirectoryService;
 import org.apache.directory.server.dns.DnsConfiguration;
 import org.apache.directory.server.dns.DnsException;
 import org.apache.directory.server.dns.messages.QuestionRecord;
@@ -40,6 +33,13 @@
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import javax.naming.Context;
+import javax.naming.NamingException;
+import javax.naming.directory.DirContext;
+import javax.naming.directory.InitialDirContext;
+import java.util.Hashtable;
+import java.util.Set;
+
 
 /**
  * A JNDI-backed search strategy implementation.  This search strategy searches a
@@ -50,23 +50,21 @@
  */
 public class SingleBaseSearch implements SearchStrategy
 {
-    /** the log for this class */
-    private static final Logger log = LoggerFactory.getLogger( SingleBaseSearch.class );
+    /** the LOG for this class */
+    private static final Logger LOG = LoggerFactory.getLogger( SingleBaseSearch.class );
 
     private DirContext ctx;
     private Hashtable<String, Object> env = new Hashtable<String, Object>();
-    private InitialContextFactory factory;
 
 
-    SingleBaseSearch( DnsConfiguration config, InitialContextFactory factory )
+    SingleBaseSearch( DnsConfiguration config, DirectoryService directoryService )
     {
         env.put( Context.INITIAL_CONTEXT_FACTORY, config.getInitialContextFactory() );
         env.put( Context.PROVIDER_URL, config.getSearchBaseDn() );
         env.put( Context.SECURITY_AUTHENTICATION, config.getSecurityAuthentication() );
         env.put( Context.SECURITY_CREDENTIALS, config.getSecurityCredentials() );
         env.put( Context.SECURITY_PRINCIPAL, config.getSecurityPrincipal() );
-
-        this.factory = factory;
+        env.put( DirectoryService.JNDI_KEY, directoryService );
     }
 
 
@@ -84,18 +82,18 @@
 	        {
 	            try
 	            {
-	                ctx = ( DirContext ) factory.getInitialContext( env );
+	                ctx = new InitialDirContext( env );
 	            }
 		        catch ( LdapNameNotFoundException lnnfe )
 			    {
-			        log.debug( "Name for DNS record search does not exist.", lnnfe );
+			        LOG.debug( "Name for DNS record search does not exist.", lnnfe );
 			
 			        throw new DnsException( ResponseCode.NAME_ERROR );
 			    }
 	            catch ( NamingException ne )
 	            {
-	                log.error( ne.getMessage(), ne );
-	                String message = "Failed to get initial context " + ( String ) env.get( Context.PROVIDER_URL );
+	                LOG.error( ne.getMessage(), ne );
+	                String message = "Failed to get initial context " + env.get( Context.PROVIDER_URL );
 	                throw new ServiceConfigurationException( message, ne );
 	            }
 	        }
@@ -104,7 +102,7 @@
         }
 	    catch ( Exception e )
 	    {
-	        log.debug( "Unexpected error retrieving DNS records.", e );
+	        LOG.debug( "Unexpected error retrieving DNS records.", e );
 	        throw new DnsException( ResponseCode.SERVER_FAILURE );
 	    }
     }

Modified: directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapConfiguration.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapConfiguration.java?rev=582462&r1=582461&r2=582462&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapConfiguration.java (original)
+++ directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapConfiguration.java Fri Oct  5 23:48:35 2007
@@ -63,7 +63,7 @@
     private int maxTimeLimit = MAX_TIME_LIMIT_DEFAULT; // set to default value (milliseconds)
 
     /** Whether LDAPS is enabled. */
-    private boolean enableLdaps = false;
+    private boolean enableLdaps;
 
     /** The path to the certificate file. */
     private File ldapsCertificateFile = new File( "server-work" + File.separator + "certificates" + File.separator

Modified: directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapProtocolProvider.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapProtocolProvider.java?rev=582462&r1=582461&r2=582462&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapProtocolProvider.java (original)
+++ directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapProtocolProvider.java Fri Oct  5 23:48:35 2007
@@ -20,62 +20,12 @@
 package org.apache.directory.server.ldap;
 
 
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-
-import javax.naming.Context;
-
-import org.apache.directory.server.ldap.support.AbandonHandler;
-import org.apache.directory.server.ldap.support.AddHandler;
-import org.apache.directory.server.ldap.support.BindHandler;
-import org.apache.directory.server.ldap.support.CompareHandler;
-import org.apache.directory.server.ldap.support.DeleteHandler;
-import org.apache.directory.server.ldap.support.ExtendedHandler;
-import org.apache.directory.server.ldap.support.ModifyDnHandler;
-import org.apache.directory.server.ldap.support.ModifyHandler;
-import org.apache.directory.server.ldap.support.SearchHandler;
-import org.apache.directory.server.ldap.support.UnbindHandler;
+import org.apache.directory.server.core.DirectoryService;
+import org.apache.directory.server.ldap.support.*;
 import org.apache.directory.shared.asn1.codec.Asn1CodecDecoder;
 import org.apache.directory.shared.asn1.codec.Asn1CodecEncoder;
 import org.apache.directory.shared.ldap.exception.LdapNamingException;
-import org.apache.directory.shared.ldap.message.AbandonRequest;
-import org.apache.directory.shared.ldap.message.AbandonRequestImpl;
-import org.apache.directory.shared.ldap.message.AddRequest;
-import org.apache.directory.shared.ldap.message.AddRequestImpl;
-import org.apache.directory.shared.ldap.message.BindRequest;
-import org.apache.directory.shared.ldap.message.BindRequestImpl;
-import org.apache.directory.shared.ldap.message.CascadeControl;
-import org.apache.directory.shared.ldap.message.CompareRequest;
-import org.apache.directory.shared.ldap.message.CompareRequestImpl;
-import org.apache.directory.shared.ldap.message.MutableControl;
-import org.apache.directory.shared.ldap.message.DeleteRequest;
-import org.apache.directory.shared.ldap.message.DeleteRequestImpl;
-import org.apache.directory.shared.ldap.message.EntryChangeControl;
-import org.apache.directory.shared.ldap.message.ExtendedRequest;
-import org.apache.directory.shared.ldap.message.ExtendedRequestImpl;
-import org.apache.directory.shared.ldap.message.ManageDsaITControl;
-import org.apache.directory.shared.ldap.message.MessageDecoder;
-import org.apache.directory.shared.ldap.message.MessageEncoder;
-import org.apache.directory.shared.ldap.message.ModifyDnRequest;
-import org.apache.directory.shared.ldap.message.ModifyDnRequestImpl;
-import org.apache.directory.shared.ldap.message.ModifyRequest;
-import org.apache.directory.shared.ldap.message.ModifyRequestImpl;
-import org.apache.directory.shared.ldap.message.PersistentSearchControl;
-import org.apache.directory.shared.ldap.message.Request;
-import org.apache.directory.shared.ldap.message.ResponseCarryingMessageException;
-import org.apache.directory.shared.ldap.message.ResultCodeEnum;
-import org.apache.directory.shared.ldap.message.ResultResponse;
-import org.apache.directory.shared.ldap.message.ResultResponseRequest;
-import org.apache.directory.shared.ldap.message.SearchRequest;
-import org.apache.directory.shared.ldap.message.SearchRequestImpl;
-import org.apache.directory.shared.ldap.message.SubentriesControl;
-import org.apache.directory.shared.ldap.message.UnbindRequest;
-import org.apache.directory.shared.ldap.message.UnbindRequestImpl;
+import org.apache.directory.shared.ldap.message.*;
 import org.apache.directory.shared.ldap.message.extended.NoticeOfDisconnect;
 import org.apache.mina.common.IoFilterChain;
 import org.apache.mina.common.IoHandler;
@@ -89,6 +39,9 @@
 import org.apache.mina.handler.demux.MessageHandler;
 import org.apache.mina.util.SessionLog;
 
+import javax.naming.Context;
+import java.util.*;
+
 
 /**
  * An LDAP protocol provider implementation which dynamically associates
@@ -106,15 +59,16 @@
     /** the constant service name of this ldap protocol provider **/
     public static final String SERVICE_NAME = "ldap";
     /** a map of the default request object class name to the handler class name */
-    private static final Map DEFAULT_HANDLERS;
+    private static final Map<String,Class> DEFAULT_HANDLERS;
     /** a set of supported controls */
     private static final Set SUPPORTED_CONTROLS;
     /** configuration for the LDAP protocol provider **/
     private LdapConfiguration cfg;
+    private DirectoryService directoryService;
 
     static
     {
-        Map<Object, Object> map = new HashMap<Object, Object>();
+        Map<String, Class> map = new HashMap<String, Class>();
 
         /*
          * Note:
@@ -184,20 +138,23 @@
      * @param env environment properties used to configure the provider and
      * underlying codec providers if any
      */
-    public LdapProtocolProvider( LdapConfiguration cfg, Hashtable env) throws LdapNamingException
+    public LdapProtocolProvider( DirectoryService directoryService, LdapConfiguration cfg, Hashtable env )
+            throws LdapNamingException
     {
         this.cfg = cfg;
+        this.directoryService = directoryService;
 
         Hashtable copy = ( Hashtable ) env.clone();
         copy.put( Context.PROVIDER_URL, "" );
+        copy.put( Context.INITIAL_CONTEXT_FACTORY, "org.apache.directory.server.core.jndi.CoreContextFactory" );
+        copy.put( DirectoryService.JNDI_KEY, directoryService );
+
         SessionRegistry.releaseSingleton();
         new SessionRegistry( cfg, copy );
 
-        Iterator requestTypes = DEFAULT_HANDLERS.keySet().iterator();
-        while ( requestTypes.hasNext() )
+        for ( String type : DEFAULT_HANDLERS.keySet() )
         {
-            MessageHandler handler = null;
-            String type = ( String ) requestTypes.next();
+            MessageHandler handler;
             Class clazz = null;
 
             if ( copy.containsKey( type ) )
@@ -225,6 +182,12 @@
             {
                 Class typeClass = Class.forName( type );
                 handler = ( MessageHandler ) clazz.newInstance();
+
+                if ( handler instanceof BindHandler )
+                {
+                    ( ( BindHandler ) handler ).setDirectoryService( directoryService );
+                }
+
                 this.handler.addMessageHandler( typeClass, handler );
             }
             catch ( Exception e )

Modified: directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/gui/SessionsFrame.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/gui/SessionsFrame.java?rev=582462&r1=582461&r2=582462&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/gui/SessionsFrame.java (original)
+++ directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/gui/SessionsFrame.java Fri Oct  5 23:48:35 2007
@@ -756,23 +756,6 @@
                         "Send graceful disconnect before disconnect notice?", JOptionPane.YES_NO_CANCEL_OPTION );
                     IoAcceptor acceptor = ( IoAcceptor ) requestor.getService();
                     List sessions = new ArrayList( acceptor.getManagedSessions( requestor.getServiceAddress() ) );
-                    //                    ServerLdapContext ctx;
-                    //                    try
-                    //                    {
-                    //                        ctx = ( ServerLdapContext ) SessionRegistry.getSingleton()
-                    //                            .getLdapContext( requestor, null, false );
-                    //                    }
-                    //                    catch ( NamingException ne )
-                    //                    {
-                    //                        JOptionPane.showInternalMessageDialog( SessionsFrame.this, 
-                    //                            ne.getMessage(), "Encountered an Error", JOptionPane.ERROR_MESSAGE );
-                    //                        log.warn( "Could not access requestor's context.", ne );
-                    //                        return;
-                    //                    }
-                    //                    DirectoryService service = ctx.getService();
-                    //                    StartupConfiguration cfg = service.getConfiguration().getStartupConfiguration();
-                    // might add an exit vm feature using the default from the 
-                    // configuration property
 
                     if ( input == JOptionPane.CANCEL_OPTION )
                     {

Modified: directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/BindHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/BindHandler.java?rev=582462&r1=582461&r2=582462&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/BindHandler.java (original)
+++ directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/BindHandler.java Fri Oct  5 23:48:35 2007
@@ -20,26 +20,13 @@
 package org.apache.directory.server.ldap.support;
 
 
-import java.util.Hashtable;
-import java.util.Set;
-
-import javax.naming.Context;
-import javax.naming.NamingException;
-import javax.naming.ldap.InitialLdapContext;
-import javax.naming.ldap.LdapContext;
-import javax.naming.spi.InitialContextFactory;
-
+import org.apache.directory.server.core.DirectoryService;
 import org.apache.directory.server.core.jndi.ServerLdapContext;
 import org.apache.directory.server.ldap.LdapConfiguration;
 import org.apache.directory.server.ldap.SessionRegistry;
 import org.apache.directory.server.ldap.support.bind.BindHandlerChain;
 import org.apache.directory.shared.ldap.exception.LdapException;
-import org.apache.directory.shared.ldap.message.BindRequest;
-import org.apache.directory.shared.ldap.message.BindResponse;
-import org.apache.directory.shared.ldap.message.MutableControl;
-import org.apache.directory.shared.ldap.message.LdapResult;
-import org.apache.directory.shared.ldap.message.ManageDsaITControl;
-import org.apache.directory.shared.ldap.message.ResultCodeEnum;
+import org.apache.directory.shared.ldap.message.*;
 import org.apache.directory.shared.ldap.name.LdapDN;
 import org.apache.directory.shared.ldap.util.ExceptionUtils;
 import org.apache.mina.common.IoSession;
@@ -48,6 +35,14 @@
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import javax.naming.Context;
+import javax.naming.NamingException;
+import javax.naming.ldap.InitialLdapContext;
+import javax.naming.ldap.LdapContext;
+import javax.naming.spi.InitialContextFactory;
+import java.util.Hashtable;
+import java.util.Set;
+
 
 /**
  * A single reply handler for {@link org.apache.directory.shared.ldap.message.BindRequest}s.
@@ -59,7 +54,7 @@
  */
 public class BindHandler extends AbstractLdapHandler implements MessageHandler
 {
-    private static final Logger log = LoggerFactory.getLogger( BindHandler.class );
+    private static final Logger LOG = LoggerFactory.getLogger( BindHandler.class );
 
     /** A class to handle SASL bind requests */
     private IoHandlerCommand saslBindHandler;
@@ -78,9 +73,15 @@
      */                                                                      
     public BindHandler()
     {
-        saslBindHandler = new BindHandlerChain();
     }
-    
+
+
+    public void setDirectoryService( DirectoryService directoryService )
+    {
+        saslBindHandler = new BindHandlerChain( directoryService );
+    }
+
+
     /**
      * Create an environment object and inject the Bond informations collected
      * from the BindRequest message :
@@ -98,11 +99,11 @@
          */
         Object credentials = bindRequest.getCredentials();
 
-        if ( log.isDebugEnabled() )
+        if ( LOG.isDebugEnabled() )
         {
-            log.debug( "{} {}", Context.SECURITY_PRINCIPAL, principal );
-            log.debug( "{} {}", Context.SECURITY_CREDENTIALS, credentials );
-            log.debug( "{} {}", Context.SECURITY_AUTHENTICATION, authenticationLevel );
+            LOG.debug( "{} {}", Context.SECURITY_PRINCIPAL, principal );
+            LOG.debug( "{} {}", Context.SECURITY_CREDENTIALS, credentials );
+            LOG.debug( "{} {}", Context.SECURITY_AUTHENTICATION, authenticationLevel );
         }
 
         // clone the environment first then add the required security settings
@@ -149,7 +150,7 @@
 
                 if ( factory == null )
                 {
-                    log.error( "The property 'server.use.factory.instance'  was set in env but was null" );
+                    LOG.error( "The property 'server.use.factory.instance'  was set in env but was null" );
                     throw new NullPointerException( "server.use.factory.instance was set in env but was null" );
                 }
 
@@ -179,11 +180,11 @@
 
             String msg = "Bind failed: " + e.getMessage();
 
-            if ( log.isDebugEnabled() )
+            if ( LOG.isDebugEnabled() )
             {
                 msg += ":\n" + ExceptionUtils.getStackTrace( e );
                 msg += "\n\nBindRequest = \n" + bindRequest.toString();
-                log.debug(  msg  );
+                LOG.debug(  msg  );
             }
 
             if ( ( e.getResolvedName() != null )
@@ -218,7 +219,7 @@
         // Guard clause:  Reject SIMPLE mechanism.
         if ( !supportedMechanisms.contains( "SIMPLE" ) )
         {
-            log.error( "Bind error : SIMPLE authentication not supported. Please check the server.xml configuration file (supportedMechanisms field)" );
+            LOG.error( "Bind error : SIMPLE authentication not supported. Please check the server.xml configuration file (supportedMechanisms field)" );
 
             bindResult.setResultCode( ResultCodeEnum.STRONG_AUTH_REQUIRED );
             bindResult.setErrorMessage( "Simple binds are disabled." );
@@ -242,7 +243,7 @@
             BindResponse response = ( BindResponse ) bindRequest.getResultResponse();
             response.addAll( newCtx.getResponseControls() );
             session.write( response );
-            log.debug( "Returned SUCCESS message." );
+            LOG.debug( "Returned SUCCESS message." );
         }
     }
 
@@ -253,25 +254,25 @@
     {
         BindRequest bindRequest = ( BindRequest ) message;
 
-        if ( log.isDebugEnabled() )
+        if ( LOG.isDebugEnabled() )
         {
-        	log.debug( "User {} is binding", bindRequest.getName() );
+        	LOG.debug( "User {} is binding", bindRequest.getName() );
         	
             if ( bindRequest.isSimple() )
             {
-                log.debug( "Using simple authentication." );
+                LOG.debug( "Using simple authentication." );
                 
             }
             else
             {
-                log.debug( "Using SASL authentication with mechanism:  {}", bindRequest.getSaslMechanism() );
+                LOG.debug( "Using SASL authentication with mechanism:  {}", bindRequest.getSaslMechanism() );
             }
         }
         
         // Guard clause:  LDAP version 3
         if ( !bindRequest.getVersion3() )
         {
-            log.error( "Bind error : Only LDAP v3 is supported." );
+            LOG.error( "Bind error : Only LDAP v3 is supported." );
             LdapResult bindResult = bindRequest.getResultResponse().getLdapResult();
             bindResult.setResultCode( ResultCodeEnum.PROTOCOL_ERROR );
             bindResult.setErrorMessage( "Only LDAP v3 is supported." );

Modified: directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/bind/AbstractSaslCallbackHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/bind/AbstractSaslCallbackHandler.java?rev=582462&r1=582461&r2=582462&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/bind/AbstractSaslCallbackHandler.java (original)
+++ directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/bind/AbstractSaslCallbackHandler.java Fri Oct  5 23:48:35 2007
@@ -20,7 +20,17 @@
 package org.apache.directory.server.ldap.support.bind;
 
 
-import java.util.Hashtable;
+import org.apache.directory.server.core.DirectoryService;
+import org.apache.directory.shared.ldap.exception.LdapException;
+import org.apache.directory.shared.ldap.message.BindRequest;
+import org.apache.directory.shared.ldap.message.LdapResult;
+import org.apache.directory.shared.ldap.message.MutableControl;
+import org.apache.directory.shared.ldap.message.ResultCodeEnum;
+import org.apache.directory.shared.ldap.name.LdapDN;
+import org.apache.directory.shared.ldap.util.ExceptionUtils;
+import org.apache.mina.common.IoSession;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import javax.naming.Context;
 import javax.naming.NamingException;
@@ -33,17 +43,7 @@
 import javax.security.auth.callback.PasswordCallback;
 import javax.security.sasl.AuthorizeCallback;
 import javax.security.sasl.RealmCallback;
-
-import org.apache.directory.shared.ldap.exception.LdapException;
-import org.apache.directory.shared.ldap.message.BindRequest;
-import org.apache.directory.shared.ldap.message.MutableControl;
-import org.apache.directory.shared.ldap.message.LdapResult;
-import org.apache.directory.shared.ldap.message.ResultCodeEnum;
-import org.apache.directory.shared.ldap.name.LdapDN;
-import org.apache.directory.shared.ldap.util.ExceptionUtils;
-import org.apache.mina.common.IoSession;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import java.util.Hashtable;
 
 
 /**
@@ -64,6 +64,13 @@
     private String realm;
 
 
+    protected AbstractSaslCallbackHandler( DirectoryService directoryService )
+    {
+        this.directoryService = directoryService;
+    }
+
+
+
     /**
      * Implementors use this method to access the username resulting from a callback.
      * Callback default name will be username, eg 'hnelson', for CRAM-MD5 and DIGEST-MD5.
@@ -85,6 +92,7 @@
         return realm;
     }
 
+    protected final DirectoryService directoryService;
 
     /**
      * Implementors set the password based on a lookup, using the username and
@@ -212,6 +220,7 @@
             else
             {
                 MutableControl[] connCtls = request.getControls().values().toArray( EMPTY );
+                env.put( DirectoryService.JNDI_KEY, directoryService );
                 ctx = new InitialLdapContext( env, connCtls );
             }
         }

Modified: directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/bind/BindHandlerChain.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/bind/BindHandlerChain.java?rev=582462&r1=582461&r2=582462&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/bind/BindHandlerChain.java (original)
+++ directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/bind/BindHandlerChain.java Fri Oct  5 23:48:35 2007
@@ -20,6 +20,7 @@
 package org.apache.directory.server.ldap.support.bind;
 
 
+import org.apache.directory.server.core.DirectoryService;
 import org.apache.mina.handler.chain.IoHandlerChain;
 
 
@@ -32,11 +33,11 @@
     /**
      * Creates a new instance of BindHandlerChain.
      */
-    public BindHandlerChain()
+    public BindHandlerChain( DirectoryService directoryService )
     {
         addLast( "configureChain", new ConfigureChain() );
         addLast( "chainGuard", new ChainGuard() );
-        addLast( "handleSasl", new HandleSasl() );
+        addLast( "handleSasl", new HandleSasl( directoryService ) );
         addLast( "handleSimple", new HandleSimple() );
         addLast( "getLdapContext", new GetLdapContext() );
         addLast( "returnSuccess", new ReturnSuccess() );

Modified: directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/bind/CramMd5CallbackHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/bind/CramMd5CallbackHandler.java?rev=582462&r1=582461&r2=582462&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/bind/CramMd5CallbackHandler.java (original)
+++ directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/bind/CramMd5CallbackHandler.java Fri Oct  5 23:48:35 2007
@@ -20,15 +20,15 @@
 package org.apache.directory.server.ldap.support.bind;
 
 
-import java.util.Hashtable;
+import org.apache.directory.server.core.DirectoryService;
+import org.apache.mina.common.IoSession;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import javax.naming.Context;
 import javax.naming.ldap.LdapContext;
 import javax.security.sasl.AuthorizeCallback;
-
-import org.apache.mina.common.IoSession;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import java.util.Hashtable;
 
 
 /**
@@ -37,7 +37,7 @@
  */
 public class CramMd5CallbackHandler extends AbstractSaslCallbackHandler
 {
-    private static final Logger log = LoggerFactory.getLogger( CramMd5CallbackHandler.class );
+    private static final Logger LOG = LoggerFactory.getLogger( CramMd5CallbackHandler.class );
 
     private IoSession session;
     private Object message;
@@ -49,11 +49,13 @@
     /**
      * Creates a new instance of CramMd5CallbackHandler.
      *
-     * @param session
-     * @param message
+     * @param session the mina IoSession
+     * @param message the bind message
+     * @param directoryService the directory service core
      */
-    public CramMd5CallbackHandler( IoSession session, Object message )
+    public CramMd5CallbackHandler( DirectoryService directoryService,  IoSession session, Object message )
     {
+        super( directoryService );
         this.session = session;
         this.message = message;
     }
@@ -78,9 +80,9 @@
 
     protected void authorize( AuthorizeCallback authorizeCB )
     {
-        if ( log.isDebugEnabled() )
+        if ( LOG.isDebugEnabled() )
         {
-            log.debug( "Converted username " + getUsername() + " to DN " + bindDn + " with password " + userPassword );
+            LOG.debug( "Converted username " + getUsername() + " to DN " + bindDn + " with password " + userPassword );
         }
 
         session.setAttribute( Context.SECURITY_PRINCIPAL, bindDn );

Modified: directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/bind/CramMd5MechanismHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/bind/CramMd5MechanismHandler.java?rev=582462&r1=582461&r2=582462&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/bind/CramMd5MechanismHandler.java (original)
+++ directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/bind/CramMd5MechanismHandler.java Fri Oct  5 23:48:35 2007
@@ -20,14 +20,14 @@
 package org.apache.directory.server.ldap.support.bind;
 
 
-import java.util.HashMap;
-import java.util.Map;
+import org.apache.directory.server.core.DirectoryService;
+import org.apache.mina.common.IoSession;
 
 import javax.security.auth.callback.CallbackHandler;
 import javax.security.sasl.Sasl;
 import javax.security.sasl.SaslServer;
-
-import org.apache.mina.common.IoSession;
+import java.util.HashMap;
+import java.util.Map;
 
 
 /**
@@ -36,6 +36,15 @@
  */
 public class CramMd5MechanismHandler implements MechanismHandler
 {
+    private final DirectoryService directoryService;
+
+
+    public CramMd5MechanismHandler( DirectoryService directoryService )
+    {
+        this.directoryService = directoryService;
+    }
+
+
     public SaslServer handleMechanism( IoSession session, Object message ) throws Exception
     {
         SaslServer ss;
@@ -54,7 +63,7 @@
              */
             Map<String, String> saslProps = new HashMap<String, String>();
 
-            CallbackHandler callbackHandler = new CramMd5CallbackHandler( session, message );
+            CallbackHandler callbackHandler = new CramMd5CallbackHandler( directoryService, session, message );
 
             ss = Sasl.createSaslServer( "CRAM-MD5", "ldap", saslHost, saslProps, callbackHandler );
             session.setAttribute( SASL_CONTEXT, ss );

Modified: directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/bind/DigestMd5CallbackHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/bind/DigestMd5CallbackHandler.java?rev=582462&r1=582461&r2=582462&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/bind/DigestMd5CallbackHandler.java (original)
+++ directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/bind/DigestMd5CallbackHandler.java Fri Oct  5 23:48:35 2007
@@ -20,15 +20,15 @@
 package org.apache.directory.server.ldap.support.bind;
 
 
-import java.util.Hashtable;
+import org.apache.directory.server.core.DirectoryService;
+import org.apache.mina.common.IoSession;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import javax.naming.Context;
 import javax.naming.ldap.LdapContext;
 import javax.security.sasl.AuthorizeCallback;
-
-import org.apache.mina.common.IoSession;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import java.util.Hashtable;
 
 
 /**
@@ -37,7 +37,7 @@
  */
 public class DigestMd5CallbackHandler extends AbstractSaslCallbackHandler
 {
-    private static final Logger log = LoggerFactory.getLogger( DigestMd5CallbackHandler.class );
+    private static final Logger LOG = LoggerFactory.getLogger( DigestMd5CallbackHandler.class );
 
     private IoSession session;
     private Object message;
@@ -49,11 +49,13 @@
     /**
      * Creates a new instance of DigestMd5CallbackHandler.
      *
-     * @param session
-     * @param message
+     * @param session the mina IoSession
+     * @param message the message
+     * @param directoryService the directory service core
      */
-    public DigestMd5CallbackHandler( IoSession session, Object message )
+    public DigestMd5CallbackHandler( DirectoryService directoryService, IoSession session, Object message )
     {
+        super( directoryService );
         this.session = session;
         this.message = message;
     }
@@ -80,9 +82,9 @@
 
     protected void authorize( AuthorizeCallback authorizeCB )
     {
-        if ( log.isDebugEnabled() )
+        if ( LOG.isDebugEnabled() )
         {
-            log.debug( "Converted username " + getUsername() + " to DN " + bindDn + " with password " + userPassword + "." );
+            LOG.debug( "Converted username " + getUsername() + " to DN " + bindDn + " with password " + userPassword + "." );
         }
 
         session.setAttribute( Context.SECURITY_PRINCIPAL, bindDn );

Modified: directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/bind/DigestMd5MechanismHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/bind/DigestMd5MechanismHandler.java?rev=582462&r1=582461&r2=582462&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/bind/DigestMd5MechanismHandler.java (original)
+++ directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/bind/DigestMd5MechanismHandler.java Fri Oct  5 23:48:35 2007
@@ -20,13 +20,13 @@
 package org.apache.directory.server.ldap.support.bind;
 
 
-import java.util.Map;
+import org.apache.directory.server.core.DirectoryService;
+import org.apache.mina.common.IoSession;
 
 import javax.security.auth.callback.CallbackHandler;
 import javax.security.sasl.Sasl;
 import javax.security.sasl.SaslServer;
-
-import org.apache.mina.common.IoSession;
+import java.util.Map;
 
 
 /**
@@ -35,6 +35,15 @@
  */
 public class DigestMd5MechanismHandler implements MechanismHandler
 {
+    private final DirectoryService directoryService;
+
+
+    public DigestMd5MechanismHandler( DirectoryService directoryService )
+    {
+        this.directoryService = directoryService;
+    }
+
+    
     public SaslServer handleMechanism( IoSession session, Object message ) throws Exception
     {
         SaslServer ss;
@@ -46,9 +55,10 @@
         else
         {
             String saslHost = ( String ) session.getAttribute( "saslHost" );
-            Map<String, String> saslProps = ( Map ) session.getAttribute( "saslProps" );
+            //noinspection unchecked
+            Map<String, String> saslProps = ( Map<String,String> ) session.getAttribute( "saslProps" );
 
-            CallbackHandler callbackHandler = new DigestMd5CallbackHandler( session, message );
+            CallbackHandler callbackHandler = new DigestMd5CallbackHandler( directoryService, session, message );
 
             ss = Sasl.createSaslServer( "DIGEST-MD5", "ldap", saslHost, saslProps, callbackHandler );
             session.setAttribute( SASL_CONTEXT, ss );

Modified: directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/bind/GssapiCallbackHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/bind/GssapiCallbackHandler.java?rev=582462&r1=582461&r2=582462&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/bind/GssapiCallbackHandler.java (original)
+++ directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/bind/GssapiCallbackHandler.java Fri Oct  5 23:48:35 2007
@@ -20,19 +20,19 @@
 package org.apache.directory.server.ldap.support.bind;
 
 
-import java.util.Hashtable;
-
-import javax.naming.Context;
-import javax.naming.ldap.LdapContext;
-import javax.security.auth.kerberos.KerberosPrincipal;
-import javax.security.sasl.AuthorizeCallback;
-
+import org.apache.directory.server.core.DirectoryService;
 import org.apache.directory.server.kerberos.shared.store.PrincipalStoreEntry;
 import org.apache.directory.server.kerberos.shared.store.operations.GetPrincipal;
 import org.apache.mina.common.IoSession;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import javax.naming.Context;
+import javax.naming.ldap.LdapContext;
+import javax.security.auth.kerberos.KerberosPrincipal;
+import javax.security.sasl.AuthorizeCallback;
+import java.util.Hashtable;
+
 
 /**
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
@@ -40,7 +40,7 @@
  */
 public class GssapiCallbackHandler extends AbstractSaslCallbackHandler
 {
-    private static final Logger log = LoggerFactory.getLogger( GssapiCallbackHandler.class );
+    private static final Logger LOG = LoggerFactory.getLogger( GssapiCallbackHandler.class );
 
     private IoSession session;
     private Object message;
@@ -49,11 +49,13 @@
     /**
      * Creates a new instance of GssapiCallbackHandler.
      *
-     * @param session
-     * @param message
+     * @param session the mina IO session
+     * @param message the bind message
+     * @param directoryService the directory service core
      */
-    public GssapiCallbackHandler( IoSession session, Object message )
+    public GssapiCallbackHandler( DirectoryService directoryService, IoSession session, Object message )
     {
+        super( directoryService );
         this.session = session;
         this.message = message;
     }
@@ -68,7 +70,7 @@
 
     protected void authorize( AuthorizeCallback authorizeCB )
     {
-        log.debug( "Processing conversion of principal name to DN." );
+        LOG.debug( "Processing conversion of principal name to DN." );
 
         Hashtable env = getEnvironment( session );
 
@@ -80,7 +82,7 @@
         PrincipalStoreEntry entry = ( PrincipalStoreEntry ) getPrincipal.execute( ctx, null );
         String bindDn = entry.getDistinguishedName();
 
-        log.debug( "Converted username {} to DN {}.", username, bindDn );
+        LOG.debug( "Converted username {} to DN {}.", username, bindDn );
         session.setAttribute( Context.SECURITY_PRINCIPAL, bindDn );
 
         authorizeCB.setAuthorizedID( bindDn );



Mime
View raw message