List of usage examples for javax.servlet ServletSecurityElement ServletSecurityElement
public ServletSecurityElement(HttpConstraintElement constraint,
Collection<HttpMethodConstraintElement> methodConstraints)
From source file:com.jsmartframework.web.manager.ContextControl.java
private ServletSecurityElement getServletSecurityElement(ServletContext servletContext) { SecureMethod[] secureMethods = CONFIG.getContent().getSecureMethods(); if (secureMethods != null && secureMethods.length > 0) { HttpConstraintElement constraint = new HttpConstraintElement(); SecureMethod allMethods = CONFIG.getContent().getSecureMethod("*"); Set<HttpMethodConstraintElement> methodConstraints = new HashSet<HttpMethodConstraintElement>(); if (allMethods != null) { for (String method : METHODS) { HttpConstraintElement constraintElement = getHttpConstraintElement(allMethods); if (constraintElement != null) { methodConstraints.add(new HttpMethodConstraintElement(method, constraintElement)); }/*from ww w . j a va 2 s.c om*/ } } else { for (SecureMethod secureMethod : secureMethods) { HttpConstraintElement constraintElement = getHttpConstraintElement(secureMethod); if (constraintElement != null) { if (secureMethod.getMethod() == null || !METHODS.contains(secureMethod.getMethod().toUpperCase())) { throw new RuntimeException( "Method name declared in [secure-method] tag is unsupported! Supported values are HTTP methods."); } methodConstraints.add(new HttpMethodConstraintElement( secureMethod.getMethod().toUpperCase(), constraintElement)); } } } return new ServletSecurityElement(constraint, methodConstraints); } return null; }