views:

60

answers:

2

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?

+1  A: 

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.

Jeff Beck
thanks guys,, you were so helpful
Bassel Alkhateeb
+1  A: 

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.

alex
"Think about what you are trying to achieve" is always good advice when security is an issue. In particular, think about what kind of attacks you're trying to prevent. If the applet can be teivialkt decompiled, and the network sniffed, then restricting it to run from a particular server isn't going to increase security much.
Mark Bessey
thanks for the great answer, may I have your contact or facebook page?thanks again
Bassel Alkhateeb