public final class MediaTypeSupport extends Object
MediaType.| Modifier and Type | Field and Description |
|---|---|
private static com.google.common.base.Function<com.google.common.net.MediaType,com.google.common.net.MediaType> |
STRIP_PARAMS
Function to strip MediaType parameters.
|
| Modifier | Constructor and Description |
|---|---|
private |
MediaTypeSupport()
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
static boolean |
validateContentType(String contentType,
Set<com.google.common.net.MediaType> validTypes,
boolean noContentTypeIsValid,
boolean isOneOfStrategy)
Validate the specified Content-Type.
|
private static final com.google.common.base.Function<com.google.common.net.MediaType,com.google.common.net.MediaType> STRIP_PARAMS
public static boolean validateContentType(String contentType, Set<com.google.common.net.MediaType> validTypes, boolean noContentTypeIsValid, boolean isOneOfStrategy)
2 strategies are supported for evaluating a content type:
MediaType parsed from the content type value is compared to each
of the specified valid types via MediaType.is(MediaType). If any pass, the type is considered
valid. This allows use of MediaType's support for wildcard and parameter evaluation.
MediaType parsed 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.
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)Copyright © 1999–2019 Shibboleth Consortium. All rights reserved.