I have a encrypted zip with a file inside it. I want to decrypt said file, and use the path of the decrypted file as a input to a new java program.
I don't want anyone to read my decrypted file, nor do anything else with it.
The best solution I've found is to have several different processes monitoring the folder where I extracted my zip, to check if anyone is reading the file or copying to another place.
If I use http://docs.oracle.com/javase/7/docs/api/java/nio/channels/FileLock.html, the lock is only respected on the JVM right? If I use the operating system clipboard to copy the file to another place it circumvents my lock right?
Besides that, I have a java program that unzips the file and after that calls the command that will in fact read the unzipped file.This means I can't lock the file on the JVM, I have to lock it to be used by a third party command.
What would be the best approach or what topic I should google?
The Java
FileLock
may be enough for your needs, but doesn't work on all platforms. From the javadoc:How big is the file? You should decrypt the file into memory so that only your process has access to it.