directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From szoer...@apache.org
Subject svn commit: r907423 - /directory/sandbox/szoerner/passwordHashInterceptor/src/main/java/org/apache/directory/samples/interceptor/pwdhash/Main.java
Date Sun, 07 Feb 2010 14:34:32 GMT
Author: szoerner
Date: Sun Feb  7 14:34:31 2010
New Revision: 907423

URL: http://svn.apache.org/viewvc?rev=907423&view=rev
Log:
insert the interceptor just behind the NormalizationInterceptor

Modified:
    directory/sandbox/szoerner/passwordHashInterceptor/src/main/java/org/apache/directory/samples/interceptor/pwdhash/Main.java

Modified: directory/sandbox/szoerner/passwordHashInterceptor/src/main/java/org/apache/directory/samples/interceptor/pwdhash/Main.java
URL: http://svn.apache.org/viewvc/directory/sandbox/szoerner/passwordHashInterceptor/src/main/java/org/apache/directory/samples/interceptor/pwdhash/Main.java?rev=907423&r1=907422&r2=907423&view=diff
==============================================================================
--- directory/sandbox/szoerner/passwordHashInterceptor/src/main/java/org/apache/directory/samples/interceptor/pwdhash/Main.java
(original)
+++ directory/sandbox/szoerner/passwordHashInterceptor/src/main/java/org/apache/directory/samples/interceptor/pwdhash/Main.java
Sun Feb  7 14:34:31 2010
@@ -24,12 +24,13 @@
 import org.apache.directory.server.core.DefaultDirectoryService;
 import org.apache.directory.server.core.DirectoryService;
 import org.apache.directory.server.core.interceptor.Interceptor;
+import org.apache.directory.server.core.normalization.NormalizationInterceptor;
 import org.apache.directory.server.ldap.LdapServer;
 import org.apache.directory.server.protocol.shared.transport.TcpTransport;
 
 /**
- * Main class which starts an embedded server with the interceptor added to the
- * chain.
+ * Main class which starts an embedded server with the interceptor inserted into
+ * the chain.
  */
 public class Main {
 
@@ -38,14 +39,25 @@
         DirectoryService directoryService = new DefaultDirectoryService();
         directoryService.setShutdownHookEnabled(true);
 
+        List<Interceptor> interceptors = directoryService.getInterceptors();
+
+        // Find Normalization interceptor in chain
+        int insertionPosition = -1;
+        for (int pos = 0; pos < interceptors.size(); ++pos) {
+            Interceptor interceptor = interceptors.get(pos);
+            if (interceptor instanceof NormalizationInterceptor) {
+                insertionPosition = pos;
+            }
+        }
+
+        // insert our new interceptor just behind
+        interceptors.add(insertionPosition + 1, new PasswordHashInterceptor());
+        directoryService.setInterceptors(interceptors);
+
         LdapServer ldapServer = new LdapServer();
         ldapServer.setDirectoryService(directoryService);
         ldapServer.setAllowAnonymousAccess(true);
 
-        List<Interceptor> is = directoryService.getInterceptors();
-        is.add(new PasswordHashInterceptor());
-        directoryService.setInterceptors(is);
-
         TcpTransport ldapTransport = new TcpTransport(10389);
         ldapServer.setTransports(ldapTransport);
 



Mime
View raw message