Class FileQuarantineManager

java.lang.Object
org.pwss.quarantineManager_aes.FileQuarantineManager

public final class FileQuarantineManager extends Object
This class provides functionality for quarantining (isolating) suspicious files by encrypting them, storing their keys separately, and tracking their metadata. It also supports unquarantining the files by decrypting them using their corresponding keys.
  • Constructor Details

    • FileQuarantineManager

      public FileQuarantineManager()
      Constructs a new instance of FileQuarantineManager.

      Note: This class is designed to ensure that only one instance of the nested classes within FileQuarantineManager can exist at any given time. As such, if this class is the sole running instance, it guarantees that no other instances of its nested classes will be in operation concurrently as the application will exit.

  • Method Details

    • quarantine

      public final MetaDataResult quarantine(Path fileToQuarantine) throws Exception
      Quarantines a file by encrypting it, generating and storing an AES key, deleting the original file, and saving metadata.
      Parameters:
      fileToQuarantine - The path of the file to be quarantined.
      Returns:
      A MetaDataResult object indicating the success or failure of the quarantine operation.
      Throws:
      Exception - If an error occurs during encryption or file operations.
    • unquarantine

      public final MetaDataResult unquarantine(String keyPath) throws Exception
      Unquarantines a file by decrypting it using the corresponding key, restoring the original file, deleting the encrypted file and its key, and removing metadata.
      Parameters:
      keyPath - The original absolute path of the encrypted (quarantined) file separated by dots with the colon of the drive letter substituted into _drive__ (e.g., C:\path\to\file.txt becomes C_drive__.path.to.file.txt for Windows).
      Returns:
      A MetaDataResult object indicating whether the unquarantine operation was successful or not, along with any relevant metadata.
      Throws:
      Exception - If an error occurs during decryption or file operations.