I want to make an desktop application that only runs on machines that have key or licence. How this can be achieved?
Java is Platform independet. This says it all.It can run on any operating system because it compiles to bytecode which then runs on a Virtual machine.
Java security technology includes a large set of APIs, tools, and implementations of commonly used security algorithms, mechanisms, and protocols. The Java security APIs span a wide range of areas, including cryptography, public key infrastructure, secure communication, authentication, and access control.
This depends entirely on how secure you want to make it...
The problem with Java is that you can reverse compile it. So if someone wanted to, they could download your software, reverse compile it, and then remove whatever security you have put in place (and then redistribute it if they wanted).
This is only a problem if you plan on going mass market and selling it and piracy would actually be a problem though.
If you're not concerned about this, then you can either go for online, or offline checking.
The company I work with uses the online method; there are a few steps:
EDIT: I've since changed how this works, as the old way was a maintenance nightmare.
name
company
email
key
. i.e. the JDU8-AJS9-88DF-SASF-ASF9
kind of thing you often see.To generate the keys, just use the same hashing function, and then upload the hash to your server.
If you want it to be offline, you could include the hashes in the code I guess and check against them there.
I should point out, however, that I'm not a security expert by any means, I just develop for a company as a portion of a Ph.D. and this is just how I did it.
Edit: this image might be helpful:
Second Edit:
I have now included "offline verification" in the process. It's not really offline verification, it just uses the user as a proxy - they need to access the internet another way.
it works like this:
every time the program successfully verifies online, it also adds an offline access password to the license file, which means it's robust against temporary internet downtime, and will only stop working if the internet is down for more than a week/month/however long it's set up to work for.
You can track licencing of a machine with macIP on online . Even in windows you can write in registry there is no api but still you can do it. Find snippet bellow to read registry -
public static final String readRegistry(String location, String key){
try {
// Run reg query, then read output with StreamReader (internal class)
Process process = Runtime.getRuntime().exec("reg query " +
'"'+ location + "\" /v " + key);
StreamReader reader = new StreamReader(process.getInputStream());
reader.start();
process.waitFor();
reader.join();
String output = reader.getResult();
// Output has the following format:
// \n<Version information>\n\n<key>\t<registry type>\t<value>
if( ! output.contains("\t")){
return null;
}
// Parse out the value
String[] parsed = output.split("\t");
return parsed[parsed.length-1];
}
catch (Exception e) {
return null;
}
}
And in class level if you want to obfuscate use proGuard .
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With