Class MalwareScanner

java.lang.Object
de.xima.fc.security.malware.MalwareScanner

public final class MalwareScanner extends Object
Utility class that scans files and data for malware.
Since:
7.0.13
Author:
XIMA MEDIA GmbH
  • Method Details

    • scanBase64Data

      public MalwareScanReport scanBase64Data(String base64EncodedData)
      Scans a base64 encoded string with data for malware and returns a report with the scan result. Note that this method may not create a file on the file system when the malware plugin supports stream scanning.
      Parameters:
      base64EncodedData - Raw data to scan.
      Returns:
      A report with the result of the malware scan.
    • scanData

      public MalwareScanReport scanData(byte[] data)
      Scans some data for malware and returns a report with the scan result. Note that this method may not create a file on the file system when the malware plugin supports stream scanning.
      Parameters:
      data - Raw data to scan.
      Returns:
      A report with the result of the malware scan.
    • scanFile

      public MalwareScanReport scanFile(File file, boolean deleteOnMalware)
      Scans a file for malware and returns a report with the scan result.
      Parameters:
      file - A file to scan.
      deleteOnMalware - If true, the file is deleted immediately once malware was found.
      Returns:
      A report with the result of the malware scan.
    • scanFile

      public MalwareScanReport scanFile(Path file, boolean deleteOnMalware)
      Scans a file for malware and returns a report with the scan result.
      Parameters:
      file - A file to scan.
      deleteOnMalware - If true, the file is deleted immediately once malware was found.
      Returns:
      A report with the result of the malware scan. Use MalwareScanReport.isSafe() to check whether the file may contain malware.
    • scanFileItem

      public MalwareScanReport scanFileItem(org.apache.commons.fileupload.FileItem fileItem, boolean deleteOnMalware)
      Scans a file item for malware and returns a report with the scan result.
      Parameters:
      fileItem - A file to scan.
      deleteOnMalware - If true, the file is deleted immediately once malware was found.
      Returns:
      A report with the result of the malware scan.
    • scanStream

      public MalwareScanReport scanStream(InputStream inputStream)
      Scans some data for malware and returns a report with the scan result. Note that this method may not create a file on the file system when the malware plugin supports stream scanning.
      Parameters:
      inputStream - Input stream with the data to scan. The input stream must be closed externally.
      Returns:
      A report with the result of the malware scan.
    • scanUploadedFile

      public MalwareScanReport scanUploadedFile(org.primefaces.model.file.UploadedFile uploadedFile, boolean deleteOnMalware)
      Scans a file item for malware and returns a report with the scan result.
      Parameters:
      uploadedFile - A file to scan.
      deleteOnMalware - If true, the file is deleted immediately once malware was found.
      Returns:
      A report with the result of the malware scan.
    • forClientScope

      public static MalwareScanner forClientScope(Mandant client)
      Creates a malware scanner that includes client-scoped malware plugins.
      Parameters:
      client - Client scope to use.
      Returns:
      A new malware scanner.
    • forClientScope

      public static MalwareScanner forClientScope(UUID clientUuid)
      Creates a malware scanner that includes client-scoped malware plugins.
      Parameters:
      clientUuid - Client scope to use.
      Returns:
      A new malware scanner.
    • forScope

      public static MalwareScanner forScope(WorkspaceScope scope)
      Creates a malware scanner for the given workspace scope. For system scopes, the malware scanner considers only system-scoped malware plugins. For client scopes, it considers system plugin and plugin within the scope of that client.
      Parameters:
      scope - Scope for which to get a malware scanner.
      Returns:
      A new malware scanner.
    • forSystemScope

      public static MalwareScanner forSystemScope()
      Creates a malware scanner that only includes system-scoped malware plugins.
      Returns:
      A new malware scanner.