directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r122688 - in incubator/directory/kerberos/trunk: . core protocol protocol/src/java/org/apache/kerberos/kdc/server/seda store
Date Sat, 18 Dec 2004 00:10:52 GMT
Author: akarasulu
Date: Fri Dec 17 16:10:50 2004
New Revision: 122688

URL: http://svn.apache.org/viewcvs?view=rev&rev=122688
Log:
Changes ...

 o added deps needed for eve, core and store
 o implemented decoder as a tree decoder (creates a tlv tree) then encodes it
   back into bytes; inefficient way to figure out start and stop of a PDU but
   it works for now and is ok for small PDUs that kerberos usually has
 o implemented provider in total
 o decoder and encoder really don't do much since reliance of server internals
   are still on BC APIs
 o corrected some constants based on EnvKeys
 o version of all artifacts are now set at the top parent project's pom instead
   of individually in each maven child project pom



Removed:
   incubator/directory/kerberos/trunk/protocol/src/java/org/apache/kerberos/kdc/server/seda/KerberosHandler.java
Modified:
   incubator/directory/kerberos/trunk/core/project.xml
   incubator/directory/kerberos/trunk/project.xml
   incubator/directory/kerberos/trunk/protocol/project.xml
   incubator/directory/kerberos/trunk/protocol/src/java/org/apache/kerberos/kdc/server/seda/EveKerberosSedaMain.java
   incubator/directory/kerberos/trunk/protocol/src/java/org/apache/kerberos/kdc/server/seda/KerberosDecoder.java
   incubator/directory/kerberos/trunk/protocol/src/java/org/apache/kerberos/kdc/server/seda/KerberosProtocolProvider.java
   incubator/directory/kerberos/trunk/store/project.xml

Modified: incubator/directory/kerberos/trunk/core/project.xml
Url: http://svn.apache.org/viewcvs/incubator/directory/kerberos/trunk/core/project.xml?view=diff&rev=122688&p1=incubator/directory/kerberos/trunk/core/project.xml&r1=122687&p2=incubator/directory/kerberos/trunk/core/project.xml&r2=122688
==============================================================================
--- incubator/directory/kerberos/trunk/core/project.xml	(original)
+++ incubator/directory/kerberos/trunk/core/project.xml	Fri Dec 17 16:10:50 2004
@@ -7,7 +7,6 @@
   <id>kerberos-core</id>
   <name>Apache Kerberos Server</name>
   <package>org.apache.kerberos</package>
-  <currentVersion>0.4-SNAPSHOT</currentVersion>
   <inceptionYear>2002</inceptionYear>
   <shortDescription>The Apache Kerberos Server Core</shortDescription>
   <description>

Modified: incubator/directory/kerberos/trunk/project.xml
Url: http://svn.apache.org/viewcvs/incubator/directory/kerberos/trunk/project.xml?view=diff&rev=122688&p1=incubator/directory/kerberos/trunk/project.xml&r1=122687&p2=incubator/directory/kerberos/trunk/project.xml&r2=122688
==============================================================================
--- incubator/directory/kerberos/trunk/project.xml	(original)
+++ incubator/directory/kerberos/trunk/project.xml	Fri Dec 17 16:10:50 2004
@@ -5,6 +5,7 @@
     <id>kerberos</id>
     <name>Apache Kerberos</name>
     <version>SNAPSHOT</version>
+    <currentVersion>0.4-SNAPSHOT</currentVersion>
     
     <organization>
       <name>The Apache Incubator</name>

Modified: incubator/directory/kerberos/trunk/protocol/project.xml
Url: http://svn.apache.org/viewcvs/incubator/directory/kerberos/trunk/protocol/project.xml?view=diff&rev=122688&p1=incubator/directory/kerberos/trunk/protocol/project.xml&r1=122687&p2=incubator/directory/kerberos/trunk/protocol/project.xml&r2=122688
==============================================================================
--- incubator/directory/kerberos/trunk/protocol/project.xml	(original)
+++ incubator/directory/kerberos/trunk/protocol/project.xml	Fri Dec 17 16:10:50 2004
@@ -38,6 +38,24 @@
       <version>0.2-SNAPSHOT</version>
       <url>http://incubator.apache.org/directory/subprojects/seda</url>
     </dependency>
+    <dependency>
+      <groupId>incubator-directory</groupId>
+      <artifactId>eve</artifactId>
+      <version>0.8-SNAPSHOT</version>
+      <url>http://incubator.apache.org/directory/subprojects/eve</url>
+    </dependency>
+    <dependency>
+      <groupId>incubator-directory</groupId>
+      <artifactId>kerberos-core</artifactId>
+      <version>0.4-SNAPSHOT</version>
+      <url>http://incubator.apache.org/directory/subprojects/kerberos</url>
+    </dependency>
+    <dependency>
+      <groupId>incubator-directory</groupId>
+      <artifactId>kerberos-store</artifactId>
+      <version>0.4-SNAPSHOT</version>
+      <url>http://incubator.apache.org/directory/subprojects/kerberos</url>
+    </dependency>
   </dependencies>
 
   <reports>

Modified: incubator/directory/kerberos/trunk/protocol/src/java/org/apache/kerberos/kdc/server/seda/EveKerberosSedaMain.java
Url: http://svn.apache.org/viewcvs/incubator/directory/kerberos/trunk/protocol/src/java/org/apache/kerberos/kdc/server/seda/EveKerberosSedaMain.java?view=diff&rev=122688&p1=incubator/directory/kerberos/trunk/protocol/src/java/org/apache/kerberos/kdc/server/seda/EveKerberosSedaMain.java&r1=122687&p2=incubator/directory/kerberos/trunk/protocol/src/java/org/apache/kerberos/kdc/server/seda/EveKerberosSedaMain.java&r2=122688
==============================================================================
--- incubator/directory/kerberos/trunk/protocol/src/java/org/apache/kerberos/kdc/server/seda/EveKerberosSedaMain.java
(original)
+++ incubator/directory/kerberos/trunk/protocol/src/java/org/apache/kerberos/kdc/server/seda/EveKerberosSedaMain.java
Fri Dec 17 16:10:50 2004
@@ -17,7 +17,7 @@
 package org.apache.kerberos.kdc.server.seda;
 
 
-import org.apache.eve.jndi.EveContextFactory;
+import org.apache.eve.jndi.EnvKeys;
 import org.apache.kerberos.kdc.EmbeddedEveStore;
 import org.apache.kerberos.kdc.KdcConfiguration;
 import org.apache.kerberos.kdc.KdcDispatcher;
@@ -61,18 +61,20 @@
     /** the server port number for the protocol */
     protected int port;
 
+
     public static void main( String[] args )
     {
         EveKerberosSedaMain m = new EveKerberosSedaMain();
         m.go();
     }
 
+
     private void go()
     {
         Hashtable env = new Hashtable();
         env.put( Context.PROVIDER_URL, "dc=example,dc=com" );
         env.put( Context.INITIAL_CONTEXT_FACTORY, "org.apache.eve.jndi.EveContextFactory"
);
-        env.put( EveContextFactory.WKDIR_ENV, "target" + File.separator + "eve" );
+        env.put( EnvKeys.WKDIR, "target" + File.separator + "eve" );
 
         BasicAttributes attrs = new BasicAttributes( true );
         BasicAttribute attr = new BasicAttribute( "objectClass" );
@@ -84,10 +86,10 @@
         attr.add( "testing" );
         attrs.put( attr );
 
-        env.put( EveContextFactory.PARTITIONS_ENV, "example" );
-        env.put( EveContextFactory.SUFFIX_BASE_ENV + "example", "dc=example,dc=com" );
-        env.put( EveContextFactory.INDICES_BASE_ENV + "example", "ou objectClass" );
-        env.put( EveContextFactory.ATTRIBUTES_BASE_ENV + "example", attrs );
+        env.put( EnvKeys.PARTITIONS, "example" );
+        env.put( EnvKeys.SUFFIX + "example", "dc=example,dc=com" );
+        env.put( EnvKeys.INDICES + "example", "ou objectClass" );
+        env.put( EnvKeys.ATTRIBUTES + "example", attrs );
 
         env.put( EmbeddedEveStore.KDC_ENTRY_LDIF_FILE, "./src/ldif/example.com" );
         env.put( EmbeddedEveStore.KDC_ENTRY_BASEDN_KEY, "ou=Users,dc=example,dc=com" );
@@ -98,9 +100,9 @@
 
         try
         {
-            proto = new KerberosProtocolProvider();
-            setup();
             kdc = new KdcDispatcher( config, bootstrap, ldap );
+            proto = new KerberosProtocolProvider( kdc );
+            setup();
         }
         catch (Exception e)
         {
@@ -108,6 +110,7 @@
         }
     }
 
+
     /**
      * Instantiates the factory then gets a handle on the Frontend.
      *
@@ -131,6 +134,7 @@
         udpConfig = new UDPListenerConfig(InetAddress.getLocalHost(), srvEntry);
         fe.getUDPListenerManager().bind(udpConfig);
     }
+
 
     private void init()
     {

Modified: incubator/directory/kerberos/trunk/protocol/src/java/org/apache/kerberos/kdc/server/seda/KerberosDecoder.java
Url: http://svn.apache.org/viewcvs/incubator/directory/kerberos/trunk/protocol/src/java/org/apache/kerberos/kdc/server/seda/KerberosDecoder.java?view=diff&rev=122688&p1=incubator/directory/kerberos/trunk/protocol/src/java/org/apache/kerberos/kdc/server/seda/KerberosDecoder.java&r1=122687&p2=incubator/directory/kerberos/trunk/protocol/src/java/org/apache/kerberos/kdc/server/seda/KerberosDecoder.java&r2=122688
==============================================================================
--- incubator/directory/kerberos/trunk/protocol/src/java/org/apache/kerberos/kdc/server/seda/KerberosDecoder.java
(original)
+++ incubator/directory/kerberos/trunk/protocol/src/java/org/apache/kerberos/kdc/server/seda/KerberosDecoder.java
Fri Dec 17 16:10:50 2004
@@ -17,7 +17,14 @@
 
 package org.apache.kerberos.kdc.server.seda;
 
-import org.apache.snickers.codec.stateful.AbstractStatefulDecoder;
+import java.nio.ByteBuffer;
+
+import org.apache.snickers.codec.stateful.*;
+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;
 
 
 /**
@@ -28,6 +35,17 @@
  */
 public class KerberosDecoder extends AbstractStatefulDecoder
 {
+    TupleTreeDecoder treeDecoder = new TupleTreeDecoder();
+    TupleEncodingVisitor treeEncoder = new TupleEncodingVisitor();
+
+
+    public KerberosDecoder()
+    {
+        treeDecoder.setCallback( new TreeDecodedCallback() );
+        treeEncoder.setCallback( new TreeEncodedCallback() );
+    }
+
+
     /**
      * Returns a decoded Kerberos PDU.  The codec is an identity
      * operation.  Each decode call triggers a callback since we're presuming
@@ -35,9 +53,68 @@
      *
      * @param encoded the object to return which is a buffer
      */
-    public void decode(Object encoded)
+    public void decode( Object encoded ) throws DecoderException
+    {
+        treeDecoder.decode( encoded );
+    }
+
+
+    /**
+     * Callback set for the TupleTreeDecoder to trigger event for the creation
+     * of a tupe tree.
+     */
+    class TreeDecodedCallback implements DecoderCallback
+    {
+        public void decodeOccurred( StatefulDecoder decoder, Object decoded )
+        {
+            TupleNode root = ( TupleNode ) decoded;
+
+            try
+            {
+                treeEncoder.encode( root );
+                treeEncoder.flush();
+            }
+            catch ( EncoderException e )
+            {
+                e.printStackTrace();
+            }
+        }
+    }
+
+
+    class TreeEncodedCallback implements EncoderCallback
     {
-        super.decodeOccurred(encoded);
+        public void encodeOccurred( StatefulEncoder encoder, Object encoded )
+        {
+            if ( encoded instanceof ByteBuffer )
+            {
+                KerberosDecoder.this.decodeOccurred( encoded );
+                return;
+            }
+
+
+            if ( encoded instanceof ByteBuffer[] )
+            {
+                int size = 0;
+                ByteBuffer[] buffers = ( ByteBuffer[] ) encoded;
+                for ( int ii = 0; ii < buffers.length; ii++ )
+                {
+                    size += buffers[ii].remaining();
+                }
+
+                ByteBuffer consolidated = ByteBuffer.wrap( new byte[size] );
+                for ( int ii = 0; ii < buffers.length; ii++ )
+                {
+                    consolidated.put( buffers[ii] );
+                }
+
+                KerberosDecoder.this.decodeOccurred( consolidated );
+                return;
+            }
+
+            throw new IllegalArgumentException( "expected a ByteBuffer or a " +
+                    "ByteBuffer[] but got back a " + encoded.getClass() );
+        }
     }
 }
 

Deleted: /incubator/directory/kerberos/trunk/protocol/src/java/org/apache/kerberos/kdc/server/seda/KerberosHandler.java
Url: http://svn.apache.org/viewcvs/incubator/directory/kerberos/trunk/protocol/src/java/org/apache/kerberos/kdc/server/seda/KerberosHandler.java?view=auto&rev=122687
==============================================================================

Modified: incubator/directory/kerberos/trunk/protocol/src/java/org/apache/kerberos/kdc/server/seda/KerberosProtocolProvider.java
Url: http://svn.apache.org/viewcvs/incubator/directory/kerberos/trunk/protocol/src/java/org/apache/kerberos/kdc/server/seda/KerberosProtocolProvider.java?view=diff&rev=122688&p1=incubator/directory/kerberos/trunk/protocol/src/java/org/apache/kerberos/kdc/server/seda/KerberosProtocolProvider.java&r1=122687&p2=incubator/directory/kerberos/trunk/protocol/src/java/org/apache/kerberos/kdc/server/seda/KerberosProtocolProvider.java&r2=122688
==============================================================================
--- incubator/directory/kerberos/trunk/protocol/src/java/org/apache/kerberos/kdc/server/seda/KerberosProtocolProvider.java
(original)
+++ incubator/directory/kerberos/trunk/protocol/src/java/org/apache/kerberos/kdc/server/seda/KerberosProtocolProvider.java
Fri Dec 17 16:10:50 2004
@@ -17,6 +17,9 @@
 
 package org.apache.kerberos.kdc.server.seda;
 
+import java.nio.ByteBuffer;
+import java.io.IOException;
+
 import org.apache.snickers.codec.stateful.DecoderFactory;
 import org.apache.snickers.codec.stateful.EncoderFactory;
 import org.apache.snickers.codec.stateful.StatefulDecoder;
@@ -25,6 +28,9 @@
 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;
 
 
 /**
@@ -39,17 +45,17 @@
     /** the authoritative service name of this internet protocol: 'kerberos' */
     public static final String NAME = "kerberos";
 
-    /** a null decoder that triggers a callback returning the substrate as is */
-    public static final StatefulDecoder KERBEROS_DECODER =
-        new KerberosDecoder();
-
-    /** a null encoder that triggers a callback returning the substrate as is */
-    public static final StatefulEncoder KERBEROS_ENCODER =
-        new KerberosEncoder();
-
     /** kerberos handler where request is return back as a response */
-    public static final SingleReplyHandler KERBEROS_HANDLER =
-        new KerberosHandler();
+    public final SingleReplyHandler handler = new KerberosHandler();
+    /** the kerberos dispatcher */
+    public final KdcDispatcher kdc;
+
+
+    public KerberosProtocolProvider( KdcDispatcher kdc )
+    {
+        this.kdc = kdc;
+    }
+
 
     /**
      * Gets the authoritative name for the service of this provider.
@@ -81,7 +87,7 @@
                  */
                 public StatefulDecoder createDecoder()
                 {
-                    return KERBEROS_DECODER;
+                    return new KerberosDecoder();
                 }
             };
     }
@@ -105,7 +111,7 @@
                  */
                 public StatefulEncoder createEncoder()
                 {
-                    return KERBEROS_ENCODER;
+                    return new KerberosEncoder();
                 }
             };
     }
@@ -116,7 +122,41 @@
      */
     public RequestHandler getHandler(ClientKey key, Object request)
     {
-        return KERBEROS_HANDLER;
+        return handler;
+    }
+
+
+
+    class KerberosHandler implements SingleReplyHandler
+    {
+        public HandlerTypeEnum getHandlerType()
+        {
+            return HandlerTypeEnum.SINGLEREPLY;
+        }
+
+
+        public Object handle( ClientKey key, Object request )
+        {
+            /*
+             * We know this is really bad form: meaning the .array() usage.
+             * Basically this is designed for the current decoder which we know
+             * creates consolidated byte[]s of multiple buffers.  So .array()
+             * does return the entire pdu or the entire buffer and we know this
+             * is wrapped instead of direct.  This MUST change in the future!
+             */
+            byte[] pdu = ( ( ByteBuffer ) request ).array();
+
+            try
+            {
+                return ByteBuffer.wrap( kdc.dispatch( pdu ) );
+            }
+            catch( IOException e )
+            {
+                e.printStackTrace();
+                throw new NestableRuntimeException(
+                        "Dispatcher failed to process kerberos request!", e );
+            }
+        }
     }
 }
 

Modified: incubator/directory/kerberos/trunk/store/project.xml
Url: http://svn.apache.org/viewcvs/incubator/directory/kerberos/trunk/store/project.xml?view=diff&rev=122688&p1=incubator/directory/kerberos/trunk/store/project.xml&r1=122687&p2=incubator/directory/kerberos/trunk/store/project.xml&r2=122688
==============================================================================
--- incubator/directory/kerberos/trunk/store/project.xml	(original)
+++ incubator/directory/kerberos/trunk/store/project.xml	Fri Dec 17 16:10:50 2004
@@ -6,7 +6,6 @@
   <id>kerberos-store</id>
   <name>Apache Kerberos Backed by Eve</name>
   <package>org.apache.kerberos</package>
-  <currentVersion>SNAPSHOT</currentVersion>
   <inceptionYear>2002</inceptionYear>
   <shortDescription>The Apache Kerberos Server using Eve (LDAP) Server as a backend</shortDescription>
   <description>

Mime
View raw message