Class BasicHttpServletRequestContentTypeValidator

java.lang.Object
net.shibboleth.shared.component.AbstractInitializableComponent
net.shibboleth.shared.servlet.impl.BasicHttpServletRequestContentTypeValidator
All Implemented Interfaces:
Component, DestructableComponent, InitializableComponent, HttpServletRequestValidator

public class BasicHttpServletRequestContentTypeValidator extends AbstractInitializableComponent implements HttpServletRequestValidator
Component that validates the HTTP content type as one of an allowed set.

Optionally allows for no type to be specified.

Since:
9.2.0
  • Field Details

    • allowedContentTypes

      @Nonnull private Set<MediaType> allowedContentTypes
      Allowed parameters.
    • allowNullContentType

      private boolean allowNullContentType
      Whether an absent content type is allowed.
  • Constructor Details

    • BasicHttpServletRequestContentTypeValidator

      public BasicHttpServletRequestContentTypeValidator()
      Constructor.
  • Method Details

    • getAllowedContentTypes

      @Nonnull @Unmodifiable @NotLive public Set<String> getAllowedContentTypes()
      Get the allowed types.
      Returns:
      the allowed types
    • setAllowedContentTypes

      public void setAllowedContentTypes(@Nullable Collection<String> types)
      Set the allowed types.
      Parameters:
      types - the allowed types
    • getAllowNullContentType

      public boolean getAllowNullContentType()
      Gets whether to allow an absent content type.
      Returns:
      whether to allow an absent content type
    • setAllowNullContentType

      public void setAllowNullContentType(boolean flag)
      Sets whether to allow an absent content type.

      Defaults to false.

      Parameters:
      flag - flag to set
    • validate

      public void validate(@Nonnull HttpServletRequest request) throws ServletException
      Validate the request.
      Specified by:
      validate in interface HttpServletRequestValidator
      Parameters:
      request - the request to validate
      Throws:
      ServletException - if the request is determined to be invalid