From 12121dcc540e941c627211648e74f2456ff6d500 Mon Sep 17 00:00:00 2001 From: Luke Taylor Date: Tue, 3 May 2011 18:19:31 +0100 Subject: [PATCH] SEC-1732: Raise an exception if more than one LDIF resource is found. --- .../security/ldap/server/ApacheDSContainer.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/ldap/src/main/java/org/springframework/security/ldap/server/ApacheDSContainer.java b/ldap/src/main/java/org/springframework/security/ldap/server/ApacheDSContainer.java index c9a1209581..cf8c2b0833 100644 --- a/ldap/src/main/java/org/springframework/security/ldap/server/ApacheDSContainer.java +++ b/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); } }