List of usage examples for javax.servlet HttpConstraintElement HttpConstraintElement
public HttpConstraintElement()
From source file:org.brutusin.rpc.RpcWebInitializer.java
private RpcServlet registerRpcServlet(ServletContext ctx) { LOGGER.info("Starting HTTP RPC runtime"); RpcServlet servlet = new RpcServlet(); ServletRegistration.Dynamic regInfo = ctx.addServlet(RpcServlet.class.getName(), servlet); ServletSecurityElement sec = new ServletSecurityElement(new HttpConstraintElement()); regInfo.setServletSecurity(sec);//w w w .ja va 2 s .com regInfo.setLoadOnStartup(1); regInfo.addMapping(RpcConfig.getInstance().getPath() + "/http"); return servlet; }
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 v a 2 s . c o m } } 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; }