I have an encrypted and signed JAR file. I would like to decrypt this file in-memory and load and run main on the main class, thus kind of giving the encrypted JAR full controll.
How would you go about this?
My first thoughts were using jimfs and URLClassLoader, which means I don't have to write my own class loader. However, this means that the ramfs will have to be kept open with the jar in it.
Second option is custom class loader. I see two ways - one is to get list of files in the JAR and load them on-demand by seeking in the encrypted file and decrypting the parts I need (however that more or less means no compression). The second way is kind of like here, however loading all classes at once will slow down startup and possibly incerase memory requirements, plus I'm not sure how resource loading would work in this context.
How would you go about this? Is there any better way?