Top Description Inners Fields Methods
org.eclipse.jetty.security

public Interface Constraint

Imports
java.util.Arrays, .Collections, .HashSet, .Set

A Security constraint that is applied to a request, which contain:

The core constraint is not the same as the servlet specification AuthConstraint, but it is sufficiently capable to represent servlet constraints.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static enum
Constraint.Authorization

The Authorization applied to any authentication of the request/

public static class
Constraint.Builder

Builder for Constraint.

public static enum
Constraint.Transport

The constraints requirement for the transport

Field Summary

Modifier and TypeField and Description
public static final Constraint
ALLOWED

A static Constraint that has Authorization#ALLOWED and Transport#INHERIT.

public static final Constraint
public static final Constraint
ANY_TRANSPORT

A static Constraint that has Transport#ANY and Authorization#INHERIT

public static final Constraint
ANY_USER

A static Constraint that has Authorization#ANY_USER and Transport#INHERIT.

public static final Constraint
FORBIDDEN

A static Constraint that has Authorization#FORBIDDEN and Transport#INHERIT.

public static final Constraint
KNOWN_ROLE

A static Constraint that has Authorization#KNOWN_ROLE and Transport#INHERIT.

public static final Constraint

Method Summary

Modifier and TypeMethod and Description
public static Constraint

Returns:

the combined constraint.
combine
(Constraint
Constraint to combine
leastSpecific
,
Constraint
Constraint to combine
mostSpecific
)

Combine two Constraints by using combine(String, Constraint, Constraint) with a generated name.

public static Constraint

Returns:

the combined constraint.
combine
(String
The name to use for the combined constraint
name
,
Constraint
Constraint to combine
leastSpecific
,
Constraint
Constraint to combine
mostSpecific
)

Combine two Constraints by:

public static Constraint
from(String... roles)

public static Constraint
from(String name, Constraint.Transport transport)

public static Constraint
from(String name, Constraint.Authorization authorization, String... roles)

public static Constraint
from(Constraint.Transport transport, Constraint.Authorization authorization, Set<String> roles)

public static Constraint
from(String name, Constraint.Transport transport, Constraint.Authorization authorization, Set<String> roles)

public Constraint.Authorization

Returns:

The Authorization criteria applied by this Constraint or null if this constraint does not have any authorization requirements.
getAuthorization
()

public String

Returns:

The name for the Constraint or "unnamed@hashcode" if not named
getName
()

public Set<String>

Returns:

The set of roles applied by this Constraint or the empty set.
getRoles
()

public Constraint.Transport

Returns:

The required Transport or null if the transport can be either.
getTransport
()

Field Detail

ALLOWEDback to summary
public static final Constraint ALLOWED

A static Constraint that has Authorization#ALLOWED and Transport#INHERIT.

ALLOWED_ANY_TRANSPORTback to summary
public static final Constraint ALLOWED_ANY_TRANSPORT

A static Constraint that has Authorization#ALLOWED and Transport#ANY.

ANY_TRANSPORTback to summary
public static final Constraint ANY_TRANSPORT

A static Constraint that has Transport#ANY and Authorization#INHERIT

ANY_USERback to summary
public static final Constraint ANY_USER

A static Constraint that has Authorization#ANY_USER and Transport#INHERIT.

FORBIDDENback to summary
public static final Constraint FORBIDDEN

A static Constraint that has Authorization#FORBIDDEN and Transport#INHERIT.

KNOWN_ROLEback to summary
public static final Constraint KNOWN_ROLE

A static Constraint that has Authorization#KNOWN_ROLE and Transport#INHERIT.

SECURE_TRANSPORTback to summary
public static final Constraint SECURE_TRANSPORT

A static Constraint that has Transport#SECURE and Authorization#INHERIT

Method Detail

combineback to summary
public static Constraint combine(Constraint leastSpecific, Constraint mostSpecific)

Combine two Constraints by using combine(String, Constraint, Constraint) with a generated name.

Parameters
leastSpecific:Constraint

Constraint to combine

mostSpecific:Constraint

Constraint to combine

Returns:Constraint

the combined constraint.

See Also
combine(String, Constraint, Constraint)
combineback to summary
public static Constraint combine(String name, Constraint leastSpecific, Constraint mostSpecific)

Combine two Constraints by:

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 have Authorization#SPECIFIC_ROLE from the /admin/* constraint and Transport#SECURE inherited from the /* constraint. For more examples see SecurityHandler.PathMapped.

Note that this combination is not equivalent to the combination done by the EE servlet specification.

Parameters
name:String

The name to use for the combined constraint

leastSpecific:Constraint

Constraint to combine

mostSpecific:Constraint

Constraint to combine

Returns:Constraint

the combined constraint.

fromback to summary
public static Constraint from(String... roles)
fromback to summary
public static Constraint from(String name, Constraint.Transport transport)
fromback to summary
public static Constraint from(String name, Constraint.Authorization authorization, String... roles)
fromback to summary
public static Constraint from(Constraint.Transport transport, Constraint.Authorization authorization, Set<String> roles)
fromback to summary
public static Constraint from(String name, Constraint.Transport transport, Constraint.Authorization authorization, Set<String> roles)
getAuthorizationback to summary
public Constraint.Authorization getAuthorization()
Returns:Constraint.Authorization

The Authorization criteria applied by this Constraint or null if this constraint does not have any authorization requirements.

getNameback to summary
public String getName()
Returns:String

The name for the Constraint or "unnamed@hashcode" if not named

getRolesback to summary
public Set<String> getRoles()
Returns:Set<String>

The set of roles applied by this Constraint or the empty set.

getTransportback to summary
public Constraint.Transport getTransport()
Returns:Constraint.Transport

The required Transport or null if the transport can be either.

org.eclipse.jetty.security back to summary

public final Enum Constraint.Authorization

extends Enum<Constraint.Authorization>
Class Inheritance

The Authorization applied to any authentication of the request/

Field Summary

Modifier and TypeField and Description
public static final Constraint.Authorization
ALLOWED

Access allowed.

public static final Constraint.Authorization
ANY_USER

Access allowed for any authenticated user regardless of role.

public static final Constraint.Authorization
FORBIDDEN

Access not allowed.

public static final Constraint.Authorization
INHERIT

Inherit the authorization from a less specific constraint when passed to combine(Constraint, Constraint), otherwise act as ALLOWED.

public static final Constraint.Authorization
KNOWN_ROLE

Access allowed for authenticated user with any known role.

public static final Constraint.Authorization
SPECIFIC_ROLE

Access allowed only for authenticated user with specific role(s).

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static Constraint.Authorization
public static Constraint.Authorization[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

ALLOWEDback to summary
public static final Constraint.Authorization ALLOWED

Access allowed. Equivalent to Servlet AuthConstraint without any Authorization.

ANY_USERback to summary
public static final Constraint.Authorization ANY_USER

Access allowed for any authenticated user regardless of role. Equivalent to Servlet role "**". For example, a web application that defines only an "admin" can use this Authorization to allow any authenticated user known to the configured LoginService, even if their roles are not know to the web application.

FORBIDDENback to summary
public static final Constraint.Authorization FORBIDDEN

Access not allowed. Equivalent to Servlet AuthConstraint with no roles.

INHERITback to summary
public static final Constraint.Authorization INHERIT

Inherit the authorization from a less specific constraint when passed to combine(Constraint, Constraint), otherwise act as ALLOWED.

KNOWN_ROLEback to summary
public static final Constraint.Authorization KNOWN_ROLE

Access allowed for authenticated user with any known role. Equivalent to Servlet role "*". For example, a web application that defines roles "admin" and "user" might be deployed to a server with a configured LoginService that also has users with "operator" role. This constraint would not allow an "operator" user, as that role is not known to the web application.

SPECIFIC_ROLEback to summary
public static final Constraint.Authorization SPECIFIC_ROLE

Access allowed only for authenticated user with specific role(s).

Constructor Detail

Authorizationback to summary
private Authorization()

Method Detail

valueOfback to summary
public static Constraint.Authorization valueOf(String name)
valuesback to summary
public static Constraint.Authorization[] values()
org.eclipse.jetty.security back to summary

public Class Constraint.Builder

extends Object
Class Inheritance

Builder for Constraint.

Field Summary

Modifier and TypeField and Description
private Constraint.Authorization
private String
private Set<String>
private Constraint.Transport

Constructor Summary

AccessConstructor and Description
public
public
Builder(Constraint constraint)

Method Summary

Modifier and TypeMethod and Description
public Constraint.Builder
public Constraint
public Constraint.Authorization
public String
public Set<String>
public Constraint.Transport
public Constraint.Builder
name(String name)

public Constraint.Builder
roles(String... roles)

public Constraint.Builder
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

_authorizationback to summary
private Constraint.Authorization _authorization
_nameback to summary
private String _name
_rolesback to summary
private Set<String> _roles
_transportback to summary
private Constraint.Transport _transport

Constructor Detail

Builderback to summary
public Builder()
Builderback to summary
public Builder(Constraint constraint)

Method Detail

authorizationback to summary
public Constraint.Builder authorization(Constraint.Authorization authorization)
buildback to summary
public Constraint build()
getAuthorizationback to summary
public Constraint.Authorization getAuthorization()
getNameback to summary
public String getName()
getRolesback to summary
public Set<String> getRoles()
getTransportback to summary
public Constraint.Transport getTransport()
nameback to summary
public Constraint.Builder name(String name)
rolesback to summary
public Constraint.Builder roles(String... roles)
transportback to summary
public Constraint.Builder transport(Constraint.Transport transport)
org.eclipse.jetty.security back to summary

public final Enum Constraint.Transport

extends Enum<Constraint.Transport>
Class Inheritance

The constraints requirement for the transport

Field Summary

Modifier and TypeField and Description
public static final Constraint.Transport
ANY

The transport can be either secure or not secure.

public static final Constraint.Transport
INHERIT

Inherit the transport constraint from a less specific constraint when passed to combine(Constraint, Constraint), otherwise act as ANY.

public static final Constraint.Transport
SECURE

The transport must be secure (e.g. TLS)

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static Constraint.Transport
public static Constraint.Transport[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

ANYback to summary
public static final Constraint.Transport ANY

The transport can be either secure or not secure.

INHERITback to summary
public static final Constraint.Transport INHERIT

Inherit the transport constraint from a less specific constraint when passed to combine(Constraint, Constraint), otherwise act as ANY.

SECUREback to summary
public static final Constraint.Transport SECURE

The transport must be secure (e.g. TLS)

Constructor Detail

Transportback to summary
private Transport()

Method Detail

valueOfback to summary
public static Constraint.Transport valueOf(String name)
valuesback to summary
public static Constraint.Transport[] values()