advertisement
javaboutique
Search Tips
Articles  |   Tutorials  |   Reviews  |   Tools  |   by Category  |   by Date  |   by Name  |   Submit  |   Source  |   Forums  |  
javaboutique
Browse DevX


Partners & Affiliates











advertisement

JavaBoutique: Articles: Programmers:

Contents
Introduction
Sample Code
In Conclusion

Java Jive: "I Said a Sip, Not the Whole Cup!"

We have to use what we have available, and we know we can call on getDocumentBase() for help.

What can be done to stop the majority of these thefts? Well, we have to use what we have available, and we know we can call on getDocumentBase() for help. This method comes from the Class Applet, in the package java.applet. The method getDocumentBase() tells you where the HTML page was served from. Using getDocumentBase(), one can determine the page's origin, and if we call these methods from within the applet, we can prevent it from working if it's not coming from the correct server. Here's a simple applet showing how it works:

import java.net.*;
import java.applet.*;

public class stopthief extends Applet {

public void init() {
String stolen;
Stringowner =
getDocumentBase().getHost();
if (owner.equals("www.yourdomain.com")) {
// this is where you would insert 
// your stuff for legit users
} else {
System.exit(1);  
// this is where you'll kill or 
// otherwise alter the applet for 
// thieves
}
}
}

What this does is to cause a security exception at System.exit(1) if the applet is not coming from your site. This is just an example, as you could cause it to do almost anything, but this way, it just won't work for thieves. One negative aspect of this method is that you'll have to change and recompile the applet if you change servers.

And just how secure is this method? Secure enough to thwart most applet thieves, but not enough to stop professionals, or even those with a lot of determination. How can they still make the applets function? Anyone familiar with a hex editor can tell you. There's no magic involved...just a little search and replace. So why implement the method at all then? Because it'll stop about ninety percent of those that would hack your applet, and the other ten percent will find a way to hack it anyway.

If you're not afraid to enter the world of CGI (and why would you be...you're already into programming enough to read this column), then you can create a CGI script that is called by the applet, and if the CGI doesn't pass the correct information to the applet, the applet will not function. Is it simple? Not particularly, but it is effective-more so than our previous example.

NEXT


Reprinted from Web DeveloperŪ magazine, Vol. 3 No.2 Mar/Apr 1997 (c) 1997 internet.com Corporation. All rights reserved.


How to Add Java Applets to Your Site

New on the Java Boutique:

New Review:

Time Management Made Easy with the Quartz Enterprise Job Scheduler
Why not just use the Java timer API? This open source scheduling API boasts simplicity, ease-of-integration, a well-rounded feature set, and it's free!

New Applet:

Reverse Complement
Reverse Complement is a simple applet that converts DNA or RNA sequences into three useful formats.

Elsewhere on internet.com:

WebDeveloper Java
Lots of Java information on webdeveloper.com

WDVL Java
Thorough Java resource at the Web Developer's Virtual Library.

ScriptSearch Java
Hundreds of free Java code files to download.

jGuru: Your View of the Java Universe
Customizable portal with online training, FAQs, regular news updates, and tutorials.

 IBM Software Construction Toolbox
 Microsoft RIA Development Center
 Destination .NET
XML error: not well-formed (invalid token) at line 33
advertisement
Receive Articles via our XML/RSS feed
Receive Articles via our XML/RSS feed

JavaBytes
Internet Cyclone
This powerful, easy-to-use, internet optimizer is for Windows 95, 98, ME, NT, 2000 and XP. It's designed to automatically optimize your Windows settings, boosting your Internet connection up to 200%.

The Pitfalls of Open Source Litigation
LiMo Open to Working With Google on Mobile
Google Gadgets Under Attack at Black Hat
IBM, Linux and the Microsoft-Free PC
Opengear's Open Source Odyssey
Sun Moves JavaFX Closer to Primetime
Will LSB 4 Standardize Linux?
Making a Case for an Android-Symbian Merger
Ubuntu Launchpad Opens Up Development
BT Buys Voice Software Startup

An Introduction to F# for Functional Programming
The Basics of REALbasic, Cross-platform RAD Tool in the Mold of VB
Silverlight Streaming: Free Video Hosting for All
What's New in ASP.NET 3.5?
Putting SharePoint to Work for You
Putting IntelŪ Threading Building Blocks to Work
Achieve the Best of Two Worlds with Behavior-Driven Development
Understanding Windows Mobile Security
RODCs Transform Branch Office Security
SQL Server 2008 Express: The Free Database from Microsoft

Advertising Info  |   Member Services  |   Contact Us  |   Help  |   Feedback  |   Site Map  |   Network Map  |   About



JupiterOnlineMedia

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info


Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers