directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r584656 - /directory/apacheds/branches/bigbang/server-jndi/src/main/java/org/apache/directory/server/configuration/ApacheDS.java
Date Mon, 15 Oct 2007 02:25:20 GMT
Author: akarasulu
Date: Sun Oct 14 19:25:19 2007
New Revision: 584656

URL: http://svn.apache.org/viewvc?rev=584656&view=rev
Log:
cleaning up ApacheDS object and removing need to authenticate

Modified:
    directory/apacheds/branches/bigbang/server-jndi/src/main/java/org/apache/directory/server/configuration/ApacheDS.java

Modified: directory/apacheds/branches/bigbang/server-jndi/src/main/java/org/apache/directory/server/configuration/ApacheDS.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/server-jndi/src/main/java/org/apache/directory/server/configuration/ApacheDS.java?rev=584656&r1=584655&r2=584656&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/server-jndi/src/main/java/org/apache/directory/server/configuration/ApacheDS.java
(original)
+++ directory/apacheds/branches/bigbang/server-jndi/src/main/java/org/apache/directory/server/configuration/ApacheDS.java
Sun Oct 14 19:25:19 2007
@@ -24,28 +24,28 @@
 import org.apache.directory.server.constants.ApacheSchemaConstants;
 import org.apache.directory.server.core.DefaultDirectoryService;
 import org.apache.directory.server.core.DirectoryService;
-import org.apache.directory.server.core.jndi.CoreContextFactory;
+import org.apache.directory.server.core.authn.LdapPrincipal;
+import org.apache.directory.server.core.partition.PartitionNexus;
 import org.apache.directory.server.ldap.LdapServer;
 import org.apache.directory.server.protocol.shared.store.LdifFileLoader;
 import org.apache.directory.server.protocol.shared.store.LdifLoadFilter;
+import org.apache.directory.shared.ldap.aci.AuthenticationLevel;
 import org.apache.directory.shared.ldap.constants.SchemaConstants;
 import org.apache.directory.shared.ldap.message.AttributesImpl;
+import org.apache.directory.shared.ldap.name.LdapDN;
 import org.apache.directory.shared.ldap.util.StringTools;
 import org.apache.mina.common.ByteBuffer;
 import org.apache.mina.common.SimpleByteBufferAllocator;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import javax.naming.Context;
 import javax.naming.NamingException;
 import javax.naming.directory.Attributes;
 import javax.naming.directory.DirContext;
-import javax.naming.directory.InitialDirContext;
 import java.io.File;
 import java.io.FileFilter;
 import java.io.IOException;
 import java.util.ArrayList;
-import java.util.Hashtable;
 import java.util.List;
 
 
@@ -67,8 +67,6 @@
     private static final long DEFAULT_SYNC_PERIOD_MILLIS = 20000;
 
     private long synchPeriodMillis = DEFAULT_SYNC_PERIOD_MILLIS;
-    private boolean enableNetworking = true;
-    private Hashtable<String,Object> environment = new Hashtable<String,Object>();
 
     private File ldifDirectory;
     private final List<LdifLoadFilter> ldifFilters = new ArrayList<LdifLoadFilter>();
@@ -77,24 +75,14 @@
     private final LdapServer ldapsServer;
     private final DirectoryService directoryService;
 
-//    private SocketAcceptor tcpAcceptor;
-//    protected ExecutorService ioExecutor;
-//    protected ExecutorService logicExecutor;
 
-    
     public ApacheDS( DirectoryService directoryService, LdapServer ldapServer, LdapServer
ldapsServer )
     {
         this.directoryService = directoryService == null? new DefaultDirectoryService():
directoryService;
         this.ldapServer = ldapServer;
         this.ldapsServer = ldapsServer;
-//        ldapServer.setEnabled( true );
-
         ByteBuffer.setAllocator( new SimpleByteBufferAllocator() );
         ByteBuffer.setUseDirectBuffers( false );
-//        ioExecutor = Executors.newCachedThreadPool();
-//        logicExecutor = Executors.newFixedThreadPool( maxThreads );
-//        tcpAcceptor = new SocketAcceptor( Runtime.getRuntime().availableProcessors(), ioExecutor
);
-//        tcpAcceptor.getFilterChain().addLast( "executor", new ExecutorFilter( logicExecutor
) );
     }
 
 
@@ -106,10 +94,12 @@
         {
             directoryService.startup();
         }
+
         if ( ldapServer != null && ! ldapServer.isStarted() )
         {
             ldapServer.start();
         }
+
         if ( ldapsServer != null && ! ldapsServer.isStarted() )
         {
             ldapsServer.start();
@@ -141,6 +131,7 @@
         {
              return (ldapServer != null && ldapServer.isStarted()) || (ldapsServer
!= null && ldapsServer.isStarted());
         }
+        
         return directoryService.isStarted();
     }
     
@@ -157,36 +148,6 @@
             ldapsServer.stop();
         }
 
-/*
-        logicExecutor.shutdown();
-        for (;;) {
-            try {
-                if ( logicExecutor.awaitTermination( Integer.MAX_VALUE, TimeUnit.SECONDS
) )
-                {
-                    break;
-                }
-            }
-            catch ( InterruptedException e )
-            {
-                LOG.error( "Failed to terminate logic executor", e );
-            }
-        }
-
-        ioExecutor.shutdown();
-        for (;;) {
-            try {
-                if ( ioExecutor.awaitTermination( Integer.MAX_VALUE, TimeUnit.SECONDS ) )
-                {
-                    break;
-                }
-            }
-            catch ( InterruptedException e )
-            {
-                LOG.error( "Failed to terminate io executor", e );
-            }
-        }
-*/
-
         directoryService.shutdown();
     }
 
@@ -244,18 +205,6 @@
     }
 
 
-    public boolean isEnableNetworking()
-    {
-        return enableNetworking;
-    }
-
-
-    public void setEnableNetworking( boolean enableNetworking )
-    {
-        this.enableNetworking = enableNetworking;
-    }
-
-
     public File getLdifDirectory()
     {
         if ( ldifDirectory == null )
@@ -352,6 +301,7 @@
         return buf.toString();
     }
 
+    
     private void addFileEntry( DirContext root, File ldif ) throws NamingException
     {
 		String rdnAttr = File.separatorChar == '\\' ? WINDOWSFILE_ATTR : UNIXFILE_ATTR;
@@ -413,15 +363,10 @@
             return;
         }
 
-        // get an initial context to the rootDSE for creating the LDIF entries
-        //noinspection unchecked
-        Hashtable<String, Object> env = ( Hashtable<String, Object> ) environment.clone();
-        env.put( Context.PROVIDER_URL, "" );
-        env.put( DirectoryService.JNDI_KEY, directoryService );
-        env.put( Context.INITIAL_CONTEXT_FACTORY, CoreContextFactory.class.getName() );
-        DirContext root = new InitialDirContext( env );
 
-        // make sure the configuration area for loaded ldif files is present
+        LdapPrincipal admin = new LdapPrincipal( new LdapDN( PartitionNexus.ADMIN_PRINCIPAL
),
+                AuthenticationLevel.STRONG );
+        DirContext root = directoryService.getJndiContext( admin );
         ensureLdifFileBase( root );
 
         // if ldif directory is a file try to load it
@@ -491,17 +436,5 @@
             LOG.info( "Loaded " + count + " entries from LDIF file '" + getCanonical( ldifFile
) + "'" );
             addFileEntry( root, ldifFile );
         }
-    }
-
-
-    public Hashtable<String, Object> getEnvironment()
-    {
-        return environment;
-    }
-
-
-    public void setEnvironment( Hashtable<String, Object> environment )
-    {
-        this.environment = environment;
     }
 }



Mime
View raw message