Class MultipartFormdataMalwareScanReader

java.lang.Object
de.xima.fc.api.rest.impl.common.reader.MultipartFormdataMalwareScanReader
All Implemented Interfaces:
javax.ws.rs.ext.MessageBodyReader<org.jboss.resteasy.plugins.providers.multipart.MultipartFormDataInput>

@Provider @Priority(5000) @Consumes("multipart/form-data") public class MultipartFormdataMalwareScanReader extends Object
A reader for multipart/form-data requests that checks uploads for invalid/illegal content. If such content is detected, the request is rejected.
Since:
8.4.0
Author:
XIMA MEDIA GmbH, Dresden
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected javax.ws.rs.ext.Providers
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    isReadable(Class<?> type, Type genericType, Annotation[] annotations, javax.ws.rs.core.MediaType mediaType)
    Checks if the given type is supported by this multipart reader implementation.
    protected org.jboss.resteasy.plugins.providers.multipart.MultipartFormDataInput
    prepareAndVerify(javax.ws.rs.core.MediaType mediaType, javax.servlet.http.HttpServletRequest servletRequest, Supplier<org.jboss.resteasy.plugins.providers.multipart.MultipartInputImpl> multipartInputFactory)
    Processes the multipart data and does the actual malware and content type checks.
    org.jboss.resteasy.plugins.providers.multipart.MultipartFormDataInput
    readFrom(Class<org.jboss.resteasy.plugins.providers.multipart.MultipartFormDataInput> type, Type genericType, Annotation[] annotations, javax.ws.rs.core.MediaType mediaType, javax.ws.rs.core.MultivaluedMap<String,String> httpHeaders, InputStream entityStream)
    Reads the request and scans the content of the parts for malware.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • workers

      @Context protected javax.ws.rs.ext.Providers workers
  • Constructor Details

    • MultipartFormdataMalwareScanReader

      public MultipartFormdataMalwareScanReader()
  • Method Details

    • readFrom

      public org.jboss.resteasy.plugins.providers.multipart.MultipartFormDataInput readFrom(Class<org.jboss.resteasy.plugins.providers.multipart.MultipartFormDataInput> type, Type genericType, Annotation[] annotations, javax.ws.rs.core.MediaType mediaType, javax.ws.rs.core.MultivaluedMap<String,String> httpHeaders, InputStream entityStream) throws IOException, javax.ws.rs.WebApplicationException
      Reads the request and scans the content of the parts for malware. If malware is detected, the request is rejected.
      Parameters:
      type - the type of the input
      genericType - the generic type
      annotations - the annotations
      mediaType - the media type
      httpHeaders - the HTTP headers
      entityStream - the input stream
      Returns:
      the parsed and verified MultipartFormDataInput
      Throws:
      IOException - if an I/O error occurs
      javax.ws.rs.WebApplicationException - if a web application error occurs
    • isReadable

      public boolean isReadable(Class<?> type, Type genericType, Annotation[] annotations, javax.ws.rs.core.MediaType mediaType)
      Checks if the given type is supported by this multipart reader implementation.
      Specified by:
      isReadable in interface javax.ws.rs.ext.MessageBodyReader<T extends org.jboss.resteasy.plugins.providers.multipart.MultipartInput>
      Parameters:
      type - the type to check
      genericType - the generic type
      annotations - the annotations
      mediaType - the media type
      Returns:
      true if the type matches, false otherwise
    • prepareAndVerify

      protected org.jboss.resteasy.plugins.providers.multipart.MultipartFormDataInput prepareAndVerify(javax.ws.rs.core.MediaType mediaType, javax.servlet.http.HttpServletRequest servletRequest, Supplier<org.jboss.resteasy.plugins.providers.multipart.MultipartInputImpl> multipartInputFactory) throws IOException, UnsafeUploadRequestException
      Processes the multipart data and does the actual malware and content type checks.
      Parameters:
      mediaType - the media type
      servletRequest - resteasy context: the related request
      multipartInputFactory - supplier for creating the concrete MultipartInput instance
      Returns:
      a new instance of T
      Throws:
      IOException - in case of an I/O error
      javax.ws.rs.WebApplicationException - in case of detected malware or a mismatching content type
      UnsafeUploadRequestException