Remove use of property editor internally.
This commit is contained in:
parent
074fa7d629
commit
f6e2e36346
|
@ -1,6 +1,8 @@
|
||||||
package org.springframework.security.config;
|
package org.springframework.security.config;
|
||||||
|
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import org.springframework.aop.config.AbstractInterceptorDrivenBeanDefinitionDecorator;
|
import org.springframework.aop.config.AbstractInterceptorDrivenBeanDefinitionDecorator;
|
||||||
import org.springframework.beans.factory.config.BeanDefinition;
|
import org.springframework.beans.factory.config.BeanDefinition;
|
||||||
|
@ -10,7 +12,10 @@ import org.springframework.beans.factory.support.BeanDefinitionBuilder;
|
||||||
import org.springframework.beans.factory.support.RootBeanDefinition;
|
import org.springframework.beans.factory.support.RootBeanDefinition;
|
||||||
import org.springframework.beans.factory.xml.BeanDefinitionDecorator;
|
import org.springframework.beans.factory.xml.BeanDefinitionDecorator;
|
||||||
import org.springframework.beans.factory.xml.ParserContext;
|
import org.springframework.beans.factory.xml.ParserContext;
|
||||||
|
import org.springframework.security.access.ConfigAttribute;
|
||||||
|
import org.springframework.security.access.SecurityConfig;
|
||||||
import org.springframework.security.access.intercept.aopalliance.MethodSecurityInterceptor;
|
import org.springframework.security.access.intercept.aopalliance.MethodSecurityInterceptor;
|
||||||
|
import org.springframework.security.access.method.MapBasedMethodSecurityMetadataSource;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
import org.springframework.util.xml.DomUtils;
|
import org.springframework.util.xml.DomUtils;
|
||||||
import org.w3c.dom.Element;
|
import org.w3c.dom.Element;
|
||||||
|
@ -65,11 +70,10 @@ class InternalInterceptMethodsBeanDefinitionDecorator extends AbstractIntercepto
|
||||||
|
|
||||||
// Parse the included methods
|
// Parse the included methods
|
||||||
List<Element> methods = DomUtils.getChildElementsByTagName(interceptMethodsElt, Elements.PROTECT);
|
List<Element> methods = DomUtils.getChildElementsByTagName(interceptMethodsElt, Elements.PROTECT);
|
||||||
|
Map<String, List<ConfigAttribute>> mappings = new LinkedHashMap<String, List<ConfigAttribute>>();
|
||||||
StringBuffer sb = new StringBuffer();
|
|
||||||
|
|
||||||
for (Element protectmethodElt : methods) {
|
for (Element protectmethodElt : methods) {
|
||||||
String accessConfig = protectmethodElt.getAttribute(ATT_ACCESS);
|
String[] tokens = StringUtils.commaDelimitedListToStringArray(protectmethodElt.getAttribute(ATT_ACCESS));
|
||||||
|
|
||||||
// Support inference of class names
|
// Support inference of class names
|
||||||
String methodName = protectmethodElt.getAttribute(ATT_METHOD);
|
String methodName = protectmethodElt.getAttribute(ATT_METHOD);
|
||||||
|
@ -80,11 +84,11 @@ class InternalInterceptMethodsBeanDefinitionDecorator extends AbstractIntercepto
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Rely on the default property editor for MethodSecurityInterceptor.setSecurityMetadataSource to setup the MethodSecurityMetadataSource
|
mappings.put(methodName, SecurityConfig.createList(tokens));
|
||||||
sb.append(methodName + "=" + accessConfig).append("\r\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
interceptor.addPropertyValue("securityMetadataSource", sb.toString());
|
// TODO: Use a bean for the metadata source
|
||||||
|
interceptor.addPropertyValue("securityMetadataSource", new MapBasedMethodSecurityMetadataSource(mappings));
|
||||||
|
|
||||||
return interceptor.getBeanDefinition();
|
return interceptor.getBeanDefinition();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue