Tips for protecting applets from theft

Source: Internet
Author: User

We know that the Javaapplet in the Web page is not like the image file can be directly from the browser to the SaveAs command to obtain, but still may be browsed from the cache to find, put their own web page. Therefore, one way to protect your applet from "stealing" is to have the applet run only on the Web page of the specified URL. In the Java language, the URL of the Web page where the applet resides can be obtained by means of a method getdocumenbase () in the Java.applet package.

For example, in the following procedure, the applet detects the current URL in the initialization phase and, once it does not match the setting, outputs the warning message in the Java Console (Javaconsole) and automatically aborts the operation, thus enabling the applet's "copyright protection".

import java.net.*;
import java.applet.*;
public class myonly extends Applet{
public void init(){
String ower=getDocumentBase().getHost();
if(!ower.equals("www.mydomain.com")){
System.out.println("Warning ! A stolen Applet.");
System.exit(1);
}
else{
… …
}
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.