diff --git a/config/src/main/java/org/springframework/security/config/http/FilterInvocationSecurityMetadataSourceParser.java b/config/src/main/java/org/springframework/security/config/http/FilterInvocationSecurityMetadataSourceParser.java index 4d7b68b6d3..57693d9314 100644 --- a/config/src/main/java/org/springframework/security/config/http/FilterInvocationSecurityMetadataSourceParser.java +++ b/config/src/main/java/org/springframework/security/config/http/FilterInvocationSecurityMetadataSourceParser.java @@ -65,11 +65,10 @@ public class FilterInvocationSecurityMetadataSourceParser implements BeanDefinit static BeanDefinition createSecurityMetadataSource(List interceptUrls, Element elt, ParserContext pc) { UrlMatcher matcher = HttpSecurityBeanDefinitionParser.createUrlMatcher(elt); - boolean convertPathsToLowerCase = (matcher instanceof AntUrlPathMatcher) && matcher.requiresLowerCaseUrl(); boolean useExpressions = isUseExpressions(elt); ManagedMap requestToAttributesMap = parseInterceptUrlsForFilterInvocationRequestMap( - interceptUrls, convertPathsToLowerCase, useExpressions, pc); + interceptUrls, useExpressions, pc); BeanDefinitionBuilder fidsBuilder; if (useExpressions) { @@ -105,7 +104,7 @@ public class FilterInvocationSecurityMetadataSourceParser implements BeanDefinit } private static ManagedMap parseInterceptUrlsForFilterInvocationRequestMap(List urlElts, - boolean useLowerCasePaths, boolean useExpressions, ParserContext parserContext) { + boolean useExpressions, ParserContext parserContext) { ManagedMap filterInvocationDefinitionMap = new ManagedMap(); @@ -121,17 +120,11 @@ public class FilterInvocationSecurityMetadataSourceParser implements BeanDefinit parserContext.getReaderContext().error("path attribute cannot be empty or null", urlElt); } - if (useLowerCasePaths) { - path = path.toLowerCase(); - } - String method = urlElt.getAttribute(ATT_HTTP_METHOD); if (!StringUtils.hasText(method)) { method = null; } - // Use beans to - BeanDefinitionBuilder keyBldr = BeanDefinitionBuilder.rootBeanDefinition(RequestKey.class); keyBldr.addConstructorArgValue(path); keyBldr.addConstructorArgValue(method); @@ -141,7 +134,7 @@ public class FilterInvocationSecurityMetadataSourceParser implements BeanDefinit if (useExpressions) { logger.info("Creating access control expression attribute '" + access + "' for " + path); - // The expression will be parsed later by the ExpressionFilterInvocationSecurityMetadataSource + // The single expression will be parsed later by the ExpressionFilterInvocationSecurityMetadataSource attributeBuilder.setFactoryMethod("createList"); } else { @@ -160,5 +153,4 @@ public class FilterInvocationSecurityMetadataSourceParser implements BeanDefinit return filterInvocationDefinitionMap; } - } diff --git a/config/src/main/java/org/springframework/security/config/http/PortMappingsBeanDefinitionParser.java b/config/src/main/java/org/springframework/security/config/http/PortMappingsBeanDefinitionParser.java index c28b68a882..e4903f09ca 100644 --- a/config/src/main/java/org/springframework/security/config/http/PortMappingsBeanDefinitionParser.java +++ b/config/src/main/java/org/springframework/security/config/http/PortMappingsBeanDefinitionParser.java @@ -1,20 +1,19 @@ package org.springframework.security.config.http; -import org.springframework.security.config.Elements; -import org.springframework.security.web.PortMapperImpl; -import org.springframework.beans.factory.xml.BeanDefinitionParser; -import org.springframework.beans.factory.xml.ParserContext; +import java.util.List; +import java.util.Map; + import org.springframework.beans.factory.config.BeanDefinition; +import org.springframework.beans.factory.support.ManagedMap; import org.springframework.beans.factory.support.RootBeanDefinition; +import org.springframework.beans.factory.xml.BeanDefinitionParser; +import org.springframework.beans.factory.xml.ParserContext; +import org.springframework.security.config.Elements; +import org.springframework.security.web.PortMapperImpl; import org.springframework.util.StringUtils; import org.springframework.util.xml.DomUtils; - import org.w3c.dom.Element; -import java.util.List; -import java.util.Map; -import java.util.HashMap; - /** * Parses a port-mappings element, producing a single {@link org.springframework.security.web.PortMapperImpl} * bean. @@ -37,7 +36,7 @@ class PortMappingsBeanDefinitionParser implements BeanDefinitionParser { parserContext.getReaderContext().error("No port-mapping child elements specified", element); } - Map mappings = new HashMap(); + Map mappings = new ManagedMap(); for (Element elt : mappingElts) { String httpPort = elt.getAttribute(ATT_HTTP_PORT); diff --git a/config/src/test/java/org/springframework/security/config/http/HttpSecurityBeanDefinitionParserTests.java b/config/src/test/java/org/springframework/security/config/http/HttpSecurityBeanDefinitionParserTests.java index dbc2b907eb..4d7c428535 100644 --- a/config/src/test/java/org/springframework/security/config/http/HttpSecurityBeanDefinitionParserTests.java +++ b/config/src/test/java/org/springframework/security/config/http/HttpSecurityBeanDefinitionParserTests.java @@ -329,7 +329,7 @@ public class HttpSecurityBeanDefinitionParserTests { // SEC-1201 @Test public void interceptUrlsAndFormLoginSupportPropertyPlaceholders() throws Exception { - System.setProperty("secure.url", "/secure"); + System.setProperty("secure.Url", "/Secure"); System.setProperty("secure.role", "ROLE_A"); System.setProperty("login.page", "/loginPage"); System.setProperty("default.target", "/defaultTarget"); @@ -337,11 +337,32 @@ public class HttpSecurityBeanDefinitionParserTests { setContext( "" + "" + - " " + + " " + " " + "" + AUTH_PROVIDER_XML); + checkPropertyValues() ; + } + + // SEC-1309 + @Test + public void interceptUrlsAndFormLoginSupportEL() throws Exception { + System.setProperty("secure.url", "/Secure"); + System.setProperty("secure.role", "ROLE_A"); + System.setProperty("login.page", "/loginPage"); + System.setProperty("default.target", "/defaultTarget"); + System.setProperty("auth.failure", "/authFailure"); + setContext( + "" + + "" + + " " + + " " + + "" + AUTH_PROVIDER_XML); + checkPropertyValues() ; + } + private void checkPropertyValues() throws Exception { // Check the security attribute FilterSecurityInterceptor fis = (FilterSecurityInterceptor) getFilter(FilterSecurityInterceptor.class); FilterInvocationSecurityMetadataSource fids = fis.getSecurityMetadataSource(); @@ -452,14 +473,14 @@ public class HttpSecurityBeanDefinitionParserTests { } @Test - public void portMappingsWorkWithPlaceholders() throws Exception { + public void portMappingsWorkWithPlaceholdersAndEL() throws Exception { System.setProperty("http", "9080"); System.setProperty("https", "9443"); setContext( " " + " " + " " + - " " + + " " + " " + " " + AUTH_PROVIDER_XML); @@ -475,7 +496,7 @@ public class HttpSecurityBeanDefinitionParserTests { } @Test - public void accessDeniedPageWorkWithPlaceholders() throws Exception { + public void accessDeniedPageWorksWithPlaceholders() throws Exception { System.setProperty("accessDenied", "/go-away"); setContext( " " + @@ -485,10 +506,10 @@ public class HttpSecurityBeanDefinitionParserTests { } @Test - public void accessDeniedHandlerPageIsSetCorectly() throws Exception { + public void accessDeniedHandlerPageWorksWithEL() throws Exception { setContext( " " + - " " + + " " + " " + AUTH_PROVIDER_XML); ExceptionTranslationFilter filter = (ExceptionTranslationFilter) getFilter(ExceptionTranslationFilter.class); assertEquals("/go-away", FieldUtils.getFieldValue(filter, "accessDeniedHandler.errorPage")); @@ -507,7 +528,7 @@ public class HttpSecurityBeanDefinitionParserTests { } @Test(expected=BeanDefinitionParsingException.class) - public void accessDeniedHandlerAndAccessDeniedHandlerAreMutuallyExclusive() throws Exception { + public void accessDeniedPageAndAccessDeniedHandlerAreMutuallyExclusive() throws Exception { setContext( " " + " " + @@ -595,11 +616,11 @@ public class HttpSecurityBeanDefinitionParserTests { public void rememberMeServiceWorksWithExternalServicesImpl() throws Exception { setContext( "" + - " " + + " " + "" + " " + " " + - " " + + " " + " " + "" + AUTH_PROVIDER_XML);