Class StoreEncryption

java.lang.Object
com.logicaldoc.enterprise.store.StoreEncryption

public class StoreEncryption extends Object
Utility methods useful for those Stores that supports the encryption
Since:
7.7.1
Author:
Marco Meschieri - LogicalDOC
  • Field Details

  • Method Details

    • getStream

      public static InputStream getStream(File file, String resource, boolean useAutoDelete) throws com.logicaldoc.util.crypt.CryptUtil.EncryptionException, IOException
      Retrieves the stream of a resource inside a zip file.
      Parameters:
      file - The zip file
      resource - Name of the resource
      useAutoDelete - true to return a stream that deletes the file once completely read
      Returns:
      The stream
      Throws:
      com.logicaldoc.util.crypt.CryptUtil.EncryptionException - the file is encrypted
      IOException - I/O error
    • getUncompressedSize

      public static long getUncompressedSize(File file, String resource) throws IOException, com.logicaldoc.util.crypt.CryptUtil.EncryptionException
      Retrieves the real size of a resource inside a zip
      Parameters:
      file - The zip file
      resource - The name of the resource
      Returns:
      The uncompressed size expressed in bytes
      Throws:
      IOException - Error accessing the file
      com.logicaldoc.util.crypt.CryptUtil.EncryptionException - Error in the decryption
    • writeZip

      public static long writeZip(InputStream stream, String resource, File dest, int compressionLevel) throws IOException
      Writes the stream of a resource into a zip file
      Parameters:
      stream - The input stream (it will be closed at the end)
      resource - The name of the resource inside the zip
      dest - The destination file
      compressionLevel - level of compression (between 0 and 9)
      Returns:
      the uncompressed size of the resource
      Throws:
      IOException - I/O error reading the stream
    • writeZip

      public static long writeZip(File src, String resource, File dest, int compressionLevel) throws IOException
      Writes a resource into a zip file
      Parameters:
      src - The input file
      resource - The name of the resource inside the zip
      dest - The destination file
      compressionLevel - level of compression (between 0 and 9)
      Returns:
      the uncompressed size of the resource
      Throws:
      IOException - error reading the source or writing the destination