RequestFilterChain requestChain(String pattern) { for (RequestFilterChain requestChain : requestChains) { if (requestChain.getPatterns().contains(pattern)) { return requestChain; } } return null; } }
/** * Get a list of patterns having the filter in their chain. If includeAll is false, only * authentication filters are searched */ public List<String> patternsForFilter(String filterName, boolean includeAll) { List<String> result = new ArrayList<String>(); for (RequestFilterChain requestChain : requestChains) { List<String> filterNames = includeAll ? requestChain.getCompiledFilterNames() : requestChain.getFilterNames(); if (filterNames.contains(filterName)) { result.addAll(requestChain.getPatterns()); } } return result; }
public static RequestFilterChain lookupRequestChainByPattern( String pattern, GeoServerSecurityManager secMgr) { // this is kind of a hack but we create an initial filter chain and run it through the // security provider extension points to get an actual final chain, and then look through // the elements for a matching name GeoServerSecurityFilterChain filterChain = createInitialChain(); filterChain.postConfigure(secMgr); for (RequestFilterChain requestChain : filterChain.getRequestChains()) { if (requestChain.getPatterns().contains(pattern)) { return requestChain; } } return null; }
/** * Creates a {@link GeoServerRequestMatcher} object for the specified {@link RequestFilterChain} * * @param chain */ public GeoServerRequestMatcher matcherForChain(RequestFilterChain chain) { Set<HTTPMethod> methods = chain.getHttpMethods(); if (chain.isMatchHTTPMethod() == false) methods = null; List<String> tmp = chain.getPatterns(); if (tmp == null) return new GeoServerRequestMatcher(methods, (RequestMatcher[]) null); // resolve multiple patterns separated by a comma List<String> patterns = new ArrayList<String>(); for (String pattern : tmp) { String[] array = pattern.split(","); for (String singlePattern : array) patterns.add(singlePattern); } RequestMatcher[] matchers = new RequestMatcher[patterns.size()]; for (int i = 0; i < matchers.length; i++) { matchers[i] = new IncludeQueryStringAntPathRequestMatcher(patterns.get(i)); } return new GeoServerRequestMatcher(methods, matchers); }
/** * converts an 2.3.x security configuration to 2.4.x * * @return <code>true</code> if migration has taken place */ boolean migrateFrom23() throws Exception { SecurityManagerConfig config = loadSecurityConfig(); RequestFilterChain webChain = config.getFilterChain() .getRequestChainByName(GeoServerSecurityFilterChain.WEB_CHAIN_NAME); boolean migrated = false; List<String> patterns = webChain.getPatterns(); if (patterns.contains("/") == false) { patterns.add("/"); saveSecurityConfig(config); migrated |= true; } return migrated; }
for (String s : requestChain.getPatterns()) { sb.append(s).append(",");
if (requestChain.getPatterns().isEmpty()) { throw createSecurityException( SecurityConfigException.PATTERN_LIST_EMPTY_$1, requestChain.getName());
public List<String> getPatterns() { return chain.getPatterns(); } public void setPatterns(List<String> patterns) {
public List<String> getPatterns() { return chain.getPatterns(); }
public String getPatternString() { if (chain.getPatterns()!=null) return StringUtils.collectionToCommaDelimitedString(chain.getPatterns()); else return ""; } public void setPatternString(String patternString) {
public String getPatternString() { if (chain.getPatterns() != null) return StringUtils.collectionToCommaDelimitedString(chain.getPatterns()); else return ""; }
@Override public Object getPropertyValue(RequestFilterChain item) { return StringUtils.collectionToCommaDelimitedString(item.getPatterns()); } };
public void setPatternString(String patternString) { if (StringUtils.hasLength(patternString)) chain.setPatterns( Arrays.asList(StringUtils.commaDelimitedListToStringArray(patternString))); else chain.getPatterns().clear(); }
@Override public Object getPropertyValue(RequestFilterChain item) { return StringUtils.collectionToCommaDelimitedString(item.getPatterns()); } };
public void setPatternString(String patternString) { if (StringUtils.hasLength(patternString)) chain.setPatterns( Arrays.asList(StringUtils.commaDelimitedListToStringArray(patternString))); else chain.getPatterns().clear(); } public boolean isGET() {