mirror of
https://github.com/spring-projects/spring-security.git
synced 2025-07-07 19:22:14 +00:00
SEC-1342: Introduced extra factory method in SecurityConfig to get round problem with Spring converting a string with commas to an array
This commit is contained in:
parent
115d5b84ff
commit
bcb1ff8921
@ -135,7 +135,7 @@ public class FilterInvocationSecurityMetadataSourceParser implements BeanDefinit
|
|||||||
if (useExpressions) {
|
if (useExpressions) {
|
||||||
logger.info("Creating access control expression attribute '" + access + "' for " + path);
|
logger.info("Creating access control expression attribute '" + access + "' for " + path);
|
||||||
// The single expression will be parsed later by the ExpressionFilterInvocationSecurityMetadataSource
|
// The single expression will be parsed later by the ExpressionFilterInvocationSecurityMetadataSource
|
||||||
attributeBuilder.setFactoryMethod("createList");
|
attributeBuilder.setFactoryMethod("createSingleAttributeList");
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
attributeBuilder.setFactoryMethod("createListFromCommaDelimitedString");
|
attributeBuilder.setFactoryMethod("createListFromCommaDelimitedString");
|
||||||
|
@ -1004,7 +1004,7 @@ public class HttpSecurityBeanDefinitionParserTests {
|
|||||||
public void expressionBasedAccessAllowsAndDeniesAccessAsExpected() throws Exception {
|
public void expressionBasedAccessAllowsAndDeniesAccessAsExpected() throws Exception {
|
||||||
setContext(
|
setContext(
|
||||||
" <http auto-config='true' use-expressions='true'>" +
|
" <http auto-config='true' use-expressions='true'>" +
|
||||||
" <intercept-url pattern='/secure*' access=\"hasRole('ROLE_A')\" />" +
|
" <intercept-url pattern='/secure*' access=\"hasAnyRole('ROLE_A','ROLE_C')\" />" +
|
||||||
" <intercept-url pattern='/**' access='permitAll()' />" +
|
" <intercept-url pattern='/**' access='permitAll()' />" +
|
||||||
" </http>" + AUTH_PROVIDER_XML);
|
" </http>" + AUTH_PROVIDER_XML);
|
||||||
|
|
||||||
|
@ -67,8 +67,12 @@ public class SecurityConfig implements ConfigAttribute {
|
|||||||
return createList(StringUtils.commaDelimitedListToStringArray(access));
|
return createList(StringUtils.commaDelimitedListToStringArray(access));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public final static List<ConfigAttribute> createSingleAttributeList(String access) {
|
||||||
|
return createList(access);
|
||||||
|
}
|
||||||
|
|
||||||
public final static List<ConfigAttribute> createList(String... attributeNames) {
|
public final static List<ConfigAttribute> createList(String... attributeNames) {
|
||||||
Assert.notNull(attributeNames, "You must supply a list of argument names");
|
Assert.notNull(attributeNames, "You must supply an array of attribute names");
|
||||||
List<ConfigAttribute> attributes = new ArrayList<ConfigAttribute>(attributeNames.length);
|
List<ConfigAttribute> attributes = new ArrayList<ConfigAttribute>(attributeNames.length);
|
||||||
|
|
||||||
for (String attribute : attributeNames) {
|
for (String attribute : attributeNames) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user