Question

Using TrueZIP, is there a way to open and modify an existing ZIP file from a stream (it may of course be outputted using another stream)?

I have code for modifying a ZIP that works perfectly as long as I work on an existing real ZIP file on the file system but I have a requirement that all temporary files need to be encrypted while stored on disk. In most part of our application this is easy to achieve (using CipherOutputStream and CipherInputStream) but I have one function that uses TrueZIP to update an existing ZIP file. This part obviously fails if the file is encrypted.

The ZIP files will be consumed by proprietary applications that do not support encryption so using the encryption that is part of the ZIP specification isn't possible.

The reason we are using TrueZIP is that we need the support for Zip64 (which I know is included in Java 7 but we cannot switch right now).

Was it helpful?

Solution

No, an archive file must be stored in accessible file system to use it with TrueZIP. But you have a number of other options:

  • TrueZIP uses instances of the IOPoolService interface to manage temporary files. You could provide your own implementation which encrypts all temporary files or maybe even just stores them on the heap (if they are small). Have a look at the TrueZIP Driver FILE to see the reference implementation.

  • You could use the ParanoidZipRaesDriver to use RAES encrypted ZIP files. This driver ensures that no unencrypted temporary files are used by limiting the number of concurrent threads for writing an archive file to one.

  • You could use the standard ZIP drivers with FsOutputOption.ENCRYPT to switch on WinZip AES encryption. To ensure that no unencrypted temporary files are used, you could then override the ZipDriver.newOutputSocket method just like the ParanoidZipRaesDriver does.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top