Such a licence may not be lawful.
If you're confident that it is, and that you know the law, and if you have deep enough pockets to defend the lawsuits, go ahead.
Otherwise get legal advice.
Better still, just forget it. Use a time bomb that will just stop it running, like everybody else. I find it very useful to get people to finally pay for their software.
Not really, I have expiring JARs that would take NASA resources to crack. There is always the set-the-clock-back attack but I'm prepared to live with the few people who can be bothered. Mostly it's about getting your product such that people want to use it, and the price and protection mechanisms at a point where it's easier to pay the money. The law of diminishing returns applies - you probably can't get the last few percent to pay but it probably isn't really worth it to try.
Alright well I got a little something working but now I have a problem....
This code:
this.certs = FusionInterface.class.getProtectionDomain().getCodeSource().getCodeSigners();
Date certDate = certs[i].getTimestamp().getTimestamp();
The second line of that code produces a NullPointerException which I don't understand because when I sign my jar and have it System.out all the Certs it prints them correctly with the correct Validity data.
Date certDate = certs[i].getTimestamp().getTimestamp();
It happens in the last .getTimestamp(), even though I signed the applet and when I use the jarsigner -verify it prints the whole cert and everything on the applet so I definitely signed the jar.
I can post the whole class if you would like...
import java.net.Socket;
import java.security.CodeSigner;
import java.util.Date;
public class Protection {
/** Creates a new instance of Protection */
private CodeSigner[] certs;
private HTTPSocket socket;
public Protection() {
this.certs = FusionInterface.class.getProtectionDomain().getCodeSource().getCodeSigners();
socket = new HTTPSocket();
}
public boolean check() {
String sepoch = socket.get("http://www.xav.com/time.cgi", "http://www.google.com");
long epoch = Long.parseLong(Misc.parse(sepoch, "<td align=\"right\"><tt>", "</tt></td>"));
if(certs != null) {
for(int i=0;i<certs.length;i++) {
System.out.println(certs.length);
System.out.println(epoch);
System.out.println(certs[i]);
Date certDate = certs[i].getTimestamp().getTimestamp();
Date currentDate = new Date(epoch);
if(certDate.after(currentDate)) {
return false;
} else {
return true;
}
}
} else {
return true;
}
return false;
}
}
>
The certs array is full of them, e.g. certs[0] if it's a self-signed cert. You have to typecast it.
// Not sure whether you need to verify or whether the JVM does this for you
certs[0].verify(certs[0].getPublicKey());
X509Certificate cert = (X509Certificate)certs[0];
cert.checkValidity();
For some reason the certs won't convert to a X509Certificate...
X509Certificate cert = (X509Certificate)(FusionInterface.class.getProtectionDomain().getCodeSource().getCodeSigners())[0];
It gives me the error:
/Users/jeffrey/Entelechy/src/entelechy/Protection.java:27: inconvertible types
found: java.security.CodeSigner
required: java.security.cert.X509Certificate
cert = (X509Certificate)(FusionInterface.class.getProtectionDomain().getCodeSource().getCodeSigners())[0];