Browse Source

SEC-1732: Raise an exception if more than one LDIF resource is found.

Luke Taylor 14 years ago
parent
commit
12121dcc54

+ 7 - 1
ldap/src/main/java/org/springframework/security/ldap/server/ApacheDSContainer.java

@@ -232,7 +232,11 @@ public class ApacheDSContainer implements InitializingBean, DisposableBean, Life
         // We need a standard context.
         //DirContext dirContext = contextSource.getReadWriteContext();
 
-        if(ldifs != null && ldifs.length > 0) {
+        if (ldifs == null || ldifs.length == 0) {
+            return;
+        }
+
+        if(ldifs.length == 1) {
             String ldifFile;
 
             try {
@@ -243,6 +247,8 @@ public class ApacheDSContainer implements InitializingBean, DisposableBean, Life
             logger.info("Loading LDIF file: " + ldifFile);
             LdifFileLoader loader = new LdifFileLoader(service.getAdminSession(), ldifFile);
             loader.execute();
+        } else {
+            throw new IllegalArgumentException("More than one LDIF resource found with the supplied pattern:" + ldifResources);
         }
     }