directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r725712 [5/9] - in /directory: apacheds/trunk/ apacheds/trunk/all/ apacheds/trunk/bootstrap-plugin/src/main/java/org/apache/directory/server/core/bootstrap/plugin/ apacheds/trunk/core-avl/src/main/java/org/apache/directory/server/core/avltr...
Date Thu, 11 Dec 2008 15:32:12 GMT
Modified: directory/apacheds/trunk/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/KdcServer.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/KdcServer.java?rev=725712&r1=725711&r2=725712&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/KdcServer.java (original)
+++ directory/apacheds/trunk/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/KdcServer.java Thu Dec 11 07:32:04 2008
@@ -29,12 +29,19 @@
 
 import org.apache.directory.server.constants.ServerDNConstants;
 import org.apache.directory.server.kerberos.protocol.KerberosProtocolHandler;
+import org.apache.directory.server.kerberos.protocol.KerberosTcpProtocolCodecFactory;
+import org.apache.directory.server.kerberos.protocol.KerberosUdpProtocolCodecFactory;
 import org.apache.directory.server.kerberos.shared.crypto.encryption.EncryptionType;
 import org.apache.directory.server.kerberos.shared.store.DirectoryPrincipalStore;
 import org.apache.directory.server.kerberos.shared.store.PrincipalStore;
 import org.apache.directory.server.protocol.shared.DirectoryBackedService;
-import org.apache.mina.transport.socket.nio.DatagramAcceptorConfig;
-import org.apache.mina.transport.socket.nio.SocketAcceptorConfig;
+import org.apache.mina.core.filterchain.DefaultIoFilterChainBuilder;
+import org.apache.mina.core.filterchain.IoFilterChainBuilder;
+import org.apache.mina.filter.codec.ProtocolCodecFilter;
+import org.apache.mina.transport.socket.DatagramAcceptor;
+import org.apache.mina.transport.socket.SocketAcceptor;
+import org.apache.mina.transport.socket.nio.NioDatagramAcceptor;
+import org.apache.mina.transport.socket.nio.NioSocketAcceptor;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -431,33 +438,78 @@
         PrincipalStore store;
 
         // TODO - for now ignoring this catelog crap
-        
         store = new DirectoryPrincipalStore( getDirectoryService() );
-
-        
-//        if ( isCatelogBased() )
-//        {
-//            store = new JndiPrincipalStoreImpl( getSearchBaseDn(), null, getDirectoryService() );
-//        }
-//        else
-//        {
-//            store = new JndiPrincipalStoreImpl( null, getSearchBaseDn(), getDirectoryService() );
-//        }
-        
         
-
-        if ( getDatagramAcceptor() != null )
+        // Kerberos can use UDP or TCP
+        if ( getUdpPort() != -1 )
         {
-            DatagramAcceptorConfig udpConfig = new DatagramAcceptorConfig();
-            getDatagramAcceptor().bind( new InetSocketAddress( getIpPort() ), new KerberosProtocolHandler( this, store ), udpConfig );
+            // Actually, this is not used for Datagram. But it should !
+            int nbUdpThreads = getNbUdpThreads();
+            
+            // Create the acceptor
+            DatagramAcceptor udpAcceptor = new NioDatagramAcceptor();
+            
+            // Stores it
+            setDatagramAcceptor( udpAcceptor );
+            
+            // Now, configure the acceptor
+            // Inject the chain
+            IoFilterChainBuilder udpChainBuilder = new DefaultIoFilterChainBuilder();
+
+            ((DefaultIoFilterChainBuilder)udpChainBuilder).addFirst( "codec", 
+                    new ProtocolCodecFilter( 
+                            KerberosUdpProtocolCodecFactory.getInstance() ) );
+
+            udpAcceptor.setFilterChainBuilder( udpChainBuilder );
+            
+            // Inject the protocol handler
+            udpAcceptor.setHandler( new KerberosProtocolHandler( this, store ) );
+            
+            // Bind to the configured address
+            udpAcceptor.bind( new InetSocketAddress( getUdpPort() ) );
         }
 
-        if ( getSocketAcceptor() != null )
+        if ( getTcpPort() != -1 )
         {
-            SocketAcceptorConfig tcpConfig = new SocketAcceptorConfig();
-            tcpConfig.setDisconnectOnUnbind( false );
-            tcpConfig.setReuseAddress( true );
-            getSocketAcceptor().bind( new InetSocketAddress( getIpPort() ), new KerberosProtocolHandler( this, store ), tcpConfig );
+            // First, create the acceptor with the configured number of threads (if defined)
+            int nbTcpThreads = getNbTcpThreads();
+            SocketAcceptor tcpAcceptor;
+            
+            if ( nbTcpThreads > 0 )
+            {
+                tcpAcceptor = new NioSocketAcceptor( nbTcpThreads );
+            }
+            else
+            {
+                tcpAcceptor = new NioSocketAcceptor();
+            }
+                
+            setSocketAcceptor( tcpAcceptor );
+            
+            // Now, configure the acceptor
+            // Disable the disconnection of the clients on unbind
+            tcpAcceptor.setCloseOnDeactivation( false );
+            
+            // No Nagle's algorithm
+            tcpAcceptor.getSessionConfig().setTcpNoDelay( true );
+            
+            // Allow the port to be reused even if the socket is in TIME_WAIT state
+            tcpAcceptor.setReuseAddress( true );
+            
+            // Inject the chain
+            IoFilterChainBuilder tcpChainBuilder = new DefaultIoFilterChainBuilder();
+
+            ((DefaultIoFilterChainBuilder)tcpChainBuilder).addFirst( "codec", 
+                    new ProtocolCodecFilter( 
+                            KerberosTcpProtocolCodecFactory.getInstance() ) );
+
+            tcpAcceptor.setFilterChainBuilder( tcpChainBuilder );
+            
+            // Inject the protocol handler
+            tcpAcceptor.setHandler( new KerberosProtocolHandler( this, store ) );
+            
+            // Bind to the configured address
+            tcpAcceptor.bind( new InetSocketAddress( getTcpPort() ) );
         }
         
         LOG.info( "Kerberos service started." );

Modified: directory/apacheds/trunk/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/protocol/KerberosProtocolHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/protocol/KerberosProtocolHandler.java?rev=725712&r1=725711&r2=725712&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/protocol/KerberosProtocolHandler.java (original)
+++ directory/apacheds/trunk/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/protocol/KerberosProtocolHandler.java Thu Dec 11 07:32:04 2008
@@ -38,10 +38,9 @@
 import org.apache.directory.server.kerberos.shared.messages.KdcRequest;
 import org.apache.directory.server.kerberos.shared.messages.value.KerberosTime;
 import org.apache.directory.server.kerberos.shared.store.PrincipalStore;
-import org.apache.mina.common.IdleStatus;
-import org.apache.mina.common.IoHandler;
-import org.apache.mina.common.IoSession;
-import org.apache.mina.common.TransportType;
+import org.apache.mina.core.service.IoHandler;
+import org.apache.mina.core.session.IdleStatus;
+import org.apache.mina.core.session.IoSession;
 import org.apache.mina.filter.codec.ProtocolCodecFilter;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -63,7 +62,6 @@
     private static final String CONTEXT_KEY = "context";
     
 
-
     /**
      * Creates a new instance of KerberosProtocolHandler.
      *
@@ -81,10 +79,10 @@
     {
         if ( log.isDebugEnabled() )
         {
-            log.debug( "{} CREATED:  {}", session.getRemoteAddress(), session.getTransportType() );
+            log.debug( "{} CREATED:  {}", session.getRemoteAddress(), session.getTransportMetadata() );
         }
 
-        if ( session.getTransportType() == TransportType.DATAGRAM )
+        if ( session.getTransportMetadata().isConnectionless() )
         {
             session.getFilterChain().addFirst( "codec",
                 new ProtocolCodecFilter( KerberosUdpProtocolCodecFactory.getInstance() ) );
@@ -127,7 +125,7 @@
     public void exceptionCaught( IoSession session, Throwable cause )
     {
         log.error( session.getRemoteAddress() + " EXCEPTION", cause );
-        session.close();
+        session.close( true );
     }
 
 
@@ -205,6 +203,7 @@
         }
         catch ( Exception e )
         {
+        e.printStackTrace();
             log.error( "Unexpected exception:  " + e.getMessage(), e );
 
             session.write( getErrorMessage( config.getServicePrincipal(), new KerberosException(

Modified: directory/apacheds/trunk/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/protocol/KerberosTcpDecoder.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/protocol/KerberosTcpDecoder.java?rev=725712&r1=725711&r2=725712&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/protocol/KerberosTcpDecoder.java (original)
+++ directory/apacheds/trunk/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/protocol/KerberosTcpDecoder.java Thu Dec 11 07:32:04 2008
@@ -21,9 +21,8 @@
 
 
 import org.apache.directory.server.kerberos.shared.io.decoder.KdcRequestDecoder;
-import org.apache.mina.common.BufferDataException;
-import org.apache.mina.common.ByteBuffer;
-import org.apache.mina.common.IoSession;
+import org.apache.mina.core.buffer.IoBuffer;
+import org.apache.mina.core.session.IoSession;
 import org.apache.mina.filter.codec.CumulativeProtocolDecoder;
 import org.apache.mina.filter.codec.ProtocolDecoderOutput;
 
@@ -76,7 +75,7 @@
 
 
     @Override
-    protected boolean doDecode( IoSession session, ByteBuffer in, ProtocolDecoderOutput out ) throws Exception
+    protected boolean doDecode( IoSession session, IoBuffer in, ProtocolDecoderOutput out ) throws Exception
     {
         if ( !in.prefixedDataAvailable( 4, maxObjectSize ) )
         {

Modified: directory/apacheds/trunk/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/protocol/KerberosTcpEncoder.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/protocol/KerberosTcpEncoder.java?rev=725712&r1=725711&r2=725712&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/protocol/KerberosTcpEncoder.java (original)
+++ directory/apacheds/trunk/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/protocol/KerberosTcpEncoder.java Thu Dec 11 07:32:04 2008
@@ -26,8 +26,8 @@
 import org.apache.directory.server.kerberos.shared.io.encoder.KdcReplyEncoder;
 import org.apache.directory.server.kerberos.shared.messages.ErrorMessage;
 import org.apache.directory.server.kerberos.shared.messages.KdcReply;
-import org.apache.mina.common.ByteBuffer;
-import org.apache.mina.common.IoSession;
+import org.apache.mina.core.buffer.IoBuffer;
+import org.apache.mina.core.session.IoSession;
 import org.apache.mina.filter.codec.ProtocolEncoderAdapter;
 import org.apache.mina.filter.codec.ProtocolEncoderOutput;
 
@@ -44,7 +44,7 @@
 
     public void encode( IoSession session, Object message, ProtocolEncoderOutput out ) throws IOException
     {
-        ByteBuffer buf = ByteBuffer.allocate( 1024 );
+        IoBuffer buf = IoBuffer.allocate( 1024 );
 
         // make space for int length
         buf.putInt( 0 );

Modified: directory/apacheds/trunk/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/protocol/KerberosTcpProtocolCodecFactory.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/protocol/KerberosTcpProtocolCodecFactory.java?rev=725712&r1=725711&r2=725712&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/protocol/KerberosTcpProtocolCodecFactory.java (original)
+++ directory/apacheds/trunk/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/protocol/KerberosTcpProtocolCodecFactory.java Thu Dec 11 07:32:04 2008
@@ -20,6 +20,7 @@
 package org.apache.directory.server.kerberos.protocol;
 
 
+import org.apache.mina.core.session.IoSession;
 import org.apache.mina.filter.codec.ProtocolCodecFactory;
 import org.apache.mina.filter.codec.ProtocolDecoder;
 import org.apache.mina.filter.codec.ProtocolEncoder;
@@ -51,14 +52,14 @@
     }
 
 
-    public ProtocolEncoder getEncoder()
+    public ProtocolEncoder getEncoder( IoSession session )
     {
         // Create a new encoder.
         return new KerberosTcpEncoder();
     }
 
 
-    public ProtocolDecoder getDecoder()
+    public ProtocolDecoder getDecoder( IoSession session )
     {
         // Create a new decoder.
         return new KerberosTcpDecoder();

Modified: directory/apacheds/trunk/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/protocol/KerberosUdpDecoder.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/protocol/KerberosUdpDecoder.java?rev=725712&r1=725711&r2=725712&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/protocol/KerberosUdpDecoder.java (original)
+++ directory/apacheds/trunk/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/protocol/KerberosUdpDecoder.java Thu Dec 11 07:32:04 2008
@@ -23,8 +23,8 @@
 import java.io.IOException;
 
 import org.apache.directory.server.kerberos.shared.io.decoder.KdcRequestDecoder;
-import org.apache.mina.common.ByteBuffer;
-import org.apache.mina.common.IoSession;
+import org.apache.mina.core.buffer.IoBuffer;
+import org.apache.mina.core.session.IoSession;
 import org.apache.mina.filter.codec.ProtocolDecoderAdapter;
 import org.apache.mina.filter.codec.ProtocolDecoderOutput;
 
@@ -38,7 +38,7 @@
     private KdcRequestDecoder decoder = new KdcRequestDecoder();
 
 
-    public void decode( IoSession session, ByteBuffer in, ProtocolDecoderOutput out ) throws IOException
+    public void decode( IoSession session, IoBuffer in, ProtocolDecoderOutput out ) throws IOException
     {
         out.write( decoder.decode( in.buf() ) );
     }

Modified: directory/apacheds/trunk/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/protocol/KerberosUdpEncoder.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/protocol/KerberosUdpEncoder.java?rev=725712&r1=725711&r2=725712&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/protocol/KerberosUdpEncoder.java (original)
+++ directory/apacheds/trunk/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/protocol/KerberosUdpEncoder.java Thu Dec 11 07:32:04 2008
@@ -26,8 +26,8 @@
 import org.apache.directory.server.kerberos.shared.io.encoder.KdcReplyEncoder;
 import org.apache.directory.server.kerberos.shared.messages.ErrorMessage;
 import org.apache.directory.server.kerberos.shared.messages.KdcReply;
-import org.apache.mina.common.ByteBuffer;
-import org.apache.mina.common.IoSession;
+import org.apache.mina.core.buffer.IoBuffer;
+import org.apache.mina.core.session.IoSession;
 import org.apache.mina.filter.codec.ProtocolEncoderAdapter;
 import org.apache.mina.filter.codec.ProtocolEncoderOutput;
 
@@ -44,7 +44,7 @@
 
     public void encode( IoSession session, Object message, ProtocolEncoderOutput out ) throws IOException
     {
-        ByteBuffer buf = ByteBuffer.allocate( 1024 );
+        IoBuffer buf = IoBuffer.allocate( 1024 );
 
         if ( message instanceof KdcReply )
         {

Modified: directory/apacheds/trunk/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/protocol/KerberosUdpProtocolCodecFactory.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/protocol/KerberosUdpProtocolCodecFactory.java?rev=725712&r1=725711&r2=725712&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/protocol/KerberosUdpProtocolCodecFactory.java (original)
+++ directory/apacheds/trunk/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/protocol/KerberosUdpProtocolCodecFactory.java Thu Dec 11 07:32:04 2008
@@ -20,6 +20,7 @@
 package org.apache.directory.server.kerberos.protocol;
 
 
+import org.apache.mina.core.session.IoSession;
 import org.apache.mina.filter.codec.ProtocolCodecFactory;
 import org.apache.mina.filter.codec.ProtocolDecoder;
 import org.apache.mina.filter.codec.ProtocolEncoder;
@@ -51,14 +52,14 @@
     }
 
 
-    public ProtocolEncoder getEncoder()
+    public ProtocolEncoder getEncoder( IoSession session )
     {
         // Create a new encoder.
         return new KerberosUdpEncoder();
     }
 
 
-    public ProtocolDecoder getDecoder()
+    public ProtocolDecoder getDecoder( IoSession session )
     {
         // Create a new decoder.
         return new KerberosUdpDecoder();

Modified: directory/apacheds/trunk/protocol-kerberos/src/test/java/org/apache/directory/server/kerberos/protocol/AbstractAuthenticationServiceTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-kerberos/src/test/java/org/apache/directory/server/kerberos/protocol/AbstractAuthenticationServiceTest.java?rev=725712&r1=725711&r2=725712&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-kerberos/src/test/java/org/apache/directory/server/kerberos/protocol/AbstractAuthenticationServiceTest.java (original)
+++ directory/apacheds/trunk/protocol-kerberos/src/test/java/org/apache/directory/server/kerberos/protocol/AbstractAuthenticationServiceTest.java Thu Dec 11 07:32:04 2008
@@ -27,8 +27,6 @@
 import javax.security.auth.kerberos.KerberosKey;
 import javax.security.auth.kerberos.KerberosPrincipal;
 
-import junit.framework.TestCase;
-
 import org.apache.directory.server.kerberos.shared.crypto.encryption.CipherTextHandler;
 import org.apache.directory.server.kerberos.shared.crypto.encryption.EncryptionType;
 import org.apache.directory.server.kerberos.shared.crypto.encryption.KeyUsage;
@@ -41,14 +39,12 @@
 import org.apache.directory.server.kerberos.shared.messages.value.PrincipalName;
 import org.apache.directory.server.kerberos.shared.messages.value.types.PaDataType;
 import org.apache.directory.server.kerberos.shared.messages.value.types.PrincipalNameType;
-import org.apache.mina.common.IoFilterChain;
-import org.apache.mina.common.IoHandler;
-import org.apache.mina.common.IoService;
-import org.apache.mina.common.IoServiceConfig;
-import org.apache.mina.common.IoSessionConfig;
-import org.apache.mina.common.TransportType;
-import org.apache.mina.common.WriteFuture;
-import org.apache.mina.common.support.BaseIoSession;
+import org.apache.mina.core.future.WriteFuture;
+import org.apache.mina.core.service.IoHandler;
+import org.apache.mina.core.service.IoService;
+import org.apache.mina.core.session.AbstractIoSession;
+import org.apache.mina.core.session.DummySession;
+import org.apache.mina.core.session.IoSessionConfig;
 
 
 /**
@@ -58,7 +54,7 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$, $Date$
  */
-public abstract class AbstractAuthenticationServiceTest extends TestCase
+public abstract class AbstractAuthenticationServiceTest
 {
     protected CipherTextHandler lockBox;
     protected static final SecureRandom random = new SecureRandom();
@@ -122,20 +118,35 @@
         return key;
     }
 
-    protected static class DummySession extends BaseIoSession
+    protected static class KrbDummySession extends DummySession
     {
         Object message;
+        
+        public KrbDummySession() 
+        {
+            super();
+        }
+        
+        public KrbDummySession( IoService service )
+        {
+            try
+            {
+                ((AbstractIoSession) this).setAttributeMap(service
+                        .getSessionDataStructureFactory().getAttributeMap(this));
+            }
+            catch( Exception e ) 
+            {
+                
+            }
+        }
 
-
-        @Override
         public WriteFuture write( Object message )
         {
             this.message = message;
-
-            return super.write( message );
+            
+            return null;
         }
 
-
         protected Object getMessage()
         {
             return message;
@@ -160,18 +171,6 @@
         }
 
 
-        public IoFilterChain getFilterChain()
-        {
-            return null;
-        }
-
-
-        public TransportType getTransportType()
-        {
-            return null;
-        }
-
-
         public SocketAddress getRemoteAddress()
         {
             return new InetSocketAddress( 10088 );
@@ -200,17 +199,5 @@
         {
             return null;
         }
-
-
-        public IoServiceConfig getServiceConfig()
-        {
-            return null;
-        }
-
-
-        public int getScheduledWriteBytes()
-        {
-            return 0;
-        }
     }
 }

Modified: directory/apacheds/trunk/protocol-kerberos/src/test/java/org/apache/directory/server/kerberos/protocol/AbstractTicketGrantingServiceTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-kerberos/src/test/java/org/apache/directory/server/kerberos/protocol/AbstractTicketGrantingServiceTest.java?rev=725712&r1=725711&r2=725712&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-kerberos/src/test/java/org/apache/directory/server/kerberos/protocol/AbstractTicketGrantingServiceTest.java (original)
+++ directory/apacheds/trunk/protocol-kerberos/src/test/java/org/apache/directory/server/kerberos/protocol/AbstractTicketGrantingServiceTest.java Thu Dec 11 07:32:04 2008
@@ -21,8 +21,6 @@
 
 
 import java.io.IOException;
-import java.net.InetSocketAddress;
-import java.net.SocketAddress;
 import java.security.SecureRandom;
 
 import javax.security.auth.kerberos.KerberosKey;
@@ -61,14 +59,6 @@
 import org.apache.directory.server.kerberos.shared.messages.value.flags.TicketFlags;
 import org.apache.directory.server.kerberos.shared.messages.value.types.PaDataType;
 import org.apache.directory.server.kerberos.shared.messages.value.types.PrincipalNameType;
-import org.apache.mina.common.IoFilterChain;
-import org.apache.mina.common.IoHandler;
-import org.apache.mina.common.IoService;
-import org.apache.mina.common.IoServiceConfig;
-import org.apache.mina.common.IoSessionConfig;
-import org.apache.mina.common.TransportType;
-import org.apache.mina.common.WriteFuture;
-import org.apache.mina.common.support.BaseIoSession;
 
 
 /**
@@ -323,96 +313,4 @@
 
         return principalName;
     }
-
-    protected static class DummySession extends BaseIoSession
-    {
-        Object message;
-
-
-        @Override
-        public WriteFuture write( Object message )
-        {
-            this.message = message;
-
-            return super.write( message );
-        }
-
-
-        protected Object getMessage()
-        {
-            return message;
-        }
-
-
-        protected void updateTrafficMask()
-        {
-            // Do nothing.
-        }
-
-
-        public IoService getService()
-        {
-            return null;
-        }
-
-
-        public IoHandler getHandler()
-        {
-            return null;
-        }
-
-
-        public IoFilterChain getFilterChain()
-        {
-            return null;
-        }
-
-
-        public TransportType getTransportType()
-        {
-            return null;
-        }
-
-
-        public SocketAddress getRemoteAddress()
-        {
-            return new InetSocketAddress( 10088 );
-        }
-
-
-        public SocketAddress getLocalAddress()
-        {
-            return null;
-        }
-
-
-        public IoSessionConfig getConfig()
-        {
-            return null;
-        }
-
-
-        public int getScheduledWriteRequests()
-        {
-            return 0;
-        }
-
-
-        public SocketAddress getServiceAddress()
-        {
-            return null;
-        }
-
-
-        public IoServiceConfig getServiceConfig()
-        {
-            return null;
-        }
-
-
-        public int getScheduledWriteBytes()
-        {
-            return 0;
-        }
-    }
 }

Modified: directory/apacheds/trunk/protocol-kerberos/src/test/java/org/apache/directory/server/kerberos/protocol/AuthenticationEncryptionTypeTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-kerberos/src/test/java/org/apache/directory/server/kerberos/protocol/AuthenticationEncryptionTypeTest.java?rev=725712&r1=725711&r2=725712&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-kerberos/src/test/java/org/apache/directory/server/kerberos/protocol/AuthenticationEncryptionTypeTest.java (original)
+++ directory/apacheds/trunk/protocol-kerberos/src/test/java/org/apache/directory/server/kerberos/protocol/AuthenticationEncryptionTypeTest.java Thu Dec 11 07:32:04 2008
@@ -47,6 +47,11 @@
 import org.apache.directory.server.kerberos.shared.messages.value.types.PaDataType;
 import org.apache.directory.server.kerberos.shared.store.PrincipalStore;
 
+import org.junit.Before;
+import org.junit.Test;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
 
 /**
  * Tests various facets of working with encryption types in the Authentication Service (AS).
@@ -59,18 +64,19 @@
     private KdcServer config;
     private PrincipalStore store;
     private KerberosProtocolHandler handler;
-    private DummySession session;
+    private KrbDummySession session;
 
 
     /**
      * Creates a new instance of {@link AuthenticationEncryptionTypeTest}.
      */
-    public AuthenticationEncryptionTypeTest()
+    @Before
+    public void setUp()
     {
         config = new KdcServer();
         store = new MapPrincipalStoreImpl();
         handler = new KerberosProtocolHandler( config, store );
-        session = new DummySession();
+        session = new KrbDummySession();
         lockBox = new CipherTextHandler();
     }
 
@@ -80,6 +86,7 @@
      * 
      * @throws Exception
      */
+    @Test
     public void testRequestDesCbcMd5() throws Exception
     {
         RequestBodyModifier modifier = new RequestBodyModifier();
@@ -117,6 +124,7 @@
      * 
      * @throws Exception
      */
+    @Test
     public void testRequestAes128() throws Exception
     {
         EncryptionType[] configuredEncryptionTypes =
@@ -168,6 +176,7 @@
      * 
      * @throws Exception
      */
+    @Test
     public void testNonce() throws Exception
     {
         EncryptionType[] configuredEncryptionTypes =
@@ -223,6 +232,7 @@
      * 
      * @throws Exception
      */
+    @Test
     public void testAes128Configuration() throws Exception
     {
         RequestBodyModifier modifier = new RequestBodyModifier();

Modified: directory/apacheds/trunk/protocol-kerberos/src/test/java/org/apache/directory/server/kerberos/protocol/AuthenticationPolicyTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-kerberos/src/test/java/org/apache/directory/server/kerberos/protocol/AuthenticationPolicyTest.java?rev=725712&r1=725711&r2=725712&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-kerberos/src/test/java/org/apache/directory/server/kerberos/protocol/AuthenticationPolicyTest.java (original)
+++ directory/apacheds/trunk/protocol-kerberos/src/test/java/org/apache/directory/server/kerberos/protocol/AuthenticationPolicyTest.java Thu Dec 11 07:32:04 2008
@@ -30,6 +30,10 @@
 import org.apache.directory.server.kerberos.shared.messages.value.RequestBodyModifier;
 import org.apache.directory.server.kerberos.shared.store.PrincipalStore;
 
+import org.junit.Before;
+import org.junit.Test;
+import static org.junit.Assert.assertEquals;
+
 
 /**
  * Tests configuration of Authentication Service (AS) policy.
@@ -42,18 +46,19 @@
     private KdcServer config;
     private PrincipalStore store;
     private KerberosProtocolHandler handler;
-    private DummySession session;
+    private KrbDummySession session;
 
 
     /**
      * Creates a new instance of {@link AuthenticationPolicyTest}.
      */
-    public AuthenticationPolicyTest()
+    @Before
+    public void setUp()
     {
         config = new KdcServer();
         store = new MapPrincipalStoreImpl();
         handler = new KerberosProtocolHandler( config, store );
-        session = new DummySession();
+        session = new KrbDummySession();
     }
 
 
@@ -63,6 +68,7 @@
      * 
      * @throws Exception 
      */
+    @Test
     public void testForwardableTicket() throws Exception
     {
         // Deny FORWARDABLE tickets in policy.
@@ -98,6 +104,7 @@
      * 
      * @throws Exception 
      */
+    @Test
     public void testProxiableTicket() throws Exception
     {
         // Deny PROXIABLE tickets in policy.
@@ -133,6 +140,7 @@
      * 
      * @throws Exception 
      */
+    @Test
     public void testAllowPostdate() throws Exception
     {
         // Deny POSTDATED tickets in policy.
@@ -168,6 +176,7 @@
      * 
      * @throws Exception 
      */
+    @Test
     public void testPostdate() throws Exception
     {
         // Deny POSTDATED tickets in policy.
@@ -203,6 +212,7 @@
      * 
      * @throws Exception 
      */
+    @Test
     public void testRenewableOk() throws Exception
     {
         // Deny RENEWABLE tickets in policy.
@@ -238,6 +248,7 @@
      * 
      * @throws Exception 
      */
+    @Test
     public void testRenewableTicket() throws Exception
     {
         // Deny RENEWABLE tickets in policy.
@@ -276,6 +287,7 @@
      * 
      * @throws Exception 
      */
+    @Test
     public void testEmptyAddresses() throws Exception
     {
         // Deny empty addresses in policy.

Modified: directory/apacheds/trunk/protocol-kerberos/src/test/java/org/apache/directory/server/kerberos/protocol/AuthenticationServiceTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-kerberos/src/test/java/org/apache/directory/server/kerberos/protocol/AuthenticationServiceTest.java?rev=725712&r1=725711&r2=725712&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-kerberos/src/test/java/org/apache/directory/server/kerberos/protocol/AuthenticationServiceTest.java (original)
+++ directory/apacheds/trunk/protocol-kerberos/src/test/java/org/apache/directory/server/kerberos/protocol/AuthenticationServiceTest.java Thu Dec 11 07:32:04 2008
@@ -38,6 +38,12 @@
 import org.apache.directory.server.kerberos.shared.messages.value.RequestBodyModifier;
 import org.apache.directory.server.kerberos.shared.store.PrincipalStore;
 
+import org.junit.Before;
+import org.junit.Test;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertFalse;
+
 
 /**
  * Tests the Authentication Service (AS) via the {@link KerberosProtocolHandler}.
@@ -50,18 +56,19 @@
     private KdcServer config;
     private PrincipalStore store;
     private KerberosProtocolHandler handler;
-    private DummySession session;
+    private KrbDummySession session;
 
 
     /**
      * Creates a new instance of {@link AuthenticationServiceTest}.
      */
-    public AuthenticationServiceTest()
+    @Before
+    public void setUp()
     {
         config = new KdcServer();
         store = new MapPrincipalStoreImpl();
         handler = new KerberosProtocolHandler( config, store );
-        session = new DummySession();
+        session = new KrbDummySession();
         lockBox = new CipherTextHandler();
     }
 
@@ -72,6 +79,7 @@
      * 
      * This is the request archetype.
      */
+    @Test
     public void testRequestArchetype()
     {
         RequestBodyModifier modifier = new RequestBodyModifier();
@@ -96,6 +104,7 @@
     /**
      * Tests the protocol version number, which must be '5'.
      */
+    @Test
     public void testProtocolVersionNumber()
     {
         RequestBodyModifier modifier = new RequestBodyModifier();
@@ -117,6 +126,7 @@
      * Tests that Kerberos reply messages sent to the KDC will be rejected with the
      * correct error message.
      */
+    @Test
     public void testIncorrectMessageDirection()
     {
         KdcRequest message = new KdcRequest( 5, KerberosMessageType.AS_REP, null, null );
@@ -142,6 +152,7 @@
      * unknown because it doesn't exist in the KDC's principal database,
      * then an error message with a KDC_ERR_C_PRINCIPAL_UNKNOWN is returned."
      */
+    @Test
     public void testClientNotFound()
     {
         RequestBodyModifier modifier = new RequestBodyModifier();
@@ -168,6 +179,7 @@
      * 
      * @throws Exception 
      */
+    @Test
     public void testEncryptionTypeNoSupport() throws Exception
     {
         RequestBodyModifier modifier = new RequestBodyModifier();
@@ -206,6 +218,7 @@
      * 
      * @throws Exception 
      */
+    @Test
     public void testServerNotFound() throws Exception
     {
         RequestBodyModifier modifier = new RequestBodyModifier();
@@ -232,6 +245,7 @@
      * Tests that when a client principal is not configured with Kerberos keys that
      * the correct error message is returned.
      */
+    @Test
     public void testClientNullKey()
     {
         RequestBodyModifier modifier = new RequestBodyModifier();
@@ -255,6 +269,7 @@
      * 
      * @throws Exception 
      */
+    @Test
     public void testServerNullKey() throws Exception
     {
         RequestBodyModifier modifier = new RequestBodyModifier();
@@ -289,6 +304,7 @@
      * 
      * @throws Exception 
      */
+    @Test
     public void testStartTimeAbsentNoPostdate() throws Exception
     {
         RequestBodyModifier modifier = new RequestBodyModifier();
@@ -334,6 +350,7 @@
      * 
      * @throws Exception 
      */
+    @Test
     public void testStartTimeInThePastNoPostdate() throws Exception
     {
         RequestBodyModifier modifier = new RequestBodyModifier();
@@ -382,6 +399,7 @@
      * 
      * @throws Exception 
      */
+    @Test
     public void testStartTimeAcceptableClockSkewNoPostdate() throws Exception
     {
         RequestBodyModifier modifier = new RequestBodyModifier();
@@ -428,6 +446,7 @@
      *
      * @throws Exception
      */
+    @Test
     public void testStartTimeOrderNeverValid() throws Exception
     {
         RequestBodyModifier modifier = new RequestBodyModifier();
@@ -472,6 +491,7 @@
      *
      * @throws Exception
      */
+    @Test
     public void testStartTimeMinimumNeverValid() throws Exception
     {
         RequestBodyModifier modifier = new RequestBodyModifier();
@@ -513,6 +533,7 @@
      * 
      * @throws Exception 
      */
+    @Test
     public void testStartTimeNoPostdated() throws Exception
     {
         RequestBodyModifier modifier = new RequestBodyModifier();
@@ -564,6 +585,7 @@
      * 
      * @throws Exception
      */
+    @Test
     public void testSpecificStartTime() throws Exception
     {
         RequestBodyModifier modifier = new RequestBodyModifier();
@@ -618,6 +640,7 @@
      *
      * @throws Exception
      */
+    @Test
     public void testSpecificEndTime() throws Exception
     {
         RequestBodyModifier modifier = new RequestBodyModifier();
@@ -661,6 +684,7 @@
      *
      * @throws Exception
      */
+    @Test
     public void testEndTimeExceedsMaximumAllowable() throws Exception
     {
         RequestBodyModifier modifier = new RequestBodyModifier();
@@ -700,6 +724,7 @@
      * 
      * @throws Exception
      */
+    @Test
     public void testEpochEndTime() throws Exception
     {
         RequestBodyModifier modifier = new RequestBodyModifier();
@@ -738,6 +763,7 @@
      * 
      * @throws Exception
      */
+    @Test
     public void testInitialServiceTicket() throws Exception
     {
         String servicePrincipalName = "ldap/ldap.example.com@EXAMPLE.COM";
@@ -788,6 +814,7 @@
      * 
      * @throws Exception 
      */
+    @Test
     public void testRenewableOk() throws Exception
     {
         RequestBodyModifier modifier = new RequestBodyModifier();
@@ -838,6 +865,7 @@
      * 
      * @throws Exception 
      */
+    @Test
     public void testForwardableTicket() throws Exception
     {
         RequestBodyModifier modifier = new RequestBodyModifier();
@@ -882,6 +910,7 @@
      * 
      * @throws Exception 
      */
+    @Test
     public void testAllowPostdate() throws Exception
     {
         RequestBodyModifier modifier = new RequestBodyModifier();
@@ -926,6 +955,7 @@
      * 
      * @throws Exception 
      */
+    @Test
     public void testProxiableTicket() throws Exception
     {
         RequestBodyModifier modifier = new RequestBodyModifier();
@@ -973,6 +1003,7 @@
      * 
      * @throws Exception 
      */
+    @Test
     public void testRenewableTicket() throws Exception
     {
         RequestBodyModifier modifier = new RequestBodyModifier();
@@ -1026,6 +1057,7 @@
      * 
      * @throws Exception 
      */
+    @Test
     public void testRenewableTicketExceedsMaximumAllowable() throws Exception
     {
         RequestBodyModifier modifier = new RequestBodyModifier();
@@ -1074,6 +1106,7 @@
      *
      * @throws Exception
      */
+    @Test
     public void testBadOptionRenew() throws Exception
     {
         RequestBodyModifier modifier = new RequestBodyModifier();
@@ -1110,6 +1143,7 @@
      *
      * @throws Exception
      */
+    @Test
     public void testBadOptionValidate() throws Exception
     {
         RequestBodyModifier modifier = new RequestBodyModifier();
@@ -1146,6 +1180,7 @@
      *
      * @throws Exception
      */
+    @Test
     public void testBadOptionProxy() throws Exception
     {
         RequestBodyModifier modifier = new RequestBodyModifier();
@@ -1182,6 +1217,7 @@
      *
      * @throws Exception
      */
+    @Test
     public void testBadOptionForwarded() throws Exception
     {
         RequestBodyModifier modifier = new RequestBodyModifier();
@@ -1218,6 +1254,7 @@
      *
      * @throws Exception
      */
+    @Test
     public void testBadOptionEncTktInSkey() throws Exception
     {
         RequestBodyModifier modifier = new RequestBodyModifier();

Modified: directory/apacheds/trunk/protocol-kerberos/src/test/java/org/apache/directory/server/kerberos/protocol/EncTktInSkeyTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-kerberos/src/test/java/org/apache/directory/server/kerberos/protocol/EncTktInSkeyTest.java?rev=725712&r1=725711&r2=725712&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-kerberos/src/test/java/org/apache/directory/server/kerberos/protocol/EncTktInSkeyTest.java (original)
+++ directory/apacheds/trunk/protocol-kerberos/src/test/java/org/apache/directory/server/kerberos/protocol/EncTktInSkeyTest.java Thu Dec 11 07:32:04 2008
@@ -23,6 +23,7 @@
 import javax.security.auth.kerberos.KerberosPrincipal;
 
 import org.apache.directory.server.kerberos.kdc.KdcServer;
+import org.apache.directory.server.kerberos.protocol.AbstractAuthenticationServiceTest.KrbDummySession;
 import org.apache.directory.server.kerberos.shared.crypto.encryption.CipherTextHandler;
 import org.apache.directory.server.kerberos.shared.messages.ErrorMessage;
 import org.apache.directory.server.kerberos.shared.messages.KdcRequest;
@@ -48,7 +49,7 @@
     private KdcServer config;
     private PrincipalStore store;
     private KerberosProtocolHandler handler;
-    private DummySession session;
+    private KrbDummySession session;
 
 
     /**
@@ -66,7 +67,7 @@
 
         store = new MapPrincipalStoreImpl();
         handler = new KerberosProtocolHandler( config, store );
-        session = new DummySession();
+        session = new KrbDummySession();
         lockBox = new CipherTextHandler();
     }
 

Modified: directory/apacheds/trunk/protocol-kerberos/src/test/java/org/apache/directory/server/kerberos/protocol/PreAuthenticationTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-kerberos/src/test/java/org/apache/directory/server/kerberos/protocol/PreAuthenticationTest.java?rev=725712&r1=725711&r2=725712&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-kerberos/src/test/java/org/apache/directory/server/kerberos/protocol/PreAuthenticationTest.java (original)
+++ directory/apacheds/trunk/protocol-kerberos/src/test/java/org/apache/directory/server/kerberos/protocol/PreAuthenticationTest.java Thu Dec 11 07:32:04 2008
@@ -38,6 +38,9 @@
 import org.apache.directory.server.kerberos.shared.messages.value.RequestBodyModifier;
 import org.apache.directory.server.kerberos.shared.messages.value.types.PaDataType;
 import org.apache.directory.server.kerberos.shared.store.PrincipalStore;
+import org.junit.Before;
+import org.junit.Test;
+import static org.junit.Assert.assertEquals;
 
 
 /**
@@ -52,18 +55,19 @@
     private KdcServer config;
     private PrincipalStore store;
     private KerberosProtocolHandler handler;
-    private DummySession session;
+    private KrbDummySession session;
 
 
     /**
      * Creates a new instance of {@link PreAuthenticationTest}.
      */
-    public PreAuthenticationTest()
+    @Before
+    public void setUp()
     {
         config = new KdcServer();
-        store = new MapPrincipalStoreImpl();
+        store  = new MapPrincipalStoreImpl();
         handler = new KerberosProtocolHandler( config, store );
-        session = new DummySession();
+        session = new KrbDummySession();
         lockBox = new CipherTextHandler();
     }
 
@@ -78,6 +82,7 @@
      * METHOD-DATA object will be stored in the e-data field of the KRB-ERROR
      * message to specify which pre-authentication mechanisms are acceptable."
      */
+    @Test
     public void testPreAuthenticationRequired()
     {
         RequestBodyModifier modifier = new RequestBodyModifier();
@@ -106,6 +111,7 @@
      * 
      * @throws Exception 
      */
+    @Test
     public void testPreAuthenticationIntegrityFailed() throws Exception
     {
         RequestBodyModifier modifier = new RequestBodyModifier();
@@ -142,6 +148,7 @@
      * 
      * @throws Exception 
      */
+    @Test
     public void testPreAuthenticationFailed() throws Exception
     {
         RequestBodyModifier modifier = new RequestBodyModifier();
@@ -179,6 +186,7 @@
      * 
      * @throws Exception 
      */
+    @Test
     public void testPreAuthenticationNoSupport() throws Exception
     {
         RequestBodyModifier modifier = new RequestBodyModifier();

Modified: directory/apacheds/trunk/protocol-kerberos/src/test/java/org/apache/directory/server/kerberos/protocol/TicketGrantingEncryptionTypeTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-kerberos/src/test/java/org/apache/directory/server/kerberos/protocol/TicketGrantingEncryptionTypeTest.java?rev=725712&r1=725711&r2=725712&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-kerberos/src/test/java/org/apache/directory/server/kerberos/protocol/TicketGrantingEncryptionTypeTest.java (original)
+++ directory/apacheds/trunk/protocol-kerberos/src/test/java/org/apache/directory/server/kerberos/protocol/TicketGrantingEncryptionTypeTest.java Thu Dec 11 07:32:04 2008
@@ -27,6 +27,7 @@
 import javax.security.auth.kerberos.KerberosPrincipal;
 
 import org.apache.directory.server.kerberos.kdc.KdcServer;
+import org.apache.directory.server.kerberos.protocol.AbstractAuthenticationServiceTest.KrbDummySession;
 import org.apache.directory.server.kerberos.shared.crypto.encryption.CipherTextHandler;
 import org.apache.directory.server.kerberos.shared.crypto.encryption.EncryptionType;
 import org.apache.directory.server.kerberos.shared.crypto.encryption.KerberosKeyFactory;
@@ -54,7 +55,7 @@
     private KdcServer config;
     private PrincipalStore store;
     private KerberosProtocolHandler handler;
-    private DummySession session;
+    private KrbDummySession session;
 
 
     /**
@@ -72,7 +73,7 @@
 
         store = new MapPrincipalStoreImpl();
         handler = new KerberosProtocolHandler( config, store );
-        session = new DummySession();
+        session = new KrbDummySession();
         lockBox = new CipherTextHandler();
     }
 

Modified: directory/apacheds/trunk/protocol-kerberos/src/test/java/org/apache/directory/server/kerberos/protocol/TicketGrantingPolicyTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-kerberos/src/test/java/org/apache/directory/server/kerberos/protocol/TicketGrantingPolicyTest.java?rev=725712&r1=725711&r2=725712&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-kerberos/src/test/java/org/apache/directory/server/kerberos/protocol/TicketGrantingPolicyTest.java (original)
+++ directory/apacheds/trunk/protocol-kerberos/src/test/java/org/apache/directory/server/kerberos/protocol/TicketGrantingPolicyTest.java Thu Dec 11 07:32:04 2008
@@ -25,6 +25,7 @@
 import javax.security.auth.kerberos.KerberosPrincipal;
 
 import org.apache.directory.server.kerberos.kdc.KdcServer;
+import org.apache.directory.server.kerberos.protocol.AbstractAuthenticationServiceTest.KrbDummySession;
 import org.apache.directory.server.kerberos.shared.crypto.encryption.CipherTextHandler;
 import org.apache.directory.server.kerberos.shared.messages.ErrorMessage;
 import org.apache.directory.server.kerberos.shared.messages.KdcRequest;
@@ -52,7 +53,7 @@
     private KdcServer config;
     private PrincipalStore store;
     private KerberosProtocolHandler handler;
-    private DummySession session;
+    private KrbDummySession session;
 
 
     /**
@@ -70,7 +71,7 @@
 
         store = new MapPrincipalStoreImpl();
         handler = new KerberosProtocolHandler( config, store );
-        session = new DummySession();
+        session = new KrbDummySession();
         lockBox = new CipherTextHandler();
     }
 

Modified: directory/apacheds/trunk/protocol-kerberos/src/test/java/org/apache/directory/server/kerberos/protocol/TicketGrantingServiceTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-kerberos/src/test/java/org/apache/directory/server/kerberos/protocol/TicketGrantingServiceTest.java?rev=725712&r1=725711&r2=725712&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-kerberos/src/test/java/org/apache/directory/server/kerberos/protocol/TicketGrantingServiceTest.java (original)
+++ directory/apacheds/trunk/protocol-kerberos/src/test/java/org/apache/directory/server/kerberos/protocol/TicketGrantingServiceTest.java Thu Dec 11 07:32:04 2008
@@ -27,6 +27,7 @@
 import javax.security.auth.kerberos.KerberosPrincipal;
 
 import org.apache.directory.server.kerberos.kdc.KdcServer;
+import org.apache.directory.server.kerberos.protocol.AbstractAuthenticationServiceTest.KrbDummySession;
 import org.apache.directory.server.kerberos.shared.KerberosMessageType;
 import org.apache.directory.server.kerberos.shared.crypto.checksum.ChecksumType;
 import org.apache.directory.server.kerberos.shared.crypto.encryption.CipherTextHandler;
@@ -60,7 +61,7 @@
     private KdcServer config;
     private PrincipalStore store;
     private KerberosProtocolHandler handler;
-    private DummySession session;
+    private KrbDummySession session;
 
 
     /**
@@ -78,7 +79,7 @@
 
         store = new MapPrincipalStoreImpl();
         handler = new KerberosProtocolHandler( config, store );
-        session = new DummySession();
+        session = new KrbDummySession();
         lockBox = new CipherTextHandler();
     }
 

Modified: directory/apacheds/trunk/protocol-ldap/pom.xml
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-ldap/pom.xml?rev=725712&r1=725711&r2=725712&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-ldap/pom.xml (original)
+++ directory/apacheds/trunk/protocol-ldap/pom.xml Thu Dec 11 07:32:04 2008
@@ -47,11 +47,6 @@
     </dependency>
 
     <dependency>
-      <groupId>org.apache.mina</groupId>
-      <artifactId>mina-filter-ssl</artifactId>
-    </dependency>
-
-    <dependency>
       <groupId>org.apache.directory.server</groupId>
       <artifactId>apacheds-kerberos-shared</artifactId>
       <version>${pom.version}</version>

Modified: directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapProtocolCodecFactory.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapProtocolCodecFactory.java?rev=725712&r1=725711&r2=725712&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapProtocolCodecFactory.java (original)
+++ directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapProtocolCodecFactory.java Thu Dec 11 07:32:04 2008
@@ -28,6 +28,7 @@
 import org.apache.directory.shared.ldap.message.MessageEncoder;
 import org.apache.directory.shared.ldap.message.spi.BinaryAttributeDetector;
 import org.apache.directory.shared.ldap.schema.AttributeType;
+import org.apache.mina.core.session.IoSession;
 import org.apache.mina.filter.codec.ProtocolCodecFactory;
 import org.apache.mina.filter.codec.ProtocolDecoder;
 import org.apache.mina.filter.codec.ProtocolEncoder;
@@ -43,6 +44,9 @@
 {
     /** the directory service for which this factor generates codecs */
     final private DirectoryService directoryService;
+    
+    /** The tag stored into the session if we want to set a max PDU size */
+    public final static String MAX_PDU_SIZE = "MAX_PDU_SIZE"; 
 
 
     /**
@@ -61,7 +65,7 @@
      * (non-Javadoc)
      * @see org.apache.mina.filter.codec.ProtocolCodecFactory#getEncoder()
      */
-    public ProtocolEncoder getEncoder()
+    public ProtocolEncoder getEncoder( IoSession session )
     {
         return new Asn1CodecEncoder( new MessageEncoder() );
     }
@@ -71,7 +75,7 @@
      * (non-Javadoc)
      * @see org.apache.mina.filter.codec.ProtocolCodecFactory#getDecoder()
      */
-    public ProtocolDecoder getDecoder()
+    public ProtocolDecoder getDecoder( IoSession session )
     {
         return new Asn1CodecDecoder( new MessageDecoder( new BinaryAttributeDetector()
         {
@@ -88,6 +92,7 @@
                     return false;
                 }
             }
-        }) );
+        },
+        directoryService.getMaxPDUSize() ) );
     }
 }
\ No newline at end of file

Modified: directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapProtocolHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapProtocolHandler.java?rev=725712&r1=725711&r2=725712&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapProtocolHandler.java (original)
+++ directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapProtocolHandler.java Thu Dec 11 07:32:04 2008
@@ -31,13 +31,9 @@
 import org.apache.directory.shared.ldap.message.ResultResponse;
 import org.apache.directory.shared.ldap.message.ResultResponseRequest;
 import org.apache.directory.shared.ldap.message.extended.NoticeOfDisconnect;
-import org.apache.mina.common.IoFilterChain;
-import org.apache.mina.common.IoHandler;
-import org.apache.mina.common.IoSession;
-import org.apache.mina.filter.SSLFilter;
-import org.apache.mina.filter.codec.ProtocolCodecFilter;
+import org.apache.mina.core.session.IoSession;
+import org.apache.mina.filter.ssl.SslFilter;
 import org.apache.mina.handler.demux.DemuxingIoHandler;
-import org.apache.mina.util.SessionLog;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -79,14 +75,12 @@
     public void sessionCreated( IoSession session ) throws Exception
     {
         LdapSession ldapSession = new LdapSession( session );
-        IoFilterChain filters = session.getFilterChain();
-        filters.addLast( "codec", new ProtocolCodecFilter( ldapService.getProtocolCodecFactory() ) );
         ldapService.getLdapSessionManager().addLdapSession( ldapSession );
     }
 
 
     /*
-     * (non-Javadoc)
+     * (non-Javadoc)LdapProtocolHandler
      * @see org.apache.mina.common.IoHandlerAdapter#sessionClosed(org.apache.mina.common.IoSession)
      */
     public void sessionClosed( IoSession session )
@@ -119,7 +113,7 @@
         {
             try
             {
-                ldapSession.getIoSession().close();
+                ldapSession.getIoSession().close( true );
             }
             catch ( Throwable t )
             {
@@ -127,7 +121,18 @@
             }
         }
     }
+
     
+    /*
+     * (non-Javadoc)
+     * @see org.apache.mina.handler.demux.DemuxingIoHandler#messageReceived(org.apache.mina.common.IoSession, java.lang.Object)
+     */
+    public void messageSent( IoSession session, Object message ) throws Exception
+    {
+        // Do nothing : we have to ignore this message, otherwise we get an exception,
+        // thanks to the way MINA 2 works ...
+    }
+
 
     /*
      * (non-Javadoc)
@@ -146,14 +151,14 @@
         // and degrade authentication level to 'anonymous' as specified
         // in the RFC, and this is no threat.
 
-        if ( message == SSLFilter.SESSION_SECURED )
+        if ( message == SslFilter.SESSION_SECURED )
         {
             ExtendedRequest req = new ExtendedRequestImpl( 0 );
             req.setOid( "1.3.6.1.4.1.1466.20037" );
             req.setPayload( "SECURED".getBytes( "ISO-8859-1" ) );
             message = req;
         }
-        else if ( message == SSLFilter.SESSION_UNSECURED )
+        else if ( message == SslFilter.SESSION_UNSECURED )
         {
             ExtendedRequest req = new ExtendedRequestImpl( 0 );
             req.setOid( "1.3.6.1.4.1.1466.20037" );
@@ -199,12 +204,11 @@
             }                
         }
         
-        SessionLog.warn( session,
-            "Unexpected exception forcing session to close: sending disconnect notice to client.", cause );
+        LOG.warn( "Unexpected exception forcing session to close: sending disconnect notice to client.", cause );
 
         session.write( NoticeOfDisconnect.PROTOCOLERROR );
         LdapSession ldapSession = this.ldapService.getLdapSessionManager().removeLdapSession( session );
         cleanUpSession( ldapSession );
-        session.close();
+        session.close( true );
     }
 }
\ No newline at end of file

Modified: directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapService.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapService.java?rev=725712&r1=725711&r2=725712&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapService.java (original)
+++ directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapService.java Thu Dec 11 07:32:04 2008
@@ -25,7 +25,14 @@
 import java.security.KeyStore;
 import java.security.Provider;
 import java.security.Security;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
 
 
 import org.apache.directory.server.core.DirectoryService;
@@ -42,7 +49,7 @@
 import org.apache.directory.server.ldap.handlers.ModifyHandler;
 import org.apache.directory.server.ldap.handlers.SearchHandler;
 import org.apache.directory.server.ldap.handlers.UnbindHandler;
-import org.apache.directory.server.ldap.handlers.bind.*;
+import org.apache.directory.server.ldap.handlers.bind.MechanismHandler;
 import org.apache.directory.server.ldap.handlers.ssl.LdapsInitializer;
 import org.apache.directory.server.protocol.shared.DirectoryBackedService;
 import org.apache.directory.shared.ldap.constants.SaslQoP;
@@ -64,15 +71,20 @@
 import org.apache.directory.shared.ldap.message.control.PersistentSearchControl;
 import org.apache.directory.shared.ldap.message.control.SubentriesControl;
 import org.apache.directory.shared.ldap.message.extended.NoticeOfDisconnect;
-import org.apache.mina.common.DefaultIoFilterChainBuilder;
-import org.apache.mina.common.IoFilterChainBuilder;
-import org.apache.mina.common.IoHandler;
-import org.apache.mina.common.IoSession;
-import org.apache.mina.common.ThreadModel;
-import org.apache.mina.common.WriteFuture;
+import org.apache.directory.shared.ldap.util.StringTools;
+import org.apache.mina.core.filterchain.DefaultIoFilterChainBuilder;
+import org.apache.mina.core.filterchain.IoFilterChainBuilder;
+import org.apache.mina.core.future.WriteFuture;
+import org.apache.mina.core.service.IoHandler;
+import org.apache.mina.core.session.IoEventType;
+import org.apache.mina.core.session.IoSession;
 import org.apache.mina.filter.codec.ProtocolCodecFactory;
+import org.apache.mina.filter.codec.ProtocolCodecFilter;
+import org.apache.mina.filter.executor.ExecutorFilter;
+import org.apache.mina.filter.executor.OrderedThreadPoolExecutor;
 import org.apache.mina.handler.demux.MessageHandler;
-import org.apache.mina.transport.socket.nio.SocketAcceptorConfig;
+import org.apache.mina.transport.socket.SocketAcceptor;
+import org.apache.mina.transport.socket.nio.NioSocketAcceptor;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -196,7 +208,7 @@
      */
     public LdapService()
     {
-        super.setIpPort( IP_PORT_DEFAULT );
+        super.setTcpPort( IP_PORT_DEFAULT );
         super.setEnabled( true );
         super.setServiceId( SERVICE_PID_DEFAULT );
         super.setServiceName( SERVICE_NAME_DEFAULT );
@@ -312,6 +324,17 @@
         {
             chain = new DefaultIoFilterChainBuilder();
         }
+        
+        // Inject the codec into the chain
+        ((DefaultIoFilterChainBuilder)chain).addLast( "codec", 
+                new ProtocolCodecFilter( this.getProtocolCodecFactory() ) );
+        
+        // Now inject an ExecutorFilter for the write operations
+        // We use the same number of thread than the number of IoProcessor
+        // (NOTE : this has to be double checked)
+        ((DefaultIoFilterChainBuilder)chain).addLast( "executor", 
+                new ExecutorFilter( new OrderedThreadPoolExecutor( getNbTcpThreads() ), 
+                    IoEventType.WRITE ) );
 
         /*
          * The server is now initialized, we can
@@ -320,7 +343,7 @@
          */ 
         installDefaultHandlers();      
 
-        startLDAP0( getIpPort(), chain );
+        startNetwork( getIpAddress(), getTcpPort(), getTcpBacklog(), chain );
         
         started = true;
         
@@ -354,7 +377,7 @@
             try
             {
                 sessions = new ArrayList<IoSession>(
-                        getSocketAcceptor().getManagedSessions( new InetSocketAddress( getIpPort() ) ) );
+                        getSocketAcceptor().getManagedSessions().values() );
             }
             catch ( IllegalArgumentException e )
             {
@@ -384,8 +407,8 @@
 
             for ( WriteFuture future:writeFutures )
             {
-                future.join( 1000 );
-                sessionIt.next().close();
+                future.await( 1000L );
+                sessionIt.next().close( true );
             }
         }
         catch ( Exception e )
@@ -406,9 +429,15 @@
     }
 
 
-    private void startLDAP0( int port, IoFilterChainBuilder chainBuilder )
+    private void startNetwork( String hostname, int port,int backlog, IoFilterChainBuilder chainBuilder )
         throws Exception
     {
+        if ( backlog < 0 ) 
+        {
+            // Set the baclog to the default value when it's below 0
+            backlog = 50;
+        }
+
         PartitionNexus nexus = getDirectoryService().getPartitionNexus();
 
         for ( ExtendedOperationHandler h : extendedOperationHandlers )
@@ -422,17 +451,51 @@
 
         try
         {
-            SocketAcceptorConfig acceptorCfg = new SocketAcceptorConfig();
-
+            // First, create the acceptor with the configured number of threads (if defined)
+            int nbTcpThreads = getNbTcpThreads();
+            SocketAcceptor acceptor;
+            
+            if ( nbTcpThreads > 0 )
+            {
+                acceptor = new NioSocketAcceptor( nbTcpThreads );
+            }
+            else
+            {
+                acceptor = new NioSocketAcceptor();
+            }
+            
+            setSocketAcceptor( acceptor );
+            
+            // Set the service backlog
+            acceptor.setBacklog( backlog );
+                
+            // Now, configure the acceptor
             // Disable the disconnection of the clients on unbind
-            acceptorCfg.setDisconnectOnUnbind( false );
-            acceptorCfg.setReuseAddress( true );
-            acceptorCfg.setFilterChainBuilder( chainBuilder );
-            acceptorCfg.setThreadModel( ThreadModel.MANUAL );
-
-            acceptorCfg.getSessionConfig().setTcpNoDelay( true );
-
-            getSocketAcceptor().bind( new InetSocketAddress( port ), getHandler(), acceptorCfg );
+            acceptor.setCloseOnDeactivation( false );
+            
+            // Allow the port to be reused even if the socket is in TIME_WAIT state
+            acceptor.setReuseAddress( true );
+            
+            // No Nagle's algorithm
+            acceptor.getSessionConfig().setTcpNoDelay( true );
+            
+            // Inject the chain
+            acceptor.setFilterChainBuilder( chainBuilder );
+            
+            // Inject the protocol handler
+            acceptor.setHandler( getHandler() );
+            
+            // Bind to the configured address
+            if ( StringTools.isEmpty( hostname ) )
+            {
+                acceptor.bind( new InetSocketAddress( port ) );
+            }
+            else
+            {
+                acceptor.bind( new InetSocketAddress( hostname, port ) );
+            }
+            
+            // We are done !
             started = true;
 
             if ( LOG.isInfoEnabled() )
@@ -876,10 +939,10 @@
 
     public void setAbandonHandler( LdapRequestHandler<AbandonRequest> abandonHandler )
     {
-        this.handler.removeMessageHandler( AbandonRequest.class );
+        this.handler.removeReceivedMessageHandler( AbandonRequest.class );
         this.abandonHandler = abandonHandler;
         this.abandonHandler.setLdapServer( this );
-        this.handler.addMessageHandler( AbandonRequest.class, this.abandonHandler );
+        this.handler.addReceivedMessageHandler( AbandonRequest.class, this.abandonHandler );
     }
 
 
@@ -891,10 +954,10 @@
 
     public void setAddHandler( LdapRequestHandler<AddRequest> addHandler )
     {
-        this.handler.removeMessageHandler( AddRequest.class );
+        this.handler.removeReceivedMessageHandler( AddRequest.class );
         this.addHandler = addHandler;
         this.addHandler.setLdapServer( this );
-        this.handler.addMessageHandler( AddRequest.class, this.addHandler );
+        this.handler.addReceivedMessageHandler( AddRequest.class, this.addHandler );
     }
 
 
@@ -906,10 +969,11 @@
 
     public void setBindHandler( LdapRequestHandler<BindRequest> bindHandler )
     {
-        this.handler.removeMessageHandler( BindRequest.class );
         this.bindHandler = bindHandler;
         this.bindHandler.setLdapServer( this );
-        this.handler.addMessageHandler( BindRequest.class, this.bindHandler );
+
+        handler.removeReceivedMessageHandler( BindRequest.class );
+        handler.addReceivedMessageHandler( BindRequest.class, this.bindHandler );
     }
 
 
@@ -921,10 +985,10 @@
 
     public void setCompareHandler( LdapRequestHandler<CompareRequest> compareHandler )
     {
-        this.handler.removeMessageHandler( CompareRequest.class );
+        this.handler.removeReceivedMessageHandler( CompareRequest.class );
         this.compareHandler = compareHandler;
         this.compareHandler.setLdapServer( this );
-        this.handler.addMessageHandler( CompareRequest.class, this.compareHandler );
+        this.handler.addReceivedMessageHandler( CompareRequest.class, this.compareHandler );
     }
 
 
@@ -936,10 +1000,10 @@
 
     public void setDeleteHandler( LdapRequestHandler<DeleteRequest> deleteHandler )
     {
-        this.handler.removeMessageHandler( DeleteRequest.class );
+        this.handler.removeReceivedMessageHandler( DeleteRequest.class );
         this.deleteHandler = deleteHandler;
         this.deleteHandler.setLdapServer( this );
-        this.handler.addMessageHandler( DeleteRequest.class, this.deleteHandler );
+        this.handler.addReceivedMessageHandler( DeleteRequest.class, this.deleteHandler );
     }
 
 
@@ -951,10 +1015,10 @@
 
     public void setExtendedHandler( LdapRequestHandler<ExtendedRequest> extendedHandler )
     {
-        this.handler.removeMessageHandler( ExtendedRequest.class );
+        this.handler.removeReceivedMessageHandler( ExtendedRequest.class );
         this.extendedHandler = extendedHandler;
         this.extendedHandler.setLdapServer( this );
-        this.handler.addMessageHandler( ExtendedRequest.class, this.extendedHandler );
+        this.handler.addReceivedMessageHandler( ExtendedRequest.class, this.extendedHandler );
     }
 
 
@@ -966,10 +1030,10 @@
 
     public void setModifyHandler( LdapRequestHandler<ModifyRequest> modifyHandler )
     {
-        this.handler.removeMessageHandler( ModifyRequest.class );
+        this.handler.removeReceivedMessageHandler( ModifyRequest.class );
         this.modifyHandler = modifyHandler;
         this.modifyHandler.setLdapServer( this );
-        this.handler.addMessageHandler( ModifyRequest.class, this.modifyHandler );
+        this.handler.addReceivedMessageHandler( ModifyRequest.class, this.modifyHandler );
     }
 
 
@@ -981,10 +1045,10 @@
 
     public void setModifyDnHandler( LdapRequestHandler<ModifyDnRequest> modifyDnHandler )
     {
-        this.handler.removeMessageHandler( ModifyDnRequest.class );
+        this.handler.removeReceivedMessageHandler( ModifyDnRequest.class );
         this.modifyDnHandler = modifyDnHandler;
         this.modifyDnHandler.setLdapServer( this );
-        this.handler.addMessageHandler( ModifyDnRequest.class, this.modifyDnHandler );
+        this.handler.addReceivedMessageHandler( ModifyDnRequest.class, this.modifyDnHandler );
     }
 
 
@@ -996,10 +1060,10 @@
 
     public void setSearchHandler( LdapRequestHandler<SearchRequest> searchHandler )
     {
-        this.handler.removeMessageHandler( SearchRequest.class );
+        this.handler.removeReceivedMessageHandler( SearchRequest.class );
         this.searchHandler = searchHandler;
         this.searchHandler.setLdapServer( this );
-        this.handler.addMessageHandler( SearchRequest.class, this.searchHandler );
+        this.handler.addReceivedMessageHandler( SearchRequest.class, this.searchHandler );
     }
 
 
@@ -1011,10 +1075,10 @@
 
     public void setUnbindHandler( LdapRequestHandler<UnbindRequest> unbindHandler )
     {
-        this.handler.removeMessageHandler( UnbindRequest.class );
+        this.handler.removeReceivedMessageHandler( UnbindRequest.class );
         this.unbindHandler = unbindHandler;
         this.unbindHandler.setLdapServer( this );
-        this.handler.addMessageHandler( UnbindRequest.class, this.unbindHandler );
+        this.handler.addReceivedMessageHandler( UnbindRequest.class, this.unbindHandler );
     }
 
 

Modified: directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapSession.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapSession.java?rev=725712&r1=725711&r2=725712&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapSession.java (original)
+++ directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapSession.java Thu Dec 11 07:32:04 2008
@@ -28,7 +28,7 @@
 import org.apache.directory.server.core.CoreSession;
 import org.apache.directory.shared.ldap.message.AbandonableRequest;
 import org.apache.directory.shared.ldap.message.BindStatus;
-import org.apache.mina.common.IoSession;
+import org.apache.mina.core.session.IoSession;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 

Modified: directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapSessionManager.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapSessionManager.java?rev=725712&r1=725711&r2=725712&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapSessionManager.java (original)
+++ directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapSessionManager.java Thu Dec 11 07:32:04 2008
@@ -23,7 +23,7 @@
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 
-import org.apache.mina.common.IoSession;
+import org.apache.mina.core.session.IoSession;
 
 
 /**

Modified: directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/gui/SessionsFrame.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/gui/SessionsFrame.java?rev=725712&r1=725711&r2=725712&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/gui/SessionsFrame.java (original)
+++ directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/gui/SessionsFrame.java Thu Dec 11 07:32:04 2008
@@ -50,11 +50,11 @@
 import org.apache.directory.server.ldap.handlers.extended.GracefulShutdownHandler;
 import org.apache.directory.shared.ldap.message.extended.GracefulDisconnect;
 import org.apache.directory.shared.ldap.message.extended.NoticeOfDisconnect;
-import org.apache.mina.common.CloseFuture;
-import org.apache.mina.common.IoAcceptor;
-import org.apache.mina.common.IoHandler;
-import org.apache.mina.common.IoSession;
-import org.apache.mina.common.WriteFuture;
+import org.apache.mina.core.future.CloseFuture;
+import org.apache.mina.core.future.WriteFuture;
+import org.apache.mina.core.service.IoAcceptor;
+import org.apache.mina.core.service.IoHandler;
+import org.apache.mina.core.session.IoSession;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -481,9 +481,9 @@
                     WriteFuture future = selected.getIoSession().write( NoticeOfDisconnect.STRONGAUTHREQUIRED );
                     try
                     {
-                        future.join( 1000 );
-                        CloseFuture cfuture = selected.getIoSession().close();
-                        cfuture.join( 1000 );
+                        future.awaitUninterruptibly( 1000L );
+                        CloseFuture cfuture = selected.getIoSession().close( true );
+                        cfuture.awaitUninterruptibly( 1000L );
                     }
                     catch ( Exception e1 )
                     {
@@ -726,7 +726,7 @@
                         "Send graceful disconnect before disconnect notice?", JOptionPane.YES_NO_CANCEL_OPTION );
                     IoAcceptor acceptor = ( IoAcceptor ) requestor.getService();
                     List<IoSession> sessions = new ArrayList<IoSession>(
-                            acceptor.getManagedSessions( requestor.getServiceAddress() ) );
+                            acceptor.getManagedSessions().values() );
 
                     if ( input == JOptionPane.CANCEL_OPTION )
                     {
@@ -826,7 +826,8 @@
                 {
                     try
                     {
-                        ( ( IoAcceptor ) requestor.getService() ).bind( requestor.getServiceAddress(), getLdapProvider() );
+                        ( ( IoAcceptor ) requestor.getService() ).setHandler( getLdapProvider() );
+                        ( ( IoAcceptor ) requestor.getService() ).bind( requestor.getServiceAddress() );
                         JOptionPane.showMessageDialog( SessionsFrame.this, "Ldap service " + requestor.getServiceAddress()
                             + " has been successfully bound.\n" + " Clients may now connect to the server once again.",
                             "Success!", JOptionPane.INFORMATION_MESSAGE );

Modified: directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/AddHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/AddHandler.java?rev=725712&r1=725711&r2=725712&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/AddHandler.java (original)
+++ directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/AddHandler.java Thu Dec 11 07:32:04 2008
@@ -38,7 +38,7 @@
  */
 public class AddHandler extends LdapRequestHandler<AddRequest>
 {
-	/** The logger for this class */
+    /** The logger for this class */
     private static final Logger LOG = LoggerFactory.getLogger( AddHandler.class );
     
     
@@ -52,7 +52,7 @@
 
         try
         {
-        	// Call the underlying layer to inject the new entry 
+            // Call the underlying layer to inject the new entry 
             CoreSession coreSession = session.getCoreSession();
             coreSession.add( req );
 

Modified: directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/BindHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/BindHandler.java?rev=725712&r1=725711&r2=725712&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/BindHandler.java (original)
+++ directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/BindHandler.java Thu Dec 11 07:32:04 2008
@@ -169,22 +169,22 @@
             // opContext.setEntry( principalEntry );
 
             // And call the OperationManager bind operation.
-	        getLdapServer().getDirectoryService().getOperationManager().bind( opContext );
-	        
-	        // As a result, store the created session in the Core Session
-	        ldapSession.setCoreSession( opContext.getSession() );
-	        
-	        if ( ! ldapSession.getCoreSession().isAnonymous() )
-	        {
-	            ldapSession.setAuthenticated();
-	        }
-	        
-	        // Return the successful response
-	        sendBindSuccess( ldapSession, bindRequest, null );
+            getLdapServer().getDirectoryService().getOperationManager().bind( opContext );
+            
+            // As a result, store the created session in the Core Session
+            ldapSession.setCoreSession( opContext.getSession() );
+            
+            if ( ! ldapSession.getCoreSession().isAnonymous() )
+            {
+                ldapSession.setAuthenticated();
+            }
+            
+            // Return the successful response
+            sendBindSuccess( ldapSession, bindRequest, null );
         }
         catch ( Exception e )
         {
-        	// Something went wrong. Write back an error message        	
+            // Something went wrong. Write back an error message            
             ResultCodeEnum code = null;
             LdapResult result = bindRequest.getResultResponse().getLdapResult();
 
@@ -211,7 +211,7 @@
             
             if ( e instanceof LdapAuthenticationException )
             {
-            	name = ( ( LdapAuthenticationException ) e ).getResolvedName();
+                name = ( ( LdapAuthenticationException ) e ).getResolvedName();
             }
             
             if ( ( name != null )

Modified: directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/LdapRequestHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/LdapRequestHandler.java?rev=725712&r1=725711&r2=725712&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/LdapRequestHandler.java (original)
+++ directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/LdapRequestHandler.java Thu Dec 11 07:32:04 2008
@@ -40,8 +40,8 @@
 import org.apache.directory.shared.ldap.message.ResultResponseRequest;
 import org.apache.directory.shared.ldap.name.LdapDN;
 import org.apache.directory.shared.ldap.util.ExceptionUtils;
-import org.apache.mina.common.IoFilterChain;
-import org.apache.mina.common.IoSession;
+import org.apache.mina.core.filterchain.IoFilterChain;
+import org.apache.mina.core.session.IoSession;
 import org.apache.mina.handler.demux.MessageHandler;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -118,19 +118,11 @@
     }
 
 
-    /**
-     * Handle a LDAP message received during a session.
-     * 
-     * @param session the user session created when the user first connected
-     * to the server
-     * @param message the LDAP message received. Can be any of the LDAP Request
-     * @throws Exception the thrown exception if something went wrong during 
-     * the message processing
-     */
-    public final void messageReceived( IoSession session, T message ) throws Exception
+    public final void handleMessage( IoSession session, T message ) throws Exception
     {
         LdapSession ldapSession = ldapService.getLdapSessionManager().getLdapSession( session );
         
+        //handle( ldapSession, message );
         // TODO - session you get from LdapService should have the ldapService 
         // member already set no?  Should remove these lines where ever they
         // may be if that's the case.
@@ -167,7 +159,7 @@
         // only if it's not a BindRequest
         if ( message instanceof BindRequest )
         {
-        	handle( ldapSession, message );
+            handle( ldapSession, message );
         }
         else
         {
@@ -197,7 +189,6 @@
             return;
         }
     }
-
     
     /**
      * Handle a Ldap message associated with a session



Mime
View raw message