directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From erodrig...@apache.org
Subject svn commit: r396170 - in /directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos: kdc/ kdc/authentication/ kdc/preauthentication/ kdc/ticketgrant/ protocol/
Date Sat, 22 Apr 2006 22:03:03 GMT
Author: erodriguez
Date: Sat Apr 22 15:02:59 2006
New Revision: 396170

URL: http://svn.apache.org/viewcvs?rev=396170&view=rev
Log:
Updated protocol-kerberos to use MINA IoHandlerChain, replacing protocol-common chain.

Removed:
    directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/authentication/AuthenticationExceptionHandler.java
    directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/ticketgrant/TicketGrantingExceptionHandler.java
Modified:
    directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/KdcContext.java
    directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/MonitorContext.java
    directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/MonitorReply.java
    directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/MonitorRequest.java
    directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/SelectChecksumType.java
    directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/SelectEncryptionType.java
    directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/authentication/AuthenticationServiceChain.java
    directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/authentication/BuildReply.java
    directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/authentication/ConfigureAuthenticationChain.java
    directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/authentication/GenerateTicket.java
    directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/authentication/GetClientEntry.java
    directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/authentication/GetServerEntry.java
    directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/authentication/GetSessionKey.java
    directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/authentication/SealReply.java
    directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/preauthentication/PreAuthenticationChain.java
    directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/preauthentication/VerifierBase.java
    directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/preauthentication/VerifyEncryptedTimestamp.java
    directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/preauthentication/VerifySam.java
    directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/ticketgrant/BuildReply.java
    directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/ticketgrant/ConfigureTicketGrantingChain.java
    directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/ticketgrant/GenerateTicket.java
    directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/ticketgrant/GetAuthHeader.java
    directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/ticketgrant/GetRequestPrincipalEntry.java
    directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/ticketgrant/GetSessionKey.java
    directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/ticketgrant/GetTicketPrincipalEntry.java
    directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/ticketgrant/MonitorContext.java
    directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/ticketgrant/SealReply.java
    directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/ticketgrant/TicketGrantingServiceChain.java
    directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/ticketgrant/VerifyBodyChecksum.java
    directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/ticketgrant/VerifyTgt.java
    directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/ticketgrant/VerifyTgtAuthHeader.java
    directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/protocol/KerberosProtocolHandler.java

Modified: directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/KdcContext.java
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/KdcContext.java?rev=396170&r1=396169&r2=396170&view=diff
==============================================================================
--- directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/KdcContext.java (original)
+++ directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/KdcContext.java Sat Apr 22 15:02:59 2006
@@ -23,10 +23,9 @@
 import org.apache.directory.server.kerberos.shared.messages.KerberosMessage;
 import org.apache.directory.server.kerberos.shared.service.LockBox;
 import org.apache.directory.server.kerberos.shared.store.PrincipalStore;
-import org.apache.directory.server.protocol.shared.chain.impl.ContextBase;
 
 
-public class KdcContext extends ContextBase
+public class KdcContext
 {
     private static final long serialVersionUID = 6490030984626825108L;
 

Modified: directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/MonitorContext.java
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/MonitorContext.java?rev=396170&r1=396169&r2=396170&view=diff
==============================================================================
--- directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/MonitorContext.java (original)
+++ directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/MonitorContext.java Sat Apr 22 15:02:59 2006
@@ -17,21 +17,22 @@
 package org.apache.directory.server.kerberos.kdc;
 
 
-import org.apache.directory.server.protocol.shared.chain.Context;
-import org.apache.directory.server.protocol.shared.chain.impl.CommandBase;
+import org.apache.mina.common.IoSession;
+import org.apache.mina.handler.chain.IoHandlerCommand;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 
-public class MonitorContext extends CommandBase
+public class MonitorContext implements IoHandlerCommand
 {
     /** the log for this class */
     private static final Logger log = LoggerFactory.getLogger( MonitorContext.class );
 
+    private String contextKey = "context";
 
-    public boolean execute( Context context ) throws Exception
+    public void execute( NextCommand next, IoSession session, Object message ) throws Exception
     {
-        KdcContext kdcContext = ( KdcContext ) context;
+        KdcContext kdcContext = ( KdcContext ) session.getAttribute( getContextKey() );
 
         if ( log.isDebugEnabled() )
         {
@@ -40,6 +41,12 @@
                 + kdcContext.getRequest() + "\n\treply:                  " + kdcContext.getReply() );
         }
 
-        return CONTINUE_CHAIN;
+        next.execute( session, message );
+    }
+
+
+    public String getContextKey()
+    {
+        return ( this.contextKey );
     }
 }

Modified: directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/MonitorReply.java
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/MonitorReply.java?rev=396170&r1=396169&r2=396170&view=diff
==============================================================================
--- directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/MonitorReply.java (original)
+++ directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/MonitorReply.java Sat Apr 22 15:02:59 2006
@@ -19,45 +19,46 @@
 
 import org.apache.directory.server.kerberos.shared.messages.ErrorMessage;
 import org.apache.directory.server.kerberos.shared.messages.KdcReply;
-import org.apache.directory.server.protocol.shared.chain.Context;
-import org.apache.directory.server.protocol.shared.chain.impl.CommandBase;
+import org.apache.mina.common.IoSession;
+import org.apache.mina.handler.chain.IoHandlerCommand;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 
-public class MonitorReply extends CommandBase
+public class MonitorReply implements IoHandlerCommand
 {
     /** the log for this class */
     private static final Logger log = LoggerFactory.getLogger( MonitorReply.class );
 
+    private String contextKey = "context";
 
-    public boolean execute( Context context ) throws Exception
+    public void execute( NextCommand next, IoSession session, Object message ) throws Exception
     {
-        KdcContext kdcContext = ( KdcContext ) context;
-        Object message = kdcContext.getReply();
+        KdcContext kdcContext = ( KdcContext ) session.getAttribute( getContextKey() );
+        Object reply = kdcContext.getReply();
 
-        if ( message instanceof KdcReply )
+        if ( reply instanceof KdcReply )
         {
-            KdcReply reply = ( KdcReply ) message;
+            KdcReply success = ( KdcReply ) reply;
 
             if ( log.isDebugEnabled() )
             {
                 log.debug( "Responding to authentication request with reply:" + "\n\tclient realm:          "
-                    + reply.getClientRealm() + "\n\tserver realm:          " + reply.getServerRealm()
-                    + "\n\tserverPrincipal:       " + reply.getServerPrincipal() + "\n\tclientPrincipal:       "
-                    + reply.getClientPrincipal() + "\n\thostAddresses:         " + reply.getClientAddresses()
-                    + "\n\tstart time:            " + reply.getStartTime() + "\n\tend time:              "
-                    + reply.getEndTime() + "\n\tauth time:             " + reply.getAuthTime()
-                    + "\n\trenew till time:       " + reply.getRenewTill() + "\n\tmessageType:           "
-                    + reply.getMessageType() + "\n\tnonce:                 " + reply.getNonce()
-                    + "\n\tprotocolVersionNumber: " + reply.getProtocolVersionNumber() );
+                    + success.getClientRealm() + "\n\tserver realm:          " + success.getServerRealm()
+                    + "\n\tserverPrincipal:       " + success.getServerPrincipal() + "\n\tclientPrincipal:       "
+                    + success.getClientPrincipal() + "\n\thostAddresses:         " + success.getClientAddresses()
+                    + "\n\tstart time:            " + success.getStartTime() + "\n\tend time:              "
+                    + success.getEndTime() + "\n\tauth time:             " + success.getAuthTime()
+                    + "\n\trenew till time:       " + success.getRenewTill() + "\n\tmessageType:           "
+                    + success.getMessageType() + "\n\tnonce:                 " + success.getNonce()
+                    + "\n\tprotocolVersionNumber: " + success.getProtocolVersionNumber() );
             }
         }
         else
         {
-            if ( message instanceof ErrorMessage )
+            if ( reply instanceof ErrorMessage )
             {
-                ErrorMessage error = ( ErrorMessage ) message;
+                ErrorMessage error = ( ErrorMessage ) reply;
 
                 if ( log.isDebugEnabled() )
                 {
@@ -70,6 +71,12 @@
             }
         }
 
-        return CONTINUE_CHAIN;
+        next.execute( session, message );
+    }
+
+
+    public String getContextKey()
+    {
+        return ( this.contextKey );
     }
 }

Modified: directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/MonitorRequest.java
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/MonitorRequest.java?rev=396170&r1=396169&r2=396170&view=diff
==============================================================================
--- directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/MonitorRequest.java (original)
+++ directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/MonitorRequest.java Sat Apr 22 15:02:59 2006
@@ -19,21 +19,22 @@
 
 import org.apache.directory.server.kerberos.shared.crypto.encryption.EncryptionType;
 import org.apache.directory.server.kerberos.shared.messages.KdcRequest;
-import org.apache.directory.server.protocol.shared.chain.Context;
-import org.apache.directory.server.protocol.shared.chain.impl.CommandBase;
+import org.apache.mina.common.IoSession;
+import org.apache.mina.handler.chain.IoHandlerCommand;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 
-public class MonitorRequest extends CommandBase
+public class MonitorRequest implements IoHandlerCommand
 {
     /** the log for this class */
     private static final Logger log = LoggerFactory.getLogger( MonitorRequest.class );
 
+    private String contextKey = "context";
 
-    public boolean execute( Context context ) throws Exception
+    public void execute( NextCommand next, IoSession session, Object message ) throws Exception
     {
-        KdcContext kdcContext = ( KdcContext ) context;
+        KdcContext kdcContext = ( KdcContext ) session.getAttribute( getContextKey() );
         KdcRequest request = kdcContext.getRequest();
         String clientAddress = kdcContext.getClientAddress().getHostAddress();
 
@@ -50,7 +51,7 @@
                 + request.getProtocolVersionNumber() + "\n\ttill:                  " + request.getTill() );
         }
 
-        return CONTINUE_CHAIN;
+        next.execute( session, message );
     }
 
 
@@ -71,5 +72,11 @@
         }
 
         return sb.toString();
+    }
+
+
+    public String getContextKey()
+    {
+        return ( this.contextKey );
     }
 }

Modified: directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/SelectChecksumType.java
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/SelectChecksumType.java?rev=396170&r1=396169&r2=396170&view=diff
==============================================================================
--- directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/SelectChecksumType.java (original)
+++ directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/SelectChecksumType.java Sat Apr 22 15:02:59 2006
@@ -20,13 +20,13 @@
 import org.apache.directory.server.kerberos.shared.crypto.checksum.ChecksumType;
 import org.apache.directory.server.kerberos.shared.exceptions.ErrorType;
 import org.apache.directory.server.kerberos.shared.exceptions.KerberosException;
-import org.apache.directory.server.protocol.shared.chain.Context;
-import org.apache.directory.server.protocol.shared.chain.impl.CommandBase;
+import org.apache.mina.common.IoSession;
+import org.apache.mina.handler.chain.IoHandlerCommand;
 
 
-public class SelectChecksumType extends CommandBase
+public class SelectChecksumType implements IoHandlerCommand
 {
-    public boolean execute( Context context ) throws Exception
+    public void execute( NextCommand next, IoSession session, Object message ) throws Exception
     {
         boolean isAllowedChecksumType = true;
 
@@ -35,7 +35,7 @@
             throw new KerberosException( ErrorType.KDC_ERR_SUMTYPE_NOSUPP );
         }
 
-        return CONTINUE_CHAIN;
+        next.execute( session, message );
     }
 
 

Modified: directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/SelectEncryptionType.java
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/SelectEncryptionType.java?rev=396170&r1=396169&r2=396170&view=diff
==============================================================================
--- directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/SelectEncryptionType.java (original)
+++ directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/SelectEncryptionType.java Sat Apr 22 15:02:59 2006
@@ -20,15 +20,17 @@
 import org.apache.directory.server.kerberos.shared.crypto.encryption.EncryptionType;
 import org.apache.directory.server.kerberos.shared.exceptions.ErrorType;
 import org.apache.directory.server.kerberos.shared.exceptions.KerberosException;
-import org.apache.directory.server.protocol.shared.chain.Context;
-import org.apache.directory.server.protocol.shared.chain.impl.CommandBase;
+import org.apache.mina.common.IoSession;
+import org.apache.mina.handler.chain.IoHandlerCommand;
 
 
-public class SelectEncryptionType extends CommandBase
+public class SelectEncryptionType implements IoHandlerCommand
 {
-    public boolean execute( Context context ) throws Exception
+    private String contextKey = "context";
+
+    public void execute( NextCommand next, IoSession session, Object message ) throws Exception
     {
-        KdcContext kdcContext = ( KdcContext ) context;
+        KdcContext kdcContext = ( KdcContext ) session.getAttribute( getContextKey() );
         KdcConfiguration config = kdcContext.getConfig();
 
         EncryptionType[] requestedTypes = kdcContext.getRequest().getEType();
@@ -40,7 +42,7 @@
             throw new KerberosException( ErrorType.KDC_ERR_ETYPE_NOSUPP );
         }
 
-        return CONTINUE_CHAIN;
+        next.execute( session, message );
     }
 
 
@@ -58,5 +60,11 @@
         }
 
         return null;
+    }
+
+
+    public String getContextKey()
+    {
+        return ( this.contextKey );
     }
 }

Modified: directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/authentication/AuthenticationServiceChain.java
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/authentication/AuthenticationServiceChain.java?rev=396170&r1=396169&r2=396170&view=diff
==============================================================================
--- directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/authentication/AuthenticationServiceChain.java (original)
+++ directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/authentication/AuthenticationServiceChain.java Sat Apr 22 15:02:59 2006
@@ -19,23 +19,21 @@
 
 import org.apache.directory.server.kerberos.kdc.MonitorRequest;
 import org.apache.directory.server.kerberos.kdc.preauthentication.PreAuthenticationChain;
-import org.apache.directory.server.protocol.shared.chain.impl.ChainBase;
+import org.apache.mina.handler.chain.IoHandlerChain;
 
 
-public class AuthenticationServiceChain extends ChainBase
+public class AuthenticationServiceChain extends IoHandlerChain
 {
     public AuthenticationServiceChain()
     {
-        super();
-        addCommand( new AuthenticationExceptionHandler() );
-        addCommand( new MonitorRequest() );
-        addCommand( new ConfigureAuthenticationChain() );
-        addCommand( new GetClientEntry() );
-        addCommand( new PreAuthenticationChain() );
-        addCommand( new GetServerEntry() );
-        addCommand( new GetSessionKey() );
-        addCommand( new GenerateTicket() );
-        addCommand( new BuildReply() );
-        addCommand( new SealReply() );
+        addLast( "monitorRequest", new MonitorRequest() );
+        addLast( "configureAuthenticationChain", new ConfigureAuthenticationChain() );
+        addLast( "getClientEntry", new GetClientEntry() );
+        addLast( "preAuthenticationChain", new PreAuthenticationChain() );
+        addLast( "getServerEntry", new GetServerEntry() );
+        addLast( "getSessionKey", new GetSessionKey() );
+        addLast( "generateTicket", new GenerateTicket() );
+        addLast( "buildReply", new BuildReply() );
+        addLast( "sealReply", new SealReply() );
     }
 }

Modified: directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/authentication/BuildReply.java
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/authentication/BuildReply.java?rev=396170&r1=396169&r2=396170&view=diff
==============================================================================
--- directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/authentication/BuildReply.java (original)
+++ directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/authentication/BuildReply.java Sat Apr 22 15:02:59 2006
@@ -22,15 +22,17 @@
 import org.apache.directory.server.kerberos.shared.messages.components.Ticket;
 import org.apache.directory.server.kerberos.shared.messages.value.LastRequest;
 import org.apache.directory.server.kerberos.shared.messages.value.TicketFlags;
-import org.apache.directory.server.protocol.shared.chain.Context;
-import org.apache.directory.server.protocol.shared.chain.impl.CommandBase;
+import org.apache.mina.common.IoSession;
+import org.apache.mina.handler.chain.IoHandlerCommand;
 
 
-public class BuildReply extends CommandBase
+public class BuildReply implements IoHandlerCommand
 {
-    public boolean execute( Context ctx ) throws Exception
+    private String contextKey = "context";
+
+    public void execute( NextCommand next, IoSession session, Object message ) throws Exception
     {
-        AuthenticationContext authContext = ( AuthenticationContext ) ctx;
+        AuthenticationContext authContext = ( AuthenticationContext ) session.getAttribute( getContextKey() );
         KdcRequest request = authContext.getRequest();
         Ticket ticket = authContext.getTicket();
 
@@ -61,6 +63,12 @@
 
         authContext.setReply( reply );
 
-        return CONTINUE_CHAIN;
+        next.execute( session, message );
+    }
+
+
+    public String getContextKey()
+    {
+        return ( this.contextKey );
     }
 }

Modified: directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/authentication/ConfigureAuthenticationChain.java
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/authentication/ConfigureAuthenticationChain.java?rev=396170&r1=396169&r2=396170&view=diff
==============================================================================
--- directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/authentication/ConfigureAuthenticationChain.java (original)
+++ directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/authentication/ConfigureAuthenticationChain.java Sat Apr 22 15:02:59 2006
@@ -27,19 +27,20 @@
 import org.apache.directory.server.kerberos.shared.replay.InMemoryReplayCache;
 import org.apache.directory.server.kerberos.shared.replay.ReplayCache;
 import org.apache.directory.server.kerberos.shared.service.LockBox;
-import org.apache.directory.server.protocol.shared.chain.Context;
-import org.apache.directory.server.protocol.shared.chain.impl.CommandBase;
+import org.apache.mina.common.IoSession;
+import org.apache.mina.handler.chain.IoHandlerCommand;
 
 
-public class ConfigureAuthenticationChain extends CommandBase
+public class ConfigureAuthenticationChain implements IoHandlerCommand
 {
     private static final ReplayCache replayCache = new InMemoryReplayCache();
     private static final LockBox lockBox = new LockBox();
 
+    private String contextKey = "context";
 
-    public boolean execute( Context context ) throws Exception
+    public void execute( NextCommand next, IoSession session, Object message ) throws Exception
     {
-        AuthenticationContext authContext = ( AuthenticationContext ) context;
+        AuthenticationContext authContext = ( AuthenticationContext ) session.getAttribute( getContextKey() );
 
         authContext.setReplayCache( replayCache );
         authContext.setLockBox( lockBox );
@@ -50,6 +51,12 @@
         checksumEngines.put( ChecksumType.RSA_MD5, new RsaMd5Checksum() );
         checksumEngines.put( ChecksumType.SHA1, new Sha1Checksum() );
 
-        return CONTINUE_CHAIN;
+        next.execute( session, message );
+    }
+
+
+    public String getContextKey()
+    {
+        return ( this.contextKey );
     }
 }

Modified: directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/authentication/GenerateTicket.java
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/authentication/GenerateTicket.java?rev=396170&r1=396169&r2=396170&view=diff
==============================================================================
--- directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/authentication/GenerateTicket.java (original)
+++ directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/authentication/GenerateTicket.java Sat Apr 22 15:02:59 2006
@@ -33,21 +33,22 @@
 import org.apache.directory.server.kerberos.shared.messages.value.TicketFlags;
 import org.apache.directory.server.kerberos.shared.messages.value.TransitedEncoding;
 import org.apache.directory.server.kerberos.shared.service.LockBox;
-import org.apache.directory.server.protocol.shared.chain.Context;
-import org.apache.directory.server.protocol.shared.chain.impl.CommandBase;
+import org.apache.mina.common.IoSession;
+import org.apache.mina.handler.chain.IoHandlerCommand;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 
-public class GenerateTicket extends CommandBase
+public class GenerateTicket implements IoHandlerCommand
 {
     /** the log for this class */
     private static final Logger log = LoggerFactory.getLogger( GenerateTicket.class );
 
+    private String contextKey = "context";
 
-    public boolean execute( Context context ) throws Exception
+    public void execute( NextCommand next, IoSession session, Object message ) throws Exception
     {
-        AuthenticationContext authContext = ( AuthenticationContext ) context;
+        AuthenticationContext authContext = ( AuthenticationContext ) session.getAttribute( getContextKey() );
 
         KdcRequest request = authContext.getRequest();
         LockBox lockBox = authContext.getLockBox();
@@ -176,6 +177,12 @@
 
         authContext.setTicket( newTicket );
 
-        return CONTINUE_CHAIN;
+        next.execute( session, message );
+    }
+
+
+    public String getContextKey()
+    {
+        return ( this.contextKey );
     }
 }

Modified: directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/authentication/GetClientEntry.java
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/authentication/GetClientEntry.java?rev=396170&r1=396169&r2=396170&view=diff
==============================================================================
--- directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/authentication/GetClientEntry.java (original)
+++ directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/authentication/GetClientEntry.java Sat Apr 22 15:02:59 2006
@@ -22,20 +22,20 @@
 import org.apache.directory.server.kerberos.shared.exceptions.ErrorType;
 import org.apache.directory.server.kerberos.shared.service.GetPrincipalStoreEntry;
 import org.apache.directory.server.kerberos.shared.store.PrincipalStore;
-import org.apache.directory.server.protocol.shared.chain.Context;
+import org.apache.mina.common.IoSession;
 
 
 public class GetClientEntry extends GetPrincipalStoreEntry
 {
-    public boolean execute( Context context ) throws Exception
+    public void execute( NextCommand next, IoSession session, Object message ) throws Exception
     {
-        AuthenticationContext authContext = ( AuthenticationContext ) context;
+        AuthenticationContext authContext = ( AuthenticationContext ) session.getAttribute( getContextKey() );
 
         KerberosPrincipal principal = authContext.getRequest().getClientPrincipal();
         PrincipalStore store = authContext.getStore();
 
         authContext.setClientEntry( getEntry( principal, store, ErrorType.KDC_ERR_C_PRINCIPAL_UNKNOWN ) );
 
-        return CONTINUE_CHAIN;
+        next.execute( session, message );
     }
 }

Modified: directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/authentication/GetServerEntry.java
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/authentication/GetServerEntry.java?rev=396170&r1=396169&r2=396170&view=diff
==============================================================================
--- directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/authentication/GetServerEntry.java (original)
+++ directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/authentication/GetServerEntry.java Sat Apr 22 15:02:59 2006
@@ -22,20 +22,20 @@
 import org.apache.directory.server.kerberos.shared.exceptions.ErrorType;
 import org.apache.directory.server.kerberos.shared.service.GetPrincipalStoreEntry;
 import org.apache.directory.server.kerberos.shared.store.PrincipalStore;
-import org.apache.directory.server.protocol.shared.chain.Context;
+import org.apache.mina.common.IoSession;
 
 
 public class GetServerEntry extends GetPrincipalStoreEntry
 {
-    public boolean execute( Context context ) throws Exception
+    public void execute( NextCommand next, IoSession session, Object message ) throws Exception
     {
-        AuthenticationContext authContext = ( AuthenticationContext ) context;
+        AuthenticationContext authContext = ( AuthenticationContext ) session.getAttribute( getContextKey() );
 
         KerberosPrincipal principal = authContext.getRequest().getServerPrincipal();
         PrincipalStore store = authContext.getStore();
 
         authContext.setServerEntry( getEntry( principal, store, ErrorType.KDC_ERR_S_PRINCIPAL_UNKNOWN ) );
 
-        return CONTINUE_CHAIN;
+        next.execute( session, message );
     }
 }

Modified: directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/authentication/GetSessionKey.java
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/authentication/GetSessionKey.java?rev=396170&r1=396169&r2=396170&view=diff
==============================================================================
--- directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/authentication/GetSessionKey.java (original)
+++ directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/authentication/GetSessionKey.java Sat Apr 22 15:02:59 2006
@@ -22,7 +22,7 @@
 import org.apache.directory.server.kerberos.shared.crypto.encryption.EncryptionType;
 import org.apache.directory.server.kerberos.shared.messages.value.EncryptionKey;
 import org.apache.directory.server.kerberos.shared.service.DesStringToKey;
-import org.apache.directory.server.protocol.shared.chain.Context;
+import org.apache.mina.common.IoSession;
 
 
 public class GetSessionKey extends DesStringToKey
@@ -30,12 +30,12 @@
     private static final SecureRandom random = new SecureRandom();
 
 
-    public boolean execute( Context context ) throws Exception
+    public void execute( NextCommand next, IoSession session, Object message ) throws Exception
     {
-        AuthenticationContext authContext = ( AuthenticationContext ) context;
+        AuthenticationContext authContext = ( AuthenticationContext ) session.getAttribute( getContextKey() );
         authContext.setSessionKey( getNewSessionKey() );
 
-        return CONTINUE_CHAIN;
+        next.execute( session, message );
     }
 
 

Modified: directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/authentication/SealReply.java
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/authentication/SealReply.java?rev=396170&r1=396169&r2=396170&view=diff
==============================================================================
--- directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/authentication/SealReply.java (original)
+++ directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/authentication/SealReply.java Sat Apr 22 15:02:59 2006
@@ -21,15 +21,17 @@
 import org.apache.directory.server.kerberos.shared.messages.value.EncryptedData;
 import org.apache.directory.server.kerberos.shared.messages.value.EncryptionKey;
 import org.apache.directory.server.kerberos.shared.service.LockBox;
-import org.apache.directory.server.protocol.shared.chain.Context;
-import org.apache.directory.server.protocol.shared.chain.impl.CommandBase;
+import org.apache.mina.common.IoSession;
+import org.apache.mina.handler.chain.IoHandlerCommand;
 
 
-public class SealReply extends CommandBase
+public class SealReply implements IoHandlerCommand
 {
-    public boolean execute( Context context ) throws Exception
+    private String contextKey = "context";
+
+    public void execute( NextCommand next, IoSession session, Object message ) throws Exception
     {
-        AuthenticationContext authContext = ( AuthenticationContext ) context;
+        AuthenticationContext authContext = ( AuthenticationContext ) session.getAttribute( getContextKey() );
 
         AuthenticationReply reply = ( AuthenticationReply ) authContext.getReply();
         EncryptionKey clientKey = authContext.getClientKey();
@@ -38,6 +40,12 @@
         EncryptedData encryptedData = lockBox.seal( clientKey, reply );
         reply.setEncPart( encryptedData );
 
-        return CONTINUE_CHAIN;
+        next.execute( session, message );
+    }
+
+
+    public String getContextKey()
+    {
+        return ( this.contextKey );
     }
 }

Modified: directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/preauthentication/PreAuthenticationChain.java
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/preauthentication/PreAuthenticationChain.java?rev=396170&r1=396169&r2=396170&view=diff
==============================================================================
--- directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/preauthentication/PreAuthenticationChain.java (original)
+++ directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/preauthentication/PreAuthenticationChain.java Sat Apr 22 15:02:59 2006
@@ -16,16 +16,16 @@
  */
 package org.apache.directory.server.kerberos.kdc.preauthentication;
 
+import org.apache.mina.handler.chain.IoHandlerChain;
 
-import org.apache.directory.server.protocol.shared.chain.impl.ChainBase;
 
 
-public class PreAuthenticationChain extends ChainBase
+
+public class PreAuthenticationChain extends IoHandlerChain
 {
     public PreAuthenticationChain()
     {
-        super();
-        addCommand( new VerifySam() );
-        addCommand( new VerifyEncryptedTimestamp() );
+        addLast( "verifySam", new VerifySam() );
+        addLast( "verifyEncryptedTimestamp", new VerifyEncryptedTimestamp() );
     }
 }

Modified: directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/preauthentication/VerifierBase.java
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/preauthentication/VerifierBase.java?rev=396170&r1=396169&r2=396170&view=diff
==============================================================================
--- directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/preauthentication/VerifierBase.java (original)
+++ directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/preauthentication/VerifierBase.java Sat Apr 22 15:02:59 2006
@@ -26,11 +26,18 @@
 import org.apache.directory.server.kerberos.shared.messages.value.PreAuthenticationData;
 import org.apache.directory.server.kerberos.shared.messages.value.PreAuthenticationDataModifier;
 import org.apache.directory.server.kerberos.shared.messages.value.PreAuthenticationDataType;
-import org.apache.directory.server.protocol.shared.chain.impl.CommandBase;
+import org.apache.mina.handler.chain.IoHandlerCommand;
 
 
-public abstract class VerifierBase extends CommandBase
+public abstract class VerifierBase implements IoHandlerCommand
 {
+    private String contextKey = "context";
+
+    public String getContextKey()
+    {
+        return ( this.contextKey );
+    }
+
     public byte[] preparePreAuthenticationError()
     {
         PreAuthenticationData[] paDataSequence = new PreAuthenticationData[2];

Modified: directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/preauthentication/VerifyEncryptedTimestamp.java
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/preauthentication/VerifyEncryptedTimestamp.java?rev=396170&r1=396169&r2=396170&view=diff
==============================================================================
--- directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/preauthentication/VerifyEncryptedTimestamp.java (original)
+++ directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/preauthentication/VerifyEncryptedTimestamp.java Sat Apr 22 15:02:59 2006
@@ -32,7 +32,7 @@
 import org.apache.directory.server.kerberos.shared.messages.value.PreAuthenticationDataType;
 import org.apache.directory.server.kerberos.shared.service.LockBox;
 import org.apache.directory.server.kerberos.shared.store.PrincipalStoreEntry;
-import org.apache.directory.server.protocol.shared.chain.Context;
+import org.apache.mina.common.IoSession;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -43,13 +43,13 @@
     private static final Logger log = LoggerFactory.getLogger( VerifyEncryptedTimestamp.class );
 
 
-    public boolean execute( Context ctx ) throws Exception
+    public void execute( NextCommand next, IoSession session, Object message ) throws Exception
     {
-        AuthenticationContext authContext = ( AuthenticationContext ) ctx;
+        AuthenticationContext authContext = ( AuthenticationContext ) session.getAttribute( getContextKey() );
 
         if ( authContext.getClientKey() != null )
         {
-            return CONTINUE_CHAIN;
+            next.execute( session, message );
         }
 
         log.debug( "Verifying using encrypted timestamp." );
@@ -138,6 +138,6 @@
             log.debug( "Pre-authentication by encrypted timestamp successful for " + clientName + "." );
         }
 
-        return CONTINUE_CHAIN;
+        next.execute( session, message );
     }
 }

Modified: directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/preauthentication/VerifySam.java
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/preauthentication/VerifySam.java?rev=396170&r1=396169&r2=396170&view=diff
==============================================================================
--- directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/preauthentication/VerifySam.java (original)
+++ directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/preauthentication/VerifySam.java Sat Apr 22 15:02:59 2006
@@ -31,7 +31,7 @@
 import org.apache.directory.server.kerberos.shared.messages.value.PreAuthenticationData;
 import org.apache.directory.server.kerberos.shared.messages.value.PreAuthenticationDataType;
 import org.apache.directory.server.kerberos.shared.store.PrincipalStoreEntry;
-import org.apache.directory.server.protocol.shared.chain.Context;
+import org.apache.mina.common.IoSession;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -48,10 +48,10 @@
     }
 
 
-    public boolean execute( Context ctx ) throws Exception
+    public void execute( NextCommand next, IoSession session, Object message ) throws Exception
     {
         log.debug( "Verifying using SAM subsystem." );
-        AuthenticationContext authContext = ( AuthenticationContext ) ctx;
+        AuthenticationContext authContext = ( AuthenticationContext ) session.getAttribute( getContextKey() );
         KdcRequest request = authContext.getRequest();
         PrincipalStoreEntry clientEntry = authContext.getClientEntry();
         String clientName = clientEntry.getPrincipal().getName();
@@ -99,6 +99,6 @@
             }
         }
 
-        return CONTINUE_CHAIN;
+        next.execute( session, message );
     }
 }

Modified: directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/ticketgrant/BuildReply.java
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/ticketgrant/BuildReply.java?rev=396170&r1=396169&r2=396170&view=diff
==============================================================================
--- directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/ticketgrant/BuildReply.java (original)
+++ directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/ticketgrant/BuildReply.java Sat Apr 22 15:02:59 2006
@@ -23,15 +23,17 @@
 import org.apache.directory.server.kerberos.shared.messages.value.EncryptionKey;
 import org.apache.directory.server.kerberos.shared.messages.value.LastRequest;
 import org.apache.directory.server.kerberos.shared.messages.value.TicketFlags;
-import org.apache.directory.server.protocol.shared.chain.Context;
-import org.apache.directory.server.protocol.shared.chain.impl.CommandBase;
+import org.apache.mina.common.IoSession;
+import org.apache.mina.handler.chain.IoHandlerCommand;
 
 
-public class BuildReply extends CommandBase
+public class BuildReply implements IoHandlerCommand
 {
-    public boolean execute( Context context ) throws Exception
+    private String contextKey = "context";
+
+    public void execute( NextCommand next, IoSession session, Object message ) throws Exception
     {
-        TicketGrantingContext tgsContext = ( TicketGrantingContext ) context;
+        TicketGrantingContext tgsContext = ( TicketGrantingContext ) session.getAttribute( getContextKey() );
         KdcRequest request = tgsContext.getRequest();
         Ticket tgt = tgsContext.getTgt();
         Ticket newTicket = tgsContext.getNewTicket();
@@ -58,6 +60,12 @@
 
         tgsContext.setReply( reply );
 
-        return CONTINUE_CHAIN;
+        next.execute( session, message );
+    }
+
+
+    public String getContextKey()
+    {
+        return ( this.contextKey );
     }
 }

Modified: directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/ticketgrant/ConfigureTicketGrantingChain.java
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/ticketgrant/ConfigureTicketGrantingChain.java?rev=396170&r1=396169&r2=396170&view=diff
==============================================================================
--- directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/ticketgrant/ConfigureTicketGrantingChain.java (original)
+++ directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/ticketgrant/ConfigureTicketGrantingChain.java Sat Apr 22 15:02:59 2006
@@ -20,23 +20,30 @@
 import org.apache.directory.server.kerberos.shared.replay.InMemoryReplayCache;
 import org.apache.directory.server.kerberos.shared.replay.ReplayCache;
 import org.apache.directory.server.kerberos.shared.service.LockBox;
-import org.apache.directory.server.protocol.shared.chain.Context;
-import org.apache.directory.server.protocol.shared.chain.impl.CommandBase;
+import org.apache.mina.common.IoSession;
+import org.apache.mina.handler.chain.IoHandlerCommand;
 
 
-public class ConfigureTicketGrantingChain extends CommandBase
+public class ConfigureTicketGrantingChain implements IoHandlerCommand
 {
     private static final ReplayCache replayCache = new InMemoryReplayCache();
     private static final LockBox lockBox = new LockBox();
 
+    private String contextKey = "context";
 
-    public boolean execute( Context context ) throws Exception
+    public void execute( NextCommand next, IoSession session, Object message ) throws Exception
     {
-        TicketGrantingContext tgsContext = ( TicketGrantingContext ) context;
+        TicketGrantingContext tgsContext = ( TicketGrantingContext ) session.getAttribute( getContextKey() );
 
         tgsContext.setReplayCache( replayCache );
         tgsContext.setLockBox( lockBox );
 
-        return CONTINUE_CHAIN;
+        next.execute( session, message );
+    }
+
+
+    public String getContextKey()
+    {
+        return ( this.contextKey );
     }
 }

Modified: directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/ticketgrant/GenerateTicket.java
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/ticketgrant/GenerateTicket.java?rev=396170&r1=396169&r2=396170&view=diff
==============================================================================
--- directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/ticketgrant/GenerateTicket.java (original)
+++ directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/ticketgrant/GenerateTicket.java Sat Apr 22 15:02:59 2006
@@ -38,15 +38,17 @@
 import org.apache.directory.server.kerberos.shared.messages.value.KerberosTime;
 import org.apache.directory.server.kerberos.shared.messages.value.TicketFlags;
 import org.apache.directory.server.kerberos.shared.service.LockBox;
-import org.apache.directory.server.protocol.shared.chain.Context;
-import org.apache.directory.server.protocol.shared.chain.impl.CommandBase;
+import org.apache.mina.common.IoSession;
+import org.apache.mina.handler.chain.IoHandlerCommand;
 
 
-public class GenerateTicket extends CommandBase
+public class GenerateTicket implements IoHandlerCommand
 {
-    public boolean execute( Context context ) throws Exception
+    private String contextKey = "context";
+
+    public void execute( NextCommand next, IoSession session, Object message ) throws Exception
     {
-        TicketGrantingContext tgsContext = ( TicketGrantingContext ) context;
+        TicketGrantingContext tgsContext = ( TicketGrantingContext ) session.getAttribute( getContextKey() );
 
         KdcRequest request = tgsContext.getRequest();
         Ticket tgt = tgsContext.getTgt();
@@ -103,7 +105,13 @@
 
         tgsContext.setNewTicket( newTicket );
 
-        return CONTINUE_CHAIN;
+        next.execute( session, message );
+    }
+
+
+    public String getContextKey()
+    {
+        return ( this.contextKey );
     }
 
 

Modified: directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/ticketgrant/GetAuthHeader.java
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/ticketgrant/GetAuthHeader.java?rev=396170&r1=396169&r2=396170&view=diff
==============================================================================
--- directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/ticketgrant/GetAuthHeader.java (original)
+++ directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/ticketgrant/GetAuthHeader.java Sat Apr 22 15:02:59 2006
@@ -27,18 +27,20 @@
 import org.apache.directory.server.kerberos.shared.messages.components.Ticket;
 import org.apache.directory.server.kerberos.shared.messages.value.PreAuthenticationData;
 import org.apache.directory.server.kerberos.shared.messages.value.PreAuthenticationDataType;
-import org.apache.directory.server.protocol.shared.chain.Context;
-import org.apache.directory.server.protocol.shared.chain.impl.CommandBase;
+import org.apache.mina.common.IoSession;
+import org.apache.mina.handler.chain.IoHandlerCommand;
 
 
 /*
  * differs from the changepw getAuthHeader by verifying the presence of TGS_REQ
  */
-public class GetAuthHeader extends CommandBase
+public class GetAuthHeader implements IoHandlerCommand
 {
-    public boolean execute( Context context ) throws Exception
+    private String contextKey = "context";
+
+    public void execute( NextCommand next, IoSession session, Object message ) throws Exception
     {
-        TicketGrantingContext tgsContext = ( TicketGrantingContext ) context;
+        TicketGrantingContext tgsContext = ( TicketGrantingContext ) session.getAttribute( getContextKey() );
         KdcRequest request = tgsContext.getRequest();
 
         ApplicationRequest authHeader = getAuthHeader( request );
@@ -47,7 +49,13 @@
         tgsContext.setAuthHeader( authHeader );
         tgsContext.setTgt( tgt );
 
-        return CONTINUE_CHAIN;
+        next.execute( session, message );
+    }
+
+
+    public String getContextKey()
+    {
+        return ( this.contextKey );
     }
 
 

Modified: directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/ticketgrant/GetRequestPrincipalEntry.java
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/ticketgrant/GetRequestPrincipalEntry.java?rev=396170&r1=396169&r2=396170&view=diff
==============================================================================
--- directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/ticketgrant/GetRequestPrincipalEntry.java (original)
+++ directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/ticketgrant/GetRequestPrincipalEntry.java Sat Apr 22 15:02:59 2006
@@ -23,14 +23,14 @@
 import org.apache.directory.server.kerberos.shared.service.GetPrincipalStoreEntry;
 import org.apache.directory.server.kerberos.shared.store.PrincipalStore;
 import org.apache.directory.server.kerberos.shared.store.PrincipalStoreEntry;
-import org.apache.directory.server.protocol.shared.chain.Context;
+import org.apache.mina.common.IoSession;
 
 
 public class GetRequestPrincipalEntry extends GetPrincipalStoreEntry
 {
-    public boolean execute( Context context ) throws Exception
+    public void execute( NextCommand next, IoSession session, Object message ) throws Exception
     {
-        TicketGrantingContext tgsContext = ( TicketGrantingContext ) context;
+        TicketGrantingContext tgsContext = ( TicketGrantingContext ) session.getAttribute( getContextKey() );
 
         KerberosPrincipal principal = tgsContext.getRequest().getServerPrincipal();
         PrincipalStore store = tgsContext.getStore();
@@ -38,6 +38,6 @@
         PrincipalStoreEntry entry = getEntry( principal, store, ErrorType.KDC_ERR_S_PRINCIPAL_UNKNOWN );
         tgsContext.setRequestPrincipalEntry( entry );
 
-        return CONTINUE_CHAIN;
+        next.execute( session, message );
     }
 }

Modified: directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/ticketgrant/GetSessionKey.java
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/ticketgrant/GetSessionKey.java?rev=396170&r1=396169&r2=396170&view=diff
==============================================================================
--- directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/ticketgrant/GetSessionKey.java (original)
+++ directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/ticketgrant/GetSessionKey.java Sat Apr 22 15:02:59 2006
@@ -22,7 +22,7 @@
 import org.apache.directory.server.kerberos.shared.crypto.encryption.EncryptionType;
 import org.apache.directory.server.kerberos.shared.messages.value.EncryptionKey;
 import org.apache.directory.server.kerberos.shared.service.DesStringToKey;
-import org.apache.directory.server.protocol.shared.chain.Context;
+import org.apache.mina.common.IoSession;
 
 
 public class GetSessionKey extends DesStringToKey
@@ -30,12 +30,12 @@
     private static final SecureRandom random = new SecureRandom();
 
 
-    public boolean execute( Context context ) throws Exception
+    public void execute( NextCommand next, IoSession session, Object message ) throws Exception
     {
-        TicketGrantingContext tgsContext = ( TicketGrantingContext ) context;
+        TicketGrantingContext tgsContext = ( TicketGrantingContext ) session.getAttribute( getContextKey() );
         tgsContext.setSessionKey( getNewSessionKey() );
 
-        return CONTINUE_CHAIN;
+        next.execute( session, message );
     }
 
 

Modified: directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/ticketgrant/GetTicketPrincipalEntry.java
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/ticketgrant/GetTicketPrincipalEntry.java?rev=396170&r1=396169&r2=396170&view=diff
==============================================================================
--- directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/ticketgrant/GetTicketPrincipalEntry.java (original)
+++ directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/ticketgrant/GetTicketPrincipalEntry.java Sat Apr 22 15:02:59 2006
@@ -23,14 +23,14 @@
 import org.apache.directory.server.kerberos.shared.service.GetPrincipalStoreEntry;
 import org.apache.directory.server.kerberos.shared.store.PrincipalStore;
 import org.apache.directory.server.kerberos.shared.store.PrincipalStoreEntry;
-import org.apache.directory.server.protocol.shared.chain.Context;
+import org.apache.mina.common.IoSession;
 
 
 public class GetTicketPrincipalEntry extends GetPrincipalStoreEntry
 {
-    public boolean execute( Context context ) throws Exception
+    public void execute( NextCommand next, IoSession session, Object message ) throws Exception
     {
-        TicketGrantingContext tgsContext = ( TicketGrantingContext ) context;
+        TicketGrantingContext tgsContext = ( TicketGrantingContext ) session.getAttribute( getContextKey() );
 
         KerberosPrincipal principal = tgsContext.getTgt().getServerPrincipal();
         PrincipalStore store = tgsContext.getStore();
@@ -38,6 +38,6 @@
         PrincipalStoreEntry entry = getEntry( principal, store, ErrorType.KDC_ERR_S_PRINCIPAL_UNKNOWN );
         tgsContext.setTicketPrincipalEntry( entry );
 
-        return CONTINUE_CHAIN;
+        next.execute( session, message );
     }
 }

Modified: directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/ticketgrant/MonitorContext.java
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/ticketgrant/MonitorContext.java?rev=396170&r1=396169&r2=396170&view=diff
==============================================================================
--- directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/ticketgrant/MonitorContext.java (original)
+++ directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/ticketgrant/MonitorContext.java Sat Apr 22 15:02:59 2006
@@ -29,25 +29,26 @@
 import org.apache.directory.server.kerberos.shared.replay.ReplayCache;
 import org.apache.directory.server.kerberos.shared.store.PrincipalStore;
 import org.apache.directory.server.kerberos.shared.store.PrincipalStoreEntry;
-import org.apache.directory.server.protocol.shared.chain.Context;
-import org.apache.directory.server.protocol.shared.chain.impl.CommandBase;
+import org.apache.mina.common.IoSession;
+import org.apache.mina.handler.chain.IoHandlerCommand;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 
-public class MonitorContext extends CommandBase
+public class MonitorContext implements IoHandlerCommand
 {
     /** the log for this class */
     private static final Logger log = LoggerFactory.getLogger( MonitorContext.class );
 
+    private String contextKey = "context";
 
-    public boolean execute( Context context ) throws Exception
+    public void execute( NextCommand next, IoSession session, Object message ) throws Exception
     {
         if ( log.isDebugEnabled() )
         {
             try
             {
-                TicketGrantingContext tgsContext = ( TicketGrantingContext ) context;
+                TicketGrantingContext tgsContext = ( TicketGrantingContext ) session.getAttribute( getContextKey() );
 
                 PrincipalStore store = tgsContext.getStore();
                 ApplicationRequest authHeader = tgsContext.getAuthHeader();
@@ -107,6 +108,12 @@
             }
         }
 
-        return CONTINUE_CHAIN;
+        next.execute( session, message );
+    }
+
+
+    public String getContextKey()
+    {
+        return ( this.contextKey );
     }
 }

Modified: directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/ticketgrant/SealReply.java
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/ticketgrant/SealReply.java?rev=396170&r1=396169&r2=396170&view=diff
==============================================================================
--- directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/ticketgrant/SealReply.java (original)
+++ directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/ticketgrant/SealReply.java Sat Apr 22 15:02:59 2006
@@ -22,15 +22,17 @@
 import org.apache.directory.server.kerberos.shared.messages.components.Ticket;
 import org.apache.directory.server.kerberos.shared.messages.value.EncryptedData;
 import org.apache.directory.server.kerberos.shared.service.LockBox;
-import org.apache.directory.server.protocol.shared.chain.Context;
-import org.apache.directory.server.protocol.shared.chain.impl.CommandBase;
+import org.apache.mina.common.IoSession;
+import org.apache.mina.handler.chain.IoHandlerCommand;
 
 
-public class SealReply extends CommandBase
+public class SealReply implements IoHandlerCommand
 {
-    public boolean execute( Context ctx ) throws Exception
+    private String contextKey = "context";
+
+    public void execute( NextCommand next, IoSession session, Object message ) throws Exception
     {
-        TicketGrantingContext tgsContext = ( TicketGrantingContext ) ctx;
+        TicketGrantingContext tgsContext = ( TicketGrantingContext ) session.getAttribute( getContextKey() );
 
         TicketGrantReply reply = ( TicketGrantReply ) tgsContext.getReply();
         Ticket tgt = tgsContext.getTgt();
@@ -50,6 +52,12 @@
 
         reply.setEncPart( encryptedData );
 
-        return CONTINUE_CHAIN;
+        next.execute( session, message );
+    }
+
+
+    public String getContextKey()
+    {
+        return ( this.contextKey );
     }
 }

Modified: directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/ticketgrant/TicketGrantingServiceChain.java
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/ticketgrant/TicketGrantingServiceChain.java?rev=396170&r1=396169&r2=396170&view=diff
==============================================================================
--- directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/ticketgrant/TicketGrantingServiceChain.java (original)
+++ directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/ticketgrant/TicketGrantingServiceChain.java Sat Apr 22 15:02:59 2006
@@ -19,7 +19,7 @@
 
 import org.apache.directory.server.kerberos.kdc.MonitorReply;
 import org.apache.directory.server.kerberos.kdc.MonitorRequest;
-import org.apache.directory.server.protocol.shared.chain.impl.ChainBase;
+import org.apache.mina.handler.chain.IoHandlerChain;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -27,7 +27,7 @@
 /**
  * KRB_TGS_REQ verification and KRB_TGS_REP generation
  */
-public class TicketGrantingServiceChain extends ChainBase
+public class TicketGrantingServiceChain extends IoHandlerChain
 {
     /** the log for this class */
     private static final Logger log = LoggerFactory.getLogger( TicketGrantingServiceChain.class );
@@ -35,35 +35,32 @@
 
     public TicketGrantingServiceChain()
     {
-        super();
-        addCommand( new TicketGrantingExceptionHandler() );
-
         if ( log.isDebugEnabled() )
         {
-            addCommand( new MonitorRequest() );
+            addLast( "monitorRequest", new MonitorRequest() );
         }
 
-        addCommand( new ConfigureTicketGrantingChain() );
-        addCommand( new GetAuthHeader() );
-        addCommand( new VerifyTgt() );
-        addCommand( new GetTicketPrincipalEntry() );
-        addCommand( new VerifyTgtAuthHeader() );
-        addCommand( new VerifyBodyChecksum() );
-        addCommand( new GetRequestPrincipalEntry() );
-        addCommand( new GetSessionKey() );
-        addCommand( new GenerateTicket() );
-        addCommand( new BuildReply() );
+        addLast( "configureTicketGrantingChain", new ConfigureTicketGrantingChain() );
+        addLast( "getAuthHeader", new GetAuthHeader() );
+        addLast( "verifyTgt", new VerifyTgt() );
+        addLast( "getTicketPrincipalEntry", new GetTicketPrincipalEntry() );
+        addLast( "verifyTgtAuthHeader", new VerifyTgtAuthHeader() );
+        addLast( "verifyBodyChecksum", new VerifyBodyChecksum() );
+        addLast( "getRequestPrincipalEntry", new GetRequestPrincipalEntry() );
+        addLast( "getSessionKey", new GetSessionKey() );
+        addLast( "generateTicket", new GenerateTicket() );
+        addLast( "buildReply", new BuildReply() );
 
         if ( log.isDebugEnabled() )
         {
-            addCommand( new MonitorContext() );
+            addLast( "monitorContext", new MonitorContext() );
         }
 
         if ( log.isDebugEnabled() )
         {
-            addCommand( new MonitorReply() );
+            addLast( "monitorReply", new MonitorReply() );
         }
 
-        addCommand( new SealReply() );
+        addLast( "sealReply", new SealReply() );
     }
 }

Modified: directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/ticketgrant/VerifyBodyChecksum.java
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/ticketgrant/VerifyBodyChecksum.java?rev=396170&r1=396169&r2=396170&view=diff
==============================================================================
--- directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/ticketgrant/VerifyBodyChecksum.java (original)
+++ directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/ticketgrant/VerifyBodyChecksum.java Sat Apr 22 15:02:59 2006
@@ -23,21 +23,29 @@
 import org.apache.directory.server.kerberos.shared.exceptions.ErrorType;
 import org.apache.directory.server.kerberos.shared.exceptions.KerberosException;
 import org.apache.directory.server.kerberos.shared.messages.value.Checksum;
-import org.apache.directory.server.protocol.shared.chain.Context;
-import org.apache.directory.server.protocol.shared.chain.impl.CommandBase;
+import org.apache.mina.common.IoSession;
+import org.apache.mina.handler.chain.IoHandlerCommand;
 
 
-public class VerifyBodyChecksum extends CommandBase
+public class VerifyBodyChecksum implements IoHandlerCommand
 {
-    public boolean execute( Context context ) throws Exception
+    private String contextKey = "context";
+
+    public void execute( NextCommand next, IoSession session, Object message ) throws Exception
     {
-        TicketGrantingContext tgsContext = ( TicketGrantingContext ) context;
+        TicketGrantingContext tgsContext = ( TicketGrantingContext ) session.getAttribute( getContextKey() );
         byte[] bodyBytes = tgsContext.getRequest().getBodyBytes();
         Checksum checksum = tgsContext.getAuthenticator().getChecksum();
 
         verifyChecksum( checksum, bodyBytes );
 
-        return CONTINUE_CHAIN;
+        next.execute( session, message );
+    }
+
+
+    public String getContextKey()
+    {
+        return ( this.contextKey );
     }
 
 

Modified: directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/ticketgrant/VerifyTgt.java
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/ticketgrant/VerifyTgt.java?rev=396170&r1=396169&r2=396170&view=diff
==============================================================================
--- directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/ticketgrant/VerifyTgt.java (original)
+++ directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/ticketgrant/VerifyTgt.java Sat Apr 22 15:02:59 2006
@@ -22,14 +22,14 @@
 import org.apache.directory.server.kerberos.kdc.KdcConfiguration;
 import org.apache.directory.server.kerberos.shared.messages.components.Ticket;
 import org.apache.directory.server.kerberos.shared.service.VerifyTicket;
-import org.apache.directory.server.protocol.shared.chain.Context;
+import org.apache.mina.common.IoSession;
 
 
 public class VerifyTgt extends VerifyTicket
 {
-    public boolean execute( Context context ) throws Exception
+    public void execute( NextCommand next, IoSession session, Object message ) throws Exception
     {
-        TicketGrantingContext tgsContext = ( TicketGrantingContext ) context;
+        TicketGrantingContext tgsContext = ( TicketGrantingContext ) session.getAttribute( getContextKey() );
         KdcConfiguration config = tgsContext.getConfig();
         Ticket tgt = tgsContext.getTgt();
         String primaryRealm = config.getPrimaryRealm();
@@ -37,6 +37,6 @@
 
         verifyTicket( tgt, primaryRealm, serverPrincipal );
 
-        return CONTINUE_CHAIN;
+        next.execute( session, message );
     }
 }

Modified: directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/ticketgrant/VerifyTgtAuthHeader.java
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/ticketgrant/VerifyTgtAuthHeader.java?rev=396170&r1=396169&r2=396170&view=diff
==============================================================================
--- directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/ticketgrant/VerifyTgtAuthHeader.java (original)
+++ directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/ticketgrant/VerifyTgtAuthHeader.java Sat Apr 22 15:02:59 2006
@@ -26,14 +26,14 @@
 import org.apache.directory.server.kerberos.shared.replay.ReplayCache;
 import org.apache.directory.server.kerberos.shared.service.LockBox;
 import org.apache.directory.server.kerberos.shared.service.VerifyAuthHeader;
-import org.apache.directory.server.protocol.shared.chain.Context;
+import org.apache.mina.common.IoSession;
 
 
 public class VerifyTgtAuthHeader extends VerifyAuthHeader
 {
-    public boolean execute( Context context ) throws Exception
+    public void execute( NextCommand next, IoSession session, Object message ) throws Exception
     {
-        TicketGrantingContext tgsContext = ( TicketGrantingContext ) context;
+        TicketGrantingContext tgsContext = ( TicketGrantingContext ) session.getAttribute( getContextKey() );
 
         ApplicationRequest authHeader = tgsContext.getAuthHeader();
         Ticket tgt = tgsContext.getTgt();
@@ -49,6 +49,6 @@
 
         tgsContext.setAuthenticator( authenticator );
 
-        return CONTINUE_CHAIN;
+        next.execute( session, message );
     }
 }

Modified: directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/protocol/KerberosProtocolHandler.java
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/protocol/KerberosProtocolHandler.java?rev=396170&r1=396169&r2=396170&view=diff
==============================================================================
--- directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/protocol/KerberosProtocolHandler.java (original)
+++ directory/trunks/apacheds/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/protocol/KerberosProtocolHandler.java Sat Apr 22 15:02:59 2006
@@ -20,19 +20,25 @@
 import java.net.InetAddress;
 import java.net.InetSocketAddress;
 
+import javax.security.auth.kerberos.KerberosPrincipal;
+
 import org.apache.directory.server.kerberos.kdc.KdcConfiguration;
 import org.apache.directory.server.kerberos.kdc.authentication.AuthenticationContext;
 import org.apache.directory.server.kerberos.kdc.authentication.AuthenticationServiceChain;
 import org.apache.directory.server.kerberos.kdc.ticketgrant.TicketGrantingContext;
 import org.apache.directory.server.kerberos.kdc.ticketgrant.TicketGrantingServiceChain;
 import org.apache.directory.server.kerberos.shared.exceptions.ErrorType;
+import org.apache.directory.server.kerberos.shared.exceptions.KerberosException;
+import org.apache.directory.server.kerberos.shared.messages.ErrorMessage;
+import org.apache.directory.server.kerberos.shared.messages.ErrorMessageModifier;
 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.directory.server.protocol.shared.chain.Command;
 import org.apache.mina.common.IdleStatus;
 import org.apache.mina.common.IoHandler;
 import org.apache.mina.common.IoSession;
 import org.apache.mina.filter.codec.ProtocolCodecFilter;
+import org.apache.mina.handler.chain.IoHandlerCommand;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -50,9 +56,9 @@
 
     private KdcConfiguration config;
     private PrincipalStore store;
-
-    private Command authService;
-    private Command tgsService;
+    private IoHandlerCommand authService;
+    private IoHandlerCommand tgsService;
+    private String contextKey = "context";
 
 
     public KerberosProtocolHandler(KdcConfiguration config, PrincipalStore store)
@@ -133,8 +139,9 @@
                     authContext.setStore( store );
                     authContext.setClientAddress( clientAddress );
                     authContext.setRequest( request );
+                    session.setAttribute( getContextKey(), authContext );
 
-                    authService.execute( authContext );
+                    authService.execute( null, session, message );
 
                     session.write( authContext.getReply() );
                     break;
@@ -145,8 +152,9 @@
                     tgsContext.setStore( store );
                     tgsContext.setClientAddress( clientAddress );
                     tgsContext.setRequest( request );
+                    session.setAttribute( getContextKey(), tgsContext );
 
-                    tgsService.execute( tgsContext );
+                    tgsService.execute( null, session, message );
 
                     session.write( tgsContext.getReply() );
                     break;
@@ -162,6 +170,10 @@
         catch ( Exception e )
         {
             log.error( e.getMessage() );
+
+            KerberosException ke = ( KerberosException ) e;
+
+            session.write( getErrorMessage( config.getKdcPrincipal(), ke ) );
         }
     }
 
@@ -172,5 +184,28 @@
         {
             log.debug( session.getRemoteAddress() + " SENT: " + message );
         }
+    }
+
+
+    public ErrorMessage getErrorMessage( KerberosPrincipal principal, KerberosException exception )
+    {
+        ErrorMessageModifier modifier = new ErrorMessageModifier();
+
+        KerberosTime now = new KerberosTime();
+
+        modifier.setErrorCode( exception.getErrorCode() );
+        modifier.setExplanatoryText( exception.getMessage() );
+        modifier.setServerPrincipal( principal );
+        modifier.setServerTime( now );
+        modifier.setServerMicroSecond( 0 );
+        modifier.setExplanatoryData( exception.getExplanatoryData() );
+
+        return modifier.getErrorMessage();
+    }
+
+
+    public String getContextKey()
+    {
+        return ( this.contextKey );
     }
 }



Mime
View raw message