public Collection<SecurityConstraint> getSecurityConstraintsForUrlPattern(String urlPattern) { Collection<SecurityConstraint> constraints = new HashSet<SecurityConstraint>(); for (Iterator<SecurityConstraint> i = getSecurityConstraintsSet().iterator(); i.hasNext();) { SecurityConstraint next = i.next(); boolean include = false; for (WebResourceCollection nextCol: next.getWebResourceCollections()) { for (String nextPattern: nextCol.getUrlPatterns()) { if ((urlPattern != null) && urlPattern.equals(nextPattern)) { include = true; break; } } if (include) { break; } } if (include) { constraints.add(next); } } return constraints; }
protected void combineSecurityConstraints(Set<SecurityConstraint> firstScSet, Set<SecurityConstraint> secondScSet) { Set<String> allUrlPatterns = new HashSet<String>(); for (SecurityConstraint sc : firstScSet) { for (WebResourceCollection wrc : sc.getWebResourceCollections()) { allUrlPatterns.addAll(wrc.getUrlPatterns()); } } for (SecurityConstraint sc : secondScSet) { SecurityConstraint newSc = new SecurityConstraintImpl((SecurityConstraintImpl)sc); boolean addSc = false; Iterator<WebResourceCollection> iter = newSc.getWebResourceCollections().iterator(); while (iter.hasNext()) { WebResourceCollection wrc = iter.next(); Set<String> urlPatterns = wrc.getUrlPatterns(); urlPatterns.removeAll(allUrlPatterns); boolean isEmpty = (urlPatterns.size() == 0); addSc = (addSc || (!isEmpty)); if (isEmpty) { iter.remove(); } } if (addSc) { firstScSet.add(newSc); } } }
/** * Given a WebComponentDescriptor, find the set of urlPattern which does not have * any existing url pattern in SecurityConstraint * @param webCompDesc * @return a list of url String */ public static Set<String> getUrlPatternsWithoutSecurityConstraint(WebComponentDescriptor webCompDesc) { Set<String> urlPatternsWithoutSC = new HashSet<String>(webCompDesc.getUrlPatternsSet()); WebBundleDescriptor webBundleDesc = webCompDesc.getWebBundleDescriptor(); Set<String> urlPatterns = webCompDesc.getUrlPatternsSet(); Enumeration<SecurityConstraint> eSecConstr = webBundleDesc.getSecurityConstraints(); while (eSecConstr.hasMoreElements()) { SecurityConstraint sc = eSecConstr.nextElement(); for (WebResourceCollection wrc : sc.getWebResourceCollections()) { urlPatternsWithoutSC.removeAll(wrc.getUrlPatterns()); } } return urlPatternsWithoutSC; }
public SecurityCollectionDecorator(WebResourceCollection decoree){ this.decoree = decoree; for (String urlPattern: decoree.getUrlPatterns()) { addPattern(urlPattern); } for (String httpMethod: decoree.getHttpMethods()) { addMethod(httpMethod); } for (String httpMethodOmission: decoree.getHttpMethodOmissions()) { addMethodOmission(httpMethodOmission); } }
for (String urlPattern: wrc.getUrlPatterns()) { logger.finest(" "+ urlPattern);
for (String urlPattern: wrc.getUrlPatterns()) { logger.finest(" "+ urlPattern);
for (String url: wrc.getUrlPatterns()) { if (url != null) {
for (String url: wrc.getUrlPatterns()) { if (url != null) {