|
@@ -4,12 +4,13 @@ import org.springframework.beans.factory.config.BeanDefinition;
|
|
|
import org.springframework.beans.factory.config.PropertiesFactoryBean;
|
|
|
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
|
|
|
import org.springframework.beans.factory.support.RootBeanDefinition;
|
|
|
+import org.springframework.beans.factory.BeanDefinitionStoreException;
|
|
|
import org.springframework.security.userdetails.memory.InMemoryDaoImpl;
|
|
|
import org.springframework.security.userdetails.memory.UserMap;
|
|
|
import org.springframework.security.userdetails.User;
|
|
|
import org.springframework.security.util.AuthorityUtils;
|
|
|
import org.springframework.util.StringUtils;
|
|
|
-import org.springframework.util.Assert;
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
|
import org.springframework.util.xml.DomUtils;
|
|
|
import org.w3c.dom.Element;
|
|
|
|
|
@@ -40,8 +41,10 @@ public class UserServiceBeanDefinitionParser extends AbstractUserDetailsServiceB
|
|
|
List userElts = DomUtils.getChildElementsByTagName(element, ELT_USER);
|
|
|
|
|
|
if (StringUtils.hasText(userProperties)) {
|
|
|
- Assert.isTrue(userElts.isEmpty(), "Use of a properties file ('" + ATT_PROPERTIES + "' attribute) and <" +
|
|
|
- ELT_USER + "> elements are mutually exclusive.");
|
|
|
+
|
|
|
+ if(!CollectionUtils.isEmpty(userElts)) {
|
|
|
+ throw new BeanDefinitionStoreException("Use of a properties file and user elements are mutually exclusive");
|
|
|
+ }
|
|
|
|
|
|
BeanDefinition bd = new RootBeanDefinition(PropertiesFactoryBean.class);
|
|
|
bd.getPropertyValues().addPropertyValue("location", userProperties);
|
|
@@ -50,9 +53,11 @@ public class UserServiceBeanDefinitionParser extends AbstractUserDetailsServiceB
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- Assert.notEmpty(userElts, "You must supply user definitions, either with <" + ELT_USER + "> child elements or a " +
|
|
|
- "properties file (specified with the '" + ATT_PROPERTIES + "' attribute)" );
|
|
|
-
|
|
|
+ if(CollectionUtils.isEmpty(userElts)) {
|
|
|
+ throw new BeanDefinitionStoreException("You must supply user definitions, either with <" + ELT_USER + "> child elements or a " +
|
|
|
+ "properties file (using the '" + ATT_PROPERTIES + "' attribute)" );
|
|
|
+ }
|
|
|
+
|
|
|
UserMap users = new UserMap();
|
|
|
|
|
|
for (Iterator i = userElts.iterator(); i.hasNext();) {
|