Top Description Fields Constructors Methods
jakarta.servlet

public Class ServletSecurityElement

extends HttpConstraintElement
Class Inheritance
Imports
java.util.ArrayList, .Collection, .HashMap, .HashSet, .List, .Map, jakarta.servlet.annotation.HttpMethodConstraint, .ServletSecurity

The programmatic equivalent of jakarta.servlet.annotation.ServletSecurity used to configre security constraints for a Servlet.
Since
Servlet 3.0

Field Summary

Modifier and TypeField and Description
private final Map<String, HttpMethodConstraintElement>

Constructor Summary

AccessConstructor and Description
public
ServletSecurityElement()

Use default HttpConstraint.

public
ServletSecurityElement(HttpConstraintElement
The constraint
httpConstraintElement
)

Use specified HttpConstraintElement.

public
ServletSecurityElement(Collection<HttpMethodConstraintElement>
Method constraints
httpMethodConstraints
)

Use specific constraints for specified methods and default HttpConstraintElement for all other methods.

public
ServletSecurityElement(HttpConstraintElement
Default constraint
httpConstraintElement
,
Collection<HttpMethodConstraintElement>
Method constraints
httpMethodConstraints
)

Use specified HttpConstraintElement as default and specific constraints for specified methods.

public
ServletSecurityElement(ServletSecurity
Annotation to use as the basis for the new instance
annotation
)

Create from an annotation.

Method Summary

Modifier and TypeMethod and Description
private void
public Collection<HttpMethodConstraintElement>

Returns:

The security constraints for specific methods
getHttpMethodConstraints
()

Obtain the collection of security constraints configured for specific methods.

public Collection<String>

Returns:

The names of the HTTP methods
getMethodNames
()

Obtain the collection HTTP methods for which security constraints have been defined.

Inherited from jakarta.servlet.HttpConstraintElement:
getEmptyRoleSemanticgetRolesAllowedgetTransportGuarantee

Field Detail

methodConstraintsback to summary
private final Map<String, HttpMethodConstraintElement> methodConstraints

Constructor Detail

ServletSecurityElementback to summary
public ServletSecurityElement()

Use default HttpConstraint.

ServletSecurityElementback to summary
public ServletSecurityElement(HttpConstraintElement httpConstraintElement)

Use specified HttpConstraintElement.

Parameters
httpConstraintElement:HttpConstraintElement

The constraint

ServletSecurityElementback to summary
public ServletSecurityElement(Collection<HttpMethodConstraintElement> httpMethodConstraints)

Use specific constraints for specified methods and default HttpConstraintElement for all other methods.

Parameters
httpMethodConstraints:Collection<HttpMethodConstraintElement>

Method constraints

Exceptions
IllegalArgumentException:
if a method name is specified more than once
ServletSecurityElementback to summary
public ServletSecurityElement(HttpConstraintElement httpConstraintElement, Collection<HttpMethodConstraintElement> httpMethodConstraints)

Use specified HttpConstraintElement as default and specific constraints for specified methods.

Parameters
httpConstraintElement:HttpConstraintElement

Default constraint

httpMethodConstraints:Collection<HttpMethodConstraintElement>

Method constraints

Exceptions
IllegalArgumentException:
if a method name is specified more than once
ServletSecurityElementback to summary
public ServletSecurityElement(ServletSecurity annotation)

Create from an annotation.

Parameters
annotation:ServletSecurity

Annotation to use as the basis for the new instance

Exceptions
IllegalArgumentException:
if a method name is specified more than once

Method Detail

addHttpMethodConstraintsback to summary
private void addHttpMethodConstraints(Collection<HttpMethodConstraintElement> httpMethodConstraints)
getHttpMethodConstraintsback to summary
public Collection<HttpMethodConstraintElement> getHttpMethodConstraints()

Obtain the collection of security constraints configured for specific methods.

Returns:Collection<HttpMethodConstraintElement>

The security constraints for specific methods

getMethodNamesback to summary
public Collection<String> getMethodNames()

Obtain the collection HTTP methods for which security constraints have been defined.

Returns:Collection<String>

The names of the HTTP methods