Class MediaTypeSupport
- java.lang.Object
-
- net.shibboleth.utilities.java.support.net.MediaTypeSupport
-
-
Field Summary
Fields Modifier and Type Field Description private static Function<MediaType,MediaType>STRIP_PARAMSFunction to strip MediaType parameters.
-
Constructor Summary
Constructors Modifier Constructor Description privateMediaTypeSupport()Constructor.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static booleanvalidateContentType(String contentType, Set<MediaType> validTypes, boolean noContentTypeIsValid, boolean isOneOfStrategy)Validate the specified Content-Type.
-
-
-
Method Detail
-
validateContentType
public static boolean validateContentType(String contentType, Set<MediaType> validTypes, boolean noContentTypeIsValid, boolean isOneOfStrategy)
Validate the specified Content-Type.Two strategies are supported for evaluating a content type:
-
If isOneOfStrategy is true, then the
MediaTypeparsed from the content type value is compared to each of the specified valid types viaMediaType.is(MediaType). If any pass, the type is considered valid. This allows use of MediaType's support for wildcard and parameter evaluation. -
If isOneOfStrategy is false, then the
MediaTypeparsed from the value is stripped of its parameters, as is each of the valid types. Then a simple evaluation is done that the specified content type is equal to one of the passed types. In this case, only literal types and subtypes should be passed as valid types; wildcards should not be used.
- Parameters:
contentType- the contentType to be validatedvalidTypes- the set of valid media typesnoContentTypeIsValid- flag whether the case of a missing/empty Content-Type header is considered validisOneOfStrategy- flag for the strategy used in the validation (see above for details)- Returns:
- true if the content type is valid, false if not
-
If isOneOfStrategy is true, then the
-
-