Reputation: 1584
I have a java applet, I want to make sure that nobody use it outside a specific url. How can I achieve that?
The applet connects to a Java server for data exchange. I want to check on the server side the page url that contains the applet. Is that possible?
Upvotes: 0
Views: 114
Reputation: 5211
I have a java applet, I want to make sure that nobody use it outside a specific url. How can I achieve that?
You can't.
You can make it less easy.
Plain Java is trivially decompiled and manipulated by any decent developer. Even after obfuscation, it wouldn't be very difficult to circumvent any protection; changing "boolean checkAppletOrigin()" to always return true is not very difficult.
Think about what you are trying to achieve, and you might be able to find an alternative solution.
Upvotes: 1
Reputation: 3938
In your applet you can call the applet method getCodeBase() which will give you what URL the applet is running on pass that along with the data passed to the server that will give you a check that the applet is being run from where you wanted.
There are a few problems such that the web traffic to the server if not encrypted or protect somehow could be spoofed and this check could be gotten around. But it would be much harder to do then just reposting the applet somewhere new.
Upvotes: 1