directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r521997 [2/2] - in /directory/apacheds/branches/1.0: kerberos-shared/ kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/crypto/checksum/ kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/crypt...
Date Sat, 24 Mar 2007 09:04:54 GMT
Modified: directory/apacheds/branches/1.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/authentication/BuildReply.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/1.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/authentication/BuildReply.java?view=diff&rev=521997&r1=521996&r2=521997
==============================================================================
--- directory/apacheds/branches/1.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/authentication/BuildReply.java (original)
+++ directory/apacheds/branches/1.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/authentication/BuildReply.java Sat Mar 24 02:04:51 2007
@@ -25,15 +25,21 @@
 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
+/**
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+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();
 
@@ -64,6 +70,11 @@
 
         authContext.setReply( reply );
 
-        return CONTINUE_CHAIN;
+        next.execute( session, message );
+    }
+
+    public String getContextKey()
+    {
+        return ( this.contextKey );
     }
 }

Modified: directory/apacheds/branches/1.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/authentication/ConfigureAuthenticationChain.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/1.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/authentication/ConfigureAuthenticationChain.java?view=diff&rev=521997&r1=521996&r2=521997
==============================================================================
--- directory/apacheds/branches/1.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/authentication/ConfigureAuthenticationChain.java (original)
+++ directory/apacheds/branches/1.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/authentication/ConfigureAuthenticationChain.java Sat Mar 24 02:04:51 2007
@@ -23,36 +23,38 @@
 import java.util.Map;
 
 import org.apache.directory.server.kerberos.shared.crypto.checksum.ChecksumType;
-import org.apache.directory.server.kerberos.shared.crypto.checksum.Crc32Checksum;
-import org.apache.directory.server.kerberos.shared.crypto.checksum.RsaMd4Checksum;
 import org.apache.directory.server.kerberos.shared.crypto.checksum.RsaMd5Checksum;
 import org.apache.directory.server.kerberos.shared.crypto.checksum.Sha1Checksum;
 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 );
 
         Map checksumEngines = authContext.getChecksumEngines();
-        checksumEngines.put( ChecksumType.CRC32, new Crc32Checksum() );
-        checksumEngines.put( ChecksumType.RSA_MD4, new RsaMd4Checksum() );
         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/apacheds/branches/1.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/authentication/GenerateTicket.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/1.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/authentication/GenerateTicket.java?view=diff&rev=521997&r1=521996&r2=521997
==============================================================================
--- directory/apacheds/branches/1.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/authentication/GenerateTicket.java (original)
+++ directory/apacheds/branches/1.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/authentication/GenerateTicket.java Sat Mar 24 02:04:51 2007
@@ -36,21 +36,25 @@
 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
+/**
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+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();
@@ -94,22 +98,25 @@
         {
             // TODO - possibly allow req.from range
             if ( !config.isPostdateAllowed() )
+            {
                 throw new KerberosException( ErrorType.KDC_ERR_POLICY );
+            }
+            
             newTicketBody.setFlag( TicketFlags.INVALID );
             newTicketBody.setStartTime( request.getFrom() );
         }
 
         long till = 0;
+        
         if ( request.getTill().getTime() == 0 )
+        {
             till = Long.MAX_VALUE;
+        }
         else
+        {
             till = request.getTill().getTime();
-        /*
-         new_tkt.endtime := min(till,
-         new_tkt.starttime+client.max_life,
-         new_tkt.starttime+server.max_life,
-         new_tkt.starttime+max_life_for_realm);
-         */
+        }
+        
         long endTime = Math.min( now.getTime() + config.getMaximumTicketLifetime(), till );
         KerberosTime kerberosEndTime = new KerberosTime( endTime );
         newTicketBody.setEndTime( kerberosEndTime );
@@ -121,18 +128,6 @@
             tempRtime = request.getTill().getTime();
         }
 
-        /*
-         if (req.kdc-options.RENEWABLE is set) then
-         set new_tkt.flags.RENEWABLE;
-         new_tkt.renew-till := min(rtime,
-         new_tkt.starttime+client.max_rlife,
-         new_tkt.starttime+server.max_rlife,
-         new_tkt.starttime+max_rlife_for_realm);
-         else
-         omit new_tkt.renew-till;
-         endif
-         */
-
         if ( tempRtime == 0 )
         {
             tempRtime = Long.MAX_VALUE;
@@ -179,6 +174,11 @@
 
         authContext.setTicket( newTicket );
 
-        return CONTINUE_CHAIN;
+        next.execute( session, message );
+    }
+
+    public String getContextKey()
+    {
+        return ( this.contextKey );
     }
 }

Modified: directory/apacheds/branches/1.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/authentication/GetClientEntry.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/1.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/authentication/GetClientEntry.java?view=diff&rev=521997&r1=521996&r2=521997
==============================================================================
--- directory/apacheds/branches/1.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/authentication/GetClientEntry.java (original)
+++ directory/apacheds/branches/1.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/authentication/GetClientEntry.java Sat Mar 24 02:04:51 2007
@@ -25,20 +25,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/apacheds/branches/1.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/authentication/GetServerEntry.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/1.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/authentication/GetServerEntry.java?view=diff&rev=521997&r1=521996&r2=521997
==============================================================================
--- directory/apacheds/branches/1.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/authentication/GetServerEntry.java (original)
+++ directory/apacheds/branches/1.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/authentication/GetServerEntry.java Sat Mar 24 02:04:51 2007
@@ -25,20 +25,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/apacheds/branches/1.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/authentication/GetSessionKey.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/1.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/authentication/GetSessionKey.java?view=diff&rev=521997&r1=521996&r2=521997
==============================================================================
--- directory/apacheds/branches/1.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/authentication/GetSessionKey.java (original)
+++ directory/apacheds/branches/1.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/authentication/GetSessionKey.java Sat Mar 24 02:04:51 2007
@@ -20,37 +20,32 @@
 package org.apache.directory.server.kerberos.kdc.authentication;
 
 
-import java.security.SecureRandom;
-
-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;
-
-
-public class GetSessionKey extends DesStringToKey
+import org.apache.directory.server.kerberos.shared.service.SessionKeyFactory;
+import org.apache.mina.common.IoSession;
+import org.apache.mina.handler.chain.IoHandlerCommand;
+
+/**
+ * Get a session key for this session.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class GetSessionKey implements IoHandlerCommand
 {
-    private static final SecureRandom random = new SecureRandom();
+    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;
-        authContext.setSessionKey( getNewSessionKey() );
+        AuthenticationContext authContext = ( AuthenticationContext ) session.getAttribute( getContextKey() );
+        authContext.setSessionKey( SessionKeyFactory.getSessionKey() );
 
-        return CONTINUE_CHAIN;
+        next.execute( session, message );
     }
 
 
-    private EncryptionKey getNewSessionKey()
+    protected String getContextKey()
     {
-        byte[] confounder = new byte[8];
-
-        // SecureRandom.nextBytes is already synchronized
-        random.nextBytes( confounder );
-
-        byte[] subSessionKey = getKey( new String( confounder ) );
-
-        return new EncryptionKey( EncryptionType.DES_CBC_MD5, subSessionKey );
+        return ( this.contextKey );
     }
 }

Modified: directory/apacheds/branches/1.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/authentication/SealReply.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/1.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/authentication/SealReply.java?view=diff&rev=521997&r1=521996&r2=521997
==============================================================================
--- directory/apacheds/branches/1.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/authentication/SealReply.java (original)
+++ directory/apacheds/branches/1.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/authentication/SealReply.java Sat Mar 24 02:04:51 2007
@@ -24,15 +24,21 @@
 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
+/**
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+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();
@@ -41,6 +47,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/apacheds/branches/1.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/authentication/VerifyPolicy.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/1.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/authentication/VerifyPolicy.java?view=diff&rev=521997&r1=521996&r2=521997
==============================================================================
--- directory/apacheds/branches/1.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/authentication/VerifyPolicy.java (original)
+++ directory/apacheds/branches/1.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/authentication/VerifyPolicy.java Sat Mar 24 02:04:51 2007
@@ -24,20 +24,16 @@
 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.store.PrincipalStoreEntry;
-import org.apache.directory.server.protocol.shared.chain.Context;
-import org.apache.directory.server.protocol.shared.chain.impl.CommandBase;
-//import org.slf4j.Logger;
-//import org.slf4j.LoggerFactory;
+import org.apache.mina.common.IoSession;
+import org.apache.mina.handler.chain.IoHandlerCommand;
 
-public class VerifyPolicy extends CommandBase
+public class VerifyPolicy implements IoHandlerCommand
 {
-    /** the log for this class */
-//    private static final Logger log = LoggerFactory.getLogger( VerifyPolicy.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() );
         PrincipalStoreEntry entry = authContext.getClientEntry();
 
         if ( entry.isDisabled() )
@@ -55,6 +51,11 @@
             throw new KerberosException( ErrorType.KDC_ERR_CLIENT_REVOKED );
         }
 
-        return CONTINUE_CHAIN;
+        next.execute( session, message );
+    }
+
+    public String getContextKey()
+    {
+        return ( this.contextKey );
     }
 }

Modified: directory/apacheds/branches/1.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/preauthentication/PreAuthenticationChain.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/1.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/preauthentication/PreAuthenticationChain.java?view=diff&rev=521997&r1=521996&r2=521997
==============================================================================
--- directory/apacheds/branches/1.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/preauthentication/PreAuthenticationChain.java (original)
+++ directory/apacheds/branches/1.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/preauthentication/PreAuthenticationChain.java Sat Mar 24 02:04:51 2007
@@ -20,15 +20,17 @@
 package org.apache.directory.server.kerberos.kdc.preauthentication;
 
 
-import org.apache.directory.server.protocol.shared.chain.impl.ChainBase;
+import org.apache.mina.handler.chain.IoHandlerChain;
 
-
-public class PreAuthenticationChain extends ChainBase
+/**
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class PreAuthenticationChain extends IoHandlerChain
 {
     public PreAuthenticationChain()
     {
-        super();
-        addCommand( new VerifySam() );
-        addCommand( new VerifyEncryptedTimestamp() );
+        addLast( "verifySam", new VerifySam() );
+        addLast( "verifyEncryptedTimestamp", new VerifyEncryptedTimestamp() );
     }
 }

Modified: directory/apacheds/branches/1.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/preauthentication/VerifierBase.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/1.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/preauthentication/VerifierBase.java?view=diff&rev=521997&r1=521996&r2=521997
==============================================================================
--- directory/apacheds/branches/1.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/preauthentication/VerifierBase.java (original)
+++ directory/apacheds/branches/1.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/preauthentication/VerifierBase.java Sat Mar 24 02:04:51 2007
@@ -29,11 +29,17 @@
 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/apacheds/branches/1.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/preauthentication/VerifyEncryptedTimestamp.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/1.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/preauthentication/VerifyEncryptedTimestamp.java?view=diff&rev=521997&r1=521996&r2=521997
==============================================================================
--- directory/apacheds/branches/1.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/preauthentication/VerifyEncryptedTimestamp.java (original)
+++ directory/apacheds/branches/1.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/preauthentication/VerifyEncryptedTimestamp.java Sat Mar 24 02:04:51 2007
@@ -35,7 +35,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;
 
@@ -46,13 +46,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." );
@@ -123,14 +123,6 @@
                 {
                     throw new KerberosException( ErrorType.KDC_ERR_PREAUTH_FAILED );
                 }
-
-                /*
-                 if(decrypted_enc_timestamp and usec is replay)
-                 error_out(KDC_ERR_PREAUTH_FAILED);
-                 endif
-
-                 add decrypted_enc_timestamp and usec to replay cache;
-                 */
             }
         }
 
@@ -141,6 +133,6 @@
             log.debug( "Pre-authentication by encrypted timestamp successful for " + clientName + "." );
         }
 
-        return CONTINUE_CHAIN;
+        next.execute( session, message );
     }
 }

Modified: directory/apacheds/branches/1.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/preauthentication/VerifySam.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/1.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/preauthentication/VerifySam.java?view=diff&rev=521997&r1=521996&r2=521997
==============================================================================
--- directory/apacheds/branches/1.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/preauthentication/VerifySam.java (original)
+++ directory/apacheds/branches/1.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/preauthentication/VerifySam.java Sat Mar 24 02:04:51 2007
@@ -34,7 +34,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;
 
@@ -51,10 +51,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();
@@ -102,6 +102,6 @@
             }
         }
 
-        return CONTINUE_CHAIN;
+        next.execute( session, message );
     }
 }

Modified: directory/apacheds/branches/1.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/ticketgrant/BuildReply.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/1.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/ticketgrant/BuildReply.java?view=diff&rev=521997&r1=521996&r2=521997
==============================================================================
--- directory/apacheds/branches/1.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/ticketgrant/BuildReply.java (original)
+++ directory/apacheds/branches/1.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/ticketgrant/BuildReply.java Sat Mar 24 02:04:51 2007
@@ -26,15 +26,21 @@
 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
+/**
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+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();
@@ -61,6 +67,12 @@
 
         tgsContext.setReply( reply );
 
-        return CONTINUE_CHAIN;
+        next.execute( session, message );
+    }
+
+
+    public String getContextKey()
+    {
+        return ( this.contextKey );
     }
 }

Modified: directory/apacheds/branches/1.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/ticketgrant/ConfigureTicketGrantingChain.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/1.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/ticketgrant/ConfigureTicketGrantingChain.java?view=diff&rev=521997&r1=521996&r2=521997
==============================================================================
--- directory/apacheds/branches/1.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/ticketgrant/ConfigureTicketGrantingChain.java (original)
+++ directory/apacheds/branches/1.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/ticketgrant/ConfigureTicketGrantingChain.java Sat Mar 24 02:04:51 2007
@@ -23,23 +23,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/apacheds/branches/1.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/ticketgrant/GenerateTicket.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/1.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/ticketgrant/GenerateTicket.java?view=diff&rev=521997&r1=521996&r2=521997
==============================================================================
--- directory/apacheds/branches/1.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/ticketgrant/GenerateTicket.java (original)
+++ directory/apacheds/branches/1.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/ticketgrant/GenerateTicket.java Sat Mar 24 02:04:51 2007
@@ -41,15 +41,21 @@
 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
+/**
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+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();
@@ -85,17 +91,6 @@
 
         if ( request.getOption( KdcOptions.ENC_TKT_IN_SKEY ) )
         {
-            /*
-             if (server not specified) then
-             server = req.second_ticket.client;
-             endif
-             if ((req.second_ticket is not a TGT) or
-             (req.second_ticket.client != server)) then
-             error_out(KDC_ERR_POLICY);
-             endif
-             new_tkt.enc-part := encrypt OCTET STRING
-             using etype_for_key(second-ticket.key), second-ticket.key;
-             */
             throw new KerberosException( ErrorType.KDC_ERR_SVC_UNAVAILABLE );
         }
 
@@ -106,9 +101,14 @@
 
         tgsContext.setNewTicket( newTicket );
 
-        return CONTINUE_CHAIN;
+        next.execute( session, message );
     }
 
+
+    public String getContextKey()
+    {
+        return ( this.contextKey );
+    }
 
     private void processFlags( KdcConfiguration config, KdcRequest request, Ticket tgt,
         EncTicketPartModifier newTicketBody ) throws KerberosException

Modified: directory/apacheds/branches/1.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/ticketgrant/GetAuthHeader.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/1.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/ticketgrant/GetAuthHeader.java?view=diff&rev=521997&r1=521996&r2=521997
==============================================================================
--- directory/apacheds/branches/1.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/ticketgrant/GetAuthHeader.java (original)
+++ directory/apacheds/branches/1.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/ticketgrant/GetAuthHeader.java Sat Mar 24 02:04:51 2007
@@ -30,18 +30,23 @@
 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
+/**
+ * Differs from the changepw getAuthHeader by verifying the presence of TGS_REQ.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
  */
-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 );
@@ -50,9 +55,14 @@
         tgsContext.setAuthHeader( authHeader );
         tgsContext.setTgt( tgt );
 
-        return CONTINUE_CHAIN;
+        next.execute( session, message );
     }
 
+
+    public String getContextKey()
+    {
+        return ( this.contextKey );
+    }
 
     protected ApplicationRequest getAuthHeader( KdcRequest request ) throws KerberosException, IOException
     {

Modified: directory/apacheds/branches/1.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/ticketgrant/GetRequestPrincipalEntry.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/1.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/ticketgrant/GetRequestPrincipalEntry.java?view=diff&rev=521997&r1=521996&r2=521997
==============================================================================
--- directory/apacheds/branches/1.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/ticketgrant/GetRequestPrincipalEntry.java (original)
+++ directory/apacheds/branches/1.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/ticketgrant/GetRequestPrincipalEntry.java Sat Mar 24 02:04:51 2007
@@ -26,14 +26,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();
@@ -41,6 +41,6 @@
         PrincipalStoreEntry entry = getEntry( principal, store, ErrorType.KDC_ERR_S_PRINCIPAL_UNKNOWN );
         tgsContext.setRequestPrincipalEntry( entry );
 
-        return CONTINUE_CHAIN;
+        next.execute( session, message );
     }
 }

Modified: directory/apacheds/branches/1.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/ticketgrant/GetSessionKey.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/1.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/ticketgrant/GetSessionKey.java?view=diff&rev=521997&r1=521996&r2=521997
==============================================================================
--- directory/apacheds/branches/1.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/ticketgrant/GetSessionKey.java (original)
+++ directory/apacheds/branches/1.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/ticketgrant/GetSessionKey.java Sat Mar 24 02:04:51 2007
@@ -19,38 +19,34 @@
  */
 package org.apache.directory.server.kerberos.kdc.ticketgrant;
 
+import org.apache.directory.server.kerberos.kdc.authentication.AuthenticationContext;
+import org.apache.directory.server.kerberos.shared.service.SessionKeyFactory;
+import org.apache.mina.common.IoSession;
+import org.apache.mina.handler.chain.IoHandlerCommand;
 
-import java.security.SecureRandom;
 
-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;
-
-
-public class GetSessionKey extends DesStringToKey
+/**
+ * Get a session key for this session.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class GetSessionKey implements IoHandlerCommand
 {
-    private static final SecureRandom random = new SecureRandom();
+    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;
-        tgsContext.setSessionKey( getNewSessionKey() );
-
-        return CONTINUE_CHAIN;
+        AuthenticationContext authContext = ( AuthenticationContext ) session.getAttribute( getContextKey() );
+        authContext.setSessionKey( SessionKeyFactory.getSessionKey() );
+     
+        next.execute( session, message );
     }
 
 
-    private EncryptionKey getNewSessionKey()
+    protected String getContextKey()
     {
-        byte[] confounder = new byte[8];
-
-        // SecureRandom.nextBytes is already synchronized
-        random.nextBytes( confounder );
-
-        byte[] subSessionKey = getKey( new String( confounder ) );
-
-        return new EncryptionKey( EncryptionType.DES_CBC_MD5, subSessionKey );
+        return ( this.contextKey );
     }
 }

Modified: directory/apacheds/branches/1.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/ticketgrant/GetTicketPrincipalEntry.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/1.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/ticketgrant/GetTicketPrincipalEntry.java?view=diff&rev=521997&r1=521996&r2=521997
==============================================================================
--- directory/apacheds/branches/1.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/ticketgrant/GetTicketPrincipalEntry.java (original)
+++ directory/apacheds/branches/1.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/ticketgrant/GetTicketPrincipalEntry.java Sat Mar 24 02:04:51 2007
@@ -26,14 +26,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();
@@ -41,6 +41,6 @@
         PrincipalStoreEntry entry = getEntry( principal, store, ErrorType.KDC_ERR_S_PRINCIPAL_UNKNOWN );
         tgsContext.setTicketPrincipalEntry( entry );
 
-        return CONTINUE_CHAIN;
+        next.execute( session, message );
     }
 }

Modified: directory/apacheds/branches/1.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/ticketgrant/MonitorContext.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/1.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/ticketgrant/MonitorContext.java?view=diff&rev=521997&r1=521996&r2=521997
==============================================================================
--- directory/apacheds/branches/1.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/ticketgrant/MonitorContext.java (original)
+++ directory/apacheds/branches/1.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/ticketgrant/MonitorContext.java Sat Mar 24 02:04:51 2007
@@ -32,25 +32,30 @@
 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
+/**
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+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();
@@ -110,6 +115,12 @@
             }
         }
 
-        return CONTINUE_CHAIN;
+        next.execute( session, message );
+    }
+
+
+    public String getContextKey()
+    {
+        return ( this.contextKey );
     }
 }

Modified: directory/apacheds/branches/1.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/ticketgrant/SealReply.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/1.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/ticketgrant/SealReply.java?view=diff&rev=521997&r1=521996&r2=521997
==============================================================================
--- directory/apacheds/branches/1.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/ticketgrant/SealReply.java (original)
+++ directory/apacheds/branches/1.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/ticketgrant/SealReply.java Sat Mar 24 02:04:51 2007
@@ -25,15 +25,21 @@
 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
+/**
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+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();
@@ -53,6 +59,12 @@
 
         reply.setEncPart( encryptedData );
 
-        return CONTINUE_CHAIN;
+        next.execute( session, message );
+    }
+
+
+    public String getContextKey()
+    {
+        return ( this.contextKey );
     }
 }

Modified: directory/apacheds/branches/1.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/ticketgrant/TicketGrantingServiceChain.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/1.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/ticketgrant/TicketGrantingServiceChain.java?view=diff&rev=521997&r1=521996&r2=521997
==============================================================================
--- directory/apacheds/branches/1.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/ticketgrant/TicketGrantingServiceChain.java (original)
+++ directory/apacheds/branches/1.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/ticketgrant/TicketGrantingServiceChain.java Sat Mar 24 02:04:51 2007
@@ -22,15 +22,18 @@
 
 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;
 
 
 /**
- * KRB_TGS_REQ verification and KRB_TGS_REP generation
+ * KRB_TGS_REQ verification and KRB_TGS_REP generation.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
  */
-public class TicketGrantingServiceChain extends ChainBase
+public class TicketGrantingServiceChain extends IoHandlerChain
 {
     /** the log for this class */
     private static final Logger log = LoggerFactory.getLogger( TicketGrantingServiceChain.class );
@@ -38,35 +41,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/apacheds/branches/1.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/ticketgrant/VerifyBodyChecksum.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/1.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/ticketgrant/VerifyBodyChecksum.java?view=diff&rev=521997&r1=521996&r2=521997
==============================================================================
--- directory/apacheds/branches/1.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/ticketgrant/VerifyBodyChecksum.java (original)
+++ directory/apacheds/branches/1.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/ticketgrant/VerifyBodyChecksum.java Sat Mar 24 02:04:51 2007
@@ -26,23 +26,34 @@
 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
+/**
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+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 );
+    }
 
     private void verifyChecksum( Checksum checksum, byte[] bytes ) throws KerberosException
     {

Modified: directory/apacheds/branches/1.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/ticketgrant/VerifyTgt.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/1.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/ticketgrant/VerifyTgt.java?view=diff&rev=521997&r1=521996&r2=521997
==============================================================================
--- directory/apacheds/branches/1.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/ticketgrant/VerifyTgt.java (original)
+++ directory/apacheds/branches/1.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/ticketgrant/VerifyTgt.java Sat Mar 24 02:04:51 2007
@@ -25,14 +25,18 @@
 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;
 
 
+/**
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
 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();
@@ -40,6 +44,6 @@
 
         verifyTicket( tgt, primaryRealm, serverPrincipal );
 
-        return CONTINUE_CHAIN;
+        next.execute( session, message );
     }
 }

Modified: directory/apacheds/branches/1.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/ticketgrant/VerifyTgtAuthHeader.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/1.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/ticketgrant/VerifyTgtAuthHeader.java?view=diff&rev=521997&r1=521996&r2=521997
==============================================================================
--- directory/apacheds/branches/1.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/ticketgrant/VerifyTgtAuthHeader.java (original)
+++ directory/apacheds/branches/1.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/ticketgrant/VerifyTgtAuthHeader.java Sat Mar 24 02:04:51 2007
@@ -29,14 +29,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();
@@ -52,6 +52,6 @@
 
         tgsContext.setAuthenticator( authenticator );
 
-        return CONTINUE_CHAIN;
+        next.execute( session, message );
     }
 }

Modified: directory/apacheds/branches/1.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/protocol/KerberosProtocolHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/1.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/protocol/KerberosProtocolHandler.java?view=diff&rev=521997&r1=521996&r2=521997
==============================================================================
--- directory/apacheds/branches/1.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/protocol/KerberosProtocolHandler.java (original)
+++ directory/apacheds/branches/1.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/protocol/KerberosProtocolHandler.java Sat Mar 24 02:04:51 2007
@@ -31,11 +31,11 @@
 import org.apache.directory.server.kerberos.shared.exceptions.ErrorType;
 import org.apache.directory.server.kerberos.shared.messages.KdcRequest;
 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;
 
@@ -54,8 +54,8 @@
     private KdcConfiguration config;
     private PrincipalStore store;
 
-    private Command authService;
-    private Command tgsService;
+    private IoHandlerCommand authService;
+    private IoHandlerCommand tgsService;
 
 
     public KerberosProtocolHandler(KdcConfiguration config, PrincipalStore store)
@@ -137,7 +137,7 @@
                     authContext.setClientAddress( clientAddress );
                     authContext.setRequest( request );
 
-                    authService.execute( authContext );
+                    authService.execute( null, session, message );
 
                     session.write( authContext.getReply() );
                     break;
@@ -149,7 +149,7 @@
                     tgsContext.setClientAddress( clientAddress );
                     tgsContext.setRequest( request );
 
-                    tgsService.execute( tgsContext );
+                    tgsService.execute( null, session, message );
 
                     session.write( tgsContext.getReply() );
                     break;



Mime
View raw message