HttpConstraintElement (Servlet 6.1 API Documentation - Apache Tomcat 11.0.24)
Description: declaration: package: jakarta.servlet, class: HttpConstraintElement

# Class HttpConstraintElement

java.lang.Object
jakarta.servlet.HttpConstraintElement

Direct Known Subclasses:
  `HttpMethodConstraintElement, ServletSecurityElement`

public class HttpConstraintElement extends Object
Equivalent of `HttpConstraint` for programmatic configuration of security constraints.

Since:
  Servlet 3.0

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `HttpConstraintElement()`
  Default constraint is permit with no transport guarantee.
  `HttpConstraintElement(ServletSecurity.EmptyRoleSemantic emptyRoleSemantic)`
  Construct a constraint with an empty role semantic.
  `HttpConstraintElement(ServletSecurity.EmptyRoleSemantic emptyRoleSemantic, ServletSecurity.TransportGuarantee transportGuarantee, String... rolesAllowed)`
  Construct a constraint with an empty role semantic, a transport guarantee and roles.
  `HttpConstraintElement(ServletSecurity.TransportGuarantee transportGuarantee, String... rolesAllowed)`
  Construct a constraint with a transport guarantee and roles.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `ServletSecurity.EmptyRoleSemantic`
  `getEmptyRoleSemantic()`
  Returns the empty role semantic for this constraint.
  `String[]`
  `getRolesAllowed()`
  Returns the roles allowed for this constraint.
  `ServletSecurity.TransportGuarantee`
  `getTransportGuarantee()`
  Returns the transport guarantee for this constraint.

  ### Methods inherited from class Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### HttpConstraintElement

    public HttpConstraintElement()
    Default constraint is permit with no transport guarantee.

  - ### HttpConstraintElement

    public HttpConstraintElement(ServletSecurity.EmptyRoleSemantic emptyRoleSemantic)
    Construct a constraint with an empty role semantic. Typically used with `ServletSecurity.EmptyRoleSemantic.DENY`.
    Parameters:
      `emptyRoleSemantic` - The empty role semantic to apply to the newly created constraint

  - ### HttpConstraintElement

    public HttpConstraintElement(ServletSecurity.TransportGuarantee transportGuarantee, String... rolesAllowed)
    Construct a constraint with a transport guarantee and roles.
    Parameters:
      `transportGuarantee` - The transport guarantee to apply to the newly created constraint
      `rolesAllowed` - The roles to associate with the newly created constraint

  - ### HttpConstraintElement

    public HttpConstraintElement(ServletSecurity.EmptyRoleSemantic emptyRoleSemantic, ServletSecurity.TransportGuarantee transportGuarantee, String... rolesAllowed)
    Construct a constraint with an empty role semantic, a transport guarantee and roles.
    Parameters:
      `emptyRoleSemantic` - The empty role semantic to apply to the newly created constraint
      `transportGuarantee` - The transport guarantee to apply to the newly created constraint
      `rolesAllowed` - The roles to associate with the newly created constraint
    Throws:
      `IllegalArgumentException` - if roles are specified when DENY is used

- ## Method Details

  - ### getEmptyRoleSemantic

    public ServletSecurity.EmptyRoleSemantic getEmptyRoleSemantic()
    Returns the empty role semantic for this constraint.
    Returns:
      The empty role semantic for this constraint

  - ### getTransportGuarantee

    public ServletSecurity.TransportGuarantee getTransportGuarantee()
    Returns the transport guarantee for this constraint.
    Returns:
      The transport guarantee for this constraint

  - ### getRolesAllowed

    public String[] getRolesAllowed()
    Returns the roles allowed for this constraint.
    Returns:
      The roles allowed for this constraint