I have this requirement of loading jar from an inputstream. My application is a jar file and I have encrypted it using encrytion algo. Now when my application starts, my main class will decrypt this file which returns an outputstream as decrypted stream. I want to use this stream without saving it to file. I can convert this stream to an InputStream which should be then loaded.
How can I achieve the above objective?
The reason I dont want to save it to a disk file is that, the once a jar file is available, this jar file can be decompiled and my main class code can be modified to bypass the security check/license check.
The code is already obfuscated using yGuard. Since my entry point (main class) is not obfuscated, it is possible to patch and by pass security check and enter the application. I want to avoid this and hence above solution.
Thanks for reply.
I appologize for late reply on this one.
After posting this question, I have gone further in finding the solution to my problem.
To answer your question, I want to load a class from a jar file. However, as my application requires securing Jar file, I am encrypting the whole jar file and whenever my application needs any class from this encrypted jar, I decrypt the jar file and then extract the class.
I am doing this by creating my own application class loader. I was able to get the jar decrypted and load in JarInputStream. But I am again stuck in another problem. When I take out a JarEntry from the JarInputStream (I have used a code from net from (@author Simon Mieth)), i get the size of this JarEntry as -1. I checked other variables like CRC and compressedSize, both of them are -1.
I thought it must be problem of encryption. But when I tried with plane jar file, it again gave me the same problem, that the size of JarEntry is -1.