Package org.eclipse.jetty.http
Class UriCompliance
java.lang.Object
org.eclipse.jetty.http.UriCompliance
- All Implemented Interfaces:
ComplianceViolation.Mode
URI compliance modes for Jetty request handling.
A Compliance mode consists of a set of
UriCompliance.Violation
s which are allowed
when the mode is enabled.-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
These are URI compliance "violations", which may be allowed by the compliance mode. -
Field Summary
Modifier and TypeFieldDescriptionstatic final Set<UriCompliance.Violation>
Set of violations that can trigger a HttpURI.isAmbiguous violation.static final UriCompliance
static final UriCompliance
LEGACY compliance mode that models Jetty-9.4 behavior by allowingUriCompliance.Violation.AMBIGUOUS_PATH_SEGMENT
,UriCompliance.Violation.AMBIGUOUS_EMPTY_SEGMENT
,UriCompliance.Violation.AMBIGUOUS_PATH_SEPARATOR
,UriCompliance.Violation.AMBIGUOUS_PATH_ENCODING
andUriCompliance.Violation.UTF16_ENCODINGS
.static final Set<UriCompliance.Violation>
static final UriCompliance
Compliance mode that exactly follows RFC3986, excluding all URI Violations.static final UriCompliance
Compliance mode that allows all unambiguous violations.static final UriCompliance
Compliance mode that allows all URI Violations, including allowing ambiguous paths in non-canonical form, and illegal characters -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
allows
(ComplianceViolation violation) static String
checkUriCompliance
(UriCompliance compliance, HttpURI uri, ComplianceViolation.Listener listener) static UriCompliance
Create compliance set from string.static UriCompliance
from
(Set<UriCompliance.Violation> violations) Create compliance set from a set of allowed Violations.Get the set ofUriCompliance.Violation
s allowed by this compliance mode.getKnown()
getName()
static boolean
isAmbiguous
(Set<UriCompliance.Violation> violations) static boolean
isPathViolation
(UriCompliance.Violation violation) Test if violation is referencing a HttpURI.path violation.toString()
static UriCompliance
with
(String name, UriCompliance.Violation... violations) Create a new UriCompliance mode that includes the passedUriCompliance.Violation
s.without
(String name, UriCompliance.Violation... violations) Create a new UriCompliance mode that excludes the passedUriCompliance.Violation
s.
-
Field Details
-
NO_VIOLATION
-
AMBIGUOUS_VIOLATIONS
Set of violations that can trigger a HttpURI.isAmbiguous violation. -
RFC3986
Compliance mode that exactly follows RFC3986, excluding all URI Violations. -
UNAMBIGUOUS
Compliance mode that allows all unambiguous violations. -
DEFAULT
-
LEGACY
LEGACY compliance mode that models Jetty-9.4 behavior by allowingUriCompliance.Violation.AMBIGUOUS_PATH_SEGMENT
,UriCompliance.Violation.AMBIGUOUS_EMPTY_SEGMENT
,UriCompliance.Violation.AMBIGUOUS_PATH_SEPARATOR
,UriCompliance.Violation.AMBIGUOUS_PATH_ENCODING
andUriCompliance.Violation.UTF16_ENCODINGS
. -
UNSAFE
Compliance mode that allows all URI Violations, including allowing ambiguous paths in non-canonical form, and illegal characters
-
-
Constructor Details
-
UriCompliance
-
-
Method Details
-
isAmbiguous
-
valueOf
-
from
Create compliance set from a set of allowed Violations.- Parameters:
violations
- A string of violations to allow:- Returns:
- the compliance from the string spec
-
from
Create compliance set from string.Format: <BASE>[,[-]<violation>]...
BASE is one of:
- 0
- No
UriCompliance.Violation
s - *
- All
UriCompliance.Violation
s - <name>
- The name of a static instance of UriCompliance (e.g.
RFC3986
).
The remainder of the list can contain then names of
UriCompliance.Violation
s to include them in the mode, or prefixed with a '-' to exclude them from the mode. Examples are:0,AMBIGUOUS_PATH_PARAMETER
- Only allow
UriCompliance.Violation.AMBIGUOUS_PATH_PARAMETER
*,-AMBIGUOUS_PATH_PARAMETER
- Only all except
UriCompliance.Violation.AMBIGUOUS_PATH_PARAMETER
RFC3986,AMBIGUOUS_PATH_PARAMETER
- Same as RFC3986 plus
UriCompliance.Violation.AMBIGUOUS_PATH_PARAMETER
- Parameters:
spec
- A string describing the compliance- Returns:
- the UriCompliance instance derived from the string description
-
allows
- Specified by:
allows
in interfaceComplianceViolation.Mode
- Parameters:
violation
- TheComplianceViolation
to test- Returns:
- true iff the violation is allowed by this mode.
-
getName
- Specified by:
getName
in interfaceComplianceViolation.Mode
- Returns:
- The name of the compliance violation mode.
-
getAllowed
Get the set ofUriCompliance.Violation
s allowed by this compliance mode.- Specified by:
getAllowed
in interfaceComplianceViolation.Mode
- Returns:
- The immutable set of
UriCompliance.Violation
s allowed by this compliance mode.
-
getKnown
- Specified by:
getKnown
in interfaceComplianceViolation.Mode
- Returns:
- The immutable set of all known violations for this mode.
-
with
Create a new UriCompliance mode that includes the passedUriCompliance.Violation
s.- Parameters:
name
- The name of the new modeviolations
- The violations to include- Returns:
- A new
UriCompliance
mode.
-
without
Create a new UriCompliance mode that excludes the passedUriCompliance.Violation
s.- Parameters:
name
- The name of the new modeviolations
- The violations to exclude- Returns:
- A new
UriCompliance
mode.
-
isPathViolation
Test if violation is referencing a HttpURI.path violation.- Parameters:
violation
- the violation to test.- Returns:
- true if violation is a path violation.
-
toString
-
checkUriCompliance
public static String checkUriCompliance(UriCompliance compliance, HttpURI uri, ComplianceViolation.Listener listener)
-