knox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From m...@apache.org
Subject [04/25] knox git commit: KNOX-1088 - Remove LDAP BaseDirectoryService*
Date Thu, 02 Nov 2017 18:48:08 GMT
http://git-wip-us.apache.org/repos/asf/knox/blob/41952dd3/gateway-demo-ldap/src/main/java/org/apache/hadoop/gateway/security/ldap/SimpleLdapDirectoryServer.java
----------------------------------------------------------------------
diff --git a/gateway-demo-ldap/src/main/java/org/apache/hadoop/gateway/security/ldap/SimpleLdapDirectoryServer.java
b/gateway-demo-ldap/src/main/java/org/apache/hadoop/gateway/security/ldap/SimpleLdapDirectoryServer.java
index 12fe30d..b1685a1 100644
--- a/gateway-demo-ldap/src/main/java/org/apache/hadoop/gateway/security/ldap/SimpleLdapDirectoryServer.java
+++ b/gateway-demo-ldap/src/main/java/org/apache/hadoop/gateway/security/ldap/SimpleLdapDirectoryServer.java
@@ -25,12 +25,17 @@ import org.apache.directory.api.ldap.model.name.Dn;
 import org.apache.directory.server.core.api.CoreSession;
 import org.apache.directory.server.core.api.DirectoryService;
 import org.apache.directory.server.core.api.partition.Partition;
+import org.apache.directory.server.core.factory.DefaultDirectoryServiceFactory;
 import org.apache.directory.server.core.factory.DirectoryServiceFactory;
+import org.apache.directory.server.core.factory.JdbmPartitionFactory;
+import org.apache.directory.server.core.factory.PartitionFactory;
 import org.apache.directory.server.ldap.LdapServer;
 import org.apache.directory.server.protocol.shared.store.LdifFileLoader;
 import org.apache.directory.server.protocol.shared.transport.TcpTransport;
 import org.apache.directory.server.protocol.shared.transport.Transport;
 import org.apache.log4j.PropertyConfigurator;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import java.io.File;
 import java.io.FileNotFoundException;
@@ -39,6 +44,8 @@ import java.util.UUID;
 
 public class SimpleLdapDirectoryServer {
 
+  private static final Logger LOG = LoggerFactory.getLogger(SimpleLdapDirectoryServer.class);
+
   private DirectoryServiceFactory factory;
 
   private DirectoryService service;
@@ -50,7 +57,36 @@ public class SimpleLdapDirectoryServer {
       throw new FileNotFoundException( usersLdif.getAbsolutePath() );
     }
 
-    factory = new SimpleDirectoryServiceFactory();
+    DirectoryService directoryService = null;
+    try {
+      // creating the instance here so that
+      // we we can set some properties like accesscontrol, anon access
+      // before starting up the service
+      directoryService = new SimpleDirectoryService();
+
+      // no need to register a shutdown hook during tests because this
+      // starts a lot of threads and slows down test execution
+      directoryService.setShutdownHookEnabled( false );
+    } catch ( Exception e ) {
+      throw new RuntimeException( e );
+    }
+
+    PartitionFactory partitionFactory = null;
+    try {
+      String typeName = System.getProperty( "apacheds.partition.factory" );
+
+      if ( typeName != null ) {
+        Class<? extends PartitionFactory> type = ( Class<? extends PartitionFactory>
) Class.forName( typeName );
+        partitionFactory = type.newInstance();
+      } else {
+        partitionFactory = new JdbmPartitionFactory();
+      }
+    } catch ( Exception e ) {
+      LOG.error( "Error instantiating custom partiton factory", e );
+      throw new RuntimeException( e );
+    }
+
+    factory = new DefaultDirectoryServiceFactory( directoryService, partitionFactory );
     factory.init( UUID.randomUUID().toString() );
     service = factory.getDirectoryService();
 

http://git-wip-us.apache.org/repos/asf/knox/blob/41952dd3/gateway-demo-ldap/src/test/java/org/apache/hadoop/gateway/security/ldap/SimpleLdapServerTest.java
----------------------------------------------------------------------
diff --git a/gateway-demo-ldap/src/test/java/org/apache/hadoop/gateway/security/ldap/SimpleLdapServerTest.java
b/gateway-demo-ldap/src/test/java/org/apache/hadoop/gateway/security/ldap/SimpleLdapServerTest.java
index 33a367e..7d73219 100644
--- a/gateway-demo-ldap/src/test/java/org/apache/hadoop/gateway/security/ldap/SimpleLdapServerTest.java
+++ b/gateway-demo-ldap/src/test/java/org/apache/hadoop/gateway/security/ldap/SimpleLdapServerTest.java
@@ -23,14 +23,12 @@ import org.apache.directory.api.ldap.model.exception.LdapException;
 import org.apache.directory.ldap.client.api.LdapConnection;
 import org.apache.directory.ldap.client.api.LdapNetworkConnection;
 import org.apache.directory.server.protocol.shared.transport.TcpTransport;
-import org.apache.directory.server.protocol.shared.transport.Transport;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import org.junit.Test;
 
 import java.io.File;
 import java.io.IOException;
-import java.net.ServerSocket;
 
 import static org.junit.Assert.fail;
 

http://git-wip-us.apache.org/repos/asf/knox/blob/41952dd3/gateway-test-release/pom.xml
----------------------------------------------------------------------
diff --git a/gateway-test-release/pom.xml b/gateway-test-release/pom.xml
index 3d4cbc5..81ccbe1 100644
--- a/gateway-test-release/pom.xml
+++ b/gateway-test-release/pom.xml
@@ -128,17 +128,6 @@
         </dependency>
         <dependency>
             <groupId>org.apache.directory.server</groupId>
-            <artifactId>apacheds-core-integ</artifactId>
-            <version>${apacheds-version}</version>
-            <exclusions>
-                <exclusion>
-                    <groupId>org.apache.directory.api</groupId>
-                    <artifactId>api-ldap-schema-data</artifactId>
-                </exclusion>
-            </exclusions>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.directory.server</groupId>
             <artifactId>apacheds-all</artifactId>
             <exclusions>
                 <exclusion>

http://git-wip-us.apache.org/repos/asf/knox/blob/41952dd3/gateway-test/pom.xml
----------------------------------------------------------------------
diff --git a/gateway-test/pom.xml b/gateway-test/pom.xml
index 24e894b..f8576e6 100644
--- a/gateway-test/pom.xml
+++ b/gateway-test/pom.xml
@@ -109,20 +109,6 @@
             <scope>test</scope>
         </dependency>
 
-        <!--
-        <dependency>
-            <groupId>org.apache.directory.server</groupId>
-            <artifactId>apacheds-all</artifactId>
-            <scope>test</scope>
-            <exclusions>
-                <exclusion>
-                    <groupId>org.apache.directory.shared</groupId>
-                    <artifactId>shared-ldap-schema</artifactId>
-                </exclusion>
-            </exclusions>
-        </dependency>
-        -->
-
         <dependency>
             <groupId>org.apache.velocity</groupId>
             <artifactId>velocity</artifactId>


Mime
View raw message