1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

Tonge, Rzepa, Yoshida, page 6

Only versions 4.0 or higher of both the major commercial browsers have the necessary functionality for recognising digitally signed applets.9Netscape Navigator v4.04 andlater requires the additional inclusion of calls to the Netscape Capabilities classes for fine-grained control of granting and enabling permissions to perform activities requiring authentication.10 Applet source code can be used unmodified with Internet Explorer v4.0. To enable an applet to function with both Netscape and Internet Explorer, further modifications must be made (Scheme 2).

Scheme 2. Example Code to be included in a Java Applet to permit both Netscape and Internet Explorer Signing.

import java.applet.*;
import java.awt.*;
import netscape.security.*;

public class myApplet extends Applet {
//This lists additional Java code that must be inserted in the init() //and write() methods in order to enable Netscape security classes.
boolean hasPrivilege = false, inNavigator=false, inExplorer=false;
FileDialog openDialog, saveDialog;
Textarea outText;

public void init() {
if ((System.getProperty("java.vendor").indexOf("Netscape")) != -1) {
inNavigator = true;
} else if
((System.getProperty("java.vendor").indexOf("Microsoft")) != -1) {
inExplorer = true;
}
//MSIE4.0 will give a security exception for FileDialog : //com.ms.security.SecurityExceptionEx : FileDialog creation denied
if (inNavigator) {
//FileDialog needs a parent Frame
Component c = this.getParent();
while (c != null && !(c instanceof Frame)) c = c.getParent();
openDialog = new FileDialog((Frame)c, "Open PDB", FileDialog.LOAD);
saveDialog = new FileDialog((Frame)c, "Save PDB", FileDialog.SAVE);
}
//Prompt user to enable read/write privileges
if (inNavigator) try {
PrivilegeManager.enablePrivilege("UniversalFileAccess");
hasPrivilege = true;
} catch (netscape.security.ForbiddenTargetException e) {
outText.appendText("\nPermission to write files denied ");
}
}
public void printCoords() {
//Write to new file on client
if (inNavigator) {
if (hasPrivilege == false) {
outText.appendText("\nNecessary write privilege not granted.");
return;
}
PrivilegeManager.enablePrivilege("UniversalFileAccess");
}
PrintWriter out;
String dirName, filName;