Sometimes, it is useful to force downloaded applet integrity verification, even if the code does not require any privileged capability. To enable such integrity verification, the code must be archived and signed (cab for IE, jar for Netscape). The simplest approach is to assert permissions in the applet init() method, using the lowest privileges necessary. For example:
public void init() { // ----------- Check Privileges for IE Browsers --------- try { if (Class.forName("com.ms.security.PolicyEngine") != null) { // required for IE PolicyEngine.assertPermission(PermissionID.USERFILEIO); } } catch (Throwable cnfe) { System.out.println("Problem getting privileges for IE " + cnfe) ; } // --------- Check Privileges for Netscape Browsers ------------ try{ PrivilegeManager.enablePrivilege("UniversalBrowserRead") ; // required for NN } catch(Exception cnfe) { System.out.println("netscape.security.PrivilegeManager class not found") ; } }
Depending on the particular approach (IE versus Netscape native JVMs versus JavaPlugin) it may be possible to access the archive programatically to perform further inspection/auditing.
References: