I am writing a piece of software that needs licensing from government authority, there are more modules of the same kind (but doing different work - math algorithms). I need to secure that anytime anyone (mostly a representative of government authority) comes to this software and asks for it (via network), the checksum for that particular module is printed out. I am writing this server in Java. I looked into Serialization
but it only cares about the data (attributes) in the object and not the object behaviour or other logical structure - which this absolutely needs to care about. Hence I need to access the .class
from within the running jar file and perform a checksum on it. The current structure is like this:
abstract class Module {
public abstract void run();
public String chsum ();
}
abstract class SimpleGame extends Module {
/* not that important */
}
class GameX extends SimpleGame {
public void run() {
/* some magic */
}
}
And when needed, upon receiving the proper message the network stack might call something like:
GameX gx = new GameX();
String checkSum = gx.chsum();
My current progress got me nowhere, I tried to access the .class file but without any luck - it works only if it is not a jar archive. And I need to supply the Class
instance which is not a dealbreaker but it sure is not that handy. If I could get an array of bytes containing the compiled .class
file that would be more than enough - to perform a checksum on that is a piece of cake using MessageDigest