• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Loading Jar file dynamically from an InputStream

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

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.

Please help.

Nitin

 
Bartender
Posts: 1638
IntelliJ IDE MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

nitin kumar wrote:I want to use this stream without saving it to file.



Use it for what? Do you want to load the classes present in the jar file?
 
nitin kumar
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

What do you think is the problem?
reply
    Bookmark Topic Watch Topic
  • New Topic