Securing Java


Behold the Dancing Pigs!

(Netscape version)

To use this applet, drag and click on the image. The image will "warp" based on drag. When you are comfortable with the changes you have made to the image, press the save button to write a copy of your work in GIF format to disk.

* Please note that some older versions of Communicator may not support the SAVE option because the browser's Java VM does not contain java.awt.FileDialog.

Capabilities Code

Because this applet is signed with Netscape Object Signing Class 2 Digital Certificate from Verisign, the applet may be allowed to write to the local disks. The code that requests the capabilities and that causes the security dialog box to pop up looks like this:

FileDialog fd = new FileDialog(new Frame(), "Save as GIF");
fd.setMode(FileDialog.SAVE);
fd.show();
if(fd.getFile() != null) {
  try {
    PrivilegeManager.enablePrivilege("UniversalFileWrite");
    FileOutputStream out = 
      new FileOutputStream(new File(fd.getDirectory(), fd.getFile()));
    new GifEncoder(mImage, out).encode();
    out.flush();
    out.close();
  } catch (IOException ioe) {
    showStatus("couldn't write the gif: " + ioe.getMessage());
  } catch (ForbiddenTargetException fte) {
    showStatus("permission denied: " + fte.getMessage());
  }
}
You must run a 4.x version of Netscape to correctly display this applet.
You are running Microsoft Internet Explorer. This page contains an applet that will only run correctly with Netscape.


Image Warper Applet courtesy Alex Rosen.
Netscape Capabilities Classes API
GIF encoding from Acme Labs



Menu Map -- Text links below

Chapter... Preface -- 1 -- 2 -- 3 -- 4 -- 5 -- 6 -- 7 -- 8 -- 9 -- A -- B -- C -- Refs
Front -- Contents -- Help

Copyright ©1999 Gary McGraw and Edward Felten.
All rights reserved.
Published by John Wiley & Sons, Inc.