Package org.eclipse.jetty.security
Interface Constraint
public interface Constraint
A Security constraint that is applied to a request, which contain:
- A name
- Authorization to specify if authentication is needed and what roles are applicable
- An optional list of role names used for
Constraint.Authorization.KNOWN_ROLE
- A Transport constraint, indicating if it must be secure or not.
The core constraint is not the same as the servlet specification AuthConstraint
, but it is
sufficiently capable to represent servlet constraints.
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic enum
The Authorization applied to any authentication of the request/static class
Builder for Constraint.static enum
The constraints requirement for the transport -
Field Summary
Modifier and TypeFieldDescriptionstatic final Constraint
A static Constraint that hasConstraint.Authorization.ALLOWED
andConstraint.Transport.INHERIT
.static final Constraint
A static Constraint that hasConstraint.Authorization.ALLOWED
andConstraint.Transport.ANY
.static final Constraint
A static Constraint that hasConstraint.Transport.ANY
andConstraint.Authorization.INHERIT
static final Constraint
A static Constraint that hasConstraint.Authorization.ANY_USER
andConstraint.Transport.INHERIT
.static final Constraint
A static Constraint that hasConstraint.Authorization.FORBIDDEN
andConstraint.Transport.INHERIT
.static final Constraint
A static Constraint that hasConstraint.Authorization.KNOWN_ROLE
andConstraint.Transport.INHERIT
.static final Constraint
A static Constraint that hasConstraint.Transport.SECURE
andConstraint.Authorization.INHERIT
-
Method Summary
Modifier and TypeMethodDescriptionstatic Constraint
combine
(String name, Constraint leastSpecific, Constraint mostSpecific) Combine two Constraints by:static Constraint
combine
(Constraint leastSpecific, Constraint mostSpecific) Combine two Constraints by usingcombine(String, Constraint, Constraint)
with a generated name.static Constraint
static Constraint
from
(String name, Constraint.Authorization authorization, String... roles) static Constraint
from
(String name, Constraint.Transport transport) static Constraint
from
(String name, Constraint.Transport transport, Constraint.Authorization authorization, Set<String> roles) static Constraint
from
(Constraint.Transport transport, Constraint.Authorization authorization, Set<String> roles) getName()
getRoles()
-
Field Details
-
ALLOWED
A static Constraint that hasConstraint.Authorization.ALLOWED
andConstraint.Transport.INHERIT
. -
FORBIDDEN
A static Constraint that hasConstraint.Authorization.FORBIDDEN
andConstraint.Transport.INHERIT
. -
ANY_USER
A static Constraint that hasConstraint.Authorization.ANY_USER
andConstraint.Transport.INHERIT
. -
KNOWN_ROLE
A static Constraint that hasConstraint.Authorization.KNOWN_ROLE
andConstraint.Transport.INHERIT
. -
SECURE_TRANSPORT
A static Constraint that hasConstraint.Transport.SECURE
andConstraint.Authorization.INHERIT
-
ANY_TRANSPORT
A static Constraint that hasConstraint.Transport.ANY
andConstraint.Authorization.INHERIT
-
ALLOWED_ANY_TRANSPORT
A static Constraint that hasConstraint.Authorization.ALLOWED
andConstraint.Transport.ANY
.
-
-
Method Details
-
getName
String getName()- Returns:
- The name for the
Constraint
or "unnamed@hashcode" if not named
-
getTransport
Constraint.Transport getTransport()- Returns:
- The required
Constraint.Transport
or null if the transport can be either.
-
getAuthorization
Constraint.Authorization getAuthorization()- Returns:
- The
Constraint.Authorization
criteria applied by thisConstraint
or null if this constraint does not have any authorization requirements.
-
getRoles
- Returns:
- The set of roles applied by this
Constraint
or the empty set.
-
combine
Combine two Constraints by usingcombine(String, Constraint, Constraint)
with a generated name.- Parameters:
leastSpecific
- Constraint to combinemostSpecific
- Constraint to combine- Returns:
- the combined constraint.
- See Also:
-
combine
Combine two Constraints by:
- if both constraints are
Null
, thenALLOWED
is returned. - if either constraint is
Null
the other is returned. - only if the
mostSpecific
constraint hasConstraint.Authorization.INHERIT
is theleastSpecific
constraint'sConstraint.Authorization
used, otherwise themostSpecific
's is used. - if the combined constraint has
Constraint.Authorization.SPECIFIC_ROLE
, then the role set from the constraint that specified theConstraint.Authorization.SPECIFIC_ROLE
is used. - only if the
mostSpecific
constraint hasConstraint.Transport.INHERIT
is theleastSpecific
constraint'sConstraint.Transport
used, otherwise themostSpecific
's is used.
Typically the path of the constraint is used to determine which constraint is most specific. For example if the following paths mapped to Constraints as:
/* -> Authorization.FORBIDDEN,roles=[],Transport.SECURE /admin/* -> Authorization.SPECIFIC_ROLE,roles=["admin"],Transport.INHERIT
The the
/admin/*
constraint would be consider most specific and a request to/admin/file
would haveConstraint.Authorization.SPECIFIC_ROLE
from the/admin/*
constraint andConstraint.Transport.SECURE
inherited from the/*
constraint. For more examples seeSecurityHandler.PathMapped
.Note that this combination is not equivalent to the combination done by the EE servlet specification.
- Parameters:
name
- The name to use for the combined constraintleastSpecific
- Constraint to combinemostSpecific
- Constraint to combine- Returns:
- the combined constraint.
- if both constraints are
-
from
-
from
-
from
-
from
static Constraint from(Constraint.Transport transport, Constraint.Authorization authorization, Set<String> roles) -
from
static Constraint from(String name, Constraint.Transport transport, Constraint.Authorization authorization, Set<String> roles)
-