This week's giveaway is in the JDBC forum.
We're giving away four copies of Java Database Connections & Transactions (e-book only) and have Marco Behler on-line!
See this thread for details.
Win a copy of Java Database Connections & Transactions (e-book only) this week in the JDBC forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

Loading Jar file dynamically from an InputStream  RSS feed

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • 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 Java MySQL Database
  • Mark post as helpful
  • send pies
  • 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
  • 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?
 
When I was younger I felt like a man trapped inside a woman’s body. Then I was born. My twin is a tiny ad:
how do I do my own kindle-like thing - without amazon
https://coderanch.com/t/711421/engineering/kindle-amazon
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!