directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From erodrig...@apache.org
Subject svn commit: rev 56890 - in incubator/directory/kerberos/trunk/eve-kerberos/src/java/org/apache/kerberos/kdc/server: . udp
Date Mon, 08 Nov 2004 02:12:58 GMT
Author: erodriguez
Date: Sun Nov  7 18:12:57 2004
New Revision: 56890

Added:
   incubator/directory/kerberos/trunk/eve-kerberos/src/java/org/apache/kerberos/kdc/server/
   incubator/directory/kerberos/trunk/eve-kerberos/src/java/org/apache/kerberos/kdc/server/udp/
   incubator/directory/kerberos/trunk/eve-kerberos/src/java/org/apache/kerberos/kdc/server/udp/EveKerberosMain.java
Log:
Main class for combined Eve and Kerberos.

Added: incubator/directory/kerberos/trunk/eve-kerberos/src/java/org/apache/kerberos/kdc/server/udp/EveKerberosMain.java
==============================================================================
--- (empty file)
+++ incubator/directory/kerberos/trunk/eve-kerberos/src/java/org/apache/kerberos/kdc/server/udp/EveKerberosMain.java
Sun Nov  7 18:12:57 2004
@@ -0,0 +1,125 @@
+/*
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ *
+ */
+package org.apache.kerberos.kdc.server.udp;
+
+
+import org.apache.eve.jndi.EveContextFactory;
+import org.apache.kerberos.kdc.EmbeddedEveStore;
+import org.apache.kerberos.kdc.KdcConfiguration;
+import org.apache.kerberos.kdc.KdcDispatcher;
+import org.apache.kerberos.kdc.store.BootstrapStore;
+import org.apache.kerberos.kdc.store.PrincipalStore;
+
+import javax.naming.Context;
+import javax.naming.directory.BasicAttribute;
+import javax.naming.directory.BasicAttributes;
+import java.io.File;
+import java.io.IOException;
+import java.net.DatagramPacket;
+import java.net.DatagramSocket;
+import java.util.Hashtable;
+
+
+public class EveKerberosMain
+{
+    private static final KdcConfiguration config = new KdcConfiguration();
+    private static final BootstrapStore bootstrap = new BootstrapStore( config );
+    private static PrincipalStore ldap;
+    private static final KdcDispatcher kdc = new KdcDispatcher( config, bootstrap, ldap );
+
+
+    public static void main( String[] args )
+    {
+        EveKerberosMain m = new EveKerberosMain();
+        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" );
+
+        BasicAttributes attrs = new BasicAttributes( true );
+        BasicAttribute attr = new BasicAttribute( "objectClass" );
+        attr.add( "top" );
+        attr.add( "organizationalUnit" );
+        attr.add( "extensibleObject" );
+        attrs.put( attr );
+        attr = new BasicAttribute( "ou" );
+        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( EmbeddedEveStore.KDC_ENTRY_LDIF_FILE, "./src/ldif/example.com" );
+        env.put( EmbeddedEveStore.KDC_ENTRY_BASEDN_KEY, "ou=Users,dc=example,dc=com" );
+
+        ldap = new EmbeddedEveStore( env );
+
+        init();
+
+        DatagramSocket socket = null;
+        try
+        {
+            socket = new DatagramSocket( config.getDefaultPort() );
+
+            while ( true )
+            {
+                byte[] requestBytes = new byte[config.getBufferSize()];
+
+                DatagramPacket packet = new DatagramPacket( requestBytes, requestBytes.length
);
+                socket.receive( packet );
+
+                Thread worker = new Thread( new Connection( socket, packet, kdc ) );
+                worker.start();
+            }
+        }
+        catch ( IOException ioe )
+        {
+            ioe.printStackTrace();
+        }
+        finally
+        {
+            if ( socket != null )
+            {
+                socket.close();
+            }
+        }
+    }
+
+
+    private void init()
+    {
+        Runnable runnable = new Runnable()
+        {
+            public void run()
+            {
+                bootstrap.init();
+                ldap.init();
+            }
+        };
+        Thread storeInit = new Thread( runnable );
+        storeInit.start();
+    }
+}
+

Mime
View raw message