public FilterChain getChain(ServletRequest request, ServletResponse response, FilterChain originalChain) { FilterChainManager filterChainManager = getFilterChainManager(); if (!filterChainManager.hasChains()) { return null; } String requestURI = getPathWithinApplication(request); //the 'chain names' in this implementation are actually path patterns defined by the user. We just use them //as the chain name for the FilterChainManager's requirements for (String pathPattern : filterChainManager.getChainNames()) { // If the path does match, then pass on to the subclass implementation for specific checks: if (pathMatches(pathPattern, requestURI)) { if (log.isTraceEnabled()) { log.trace("Matched path pattern [" + pathPattern + "] for requestURI [" + requestURI + "]. " + "Utilizing corresponding filter chain..."); } return filterChainManager.proxy(originalChain, pathPattern); } } return null; }
protected void registerFilters(Map<String, Filter> filters, FilterChainManager manager) { if (!CollectionUtils.isEmpty(filters)) { boolean init = getFilterConfig() != null; //only call filter.init if there is a FilterConfig available for (Map.Entry<String, Filter> entry : filters.entrySet()) { String name = entry.getKey(); Filter filter = entry.getValue(); manager.addFilter(name, filter, init); } } }
protected void createChains(Map<String, String> urls, FilterChainManager manager) { if (CollectionUtils.isEmpty(urls)) { if (log.isDebugEnabled()) { log.debug("No urls to process."); } return; } if (log.isTraceEnabled()) { log.trace("Before url processing."); } for (Map.Entry<String, String> entry : urls.entrySet()) { String path = entry.getKey(); String value = entry.getValue(); manager.createChain(path, value); } } }
@Inject public OneFilterChainResolver( Set<FilterChainConfigurator> filterChainConfigurators, BasicAuthenticationFilter basicAuthenticationFilter) { super(); FilterChainManager filterChainManager = getFilterChainManager(); filterChainManager.addFilter("authcBasic", basicAuthenticationFilter); for (FilterChainConfigurator configurator: filterChainConfigurators) { configurator.configure(filterChainManager); } filterChainManager.createChain("/**", "authcBasic"); }
protected void buildChains(FilterChainManager manager, Ini ini) { //filters section: Ini.Section section = ini.getSection(FILTERS); if (!CollectionUtils.isEmpty(section)) { String msg = "The [{}] section has been deprecated and will be removed in a future release! Please " + "move all object configuration (filters and all other objects) to the [{}] section."; log.warn(msg, FILTERS, IniSecurityManagerFactory.MAIN_SECTION_NAME); } Map<String, Object> defaults = new LinkedHashMap<String, Object>(); Map<String, Filter> defaultFilters = manager.getFilters(); //now let's see if there are any object defaults in addition to the filters //these can be used to configure the filters: //create a Map of objects to use as the defaults: if (!CollectionUtils.isEmpty(defaultFilters)) { defaults.putAll(defaultFilters); } //User-provided objects must come _after_ the default filters - to allow the user-provided //ones to override the default filters if necessary. Map<String, ?> defaultBeans = getDefaults(); if (!CollectionUtils.isEmpty(defaultBeans)) { defaults.putAll(defaultBeans); } Map<String, Filter> filters = getFilters(section, defaults); //add the filters to the manager: registerFilters(filters, manager); //urls section: section = ini.getSection(URLS); createChains(section, manager); }
public FilterChain getChain(ServletRequest request, ServletResponse response, FilterChain originalChain) { FilterChainManager filterChainManager = getFilterChainManager(); if (!filterChainManager.hasChains()) { return null; } String requestURI = getPathWithinApplication(request); //the 'chain names' in this implementation are actually path patterns defined by the user. We just use them //as the chain name for the FilterChainManager's requirements for (String pathPattern : filterChainManager.getChainNames()) { // If the path does match, then pass on to the subclass implementation for specific checks: if (pathMatches(pathPattern, requestURI)) { if (log.isTraceEnabled()) { log.trace("Matched path pattern [" + pathPattern + "] for requestURI [" + requestURI + "]. " + "Utilizing corresponding filter chain..."); } // This is the only change we have made in this method. request.setAttribute(OCTOPUS_CHAIN_NAME, pathPattern); return filterChainManager.proxy(originalChain, pathPattern); } } return null; } }
@Override public FilterChain getChain(ServletRequest request, ServletResponse response, FilterChain originalChain) { FilterChainManager filterChainManager = this.getFilterChainManager(); if (!filterChainManager.hasChains()) { return null; } else { String requestURI = this.getPathWithinApplication(request); Iterator var6 = filterChainManager.getChainNames().iterator(); return filterChainManager.proxy(originalChain, pathPattern);