directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From erodrig...@apache.org
Subject svn commit: r123282 - in incubator/directory/kerberos/trunk: main/src/java/org/apache/kerberos protocol/src/java/org/apache/kerberos/kdc/server/seda
Date Fri, 24 Dec 2004 07:12:46 GMT
Author: erodriguez
Date: Thu Dec 23 23:12:42 2004
New Revision: 123282

URL: http://svn.apache.org/viewcvs?view=rev&rev=123282
Log:
Working Kerberos SEDA protocol providers for TCP and UDP.
Modified:
   incubator/directory/kerberos/trunk/main/src/java/org/apache/kerberos/KerberosMain.java
   incubator/directory/kerberos/trunk/protocol/src/java/org/apache/kerberos/kdc/server/seda/KerberosTcpDecoder.java
   incubator/directory/kerberos/trunk/protocol/src/java/org/apache/kerberos/kdc/server/seda/KerberosTcpEncoder.java
   incubator/directory/kerberos/trunk/protocol/src/java/org/apache/kerberos/kdc/server/seda/KerberosTcpProvider.java
   incubator/directory/kerberos/trunk/protocol/src/java/org/apache/kerberos/kdc/server/seda/KerberosUdpDecoder.java
   incubator/directory/kerberos/trunk/protocol/src/java/org/apache/kerberos/kdc/server/seda/KerberosUdpEncoder.java
   incubator/directory/kerberos/trunk/protocol/src/java/org/apache/kerberos/kdc/server/seda/KerberosUdpProvider.java

Modified: incubator/directory/kerberos/trunk/main/src/java/org/apache/kerberos/KerberosMain.java
Url: http://svn.apache.org/viewcvs/incubator/directory/kerberos/trunk/main/src/java/org/apache/kerberos/KerberosMain.java?view=diff&rev=123282&p1=incubator/directory/kerberos/trunk/main/src/java/org/apache/kerberos/KerberosMain.java&r1=123281&p2=incubator/directory/kerberos/trunk/main/src/java/org/apache/kerberos/KerberosMain.java&r2=123282
==============================================================================
--- incubator/directory/kerberos/trunk/main/src/java/org/apache/kerberos/KerberosMain.java
(original)
+++ incubator/directory/kerberos/trunk/main/src/java/org/apache/kerberos/KerberosMain.java
Thu Dec 23 23:12:42 2004
@@ -16,31 +16,32 @@
  */
 package org.apache.kerberos;
 
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.util.Properties;
+
+import javax.naming.NamingException;
+import javax.naming.directory.InitialDirContext;
 
 import org.apache.eve.jndi.EnvKeys;
 import org.apache.kerberos.kdc.EmbeddedEveStore;
 import org.apache.kerberos.kdc.KdcConfiguration;
 import org.apache.kerberos.kdc.KdcDispatcher;
-import org.apache.kerberos.kdc.server.seda.KerberosProtocolProvider;
+import org.apache.kerberos.kdc.server.seda.KerberosTcpProvider;
+import org.apache.kerberos.kdc.server.seda.KerberosUdpProvider;
 import org.apache.kerberos.kdc.store.BootstrapStore;
 import org.apache.kerberos.kdc.store.PrincipalStore;
 import org.apache.seda.DefaultFrontend;
 import org.apache.seda.DefaultFrontendFactory;
 import org.apache.seda.listener.ListenerConfig;
+import org.apache.seda.listener.TCPListenerConfig;
 import org.apache.seda.listener.UDPListenerConfig;
 import org.apache.seda.protocol.DefaultInetServicesDatabase;
 import org.apache.seda.protocol.InetServiceEntry;
 import org.apache.seda.protocol.ProtocolProvider;
 import org.apache.seda.protocol.TransportTypeEnum;
 
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.util.Properties;
-import javax.naming.directory.InitialDirContext;
-import javax.naming.NamingException;
-
-
 /**
  * Simple application wrapper (used to be a testcase) around the Kerberos kdc
  * core.
@@ -58,8 +59,11 @@
     /** the frontend used to contain the protocols */
     protected DefaultFrontend fe = null;
 
-    /** the protocol provider */
-    protected ProtocolProvider proto = null;
+    /** the tcp protocol provider */
+    protected ProtocolProvider tcpProvider = null;
+
+    /** the udp protocol provider */
+    protected ProtocolProvider udpProvider = null;
 
     /** the UDP listener configuration for the protocol */
     protected ListenerConfig udpConfig;
@@ -80,7 +84,8 @@
         try
         {
             kdc = new KdcDispatcher( config, bootstrap, ldap );
-            proto = new KerberosProtocolProvider( kdc );
+            tcpProvider = new KerberosTcpProvider( kdc );
+            udpProvider = new KerberosUdpProvider( kdc );
             setup();
         }
         catch (Exception e)
@@ -167,12 +172,12 @@
 
         InetServiceEntry srvEntry;
 
-//        srvEntry = new InetServiceEntry(proto.getName(), port, proto, TransportTypeEnum.TCP);
-//        ((DefaultInetServicesDatabase) fe.getInetServicesDatabase()).addEntry(srvEntry);
-//        tcpConfig = new TCPListenerConfig(InetAddress.getLocalHost(), srvEntry);
-//        fe.getTCPListenerManager().bind(tcpConfig);
+        srvEntry = new InetServiceEntry(tcpProvider.getName(), port, tcpProvider, TransportTypeEnum.TCP);
+        ((DefaultInetServicesDatabase) fe.getInetServicesDatabase()).addEntry(srvEntry);
+        tcpConfig = new TCPListenerConfig(srvEntry);
+        fe.getTCPListenerManager().bind(tcpConfig);
 
-        srvEntry = new InetServiceEntry(proto.getName(), port, proto, TransportTypeEnum.UDP);
+        srvEntry = new InetServiceEntry(udpProvider.getName(), port, udpProvider, TransportTypeEnum.UDP);
         ((DefaultInetServicesDatabase) fe.getInetServicesDatabase()).addEntry(srvEntry);
         udpConfig = new UDPListenerConfig(srvEntry);
         fe.getUDPListenerManager().bind(udpConfig);

Modified: incubator/directory/kerberos/trunk/protocol/src/java/org/apache/kerberos/kdc/server/seda/KerberosTcpDecoder.java
Url: http://svn.apache.org/viewcvs/incubator/directory/kerberos/trunk/protocol/src/java/org/apache/kerberos/kdc/server/seda/KerberosTcpDecoder.java?view=diff&rev=123282&p1=incubator/directory/kerberos/trunk/protocol/src/java/org/apache/kerberos/kdc/server/seda/KerberosTcpDecoder.java&r1=123281&p2=incubator/directory/kerberos/trunk/protocol/src/java/org/apache/kerberos/kdc/server/seda/KerberosTcpDecoder.java&r2=123282
==============================================================================
--- incubator/directory/kerberos/trunk/protocol/src/java/org/apache/kerberos/kdc/server/seda/KerberosTcpDecoder.java
(original)
+++ incubator/directory/kerberos/trunk/protocol/src/java/org/apache/kerberos/kdc/server/seda/KerberosTcpDecoder.java
Thu Dec 23 23:12:42 2004
@@ -19,27 +19,31 @@
 
 import java.nio.ByteBuffer;
 
-import org.apache.snickers.codec.stateful.*;
+import org.apache.snickers.ber.TupleEncodingVisitor;
+import org.apache.snickers.ber.TupleNode;
+import org.apache.snickers.ber.TupleTreeDecoder;
 import org.apache.snickers.codec.DecoderException;
 import org.apache.snickers.codec.EncoderException;
-import org.apache.snickers.ber.TupleTreeDecoder;
-import org.apache.snickers.ber.TupleNode;
-import org.apache.snickers.ber.TupleEncodingVisitor;
+import org.apache.snickers.codec.stateful.AbstractStatefulDecoder;
+import org.apache.snickers.codec.stateful.DecoderCallback;
+import org.apache.snickers.codec.stateful.EncoderCallback;
+import org.apache.snickers.codec.stateful.StatefulDecoder;
+import org.apache.snickers.codec.stateful.StatefulEncoder;
 
 
 /**
- * A decoder for Kerberos requests.
+ * A decoder for Kerberos TCP requests.
  *
  * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>
  * @version $Rev: 56478 $
  */
-public class KerberosDecoder extends AbstractStatefulDecoder
+public class KerberosTcpDecoder extends AbstractStatefulDecoder
 {
     TupleTreeDecoder treeDecoder = new TupleTreeDecoder();
     TupleEncodingVisitor treeEncoder = new TupleEncodingVisitor();
 
 
-    public KerberosDecoder()
+    public KerberosTcpDecoder()
     {
         treeDecoder.setCallback( new TreeDecodedCallback() );
         treeEncoder.setCallback( new TreeEncodedCallback() );
@@ -55,6 +59,15 @@
      */
     public void decode( Object encoded ) throws DecoderException
     {
+    	ByteBuffer buf = ( ByteBuffer ) encoded;
+    	
+    	/**
+    	 * TCP requests are preceded by the length of the request as 4 octets in 
+    	 * network byte order.  We don't currently use the length, but need to
+    	 * strip it off prior to passing the PDU to the decoder.
+    	 */
+    	buf.getInt();
+    	
         treeDecoder.decode( encoded );
     }
 
@@ -88,7 +101,7 @@
         {
             if ( encoded instanceof ByteBuffer )
             {
-                KerberosDecoder.this.decodeOccurred( encoded );
+                KerberosTcpDecoder.this.decodeOccurred( encoded );
                 return;
             }
 
@@ -108,7 +121,7 @@
                     consolidated.put( buffers[ii] );
                 }
 
-                KerberosDecoder.this.decodeOccurred( consolidated );
+                KerberosTcpDecoder.this.decodeOccurred( consolidated );
                 return;
             }
 

Modified: incubator/directory/kerberos/trunk/protocol/src/java/org/apache/kerberos/kdc/server/seda/KerberosTcpEncoder.java
Url: http://svn.apache.org/viewcvs/incubator/directory/kerberos/trunk/protocol/src/java/org/apache/kerberos/kdc/server/seda/KerberosTcpEncoder.java?view=diff&rev=123282&p1=incubator/directory/kerberos/trunk/protocol/src/java/org/apache/kerberos/kdc/server/seda/KerberosTcpEncoder.java&r1=123281&p2=incubator/directory/kerberos/trunk/protocol/src/java/org/apache/kerberos/kdc/server/seda/KerberosTcpEncoder.java&r2=123282
==============================================================================
--- incubator/directory/kerberos/trunk/protocol/src/java/org/apache/kerberos/kdc/server/seda/KerberosTcpEncoder.java
(original)
+++ incubator/directory/kerberos/trunk/protocol/src/java/org/apache/kerberos/kdc/server/seda/KerberosTcpEncoder.java
Thu Dec 23 23:12:42 2004
@@ -26,7 +26,7 @@
  * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>
  * @version $Rev: 56478 $
  */
-public class KerberosEncoder extends AbstractStatefulEncoder
+public class KerberosTcpEncoder extends AbstractStatefulEncoder
 {
     /**
      * Returns an encoded Kerberos PDU.  The codec is an identity

Modified: incubator/directory/kerberos/trunk/protocol/src/java/org/apache/kerberos/kdc/server/seda/KerberosTcpProvider.java
Url: http://svn.apache.org/viewcvs/incubator/directory/kerberos/trunk/protocol/src/java/org/apache/kerberos/kdc/server/seda/KerberosTcpProvider.java?view=diff&rev=123282&p1=incubator/directory/kerberos/trunk/protocol/src/java/org/apache/kerberos/kdc/server/seda/KerberosTcpProvider.java&r1=123281&p2=incubator/directory/kerberos/trunk/protocol/src/java/org/apache/kerberos/kdc/server/seda/KerberosTcpProvider.java&r2=123282
==============================================================================
--- incubator/directory/kerberos/trunk/protocol/src/java/org/apache/kerberos/kdc/server/seda/KerberosTcpProvider.java
(original)
+++ incubator/directory/kerberos/trunk/protocol/src/java/org/apache/kerberos/kdc/server/seda/KerberosTcpProvider.java
Thu Dec 23 23:12:42 2004
@@ -17,20 +17,20 @@
 
 package org.apache.kerberos.kdc.server.seda;
 
-import java.nio.ByteBuffer;
 import java.io.IOException;
+import java.nio.ByteBuffer;
 
-import org.apache.snickers.codec.stateful.DecoderFactory;
-import org.apache.snickers.codec.stateful.EncoderFactory;
-import org.apache.snickers.codec.stateful.StatefulDecoder;
-import org.apache.snickers.codec.stateful.StatefulEncoder;
+import org.apache.kerberos.kdc.KdcDispatcher;
+import org.apache.ldap.common.util.NestableRuntimeException;
 import org.apache.seda.listener.ClientKey;
+import org.apache.seda.protocol.HandlerTypeEnum;
 import org.apache.seda.protocol.ProtocolProvider;
 import org.apache.seda.protocol.RequestHandler;
 import org.apache.seda.protocol.SingleReplyHandler;
-import org.apache.seda.protocol.HandlerTypeEnum;
-import org.apache.kerberos.kdc.KdcDispatcher;
-import org.apache.ldap.common.util.NestableRuntimeException;
+import org.apache.snickers.codec.stateful.DecoderFactory;
+import org.apache.snickers.codec.stateful.EncoderFactory;
+import org.apache.snickers.codec.stateful.StatefulDecoder;
+import org.apache.snickers.codec.stateful.StatefulEncoder;
 
 
 /**
@@ -40,7 +40,7 @@
  * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>
  * @version $Rev: 56478 $
  */
-public final class KerberosProtocolProvider implements ProtocolProvider
+public final class KerberosTcpProvider implements ProtocolProvider
 {
     /** the authoritative service name of this internet protocol: 'kerberos' */
     public static final String NAME = "kerberos";
@@ -51,7 +51,7 @@
     public final KdcDispatcher kdc;
 
 
-    public KerberosProtocolProvider( KdcDispatcher kdc )
+    public KerberosTcpProvider( KdcDispatcher kdc )
     {
         this.kdc = kdc;
     }
@@ -87,7 +87,7 @@
                  */
                 public StatefulDecoder createDecoder()
                 {
-                    return new KerberosDecoder();
+                    return new KerberosTcpDecoder();
                 }
             };
     }
@@ -111,7 +111,7 @@
                  */
                 public StatefulEncoder createEncoder()
                 {
-                    return new KerberosEncoder();
+                    return new KerberosTcpEncoder();
                 }
             };
     }
@@ -126,7 +126,6 @@
     }
 
 
-
     class KerberosHandler implements SingleReplyHandler
     {
         public HandlerTypeEnum getHandlerType()
@@ -145,10 +144,19 @@
              * is wrapped instead of direct.  This MUST change in the future!
              */
             byte[] pdu = ( ( ByteBuffer ) request ).array();
-
+            
             try
             {
-                return ByteBuffer.wrap( kdc.dispatch( pdu ) );
+            	byte[] pduBytes = kdc.dispatch( pdu );
+            	
+            	int integerLength = 4;
+            	
+            	ByteBuffer buf = ByteBuffer.allocate( pduBytes.length + integerLength );
+            	buf.putInt( pduBytes.length );
+            	buf.put( pduBytes );
+            	buf.flip();
+            	
+                return buf;
             }
             catch( IOException e )
             {

Modified: incubator/directory/kerberos/trunk/protocol/src/java/org/apache/kerberos/kdc/server/seda/KerberosUdpDecoder.java
Url: http://svn.apache.org/viewcvs/incubator/directory/kerberos/trunk/protocol/src/java/org/apache/kerberos/kdc/server/seda/KerberosUdpDecoder.java?view=diff&rev=123282&p1=incubator/directory/kerberos/trunk/protocol/src/java/org/apache/kerberos/kdc/server/seda/KerberosUdpDecoder.java&r1=123281&p2=incubator/directory/kerberos/trunk/protocol/src/java/org/apache/kerberos/kdc/server/seda/KerberosUdpDecoder.java&r2=123282
==============================================================================
--- incubator/directory/kerberos/trunk/protocol/src/java/org/apache/kerberos/kdc/server/seda/KerberosUdpDecoder.java
(original)
+++ incubator/directory/kerberos/trunk/protocol/src/java/org/apache/kerberos/kdc/server/seda/KerberosUdpDecoder.java
Thu Dec 23 23:12:42 2004
@@ -19,12 +19,16 @@
 
 import java.nio.ByteBuffer;
 
-import org.apache.snickers.codec.stateful.*;
+import org.apache.snickers.ber.TupleEncodingVisitor;
+import org.apache.snickers.ber.TupleNode;
+import org.apache.snickers.ber.TupleTreeDecoder;
 import org.apache.snickers.codec.DecoderException;
 import org.apache.snickers.codec.EncoderException;
-import org.apache.snickers.ber.TupleTreeDecoder;
-import org.apache.snickers.ber.TupleNode;
-import org.apache.snickers.ber.TupleEncodingVisitor;
+import org.apache.snickers.codec.stateful.AbstractStatefulDecoder;
+import org.apache.snickers.codec.stateful.DecoderCallback;
+import org.apache.snickers.codec.stateful.EncoderCallback;
+import org.apache.snickers.codec.stateful.StatefulDecoder;
+import org.apache.snickers.codec.stateful.StatefulEncoder;
 
 
 /**
@@ -33,13 +37,13 @@
  * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>
  * @version $Rev: 56478 $
  */
-public class KerberosDecoder extends AbstractStatefulDecoder
+public class KerberosUdpDecoder extends AbstractStatefulDecoder
 {
     TupleTreeDecoder treeDecoder = new TupleTreeDecoder();
     TupleEncodingVisitor treeEncoder = new TupleEncodingVisitor();
 
 
-    public KerberosDecoder()
+    public KerberosUdpDecoder()
     {
         treeDecoder.setCallback( new TreeDecodedCallback() );
         treeEncoder.setCallback( new TreeEncodedCallback() );
@@ -88,7 +92,7 @@
         {
             if ( encoded instanceof ByteBuffer )
             {
-                KerberosDecoder.this.decodeOccurred( encoded );
+                KerberosUdpDecoder.this.decodeOccurred( encoded );
                 return;
             }
 
@@ -108,7 +112,7 @@
                     consolidated.put( buffers[ii] );
                 }
 
-                KerberosDecoder.this.decodeOccurred( consolidated );
+                KerberosUdpDecoder.this.decodeOccurred( consolidated );
                 return;
             }
 

Modified: incubator/directory/kerberos/trunk/protocol/src/java/org/apache/kerberos/kdc/server/seda/KerberosUdpEncoder.java
Url: http://svn.apache.org/viewcvs/incubator/directory/kerberos/trunk/protocol/src/java/org/apache/kerberos/kdc/server/seda/KerberosUdpEncoder.java?view=diff&rev=123282&p1=incubator/directory/kerberos/trunk/protocol/src/java/org/apache/kerberos/kdc/server/seda/KerberosUdpEncoder.java&r1=123281&p2=incubator/directory/kerberos/trunk/protocol/src/java/org/apache/kerberos/kdc/server/seda/KerberosUdpEncoder.java&r2=123282
==============================================================================
--- incubator/directory/kerberos/trunk/protocol/src/java/org/apache/kerberos/kdc/server/seda/KerberosUdpEncoder.java
(original)
+++ incubator/directory/kerberos/trunk/protocol/src/java/org/apache/kerberos/kdc/server/seda/KerberosUdpEncoder.java
Thu Dec 23 23:12:42 2004
@@ -26,7 +26,7 @@
  * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>
  * @version $Rev: 56478 $
  */
-public class KerberosEncoder extends AbstractStatefulEncoder
+public class KerberosUdpEncoder extends AbstractStatefulEncoder
 {
     /**
      * Returns an encoded Kerberos PDU.  The codec is an identity

Modified: incubator/directory/kerberos/trunk/protocol/src/java/org/apache/kerberos/kdc/server/seda/KerberosUdpProvider.java
Url: http://svn.apache.org/viewcvs/incubator/directory/kerberos/trunk/protocol/src/java/org/apache/kerberos/kdc/server/seda/KerberosUdpProvider.java?view=diff&rev=123282&p1=incubator/directory/kerberos/trunk/protocol/src/java/org/apache/kerberos/kdc/server/seda/KerberosUdpProvider.java&r1=123281&p2=incubator/directory/kerberos/trunk/protocol/src/java/org/apache/kerberos/kdc/server/seda/KerberosUdpProvider.java&r2=123282
==============================================================================
--- incubator/directory/kerberos/trunk/protocol/src/java/org/apache/kerberos/kdc/server/seda/KerberosUdpProvider.java
(original)
+++ incubator/directory/kerberos/trunk/protocol/src/java/org/apache/kerberos/kdc/server/seda/KerberosUdpProvider.java
Thu Dec 23 23:12:42 2004
@@ -17,20 +17,20 @@
 
 package org.apache.kerberos.kdc.server.seda;
 
-import java.nio.ByteBuffer;
 import java.io.IOException;
+import java.nio.ByteBuffer;
 
-import org.apache.snickers.codec.stateful.DecoderFactory;
-import org.apache.snickers.codec.stateful.EncoderFactory;
-import org.apache.snickers.codec.stateful.StatefulDecoder;
-import org.apache.snickers.codec.stateful.StatefulEncoder;
+import org.apache.kerberos.kdc.KdcDispatcher;
+import org.apache.ldap.common.util.NestableRuntimeException;
 import org.apache.seda.listener.ClientKey;
+import org.apache.seda.protocol.HandlerTypeEnum;
 import org.apache.seda.protocol.ProtocolProvider;
 import org.apache.seda.protocol.RequestHandler;
 import org.apache.seda.protocol.SingleReplyHandler;
-import org.apache.seda.protocol.HandlerTypeEnum;
-import org.apache.kerberos.kdc.KdcDispatcher;
-import org.apache.ldap.common.util.NestableRuntimeException;
+import org.apache.snickers.codec.stateful.DecoderFactory;
+import org.apache.snickers.codec.stateful.EncoderFactory;
+import org.apache.snickers.codec.stateful.StatefulDecoder;
+import org.apache.snickers.codec.stateful.StatefulEncoder;
 
 
 /**
@@ -40,7 +40,7 @@
  * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>
  * @version $Rev: 56478 $
  */
-public final class KerberosProtocolProvider implements ProtocolProvider
+public final class KerberosUdpProvider implements ProtocolProvider
 {
     /** the authoritative service name of this internet protocol: 'kerberos' */
     public static final String NAME = "kerberos";
@@ -51,7 +51,7 @@
     public final KdcDispatcher kdc;
 
 
-    public KerberosProtocolProvider( KdcDispatcher kdc )
+    public KerberosUdpProvider( KdcDispatcher kdc )
     {
         this.kdc = kdc;
     }
@@ -87,7 +87,7 @@
                  */
                 public StatefulDecoder createDecoder()
                 {
-                    return new KerberosDecoder();
+                    return new KerberosUdpDecoder();
                 }
             };
     }
@@ -111,7 +111,7 @@
                  */
                 public StatefulEncoder createEncoder()
                 {
-                    return new KerberosEncoder();
+                    return new KerberosUdpEncoder();
                 }
             };
     }
@@ -124,7 +124,6 @@
     {
         return handler;
     }
-
 
 
     class KerberosHandler implements SingleReplyHandler

Mime
View raw message