diff --git a/core/src/main/java/org/springframework/security/config/FilterChainMapBeanDefinitionDecorator.java b/core/src/main/java/org/springframework/security/config/FilterChainMapBeanDefinitionDecorator.java index 5ffe74b7a6..63c1d9bf42 100644 --- a/core/src/main/java/org/springframework/security/config/FilterChainMapBeanDefinitionDecorator.java +++ b/core/src/main/java/org/springframework/security/config/FilterChainMapBeanDefinitionDecorator.java @@ -1,6 +1,5 @@ package org.springframework.security.config; -import org.springframework.beans.BeansException; import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.beans.factory.config.BeanDefinitionHolder; import org.springframework.beans.factory.config.RuntimeBeanReference; @@ -8,9 +7,6 @@ import org.springframework.beans.factory.support.ManagedList; import org.springframework.beans.factory.support.ManagedMap; import org.springframework.beans.factory.xml.BeanDefinitionDecorator; import org.springframework.beans.factory.xml.ParserContext; -import org.springframework.context.ApplicationContext; -import org.springframework.context.ApplicationContextAware; -import org.springframework.security.intercept.web.FilterChainMap; import org.springframework.security.util.RegexUrlPathMatcher; import org.springframework.util.Assert; import org.springframework.util.StringUtils; @@ -26,7 +22,7 @@ import java.util.*; * @author Luke Taylor * @version $Id$ */ -public class FilterChainMapBeanDefinitionDecorator implements BeanDefinitionDecorator { +class FilterChainMapBeanDefinitionDecorator implements BeanDefinitionDecorator { public static final String FILTER_CHAIN_ELT_NAME = "filter-chain"; public BeanDefinitionHolder decorate(Node node, BeanDefinitionHolder holder, ParserContext parserContext) { diff --git a/core/src/main/java/org/springframework/security/intercept/web/FilterChainMap.java b/core/src/main/java/org/springframework/security/intercept/web/FilterChainMap.java deleted file mode 100644 index d41e6f7e2f..0000000000 --- a/core/src/main/java/org/springframework/security/intercept/web/FilterChainMap.java +++ /dev/null @@ -1,107 +0,0 @@ -package org.springframework.security.intercept.web; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.springframework.beans.factory.InitializingBean; -import org.springframework.security.util.AntUrlPathMatcher; -import org.springframework.security.util.UrlMatcher; -import org.springframework.util.Assert; - -import javax.servlet.Filter; -import java.util.*; - -/** - * Maps filter invocations to filter chains. Used to configure FilterChainProxy. - * - * @see org.springframework.security.util.FilterChainProxy - * - * @author luke - * @version $Id$ - * @since 2.0 - */ -public class FilterChainMap implements InitializingBean { - private static final Log logger = LogFactory.getLog(FilterChainMap.class); - - private List paths = new ArrayList(); - private List compiledPaths = new ArrayList(); - private List filterChains = new ArrayList(); - - private UrlMatcher matcher = new AntUrlPathMatcher(); - - public FilterChainMap() { - } - - public void afterPropertiesSet() throws Exception { - Assert.notEmpty(paths, "No secure URL paths defined"); - } - - public void addSecureUrl(String path, Filter[] filters) { - Assert.hasText(path, "The Path must not be empty or null"); - Assert.notNull(filters, "The Filter array must not be null"); - paths.add(path); - compiledPaths.add(matcher.compile(path)); - filterChains.add(filters); - - if (logger.isDebugEnabled()) { - logger.debug("Added pattern: " + path + "; filters: " + Arrays.asList(filters)); - } - } - - public void setUrlPathMatcher(UrlMatcher matcher) { - this.matcher = matcher; - } - - public UrlMatcher getMatcher() { - return matcher; - } - - /** - * Returns the first filter chain matching the supplied URL. - * - * @param url the request URL - * @return an ordered array of Filters defining the filter chain - */ - public Filter[] getFilters(String url) { - - for (int i=0; i < compiledPaths.size(); i++) { - Object path = compiledPaths.get(i); - - boolean matched = matcher.pathMatchesUrl(path, url); - - if (logger.isDebugEnabled()) { - logger.debug("Candidate is: '" + url + "'; pattern is " + paths.get(i) + "; matched=" + matched); - } - - if (matched) { - return (Filter[]) filterChains.get(i); - } - } - - return null; - } - - /** - * Obtains all of the uniqueFilter instances registered in the - * FilterChainMap. - *

This is useful in ensuring a Filter is not - * initialized or destroyed twice.

- * @return all of the Filter instances which have an entry - * in the FilterChainMap (only one entry is included in the array for - * each Filter instance, even if a given - * Filter is used multiples times by the FilterChainMap) - */ - public Filter[] getAllDefinedFilters() { - Set allFilters = new HashSet(); - - Iterator it = filterChains.iterator(); - while (it.hasNext()) { - Filter[] filterChain = (Filter[])it.next(); - - for(int i=0; i < filterChain.length; i++) { - allFilters.add(filterChain[i]); - } - } - - return (Filter[]) new ArrayList(allFilters).toArray(new Filter[0]); - } -} diff --git a/core/src/main/java/org/springframework/security/util/FilterChainProxy.java b/core/src/main/java/org/springframework/security/util/FilterChainProxy.java index 59b52c47ff..3c449d9053 100644 --- a/core/src/main/java/org/springframework/security/util/FilterChainProxy.java +++ b/core/src/main/java/org/springframework/security/util/FilterChainProxy.java @@ -112,11 +112,11 @@ public class FilterChainProxy implements Filter, InitializingBean, ApplicationCo public void afterPropertiesSet() throws Exception { // Convert the FilterDefinitionSource to a filterChainMap if set if (fids != null) { - Assert.isNull(uncompiledFilterChainMap, "Set the FilterChainMap or FilterInvocationDefinitionSource but not both"); + Assert.isNull(uncompiledFilterChainMap, "Set the filterChainMap or FilterInvocationDefinitionSource but not both"); setFilterChainMap(new FIDSToFilterChainMapConverter(fids, applicationContext).getFilterChainMap()); } - Assert.notNull(uncompiledFilterChainMap, "A FilterChainMap must be supplied"); + Assert.notNull(uncompiledFilterChainMap, "filterChainMap must be set"); } public void init(FilterConfig filterConfig) throws ServletException { @@ -204,7 +204,7 @@ public class FilterChainProxy implements Filter, InitializingBean, ApplicationCo * @return all of the Filter instances in the application context which have an entry * in the map (only one entry is included in the array for * each Filter that actually exists in application context, even if a given - * Filter is defined multiples times by the FilterChainMap) + * Filter is defined multiples times in the filter chain map) */ protected Filter[] obtainAllDefinedFilters() { Set allFilters = new HashSet();