/** * Default constraint is permit with no transport guarantee. */ public HttpConstraintElement() { // Default constructor this.emptyRoleSemantic = EmptyRoleSemantic.PERMIT; this.transportGuarantee = TransportGuarantee.NONE; this.rolesAllowed = new String[0]; }
/** * Convenience constructor to specify transport guarantee and/or roles. */ public HttpConstraintElement(TransportGuarantee transportGuarantee, String... rolesAllowed) { this.emptyRoleSemantic = EmptyRoleSemantic.PERMIT; this.transportGuarantee = transportGuarantee; this.rolesAllowed = rolesAllowed; }
/** * * @param emptyRoleSemantic * @param transportGuarantee * @param rolesAllowed * @throws IllegalArgumentException if roles are specified when DENY is used */ public HttpConstraintElement(EmptyRoleSemantic emptyRoleSemantic, TransportGuarantee transportGuarantee, String... rolesAllowed) { if (rolesAllowed != null && rolesAllowed.length > 0 && EmptyRoleSemantic.DENY.equals(emptyRoleSemantic)) { throw new IllegalArgumentException(lStrings.getString( "httpConstraintElement.invalidRolesDeny")); } this.emptyRoleSemantic = emptyRoleSemantic; this.transportGuarantee = transportGuarantee; this.rolesAllowed = rolesAllowed; }
@Override public void onStartup(Set<Class<?>> c, ServletContext ctx) throws ServletException { // Register and map servlet Servlet s = new Bug50015Servlet(); ServletRegistration.Dynamic sr = ctx.addServlet("bug50015", s); sr.addMapping("/bug50015"); // Limit access to users in the Tomcat role HttpConstraintElement hce = new HttpConstraintElement( TransportGuarantee.NONE, "tomcat"); ServletSecurityElement sse = new ServletSecurityElement(hce); sr.setServletSecurity(sse); }
/** * * @param emptyRoleSemantic * @param transportGuarantee * @param rolesAllowed * @throws IllegalArgumentException * if roles are specified when DENY is used */ public HttpConstraintElement(EmptyRoleSemantic emptyRoleSemantic, TransportGuarantee transportGuarantee, String... rolesAllowed) { if (rolesAllowed != null && rolesAllowed.length > 0 && EmptyRoleSemantic.DENY.equals(emptyRoleSemantic)) { throw new IllegalArgumentException(lStrings.getString("httpConstraintElement.invalidRolesDeny")); } this.emptyRoleSemantic = emptyRoleSemantic; this.transportGuarantee = transportGuarantee; this.rolesAllowed = rolesAllowed; }
/** * Convenience constructor for {@link EmptyRoleSemantic#DENY}. * */ public HttpConstraintElement(EmptyRoleSemantic emptyRoleSemantic) { this.emptyRoleSemantic = emptyRoleSemantic; this.transportGuarantee = TransportGuarantee.NONE; this.rolesAllowed = new String[0]; }
public TransportGuarantee getTransportGuarantee() { return transportGuarantee; }
private TransportGuarantee getTransportGuarantee(String transport) { return transport.equalsIgnoreCase("confidential") ? TransportGuarantee.CONFIDENTIAL : transport.equalsIgnoreCase("none") ? TransportGuarantee.NONE : null; }