Applet Security Example: <APPLET> tag
This applet that tries to access the secure property "user.name
":
|
This applet accesses a JAR files which has been signed with a Netscape Object Signing certificate. The Java source code has also been modified to access the Netscape Capabilities API prior to access the secure property.
import java.awt.Graphics;
import java.applet.Applet;
public class SecurityApplet extends Applet {
public void init() {}
public void paint(Graphics g) {
String privilege = "UniversalPropertyRead";
try {
netscape.security.PrivilegeManager.enablePrivilege(privilege);
String thePropParam = getParameter("prop");
String theProperty = System.getProperty(thePropParam);
g.drawString("Successfully got \"" + thePropParam + "\" property: " + theProperty, 10, 10);
} catch (SecurityException se) {
g.drawString("SecurityApplet caught SecurityException: " + se.getMessage(), 10, 10);
} catch (Exception e) {
g.drawString("Netscape privilege not granted: " + privilege, 10, 10);
}
}
}