xref: /titanic_41/usr/src/cmd/krb5/kadmin/gui/KdcGui.java (revision 53391baf4e45c693cf123555e9617b5e1e0b641a)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * ident	"%Z%%M%	%I%	%E% SMI"
24  *
25  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
26  * Use is subject to license terms.
27  */
28 
29 /**
30  * GUI interface for Kerberos KDC
31  */
32 
33 // Java Workshop stuff
34 import sunsoft.jws.visual.rt.base.*;
35 import sunsoft.jws.visual.rt.base.Global;
36 import sunsoft.jws.visual.rt.awt.TabbedFolder;
37 import sunsoft.jws.visual.rt.awt.TextList;
38 import sunsoft.jws.visual.rt.awt.StringVector;
39 import sunsoft.jws.visual.rt.shadow.java.awt.*;
40 
41 // Regular JDK stuff
42 import java.awt.*;
43 import java.awt.event.*;
44 import java.util.EventListener;
45 import java.util.Properties;
46 import java.util.Vector;
47 import java.util.Random;
48 import java.util.StringTokenizer;
49 import java.io.IOException;
50 import java.io.File;
51 import java.io.InputStream;
52 import java.net.URL;
53 
54 // Stuff to support I18N
55 import java.util.Date;
56 import java.util.Calendar;
57 import java.util.GregorianCalendar;
58 import java.util.Locale;
59 import java.text.DateFormat;
60 import java.text.ParseException;
61 import java.text.DateFormatSymbols;
62 import java.text.NumberFormat;
63 import java.util.ResourceBundle;
64 import java.util.ListResourceBundle;
65 import java.util.MissingResourceException;
66 import java.util.Enumeration;
67 
68 public class KdcGui extends Group {
69 
70     // Basics
71     private KdcGuiRoot gui;
72     private Krb5Conf kc;
73     private Principal prin = null;
74     private Policy pol = null;
75     private Defaults defaults = null;
76     private Defaults olddefaults = null;
77     public Frame defaultsEditingFrame = null; // public since used
78     // by ContextHelp class
79     public Frame realMainFrame = null;
80     public Frame realLoginFrame = null;
81 
82     public Kadmin Kadmin = null;
83 
84     // Privileges stuff: corresponds to ADMCIL set in kdc.conf
85     public int privs = 0;
86     public static final int PRIV_ADD	= 0x02;		// KADM5_PRIV_ADD
87     public static final int PRIV_DELETE	= 0x08;		// KADM5_PRIV_DELETE
88     public static final int PRIV_MODIFY	= 0x04;		// KADM5_PRIV_MODIFY
89     public static final int PRIV_CHANGEPW	= 0x20;	// KADM5_PRIV_CPW
90     public static final int PRIV_INQUIRE	= 0x01;	// KADM5_PRIV_GET
91     public static final int PRIV_LIST	= 0x10;		// KADM5_PRIV_LIST
92     public boolean noLists = false;
93 
94     // For modal warning dialog and context-sensitive help dialog
95     private Dialog dialog;
96     public ContextHelp cHelp = null; // tweaked from ContextHelp when
97     // it is dismissed
98 
99     private static Toolkit toolkit;
100 
101     // For showDataFormatError() to determine what kind of error to show
102 
103     public static final int DURATION_DATA = 1;
104     public static final int DATE_DATA = 2;
105     public static final int NUMBER_DATA = 3;
106 
107     private static String[] durationErrorText = null;
108     private static String[] dateErrorText = null;
109     private static String[] numberErrorText = null;
110 
111     // For date & time helper dialogs
112     private DateTimeDialog dateTimeDialog = null;
113     private DurationHelper durationHelper = null;
114 
115     // For the encryption list helper dialog
116     private EncListDialog encListDialog = null;
117 
118     // Important defaults and current settings
119     private String DefName = null;
120     private String DefRealm = null;
121     private String DefServer = null;
122     private String DefPort = "0";
123     private String CurName, CurPass, CurRealm, CurServer;
124     private int CurPort;
125     private String CurPrincipal;
126     private String CurPolicy;
127     private String curPrPattern = "";
128     private String curPoPattern = "";
129     private int curPrListPos = 0;
130     private int curPoListPos = 0;
131     private String[] principalList = null;
132     private Date principalListDate = new Date(0);
133     private String[] policyList = null;
134     private Date policyListDate = new Date(0);
135     private static final long A_LONG_TIME = 1000 * 60 * 60 * 24 * 365;
136 
137     // General state variables
138     private boolean prSelValid = false;
139     private String[] prMulti = null;
140     private boolean prNeedSave = false;
141     private boolean poSelValid = false;
142     private String[] poMulti = null;
143     private boolean poNeedSave = false;
144     private boolean glNeedSave = false;
145     private boolean firsttime = true;
146     private boolean prnameEditable = false;
147     private boolean ponameEditable = false;
148 
149     // Support for context-sensitive help
150     private static final int BUTTON_ACTION = 1;
151     private static final int BUTTON_MOUSE = 2;
152     private static final int TEXTFIELD_ACTION = 3;
153     private static final int TEXTFIELD_MOUSE = 4;
154     private static final int TEXTFIELD_KEY = 5;
155     private static final int CHOICE_ITEM = 6;
156     private static final int CHOICE_MOUSE = 7;
157     private static final int CHECKBOX_ITEM = 8;
158     private static final int CHECKBOX_MOUSE = 9;
159     private static final int LABEL_MOUSE = 10;
160     private static final int WINDOW_LISTENER = 11;
161 
162     private boolean loginListeners = false;
163     private Vector LoginNormal = null;
164     private Vector LoginHelp = null;
165     private Vector LoginFixers = null;
166     private Vector MainNormal = null;
167     private Vector MainHelp = null;
168     private Vector MainFixers = null;
169     private Vector defaultsNormal = null;
170     private Vector defaultsHelp = null;
171     private Vector defaultsFixers = null;
172     public boolean loginHelpMode = false;
173     public boolean mainHelpMode = false;
174     public boolean defaultsHelpMode = false;
175 
176     // For Principal and Policy Keystroke listeners
177     private static final int PRINCIPAL_EDITING = 1;
178     private static final int POLICY_EDITING = 2;
179     private static final int DEFAULTS_EDITING = 3;
180     private static final int PRINCIPAL_LIST = 4;
181     private static final int POLICY_LIST = 5;
182 
183     // For status line
184     private String OpString = "";
185     private String ModeString = "";
186     private String SaveString = "";
187 
188     // For I18N
189     private static ResourceBundle rb;
190     private static ResourceBundle hrb;
191     private static DateFormat df;
192     private static NumberFormat nf;
193 
194     private static String neverString;
195 
196     // For general pupose help
197     Process browserProcess;
198     String helpIndexFile = "file:/usr/lib/krb5/HelpIndex.html";
199 
200     // For performance monitoring
201     boolean perfmon = false;
202     Date pdateFirst;
203     Date pdateAfterKrb5Conf;
204     Date pdateEndGuiRoot;
205     Date pdateBeginStartGroup;
206     Date pdateStringsDone;
207     Date pdateLoginReady;
208     Date pdateLoginDone;
209     Date pdateSessionUp;
210     Date pdatePreMainShow;
211     Date pdatePostMainShow;
212     Date pdateMainActive;
213     Date pdateStartPlist;
214     Date pdateHavePlist;
215     Date pdateEmptyPlist;
216     Date pdateDonePlist;
217 
218     public void reportTime(String s0, Date curr, Date prev) {
219         if (!perfmon)
220             return;
221         String s1 = curr.toString();
222         long curdiff = curr.getTime() - prev.getTime();
223         String s2 = (new Long(curdiff)).toString();
224         long cumdiff = curr.getTime() - pdateFirst.getTime();
225         String s3 = (new Long(cumdiff)).toString();
226         System.out.println(s0+s1+" delta "+s2+" cume "+s3);
227     }
228 
229     public void reportStartTimes() {
230         if (!perfmon)
231             return;
232         System.out.println("");
233         reportTime("First timestamp: ", pdateFirst, pdateFirst);
234         reportTime("After krb5.conf: ", pdateAfterKrb5Conf, pdateFirst);
235         reportTime("KdcGuiRoot done: ", pdateEndGuiRoot, pdateAfterKrb5Conf);
236         reportTime("At startGroup  : ", pdateBeginStartGroup, pdateEndGuiRoot);
237         reportTime("Strings set up : ", pdateStringsDone, pdateBeginStartGroup);
238         reportTime("Login ready    : ", pdateLoginReady, pdateStringsDone);
239         reportTime("Login complete : ", pdateLoginDone, pdateLoginReady);
240         reportTime("Session set up : ", pdateSessionUp, pdateLoginDone);
241         reportTime("Start main win : ", pdatePreMainShow, pdateSessionUp);
242         reportTime("Done main win  : ", pdatePostMainShow, pdatePreMainShow);
243         reportTime("Main win active: ", pdateMainActive, pdatePostMainShow);
244     }
245 
246     /**
247      * Sample method call ordering during a group's lifetime:
248      *
249      * Constructor
250      * initRoot
251      * initGroup
252      * (setOnGroup and getOnGroup may be called at any time in any
253      *  order after initGroup has been called)
254      * createGroup
255      * showGroup/hideGroup + startGroup/stopGroup
256      * destroyGroup
257      */
258 
259     /**
260      * The constructor sets up defaults for login screen
261      *
262      */
263     public KdcGui() {
264 
265         /*
266          * Set up defaults from /etc/krb5/krb5.conf
267          */
268 
269         pdateFirst = new Date();
270         DefName = System.getProperty("user.name" /* NOI18N */)+
271 	    "/admin" /* NOI18N */;
272         kc = new Krb5Conf();
273         DefRealm = kc.getDefaultRealm();
274         DefServer = kc.getRealmServer(DefRealm);
275         DefPort = kc.getRealmPort(DefRealm);
276         pdateAfterKrb5Conf = new Date();
277 
278         /*
279          * Take care of Java Workshop attribute plumbing
280          */
281         addForwardedAttributes();
282     }
283 
284     /**
285      * Inherited from the Java Workshop skeleton
286      *
287      */
288     protected Root initRoot() {
289         /*
290          * Initialize the gui components
291          */
292         gui = new KdcGuiRoot(this);
293         pdateEndGuiRoot = new Date();
294 
295         /*
296          * Take care of Java Workshop attribute plumbing.
297          */
298         addAttributeForward(gui.getMainChild());
299 
300         initLoginStrings();
301         initMainStrings();
302         pdateStringsDone = new Date();
303         return gui;
304     }
305 
306     /**
307      * Set up the login screen properly.
308      *
309      */
310     protected void startGroup() {
311         pdateBeginStartGroup = new Date();
312         realLoginFrame = (Frame)gui.loginframe.getBody();
313         realLoginFrame.setTitle(getString("SEAM Administration Login"));
314         setLoginDefaults();
315         pdateLoginReady = new Date();
316     }
317 
318     /**
319      * All cleanup done here.
320      */
321     protected void stopGroup() {
322         killHelpBrowser();
323     }
324 
325 
326     /**
327      * Callbacks from Java workshop to decide whether to take the action
328      * or show appropriate help for it.
329      *
330      * 1. Actions that are triggered from all three - mainframe,
331      *    loginframe, and defaultsEditingFrame - are: context sensitive help.
332      * 2. Actions that are triggered only from mainframe are: printing,
333      *    logging out, edit preferences.
334      * 3. Actions that are triggered from mainframe and loginframe are:
335      *    exit, general help, context sensitive help, about.
336      */
337 
338 
339     // All three frames
340 
341     public void checkContextSensitiveHelp(Frame frame) {
342         if ((loginHelpMode && frame == realLoginFrame)
343             || (mainHelpMode && frame == realMainFrame)
344 	    || (defaultsHelpMode && frame == defaultsEditingFrame))
345 	    showHelp("ContextSensitiveHelp");
346         else
347             contextHelp(frame);
348     }
349 
350     // Mainframe only
351 
352     public void checkPrintCurPr() {
353         if (mainHelpMode)
354             showHelp("PrintCurrentPrincipal");
355         else
356             printCurPr();
357     }
358 
359     public void checkPrintCurPol() {
360         if (mainHelpMode)
361             showHelp("PrintCurrentPolicy");
362         else
363             printCurPol();
364     }
365 
366     public void checkPrintPrList() {
367         if (mainHelpMode)
368             showHelp("PrintPrincipalList");
369         else
370             printPrList();
371     }
372 
373     public void checkPrintPoList() {
374         if (mainHelpMode)
375             showHelp("PrintPolicyList");
376         else
377             printPoList();
378     }
379 
380     public void checkLogout() {
381         if (mainHelpMode)
382             showHelp("Logout");
383         else if (okayToLeave(realMainFrame))
384             logout();
385     }
386 
387     public void checkEditPreferences() {
388         if (mainHelpMode)
389             showHelp("EditPreferences");
390         else
391             editPreferences();
392     }
393 
394     public void checkRefreshPrincipals() {
395         if (mainHelpMode)
396             showHelp("RefreshPrincipals");
397         else {
398             principalList = null;
399             fillPrincipalList(curPrPattern);
400         }
401     }
402 
403     public void checkRefreshPolicies() {
404         if (mainHelpMode)
405             showHelp("RefreshPolicies");
406         else {
407             policyList = null;
408             fillPolicyList(curPoPattern);
409         }
410     }
411 
412     // Mainframe and loginframe
413 
414     public void checkExit(Frame frame) {
415         if ((loginHelpMode && frame == realLoginFrame)
416             || (mainHelpMode && frame == realMainFrame))
417 	    showHelp("Exit");
418         else if (okayToLeave(frame))
419             exit();
420     }
421 
422     public void checkHelp(Frame frame) {
423         if ((loginHelpMode && frame == realLoginFrame)
424             || (mainHelpMode && frame == realMainFrame))
425 	    showHelp("HelpBrowser");
426         else
427             showHelpBrowser(frame);
428     }
429 
430     public void checkAbout(Frame frame) {
431         if ((loginHelpMode && frame == realLoginFrame)
432             || (mainHelpMode && frame == realMainFrame))
433 	    showHelp("About");
434         else
435             doAbout(frame);
436     }
437 
438     public boolean okayToLeave(Frame frame) {
439         if (prNeedSave || poNeedSave || glNeedSave) {
440             String text[] = {getString("You are about to lose changes."),
441 			     getString("Click Save to commit changes, "
442 				       +"Discard to discard changes, "
443 				       +"or Cancel to continue editing.")};
444             String resp = confirmSave(frame, text);
445             if (resp.equals(getString("Cancel")))
446                 return false;
447             else if (resp.equals(getString("Save"))) {
448                 if (prNeedSave)
449                     if (!prDoSave())
450 			return false; // found an error so cannot leave
451                 if (poNeedSave)
452                     if (!poDoSave())
453 			return false; // found an error so cannot leave
454                 if (glNeedSave)
455                     glDoSave(true);
456             } else
457                 prNeedSave = poNeedSave = glNeedSave = false;
458         }
459         return true;
460     }
461 
462     /**
463      * We use the JDK 1.1 event model for most of our events, but
464      * we do still need to handle old-style events because the
465      * tabbed folder and the card panel(supplied by Java Workshop)
466      * are not compatible with the new event model.  We use the
467      * callouts from Java Workshop to deal with the card panel,
468      * but we need to have some code here to do the right thing
469      * when the user selects a new tab in the tabbed folder.
470      *
471      * It is important that not too many conditions are tested here,
472      * because all events flow through this code path.
473      *
474      */
475     public boolean handleEvent(Message msg, Event evt) {
476 
477         /*
478          * Look for events from the principal and policy list.
479          */
480 
481         if (evt.target == gui.Prlist.getBody()) {
482             if (mainHelpMode) {
483                 if (evt.id == Event.ACTION_EVENT
484 		    || evt.id == Event.LIST_SELECT) {
485                     restorePrListSelection();
486                     showHelp(((Component)gui.Prlist.getBody()).getName());
487                 }
488             } // end of help mode
489             else if (evt.id == Event.ACTION_EVENT)
490                 prModify();
491             else if (evt.id == Event.LIST_SELECT)
492                 lookAtPrList();
493             return true;
494         } // end of Prlist
495 
496         if (evt.target == gui.Pollist.getBody()) {
497             if (mainHelpMode) {
498                 if (evt.id == Event.ACTION_EVENT
499 		    || evt.id == Event.LIST_SELECT) {
500                     restorePoListSelection();
501                     showHelp(((Component)gui.Pollist.getBody()).getName());
502                 }
503             } // end of help mode
504             else if (evt.id == Event.ACTION_EVENT)
505                 poSelected();
506             else if (evt.id == Event.LIST_SELECT)
507                 lookAtPoList();
508             return true;
509         } // end of Pollist
510 
511         /*
512          * Look for a unique event from the tabbed folder component;
513          * if I see it, I know I have a chance to disallow a switch.
514          * This makes sure data is saved before leaving a tab.
515          */
516         if (evt.id == TabbedFolder.CONFIRM_SWITCH) {
517             // System.out.println("Got confirm for "+evt.arg);
518             String e = (String)evt.arg;
519             if (!mainHelpMode && okayToLeave(realMainFrame) == false) {
520                 // System.out.println("Denying switch");
521                 ((TabbedFolder)gui.tabbedfolder1.getBody()).cancelSwitch();
522             }
523             /*
524              * Okay with switch; make sure the data is up to date
525              */
526             else if (e.compareTo(getString("Principals")) == 0) {
527                 if (mainHelpMode) {
528                     showHelp("PrincipalTab");
529                     ((TabbedFolder)gui.tabbedfolder1.getBody()).cancelSwitch();
530                 } else {
531                     showPrincipalList(curPrPattern);
532                     disablePolicyPrinting();
533                 }
534             } else if (e.compareTo(getString("Policies")) == 0) {
535                 if (mainHelpMode) {
536                     showHelp("PolicyTab");
537                     ((TabbedFolder)gui.tabbedfolder1.getBody()).cancelSwitch();
538                 } else {
539                     showPolicyList(curPoPattern);
540                     disablePrincipalPrinting();
541                 }
542             }
543         }
544         return super.handleEvent(msg, evt);
545     }
546 
547     /*
548      * New methods for the admin gui login screen.
549      */
550 
551     /**
552      * Set strings on login screen to their I18N'd values
553      *
554      */
555     public void initLoginStrings() {
556         gui.File2.set("text" /* NOI18N */, getString("File"));
557         gui.Exit2.set("text" /* NOI18N */, getString("Exit"));
558         gui.menu1.set("text" /* NOI18N */, getString("Help"));
559         gui.browserHelp1.set("text" /* NOI18N */, getString("Help Contents"));
560         gui.Context2.set("text" /* NOI18N */,
561 			 getString("Context-Sensitive Help"));
562         gui.About2.set("text" /* NOI18N */, getString("About"));
563         gui.LoginNameLabel.set("text" /* NOI18N */,
564 			       getString("Principal Name:"));
565         gui.LoginPassLabel.set("text" /* NOI18N */, getString("Password:"));
566         gui.LoginRealmLabel.set("text" /* NOI18N */, getString("Realm:"));
567         gui.LoginServerLabel.set("text" /* NOI18N */, getString("Master KDC:"));
568         gui.LoginOK.set("text" /* NOI18N */, getString("OK"));
569         gui.LoginStartOver.set("text" /* NOI18N */, getString("Start Over"));
570     }
571 
572     /**
573      * Set strings on main screen to their I18N'd values
574      *
575      */
576     public void initMainStrings() {
577         gui.mainframe.set("title" /* NOI18N */,
578 			  getString("SEAM Administration Tool"));
579         gui.File.set("text" /* NOI18N */, getString("File"));
580         gui.Print.set("text" /* NOI18N */, getString("Print"));
581         gui.PrintCurPr.set("text" /* NOI18N */, getString("Current Principal"));
582         gui.PrintCurPol.set("text" /* NOI18N */, getString("Current Policy"));
583         gui.PrintPrlist.set("text" /* NOI18N */, getString("Principal List"));
584         gui.PrintPollist.set("text" /* NOI18N */, getString("Policy List"));
585         gui.logout.set("text" /* NOI18N */, getString("Log Out"));
586         gui.Exit.set("text" /* NOI18N */, getString("Exit"));
587         gui.editMenu.set("text" /* NOI18N */, getString("Edit"));
588         gui.editPreferences.set("text" /* NOI18N */,
589 				getString("Properties..."));
590         gui.menu2.set("text" /* NOI18N */, getString("Refresh"));
591         gui.refreshPrincipals.set("text" /* NOI18N */,
592 				  getString("Principal List"));
593         gui.refreshPolicies.set("text" /* NOI18N */, getString("Policy List"));
594         gui.Help.set("text" /* NOI18N */, getString("Help"));
595         gui.browserHelp2.set("text" /* NOI18N */, getString("Help Contents"));
596         gui.Context.set("text" /* NOI18N */,
597 			getString("Context-Sensitive Help"));
598         gui.About.set("text" /* NOI18N */, getString("About"));
599 
600         gui.Prlisttab.set("layoutName", getString("Principals"));
601         gui.Pollisttab.set("layoutName", getString("Policies"));
602 
603         gui.PrListLabel.set("text" /* NOI18N */, getString("Principal List"));
604         gui.PrSearchLab.set("text" /* NOI18N */, getString("Filter Pattern:"));
605         gui.PrListClear.set("text" /* NOI18N */, getString("Clear Filter"));
606         gui.PrListModify.set("text" /* NOI18N */, getString("Modify"));
607         gui.PrListAdd.set("text" /* NOI18N */, getString("Create New"));
608         gui.PrListDelete.set("text" /* NOI18N */, getString("Delete"));
609         gui.PrListDuplicate.set("text" /* NOI18N */, getString("Duplicate"));
610 
611         gui.PrBasicLabel.set("text" /* NOI18N */,
612 			     getString("Principal Basics"));
613         gui.PrNameLabel1.set("text" /* NOI18N */, getString("Principal Name:"));
614         gui.LabelBarGeneral.set("text" /* NOI18N */, getString("General"));
615         gui.PrCommentsLabel.set("text" /* NOI18N */, getString("Comments:"));
616         gui.PrPolicyLabel.set("text" /* NOI18N */, getString("Policy:"));
617         gui.PrPasswordLabel.set("text" /* NOI18N */, getString("Password:"));
618         gui.PrBasicRandomPw.set("text" /* NOI18N */,
619 				getString("Generate Random Password"));
620         gui.EncListLabel.set("text" /* NOI18N */,
621 			getString("Encryption Key Types:"));
622         gui.LabelBarPrincipal.set("text" /* NOI18N */,
623 				  getString("Admin History"));
624         gui.PrLastChangedTimeLabel.set("text" /* NOI18N */,
625 				       getString("Last Principal Change:"));
626         gui.PrLastChangedByLabel.set("text" /* NOI18N */,
627 				     getString("Last Changed By:"));
628         gui.PrExpiryLabel.set("text" /* NOI18N */,
629 			      getString("Account Expires:"));
630         gui.PrBasicSave.set("text" /* NOI18N */, getString("Save"));
631         gui.PrBasicPrevious.set("text" /* NOI18N */, getString("Previous"));
632         gui.PrBasicNext.set("text" /* NOI18N */, getString("Next"));
633         gui.PrBasicCancel.set("text" /* NOI18N */, getString("Cancel"));
634 
635         gui.PrDetailLabel.set("text" /* NOI18N */,
636 			      getString("Principal Details"));
637         gui.LabelBarPassword.set("text" /* NOI18N */, getString("Password"));
638         gui.PrLastSuccessLabel.set("text" /* NOI18N */,
639 				   getString("Last Success:"));
640         gui.PrLastFailureLabel.set("text" /* NOI18N */,
641 				   getString("Last Failure:"));
642         gui.PrFailureCountLabel.set("text" /* NOI18N */,
643 				    getString("Failure Count:"));
644         gui.PrPwLastChangedLabel.set("text" /* NOI18N */,
645 				     getString("Last Password Change:"));
646         gui.PrPwExpiryLabel.set("text" /* NOI18N */,
647 				getString("Password Expires:"));
648         gui.PrKvnoLabel.set("text" /* NOI18N */, getString("Key Version:"));
649         gui.LabelBarTicket.set("text" /* NOI18N */,
650 			       getString("Ticket Lifetimes"));
651         gui.PrMaxTicketLifetimeLabel.set("text" /* NOI18N */,
652 				 getString("Maximum Lifetime (seconds):"));
653         gui.PrMaxTicketRenewalLabel.set("text" /* NOI18N */,
654 				getString("Maximum Renewal (seconds):"));
655         gui.PrDetailSave.set("text" /* NOI18N */, getString("Save"));
656         gui.PrDetailPrevious.set("text" /* NOI18N */, getString("Previous"));
657         gui.PrDetailNext.set("text" /* NOI18N */, getString("Next"));
658         gui.PrDetailCancel.set("text" /* NOI18N */, getString("Cancel"));
659 
660         gui.PrFlagLabel.set("text" /* NOI18N */, getString("Principal Flags"));
661         gui.LabelBarSecurity.set("text" /* NOI18N */, getString("Security"));
662 
663         gui.PrLockAcct.set("text" /* NOI18N */,
664 			   Flags.getLabel(Flags.DISALLOW_ALL_TIX));
665         gui.PrForcePwChange.set("text" /* NOI18N */,
666 				Flags.getLabel(Flags.REQUIRES_PWCHANGE));
667         gui.LabelBarTickets.set("text" /* NOI18N */, getString("Ticket"));
668         gui.PrAllowPostdated.set("text" /* NOI18N */,
669 				 Flags.getLabel(Flags.DISALLOW_POSTDATED));
670         gui.PrAllowForwardable.set("text" /* NOI18N */,
671 				   Flags.getLabel(Flags.DISALLOW_FORWARDABLE));
672         gui.PrAllowRenewable.set("text" /* NOI18N */,
673 				 Flags.getLabel(Flags.DISALLOW_RENEWABLE));
674         gui.PrAllowProxiable.set("text" /* NOI18N */,
675 				 Flags.getLabel(Flags.DISALLOW_PROXIABLE));
676         gui.PrAllowSvr.set("text" /* NOI18N */,
677 			   Flags.getLabel(Flags.DISALLOW_SVR));
678         gui.LabelBarMiscellany.set("text" /* NOI18N */,
679 				   getString("Miscellaneous"));
680         gui.PrAllowTGT.set("text" /* NOI18N */,
681 			   Flags.getLabel(Flags.DISALLOW_TGT_BASED));
682         gui.PrAllowDupAuth.set("text" /* NOI18N */,
683 			       Flags.getLabel(Flags.DISALLOW_DUP_SKEY));
684         gui.PrRequirePreAuth.set("text" /* NOI18N */,
685 				 Flags.getLabel(Flags.REQUIRE_PRE_AUTH));
686         gui.PrRequireHwPreAuth.set("text" /* NOI18N */,
687 				   Flags.getLabel(Flags.REQUIRE_HW_AUTH));
688         gui.PrFlagsSave.set("text" /* NOI18N */, getString("Save"));
689         gui.PrFlagsPrevious.set("text" /* NOI18N */, getString("Previous"));
690         gui.PrFlagsNext.set("text" /* NOI18N */, getString("Done"));
691         gui.PrFlagsCancel.set("text" /* NOI18N */, getString("Cancel"));
692 
693         gui.PoListLabel.set("text" /* NOI18N */, getString("Policy List"));
694         gui.PoListPatternLabel.set("text" /* NOI18N */,
695 				   getString("Filter Pattern:"));
696         gui.PoListClear.set("text" /* NOI18N */, getString("Clear Filter"));
697         gui.PoListModify.set("text" /* NOI18N */, getString("Modify"));
698         gui.PoListAdd.set("text" /* NOI18N */, getString("Create New"));
699         gui.PoListDelete.set("text" /* NOI18N */, getString("Delete"));
700         gui.PoListDuplicate.set("text" /* NOI18N */, getString("Duplicate"));
701 
702         gui.PoDetailLabel.set("text" /* NOI18N */, getString("Policy Details"));
703         gui.PoNameLabel.set("text" /* NOI18N */, getString("Policy Name:"));
704         gui.PoMinPwLengthLabel.set("text" /* NOI18N */,
705 				   getString("Minimum Password Length:"));
706         gui.PoMinPwClassLabel.set("text" /* NOI18N */,
707 				  getString("Minimum Password Classes:"));
708         gui.PoSavedPasswordsLabel.set("text" /* NOI18N */,
709 				      getString("Saved Password History:"));
710         gui.PoMinTicketLifetimeLabel.set("text" /* NOI18N */,
711 			 getString("Minimum Password Lifetime (seconds):"));
712         gui.PoMaxTicketLifetimeLabel.set("text" /* NOI18N */,
713 			 getString("Maximum Password Lifetime (seconds):"));
714         gui.PoReferencesLabel.set("text" /* NOI18N */,
715 				  getString("Principals Using This Policy:"));
716         gui.PoDetailSave.set("text" /* NOI18N */, getString("Save"));
717         gui.PoDetailPrevious.set("text" /* NOI18N */, getString("Previous"));
718         gui.PoDetailDone.set("text" /* NOI18N */, getString("Done"));
719         gui.PoDetailCancel.set("text" /* NOI18N */, getString("Cancel"));
720     }
721 
722     /**
723      * Allow user to see a fatal error before exiting
724      */
725     public void fatalError(Frame frame, String[] text) {
726         String title = getString("Error");
727         String[] buttons = new String[1];
728         buttons[0] = getString("OK");
729         ChoiceDialog cd = new ChoiceDialog(frame, title, text, buttons);
730         cd.getSelection();
731         exit();
732     }
733 
734     /**
735      * Set the defaults for the login screen.  Called on startup,
736      * when "Start Over" is pressed, or when "Log Out" is chosen
737      * from the main screen's menu.
738      *
739      */
740     public void setLoginDefaults() {
741         CurName = DefName;
742         CurPass = "";
743         if (DefRealm != null)
744             CurRealm = DefRealm;
745         else {
746             CurRealm = "";
747             if (firsttime) {
748                 showLoginWarning(getString("Cannot find default realm; "
749 					   +"check /etc/krb5/krb5.conf"));
750                 firsttime = false;
751             }
752         }
753         if (DefServer != null)
754             CurServer = DefServer;
755         else
756             CurServer = "";
757         CurPort = 0;
758         try {
759             Integer i = new Integer(DefPort);
760             CurPort = i.intValue();
761         } catch (NumberFormatException e) {}
762         gui.LoginName.set("text" /* NOI18N */, CurName);
763         gui.LoginPass.set("text" /* NOI18N */, CurPass);
764         gui.LoginRealm.set("text" /* NOI18N */, CurRealm);
765         gui.LoginServer.set("text" /* NOI18N */, CurServer);
766         if (CurRealm.equals("___default_realm___")) {
767             String[] error = new String[1];
768             error[0] = getString(
769 				 "Kerberos /etc/krb5/krb5.conf configuration"
770 				 +" file not configured; exiting");
771             fatalError(realLoginFrame, error);
772         }
773         if (!loginListeners)
774             setupLoginNormalListeners();
775         loginListeners = true;
776         TextField name = (TextField)gui.LoginName.getBody();
777         name.selectAll();
778         name.requestFocus();
779     }
780 
781     /**
782      * React after new realm entered
783      *
784      */
785     public void newRealm() {
786         CurRealm = (String)gui.LoginRealm.get("text" /* NOI18N */);
787         String s = kc.getRealmServer(CurRealm);
788         if (s != null) {
789             CurServer = s;
790             gui.LoginServer.set("text" /* NOI18N */, CurServer);
791 
792         } else {
793             showLoginWarning(getString("Cannot find default server for realm"));
794             CurServer = "";
795             gui.LoginServer.set("text" /* NOI18N */, CurServer);
796             ((TextField)gui.LoginServer.getBody()).requestFocus();
797         }
798     }
799 
800     /**
801      * React after new server entered
802      *
803      */
804     public void newServer() {
805         CurServer = (String)gui.LoginServer.get("text" /* NOI18N */);
806         if (CurPass.compareTo("") != 0)
807             loginComplete();
808     }
809 
810     /**
811      * React after username is complete
812      *
813      */
814     public void nameComplete() {
815         ((TextField)gui.LoginName.getBody()).select(0, 0);
816         ((TextField)gui.LoginPass.getBody()).requestFocus();
817     }
818 
819     /**
820      * React after password is complete or "OK" button is pressed.
821      * We insist that the realm and server are set here separately
822      * so that we can permit field-to-field motion if /etc/krb5/krb5.conf
823      * does not exist.
824      *
825      */
826     public void passwordComplete() {
827         CurPass = (String)gui.LoginPass.get("text" /* NOI18N */);
828         if (CurRealm.compareTo("") == 0) {
829             ((TextField)gui.LoginRealm.getBody()).requestFocus();
830             return;
831         }
832         if (CurServer.compareTo("") == 0) {
833             ((TextField)gui.LoginServer.getBody()).requestFocus();
834             return;
835         }
836         loginComplete();
837     }
838 
839     /**
840      * Check to see if we're happy with the login information.
841      * We may want to go to the main screen, principal list tab.
842      *
843      */
844     public void loginComplete() {
845         pdateLoginDone = new Date();
846         CurName   = (String)gui.LoginName.get("text" /* NOI18N */);
847         CurPass   = (String)gui.LoginPass.get("text" /* NOI18N */);
848         CurRealm  = (String)gui.LoginRealm.get("text" /* NOI18N */);
849         CurServer = (String)gui.LoginServer.get("text" /* NOI18N */);
850         if (CurPass.compareTo("") == 0) {
851             showLoginWarning(getString("A password must be specified"));
852             ((TextField)gui.LoginPass.getBody()).requestFocus();
853             return;
854         }
855         if (CurRealm.compareTo("") == 0) {
856             showLoginWarning(getString("A realm entry must be specified"));
857             ((TextField)gui.LoginRealm.getBody()).requestFocus();
858             return;
859         }
860         if (CurServer.compareTo("") == 0) {
861             showLoginWarning(getString("A master KDC entry must be specified"));
862             ((TextField)gui.LoginServer.getBody()).requestFocus();
863             return;
864         }
865 
866         realLoginFrame.setCursor(new Cursor(Cursor.WAIT_CURSOR));
867         Kadmin = new Kadmin();
868         boolean b;
869         try {
870             b = Kadmin.sessionInit(CurName, CurPass, CurRealm, CurServer,
871 				   CurPort);
872         } catch (Exception e) {
873             b = false;
874             realLoginFrame.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
875             showLoginError(e.getMessage());
876             return;
877         }
878         realLoginFrame.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
879         if (b == false) {
880             showLoginError(getString("Invalid login, please try again"));
881             return;
882         }
883         pdateSessionUp = new Date();
884 
885         // Instantiate defaults for this user
886         if (defaults == null)
887             defaults = new Defaults(System.getProperty("user.home" /* NOI18N */)
888 				    + "/.gkadmin" /* NOI18N */,
889 			    (java.awt.Color)gui.mainframe.get("background"));
890         else
891             defaults.refreshDefaults();
892 
893         // Figure out what privileges we have
894         try {
895             privs = Kadmin.getPrivs();
896         } catch (Exception e) {
897             showLoginError(e.getMessage());
898         }
899 
900         // Check privileges; if bad enough, we'll just give up.
901         if (checkPrivs() == false) {
902             try {
903                 Kadmin.sessionExit();
904             } catch (Exception e) {}
905             return;
906         }
907         reactToPrivs();
908 
909         prSetEditable(false);
910         prSetCanSave(false);
911         poSetEditable(false);
912         poSetCanSave(false);
913         prSelValid(false);
914         poSelValid(false);
915         gui.PrListPattern.set("text" /* NOI18N */, "");
916         gui.PoListPattern.set("text" /* NOI18N */, "");
917 
918         // Disable login frame
919         setListeners(LoginNormal, false);
920         loginListeners = false;
921 
922         pdatePreMainShow = new Date();
923         realLoginFrame.setCursor(new Cursor(Cursor.WAIT_CURSOR));
924         gui.mainframe.show(true);	/* XXX - done waaay too early, fix */
925         realLoginFrame.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
926         pdatePostMainShow = new Date();
927         realMainFrame  = (Frame)gui.mainframe.getBody();
928         realMainFrame.setCursor(new Cursor(Cursor.WAIT_CURSOR));
929         gui.tabbedfolder1.show(getString("Principals"));
930         gui.cardpanel2.show("List" /* NOI18N */);
931         setupMainNormalListeners();
932         setupDefaultsEditingFrame();
933         realMainFrame.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
934         pdateMainActive = new Date();
935         reportStartTimes();
936 
937         showPolicyList("");
938         showPrincipalList("");
939         setPolicyChoice();
940         /* XXX - disabled multiple selection until double-click works */
941         gui.Prlist.set("allowMultipleSelections" /* NOI18N */,
942 		       new Boolean(false));
943         gui.Pollist.set("allowMultipleSelections" /* NOI18N */,
944 			new Boolean(false));
945         if ((privs & PRIV_LIST) == 0) {
946             showWarning(
947 	getString("Unable to access lists;please use the Name field."));
948             ((TextField)gui.PrListPattern.getBody()).requestFocus();
949         }
950     }
951 
952     /**
953      * React to main screen's "Log Out" choice by going back to login screen.
954      *
955      */
956     public void logout() {
957         realMainFrame.setCursor(new Cursor(Cursor.WAIT_CURSOR));
958         setListeners(MainNormal, false);
959         setListeners(defaultsNormal, false);
960         try {
961             Kadmin.sessionExit();
962             Kadmin = null;
963         } catch (Exception e) {
964             realMainFrame.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
965             showError(e.getMessage());
966             return;
967         }
968         setLoginDefaults();
969         principalList = null;
970         gui.Prlist.set("items" /* NOI18N */, null);
971         policyList = null;
972         gui.Pollist.set("items" /* NOI18N */, null);
973         gui.mainframe.show(false);
974         curPrListPos = 0;
975         curPrPattern = "";
976         curPoListPos = 0;
977         curPoPattern = "";
978 
979         // Forget this user's print preferences
980         PrintUtil.reinitialize();
981 
982         realMainFrame.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
983     }
984 
985     public void exit() {
986         try {
987             if (Kadmin != null)
988                 Kadmin.sessionExit();
989         } catch (Exception e) {}
990         super.exit();
991     }
992 
993     /*
994      * Methods for the principal list panel
995      */
996 
997     /**
998      * Update all principal text fields from gui.
999      * Check to see if anyone of them had a parse error.
1000      * @param nullPasswdOK true if the password can be null. This is
1001      * allowed only when the operation is a modify on an existing
1002      * principal or if it is an attempt to print a new principal still
1003      * in creation.
1004      * @returns true if all is ok,  false if an error occurs
1005      */
1006     // Quits as soon as the first error is detected. The method that
1007     // detects the error also shows a dialog box with a message.
1008     public boolean prUpdateFromGui(boolean nullPasswdOK) {
1009         return (setPrName1() && setPrPassword(nullPasswdOK) && setPrExpiry() &&
1010 		setPrComments() && setPrPwExpiry() && setPrKvno() &&
1011 		setPrMaxlife() && setPrMaxrenew() && setEncType());
1012     }
1013 
1014     /**
1015      * Is the principal name field editable?
1016      *
1017      */
1018     public void prSetEditable(boolean editable) {
1019         prnameEditable = editable;
1020         Boolean b = new Boolean(editable);
1021         gui.PrName1.set("editable" /* NOI18N */, b);
1022     }
1023 
1024     /**
1025      * React to a change in the principal search pattern
1026      *
1027      */
1028     public void prPatternComplete() {
1029         curPrListPos = 0;
1030         String pattern = (String)gui.PrListPattern.get("text" /* NOI18N */);
1031         if (!noLists)
1032             showPrincipalList(pattern);
1033         else
1034             setCurPrincipal(pattern);
1035     }
1036 
1037     /**
1038      * Clear principal search pattern
1039      *
1040      */
1041     public void prPatternClear() {
1042         if (noLists) {
1043             gui.PrListPattern.set("text" /* NOI18N */, "");
1044             ((TextField)gui.PrListPattern.getBody()).requestFocus();
1045         } else {
1046             String tempName = CurPrincipal;
1047             fillPrincipalList("");
1048             selectPrincipal(tempName);
1049         }
1050     }
1051 
1052     /**
1053      * Show the principal list after applying the filter passed in.
1054      */
1055     public void showPrincipalList(String pattern) {
1056         prin = null; // we are not editing a principal
1057         fillPrincipalList(pattern);
1058         ModeString = "";
1059         OpString = "";
1060         updateStatus();
1061         gui.cardpanel1.show("List" /* NOI18N */);
1062         if (noLists)
1063             ((TextField)gui.PrListPattern.getBody()).requestFocus();
1064     }
1065 
1066     /**
1067      * Generate the principal list for the first time or after a pattern
1068      * has been chosen.
1069      *
1070      */
1071     public void fillPrincipalList(String pattern) {
1072         if (noLists) {
1073             setCurPrincipal((String)gui.PrListPattern.get("text" /* NOI18N */));
1074             ((TextField)gui.PrListPattern.getBody()).requestFocus();
1075             disablePrincipalPrinting();
1076             return;
1077         }
1078         realMainFrame.setCursor(new Cursor(Cursor.WAIT_CURSOR));
1079         pdateStartPlist = new Date();
1080         // Do we still want to cache the principal list?
1081         long cachetime = A_LONG_TIME;
1082         if (!defaults.getStaticLists())
1083             cachetime = defaults.getCacheTime() * 1000;
1084         if (principalList != null
1085 	    && ((new Date()).getTime() - principalListDate.getTime())
1086 	    <= cachetime) {
1087 
1088             // Has the pattern changed?
1089             if (pattern.compareTo(curPrPattern) != 0)
1090                 newPrPattern(pattern);
1091             realMainFrame.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
1092             selectPrincipal(curPrListPos);
1093             return;
1094 
1095         }
1096         PrincipalList p = new PrincipalList(Kadmin);
1097         gui.StatusLine.set("text" /* NOI18N */,
1098 			   getString("Loading principal list"));
1099         try {
1100             principalList = p.getPrincipalList(CurRealm);
1101             principalListDate = new Date();
1102         } catch (Exception e) {
1103             realMainFrame.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
1104             showError(e.getMessage());
1105             updateStatus();
1106             return;
1107         }
1108         updateStatus();
1109         pdateHavePlist = new Date();
1110         reportTime("Fetched Plist  : ", pdateHavePlist, pdateStartPlist);
1111         newPrPattern(pattern);
1112         selectPrincipal(curPrListPos);
1113         realMainFrame.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
1114         pdateDonePlist = new Date();
1115         reportTime("Completed Plist: ", pdateDonePlist, pdateHavePlist);
1116         if (perfmon)
1117             System.out.println("Principal list has "
1118 	       +(new Integer(principalList.length)).toString()+" items");
1119     }
1120 
1121     private void newPrPattern(String pattern) {
1122         curPrPattern = pattern;
1123         gui.PrListPattern.set("text" /* NOI18N */, pattern);
1124         refreshPrincipalList();
1125     }
1126 
1127     private void refreshPrincipalList() {
1128         if (noLists)
1129             return;
1130         Filter f = new Filter(principalList, curPrPattern);
1131         gui.Prlist.set("items" /* NOI18N */, f.out);
1132     }
1133 
1134     private void selectPrincipal(int pos) {
1135         TextList list = (TextList)gui.Prlist.getBody();
1136         if (list.countItems() == 0) {
1137             setCurPrincipal("");
1138             return;
1139         }
1140 
1141         if (pos < 0)
1142             pos = 0;
1143         else if (pos >= list.countItems())
1144             pos = list.countItems() - 1;
1145 
1146         list.select(pos);
1147         enablePrincipalPrinting();
1148         list.makeVisible(pos);
1149         setCurPrincipal(list.getItem(pos));
1150     }
1151 
1152     private void selectPrincipal(String name) {
1153         String[] list = getItemsFromTextList(((TextList)gui.Prlist.getBody()));
1154         selectPrincipal(search(list, name));
1155     }
1156 
1157     private String[] getItemsFromTextList(TextList list) {
1158         StringVector v = list.items();
1159         String [] ret = new String[v.size()];
1160         v.copyInto(ret);
1161         return ret;
1162     }
1163 
1164     /**
1165      * Find index where "name" might go in a sorted string array;
1166      * returns either the element which matches "name" exactly
1167      * or the element just lexographically greater than "name".
1168      */
1169     private int search(String[] array, String name) {
1170         int lo = 0;
1171         int hi = array.length;
1172         int mid = hi;
1173         while (lo < hi) {
1174             mid = (lo + hi) / 2;
1175             int cmp = name.concat("@").compareTo(array[mid].concat("@"));
1176             if (hi - lo == 1) {
1177                 if (cmp > 0)
1178                     mid = hi;
1179                 break;
1180             }
1181             if (cmp == 0)
1182                 break;
1183             if (cmp < 0)
1184                 hi = mid;
1185             else if (cmp > 0)
1186                 lo = mid;
1187         }
1188         return mid;
1189     }
1190 
1191     private String[] addToList(String[] list, String name) {
1192         if (list == null)
1193             return null;
1194         int index = search(list, name);
1195         int rem = list.length - index;
1196         String[] newlist = new String[list.length+1];
1197         if (index > 0)
1198             System.arraycopy(list, 0, newlist, 0, index);
1199         newlist[index] = name;
1200         if (rem > 0)
1201             System.arraycopy(list, index, newlist, index+1, rem);
1202         return newlist;
1203     }
1204 
1205     private String[] delFromList(String[] list, String name) {
1206         if (list == null)
1207             return null;
1208         int index = search(list, name);
1209         int rem = list.length - index;
1210         String[] newlist = new String[list.length-1];
1211         if (index > 0)
1212             System.arraycopy(list, 0, newlist, 0, index);
1213         if (rem > 1)
1214             System.arraycopy(list, index+1, newlist, index, rem-1);
1215         return newlist;
1216     }
1217 
1218     /**
1219      * Collect the policy choice entries
1220      *
1221      */
1222     public void setPolicyChoice() {
1223         String[] pols = null;
1224         if (!noLists) {
1225             PolicyList p = new PolicyList(Kadmin);
1226             try {
1227                 pols = p.getPolicyList();
1228             } catch (Exception e) {
1229                 showError(e.getMessage());
1230                 return;
1231             }
1232         }
1233         Choice c = (Choice)gui.PrPolicy.getBody();
1234         c.removeAll();
1235         c.add(getString("(no policy)"));
1236         for (int i = 0; pols != null && i < pols.length; i++)
1237             c.add(pols[i]);
1238     }
1239 
1240     /**
1241      * Look at the principal list to see what's selected
1242      *
1243      */
1244     public void lookAtPrList() {
1245         if (noLists)
1246             return;
1247         TextList list = (TextList) gui.Prlist.getBody();
1248         prMulti = null;
1249         String[] sel = list.getSelectedItems();
1250         if (sel.length == 1) {
1251             setCurPrincipal(sel[0]);
1252             curPrListPos = list.getSelectedIndex();
1253         } else {
1254             if (sel.length > 0)
1255                 prMulti = sel;
1256             setCurPrincipal("");
1257         }
1258     }
1259 
1260     private void restorePrListSelection() {
1261         if (noLists)
1262             return;
1263         TextList list = (TextList) gui.Prlist.getBody();
1264         list.select(curPrListPos);
1265     }
1266 
1267     /**
1268      * When the principal name choice changes, we want to reflect
1269      * the name in the other principal tabs.  We can also use this
1270      * opportunity to enable/disable buttons.
1271      *
1272      */
1273     public void setCurPrincipal(String name) {
1274         CurPrincipal = name;
1275         gui.PrName1.set("text" /* NOI18N */, name);
1276         gui.PrName2.set("text" /* NOI18N */, name);
1277         gui.PrName3.set("text" /* NOI18N */, name);
1278         if (name.compareTo("") == 0) {
1279             prSelValid(false);
1280             return;
1281         }
1282         prSelValid(true);
1283     }
1284 
1285     /**
1286      * Make Modify, Delete and Duplicate buttons react to what is selected.
1287      * Privileges:
1288      * If we have neither modify or inquire, we keep Modify disabled;
1289      * if we have no modify privileges, we permit Modify to see info,
1290      * but the principal panel components are disabled in reactToPrivs().
1291      * If we have add and inquire privileges, we can permit Duplicate;
1292      * no add also means Create New is permanently disabled in reactToPrivs().
1293      * If we have no delete privileges, we keep Delete disabled.
1294      */
1295     public void prSelValid(boolean selected) {
1296         prSelValid = selected;
1297         Boolean b = new Boolean(selected && (privs & PRIV_INQUIRE) != 0);
1298         gui.PrListModify.set("enabled" /* NOI18N */, b);
1299         int want = (PRIV_ADD | PRIV_INQUIRE);
1300         b = new Boolean(selected && (privs & want) == want);
1301         gui.PrListDuplicate.set("enabled" /* NOI18N */, b);
1302         b = new Boolean((selected || prMulti != null)
1303 			&&(privs & PRIV_DELETE) != 0);
1304         gui.PrListDelete.set("enabled" /* NOI18N */, b);
1305     }
1306 
1307     /**
1308      * Make the Save button do the right thing.
1309      *
1310      */
1311     public void prSetCanSave(boolean ok) {
1312         Boolean b = new Boolean(ok);
1313         gui.PrBasicSave.set("enabled" /* NOI18N */, b);
1314         gui.PrDetailSave.set("enabled" /* NOI18N */, b);
1315         gui.PrFlagsSave.set("enabled" /* NOI18N */, b);
1316     }
1317 
1318     /**
1319      * Update status line with current information.
1320      *
1321      */
1322     public void updateStatus() {
1323         gui.StatusLine.set("text" /* NOI18N */, ModeString+OpString+SaveString);
1324     }
1325 
1326     /**
1327      * This is a way for the data modification actions to note that
1328      * the principal has edits outstanding.
1329      *
1330      */
1331     public void prSetNeedSave() {
1332         prNeedSave = true;
1333         prSetCanSave(true);
1334         SaveString = getString("- *CHANGES*");
1335         updateStatus();
1336     }
1337 
1338     public boolean prDoSave() {
1339 
1340         // before attempting to save make sure all text fields are in order
1341         if (prUpdateFromGui(!prin.isNew) == false)
1342             return false;
1343 
1344         boolean b = true;
1345         realMainFrame.setCursor(new Cursor(Cursor.WAIT_CURSOR));
1346         try {
1347             b = prin.savePrincipal();
1348         } catch (Exception e) {
1349             b = false;
1350             showError(e.getMessage());
1351         }
1352         realMainFrame.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
1353         if (!b)
1354             return false;
1355         if (prin.isNew) {
1356             principalList = addToList(principalList, prin.PrName);
1357             refreshPrincipalList();
1358             selectPrincipal(prin.PrName);
1359         }
1360         prin.isNew = false;
1361         gui.PrPassword.set("text" /* NOI18N */, "");
1362         prin.setPassword("");
1363         prSetEditable(false);
1364         prSetCanSave(false);
1365         prNeedSave = false;
1366         SaveString = "";
1367         updateStatus();
1368         return true;
1369     }
1370 
1371     /**
1372      * React to a choice from the principal list via double-click or
1373      * single-click+Modify; we want to go to the next tab in each case.
1374      * If we don't have modify privileges, we need to simply show values.
1375      */
1376     public void prModify() {
1377         enablePrincipalPrinting();
1378         if (!prNeedSave) {
1379             prSetEditable(false);
1380             prSetCanSave(false);
1381         }
1382         if (noLists)
1383             CurPrincipal = (String)gui.PrListPattern.get("text" /* NOI18N */);
1384         realMainFrame.setCursor(new Cursor(Cursor.WAIT_CURSOR));
1385         enablePrAttributes(new Boolean((privs & (PRIV_ADD|PRIV_MODIFY)) != 0));
1386         Boolean b = new Boolean((privs & PRIV_CHANGEPW) != 0);
1387         gui.PrPassword.set("enabled" /* NOI18N */, b);
1388         gui.PrBasicRandomPw.set("enabled" /* NOI18N */, b);
1389         gui.EncList.set("enabled" /* NOI18N */, b);
1390         try {
1391             prin = new Principal(Kadmin, CurPrincipal);
1392         } catch (Exception e) {
1393             showError(e.getMessage());
1394             realMainFrame.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
1395             return;
1396         }
1397         realMainFrame.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
1398         showPrincipal(prin);
1399         String policy = (String)gui.PrPolicy.get("selectedItem" /* NOI18N */);
1400         if (policy.compareTo(getString("(no policy)")) == 0)
1401             policy = "";
1402         else
1403             setDefaultPolicy(policy);
1404         ModeString = getString("Modify")+" ";
1405         OpString = getString("Principal");
1406         updateStatus();
1407         gui.cardpanel1.show("Basics" /* NOI18N */);
1408     }
1409 
1410     /**
1411      * React to add principal button
1412      * If we got here, we need to enable attributes since we have privs.
1413      */
1414     public void prAdd() {
1415         enablePrincipalPrinting();
1416         setCurPrincipal("");
1417         prSelValid = true;
1418         prSetEditable(true);
1419         prSetNeedSave();
1420         realMainFrame.setCursor(new Cursor(Cursor.WAIT_CURSOR));
1421         Boolean b = new Boolean(true);
1422         enablePrAttributes(b);
1423         gui.PrPassword.set("enabled" /* NOI18N */, b);
1424         gui.PrBasicRandomPw.set("enabled" /* NOI18N */, b);
1425         gui.EncList.set("enabled" /* NOI18N */, b);
1426         try {
1427             prin = new Principal(Kadmin, defaults);
1428         } catch (Exception e) {
1429             showError(e.getMessage());
1430             realMainFrame.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
1431             return;
1432         }
1433         realMainFrame.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
1434         showPrincipal(prin);
1435         ModeString = getString("Create New")+" ";
1436         OpString = getString("Principal");
1437         updateStatus();
1438         gui.cardpanel1.show("Basics" /* NOI18N */);
1439         ((TextField)gui.PrName1.getBody()).requestFocus();
1440     }
1441 
1442     /**
1443      * React to duplicate principal button
1444      *
1445      */
1446     public void prDuplicate() {
1447         enablePrincipalPrinting();
1448         if (noLists)
1449             CurPrincipal = (String)gui.PrListPattern.get("text" /* NOI18N */);
1450         realMainFrame.setCursor(new Cursor(Cursor.WAIT_CURSOR));
1451         try {
1452             prin = new Principal(Kadmin, CurPrincipal);
1453         } catch (Exception e) {
1454             showError(e.getMessage());
1455             realMainFrame.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
1456             return;
1457         }
1458         realMainFrame.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
1459         setCurPrincipal("");
1460         prSelValid = true;
1461         prSetEditable(true);
1462         prSetNeedSave();
1463         realMainFrame.setCursor(new Cursor(Cursor.WAIT_CURSOR));
1464         Boolean b = new Boolean(true);
1465         enablePrAttributes(b);
1466         gui.PrPassword.set("enabled" /* NOI18N */, b);
1467         gui.PrBasicRandomPw.set("enabled" /* NOI18N */, b);
1468         gui.PrBasicRandomPw.set("enabled" /* NOI18N */, b);
1469         try {
1470             prin = new Principal(Kadmin, prin);
1471         } catch (Exception e) {
1472             showError(e.getMessage());
1473             realMainFrame.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
1474             return;
1475         }
1476         realMainFrame.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
1477         prin.PrName = "";
1478         showPrincipal(prin);
1479         ModeString = getString("Duplicate")+" ";
1480         OpString = getString("Principal");
1481         updateStatus();
1482         gui.cardpanel1.show("Basics" /* NOI18N */);
1483         ((TextField)gui.PrName1.getBody()).requestFocus();
1484     }
1485 
1486     /**
1487      * React to delete principal button
1488      */
1489     public void prDelete() {
1490         String text[] = {getString("You are about to destroy data."),
1491 			 getString("Click OK to proceed or"
1492 				   +" Cancel to continue editing.")};
1493         String resp = confirmAction(realMainFrame, text);
1494         if (resp.equals(getString("Cancel")))
1495             return;
1496         if (noLists)
1497             CurPrincipal = (String)gui.PrListPattern.get("text" /* NOI18N */);
1498         boolean b = false;
1499         try {
1500             b = Kadmin.deletePrincipal(CurPrincipal);
1501         } catch (Exception e) {
1502             showError(e.getMessage());
1503             return;
1504         }
1505         if (!b)
1506             return;
1507         principalList = delFromList(principalList, CurPrincipal);
1508         refreshPrincipalList();
1509         setCurPrincipal("");
1510         prSelValid = true;
1511         prSetEditable(true);
1512         if (curPrListPos == ((TextList)gui.Prlist.getBody()).countItems())
1513             curPrListPos--;
1514         showPrincipalList(curPrPattern);
1515     }
1516 
1517     /**
1518      * React to Previous button on basic screen
1519      *
1520      */
1521     public void prBasicPrevious() {
1522         prCancel();
1523     }
1524 
1525     /**
1526      * React to Next button on basic screen. If some changes were made
1527      * then check to see if they contain a parse error. If so, do
1528      * nothing. The method that checks for error messages also displays
1529      * the error message.
1530      *
1531      */
1532     public void prBasicNext() {
1533         if (prNeedSave)
1534             if (!prUpdateFromGui(!prin.isNew))
1535 		return;
1536 
1537         updateStatus();
1538         gui.cardpanel1.show("Details" /* NOI18N */);
1539     }
1540 
1541     /**
1542      * React to Previous button on detail screen. If some changes were made
1543      * then check to see if they contain a parse error. If so, do
1544      * nothing. The method that checks for error messages also displays
1545      * the error message.
1546      */
1547     public void prDetailPrevious() {
1548         if (prNeedSave)
1549             if (!prUpdateFromGui(!prin.isNew))
1550 		return;
1551 
1552         updateStatus();
1553         gui.cardpanel1.show("Basics" /* NOI18N */);
1554     }
1555 
1556     /**
1557      * React to Next button on detail screen. If some changes were made
1558      * then check to see if they contain a parse error. If so, do
1559      * nothing. The method that checks for error messages also displays
1560      * the error message.
1561      *
1562      */
1563     public void prDetailNext() {
1564         if (prNeedSave)
1565             if (!prUpdateFromGui(!prin.isNew))
1566 		return;
1567 
1568         updateStatus();
1569         gui.cardpanel1.show("Flags" /* NOI18N */);
1570     }
1571 
1572     /**
1573      * React to Previous button on flags screen
1574      *
1575      */
1576     public void prFlagsPrevious() {
1577         updateStatus();
1578         gui.cardpanel1.show("Details" /* NOI18N */);
1579     }
1580 
1581     /**
1582      * React to Done button on flags screen. If any changes were made to
1583      * the principal, then try to save them. If the save fails for any
1584      * reason, do not return to the principal list.
1585      *
1586      */
1587     public void prFlagsDone() {
1588         if (prNeedSave && prDoSave() == false)
1589             return;
1590         showPrincipalList(curPrPattern);
1591     }
1592 
1593     /**
1594      * React to save principal button
1595      *
1596      */
1597     public void prSave() {
1598         prDoSave();
1599     }
1600 
1601     /**
1602      * React to cancel principal button
1603      *
1604      */
1605     public void prCancel() {
1606         if (prNeedSave) {
1607             String text[] = {getString("You are about to lose changes."),
1608 			     getString("Click Save to commit changes, "
1609 				       +"Discard to discard changes, "
1610 				       +"or Cancel to continue editing.")};
1611             String resp = confirmSave(realMainFrame, text);
1612             if (resp.equals(getString("Cancel")))
1613                 return;
1614             if (resp.equals(getString("Save")))
1615                 if (!prDoSave())
1616 		    return;
1617         }
1618         prSetEditable(false);
1619         prSetCanSave(false);
1620         prNeedSave = false;
1621         lookAtPrList();
1622         SaveString = "";
1623         showPrincipalList(curPrPattern);
1624     }
1625 
1626     /*
1627      * Methods for the principal attribute panels
1628      */
1629 
1630     public boolean setPrName1() {
1631         if (!prnameEditable)
1632             return true;
1633 
1634         String p = ((String)gui.PrName1.get("text" /* NOI18N */)).trim();
1635         if (p.compareTo("") == 0) {
1636             showError(getString("Please enter a principal name or cancel"));
1637             ((TextField)gui.PrName1.getBody()).requestFocus();
1638             return false;
1639         }
1640         // visually delete any white space that was at the start or end
1641         // by resetting the field to the trimmmed String.
1642         gui.PrName1.set("text" /* NOI18N */, p);
1643         setCurPrincipal(p);
1644         prin.setName(p);
1645         return true;
1646     }
1647 
1648     public boolean setPrComments() {
1649         prin.setComments((String)gui.PrComments.get("text" /* NOI18N */));
1650         return true;
1651     }
1652 
1653     public boolean setEncType() {
1654         if (prin.setEncType((String)gui.EncList.get("text" /* NOI18N */))) {
1655             // visually delete any extraneous data that was ignored in the
1656             // parsing by resetting the gui data
1657             gui.EncList.set("text" /* NOI18N */,  prin.getEncType());
1658             return true;
1659         } else
1660             return false;
1661     }
1662 
1663     public boolean setPrExpiry() {
1664         if (prin.setExpiry((String)gui.PrExpiry.get("text" /* NOI18N */))) {
1665             // visually delete any extraneous data that was ignored in the
1666             // parsing by resetting the gui data
1667             gui.PrExpiry.set("text" /* NOI18N */,  prin.getExpiry());
1668             return true;
1669         } else {
1670             showDataFormatError(((TextField)gui.PrExpiry.getBody()),
1671 				DATE_DATA);
1672             return false;
1673         }
1674     }
1675 
1676     public boolean setPrPassword(boolean nullOK) {
1677         String p = (String)gui.PrPassword.get("text" /* NOI18N */);
1678         if (p.compareTo("") == 0) {
1679             if (!nullOK) {
1680                 showError(getString("Please enter a password or cancel"));
1681                 ((TextField)gui.PrPassword.getBody()).requestFocus();
1682                 return false;
1683             } else return true;
1684 	}
1685 
1686         prin.setPassword(p);
1687         return true;
1688     }
1689 
1690     public void genRandomPassword() {
1691         int n, count = 0;
1692         byte[] buf = new byte[20];
1693         byte b;
1694         Random r = new Random();
1695         String passlist = "abcdefghijklmnopqrstuvwxyz1234567890!#$%&*+@"
1696 	    /* NOI18N */;
1697 
1698         gui.PrPassword.set("text" /* NOI18N */, "");
1699         while (count < 10) {
1700             n = r.nextInt() & 0x7F;
1701             b = (byte)n;
1702             if (passlist.indexOf(b) == -1)
1703                 continue;
1704             buf[count++] = b;
1705         }
1706         buf[count] = 0;
1707         CurPass = new String(buf);
1708         gui.PrPassword.set("text" /* NOI18N */, CurPass);
1709         prin.setPassword((String)gui.PrPassword.get("text" /* NOI18N */));
1710     }
1711 
1712     public void setPrPolicy() {
1713         if (prin == null)
1714                 return;
1715         String policy = (String)gui.PrPolicy.get("selectedItem" /* NOI18N */);
1716         if (policy.compareTo(getString("(no policy)")) == 0)
1717             policy = "";
1718         try {
1719                 prin.setPolicy(policy);
1720         } catch (Exception e) {};
1721         setDefaultPolicy(policy);
1722     }
1723 
1724     public boolean setPrMaxlife() {
1725         if (prin.setMaxlife((String)gui.PrMaxLifetime.get("text"
1726 							  /* NOI18N */))) {
1727             // visually delete any extraneous data that was ignored in the
1728             // parsing by resetting the gui data
1729             gui.PrMaxLifetime.set("text" /* NOI18N */, prin.getMaxLife());
1730             return true;
1731         } else {
1732             showDataFormatError(((TextField)gui.PrMaxLifetime.getBody()),
1733 				DURATION_DATA);
1734             return false;
1735         }
1736     }
1737 
1738     public boolean setPrMaxrenew() {
1739         if (prin.setMaxrenew((String)gui.PrMaxRenewal.get(
1740 						  "text" /* NOI18N */))) {
1741             // visually delete any extraneous data that was ignored in the
1742             // parsing  by resetting the gui data
1743             gui.PrMaxRenewal.set("text" /* NOI18N */, prin.getMaxRenew());
1744             return true;
1745         } else {
1746             showDataFormatError(((TextField)gui.PrMaxRenewal.getBody()),
1747 				DURATION_DATA);
1748             return false;
1749         }
1750     }
1751 
1752     public boolean setPrKvno() {
1753         if (prin.setKvno((String)gui.PrKvno.get("text" /* NOI18N */))) {
1754             // visually delete any extraneous data that was ignored in the
1755             // parsing by resetting the gui data
1756             gui.PrKvno.set("text" /* NOI18N */, nf.format(prin.Kvno));
1757             return true;
1758         } else {
1759             showDataFormatError(((TextField)gui.PrKvno.getBody()), NUMBER_DATA);
1760             return false;
1761         }
1762     }
1763 
1764     public boolean setPrPwExpiry() {
1765         if (prin.setPwExpiry((String)gui.PrPwExpiry.get("text" /* NOI18N */))) {
1766             // visually delete any extraneous data that was ignored in the
1767             // parsing by resetting the gui data
1768             gui.PrPwExpiry.set("text" /* NOI18N */, prin.getPwExpireTime());
1769             return true;
1770         } else {
1771             showDataFormatError(((TextField)gui.PrPwExpiry.getBody()),
1772 				DATE_DATA);
1773             return false;
1774         }
1775     }
1776 
1777     public void setPrFlag(int bitmask) {
1778         prin.flags.toggleFlags(bitmask);
1779     }
1780 
1781     /**
1782      * Update components to reflect data in this principal
1783      *
1784      */
1785     public void showPrincipal(Principal p) {
1786 
1787         gui.PrName1.set("text" /* NOI18N */, p.PrName);
1788         gui.PrName2.set("text" /* NOI18N */, p.PrName);
1789         gui.PrName3.set("text" /* NOI18N */, p.PrName);
1790         gui.PrComments.set("text" /* NOI18N */, p.Comments);
1791         String policy = p.Policy;
1792         if (policy.compareTo("") == 0)
1793             policy = getString("(no policy)");
1794         gui.PrPolicy.set("selectedItem" /* NOI18N */, policy);
1795         gui.PrPassword.set("text" /* NOI18N */, "");
1796 
1797         gui.PrLastChangedTime.set("text" /* NOI18N */, p.getModTime());
1798         gui.PrLastChangedBy.set("text" /* NOI18N */,   p.ModName);
1799         gui.PrExpiry.set("text" /* NOI18N */,          p.getExpiry());
1800         gui.EncList.set("text" /* NOI18N */,           p.getEncType());
1801         gui.PrLastSuccess.set("text" /* NOI18N */,     p.getLastSuccess());
1802         gui.PrLastFailure.set("text" /* NOI18N */,     p.getLastFailure());
1803         gui.PrFailCount.set("text" /* NOI18N */, nf.format(p.NumFailures));
1804         gui.PrLastPwChange.set("text" /* NOI18N */,    p.getLastPwChange());
1805         gui.PrPwExpiry.set("text" /* NOI18N */,        p.getPwExpireTime());
1806         gui.PrKvno.set("text" /* NOI18N */, nf.format(p.Kvno));
1807         gui.PrMaxLifetime.set("text" /* NOI18N */, p.getMaxLife());
1808         gui.PrMaxRenewal.set("text" /* NOI18N */, p.getMaxRenew());
1809 
1810         gui.PrLockAcct.set("state" /* NOI18N */,
1811 		   new Boolean(p.flags.getFlag(Flags.DISALLOW_ALL_TIX)));
1812         gui.PrForcePwChange.set("state" /* NOI18N */,
1813 			new Boolean(p.flags.getFlag(Flags.REQUIRES_PWCHANGE)));
1814         gui.PrAllowPostdated.set("state" /* NOI18N */,
1815 		 new Boolean(!p.flags.getFlag(Flags.DISALLOW_POSTDATED)));
1816         gui.PrAllowForwardable.set("state" /* NOI18N */,
1817 		   new Boolean(!p.flags.getFlag(Flags.DISALLOW_FORWARDABLE)));
1818         gui.PrAllowRenewable.set("state" /* NOI18N */,
1819 		 new Boolean(!p.flags.getFlag(Flags.DISALLOW_RENEWABLE)));
1820         gui.PrAllowProxiable.set("state" /* NOI18N */,
1821 		 new Boolean(!p.flags.getFlag(Flags.DISALLOW_PROXIABLE)));
1822         gui.PrAllowSvr.set("state" /* NOI18N */,
1823 			   new Boolean(!p.flags.getFlag(Flags.DISALLOW_SVR)));
1824         gui.PrAllowTGT.set("state" /* NOI18N */,
1825 		   new Boolean(!p.flags.getFlag(Flags.DISALLOW_TGT_BASED)));
1826         gui.PrAllowDupAuth.set("state" /* NOI18N */,
1827 		       new Boolean(!p.flags.getFlag(Flags.DISALLOW_DUP_SKEY)));
1828         gui.PrRequirePreAuth.set("state" /* NOI18N */,
1829 			 new Boolean(p.flags.getFlag(Flags.REQUIRE_PRE_AUTH)));
1830         gui.PrRequireHwPreAuth.set("state" /* NOI18N */,
1831 			   new Boolean(p.flags.getFlag(Flags.REQUIRE_HW_AUTH)));
1832     }
1833 
1834     /**
1835      * Format a time duration for printing, using I18N formats
1836      *
1837      */
1838     public String showDuration(Integer seconds) {
1839         return nf.format(seconds.longValue());
1840     }
1841 
1842     /*
1843      * Methods for the policy list panel
1844      */
1845 
1846     /**
1847      * Update all policy text fields from gui.
1848      * Check to see if anyone of them had a parse error.
1849      * @returns true if all is ok,  false if an error occurs
1850      */
1851     // Quits as soon as the first error is detected. The method that
1852     // detects the error also shows a dialog box with a message.
1853     public boolean poUpdateFromGui() {
1854         return (setPolName() && setPolMinlife() && setPolMaxlife());
1855     }
1856 
1857     /**
1858      * If we have edited a principal, select their policy by default
1859      *
1860      */
1861     public void setDefaultPolicy(String name) {
1862         setCurPolicy(name);
1863         fillPolicyList("");
1864         TextList l = (TextList)gui.Pollist.getBody();
1865         int itemcount = l.countItems();
1866         for (int i = 0; i < itemcount; i++)
1867             if (l.getItem(i).compareTo(name) == 0) {
1868 		curPoListPos = i;
1869 		break;
1870 	    }
1871     }
1872 
1873     /**
1874      * Is the policy name field editable?
1875      *
1876      */
1877     public void poSetEditable(boolean editable) {
1878         ponameEditable = editable;
1879         Boolean b = new Boolean(editable);
1880         gui.PoName.set("editable" /* NOI18N */, b);
1881     }
1882 
1883     /**
1884      * React to a change in the policy list pattern
1885      *
1886      */
1887     public void poPatternComplete() {
1888         curPoListPos = 0;
1889         String pattern = (String)gui.PoListPattern.get("text" /* NOI18N */);
1890         if (!noLists)
1891             showPolicyList(pattern);
1892         else
1893             setCurPolicy(pattern);
1894     }
1895 
1896     /**
1897      * Clear policy list pattern
1898      *
1899      */
1900     public void poPatternClear() {
1901         if (noLists) {
1902             gui.PoListPattern.set("text" /* NOI18N */, "");
1903             ((TextField)gui.PoListPattern.getBody()).requestFocus();
1904         } else {
1905             String tempName = CurPolicy;
1906             fillPolicyList("");
1907             selectPolicy(tempName);
1908         }
1909     }
1910 
1911     /**
1912      * Show the policy list after applying the filter passed in.
1913      */
1914     public void showPolicyList(String pattern) {
1915         pol = null; // we are not editing a policy
1916         fillPolicyList(pattern);
1917         ModeString = "";
1918         OpString = "";
1919         updateStatus();
1920         gui.cardpanel2.show("List" /* NOI18N */);
1921         if (noLists)
1922             ((TextField)gui.PoListPattern.getBody()).requestFocus();
1923     }
1924 
1925     /**
1926      * Generate the policy list for the first time or after a pattern
1927      * has been chosen.
1928      *
1929      */
1930     public void fillPolicyList(String pattern) {
1931         if (noLists) {
1932             setCurPolicy((String)gui.PoListPattern.get("text" /* NOI18N */));
1933             ((TextField)gui.PoListPattern.getBody()).requestFocus();
1934             disablePolicyPrinting();
1935             return;
1936         }
1937         realMainFrame.setCursor(new Cursor(Cursor.WAIT_CURSOR));
1938         long cachetime = A_LONG_TIME;
1939         if (!defaults.getStaticLists())
1940             cachetime = defaults.getCacheTime() * 1000;
1941         if (policyList != null
1942 	    && ((new Date()).getTime() - policyListDate.getTime())
1943 	    <= cachetime) {
1944             if (pattern.compareTo(curPoPattern) != 0)
1945                 newPoPattern(pattern);
1946             realMainFrame.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
1947             selectPolicy(curPoListPos);
1948             return;
1949         }
1950         PolicyList p = new PolicyList(Kadmin);
1951         gui.StatusLine.set("text" /* NOI18N */,
1952 			   getString("Loading policy list"));
1953         try {
1954             policyList = p.getPolicyList();
1955             policyListDate = new Date();
1956         } catch (Exception e) {
1957             realMainFrame.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
1958             showError(e.getMessage());
1959             updateStatus();
1960             return;
1961         }
1962         updateStatus();
1963         newPoPattern(pattern);
1964         selectPolicy(curPoListPos);
1965         realMainFrame.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
1966     }
1967 
1968     private void newPoPattern(String pattern) {
1969         curPoPattern = pattern;
1970         gui.PoListPattern.set("text" /* NOI18N */, pattern);
1971         refreshPolicyList();
1972     }
1973 
1974     private void refreshPolicyList() {
1975         if (noLists)
1976             return;
1977         Filter f = new Filter(policyList, curPoPattern);
1978         gui.Pollist.set("items" /* NOI18N */, f.out);
1979     }
1980 
1981     private void selectPolicy(int pos) {
1982         TextList list = (TextList)gui.Pollist.getBody();
1983         if (list.countItems() == 0) {
1984             setCurPolicy("");
1985             return;
1986         }
1987 
1988         if (pos < 0)
1989             pos = 0;
1990         else if (pos >= list.countItems())
1991             pos = list.countItems() - 1;
1992 
1993         list.select(pos);
1994         enablePolicyPrinting();
1995         list.makeVisible(pos);
1996         setCurPolicy(list.getItem(pos));
1997     }
1998 
1999     private void selectPolicy(String name) {
2000         String[] list = getItemsFromTextList((TextList)gui.Pollist.getBody());
2001         selectPolicy(search(list, name));
2002     }
2003 
2004     /**
2005      * When the policy name choice changes, we want to reflect
2006      * the name in the policy detail tab.
2007      *
2008      */
2009     public void setCurPolicy(String name) {
2010         CurPolicy = name;
2011         gui.PoName.set("text" /* NOI18N */, CurPolicy);
2012         if (name.compareTo("") == 0) {
2013             poSelValid(false);
2014             return;
2015         }
2016         poSelValid(true);
2017     }
2018 
2019     /**
2020      * Look at the policy list to see what's selected
2021      *
2022      */
2023     public void lookAtPoList() {
2024         if (noLists)
2025             return;
2026         TextList list = (TextList) gui.Pollist.getBody();
2027         poMulti = null;
2028         String[] sel = list.getSelectedItems();
2029         if (sel.length == 1) {
2030             setCurPolicy(sel[0]);
2031             curPoListPos = list.getSelectedIndex();
2032         } else {
2033             if (sel.length > 0)
2034                 poMulti = sel;
2035             setCurPolicy("");
2036         }
2037     }
2038 
2039     private void restorePoListSelection() {
2040         if (noLists)
2041             return;
2042         TextList list = (TextList) gui.Pollist.getBody();
2043         list.select(curPoListPos);
2044     }
2045 
2046     /**
2047      * Make Modify, Delete and Duplicate buttons react to what is selected.
2048      *
2049      */
2050     public void poSelValid(boolean selected) {
2051         poSelValid = selected;
2052         Boolean b = new Boolean(selected && (privs & PRIV_INQUIRE) != 0);
2053         gui.PoListModify.set("enabled" /* NOI18N */, b);
2054         int want = (PRIV_ADD | PRIV_INQUIRE);
2055         b = new Boolean(selected && (privs & want) == want);
2056         gui.PoListDuplicate.set("enabled" /* NOI18N */, b);
2057         b = new Boolean((selected || poMulti != null)
2058 			&&(privs & PRIV_DELETE) != 0);
2059         gui.PoListDelete.set("enabled" /* NOI18N */, b);
2060     }
2061 
2062     /**
2063      * Make the Save button do the right thing.
2064      *
2065      */
2066     public void poSetCanSave(boolean ok) {
2067         Boolean b = new Boolean(ok);
2068         gui.PoDetailSave.set("enabled"  /* NOI18N */, b);
2069     }
2070 
2071     /**
2072      * This is a way for the data modification actions to note that
2073      * the principal has edits outstanding.
2074      *
2075      */
2076     public void poSetNeedSave() {
2077         poNeedSave = true;
2078         poSetCanSave(true);
2079         SaveString = getString("- *CHANGES*");
2080         updateStatus();
2081     }
2082 
2083     public boolean poDoSave() {
2084 
2085         // before attempting to save make sure all text fields are in order
2086         if (poUpdateFromGui() == false)
2087             return false;
2088 
2089         boolean b = true;
2090         realMainFrame.setCursor(new Cursor(Cursor.WAIT_CURSOR));
2091         try {
2092             b = pol.savePolicy();
2093         } catch (Exception e) {
2094             b = false;
2095             showError(e.getMessage());
2096         }
2097         realMainFrame.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
2098         if (!b)
2099             return false;
2100         if (pol.isNew) {
2101             policyList = addToList(policyList, pol.PolicyName);
2102             refreshPolicyList();
2103             selectPolicy(pol.PolicyName);
2104             setPolicyChoice();
2105         }
2106         pol.isNew = false;
2107         poSetEditable(false);
2108         poSetCanSave(false);
2109         poNeedSave = false;
2110         SaveString = "";
2111         updateStatus();
2112         return true;
2113     }
2114 
2115     /**
2116      * React to a choice from the policy list via double-click or
2117      * single-click+Modify; we want to go to the next tab in each case.
2118      * If we don't have modify privileges, we need to simply show values.
2119      */
2120     public void poSelected() {
2121         enablePolicyPrinting();
2122         lookAtPoList();
2123         if (!poNeedSave) {
2124             poSetEditable(false);
2125             poSetCanSave(false);
2126         }
2127         if (noLists)
2128             CurPolicy = (String)gui.PoListPattern.get("text" /* NOI18N */);
2129         realMainFrame.setCursor(new Cursor(Cursor.WAIT_CURSOR));
2130         enablePoAttributes(new Boolean((privs & (PRIV_ADD|PRIV_MODIFY)) != 0));
2131         try {
2132             pol = new Policy(Kadmin, CurPolicy);
2133         } catch (Exception e) {
2134             showError(e.getMessage());
2135             realMainFrame.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
2136             return;
2137         }
2138         realMainFrame.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
2139         showPolicy(pol);
2140         ModeString = getString("Modify")+" ";
2141         OpString = getString("Policy");
2142         updateStatus();
2143         gui.cardpanel2.show("Details" /* NOI18N */);
2144     }
2145 
2146     /**
2147      * React to add policy button
2148      * If we got here, we need to enable attributes since we have privs.
2149      */
2150     public void poAdd() {
2151         enablePolicyPrinting();
2152         setCurPolicy("");
2153         poSelValid = true;
2154         poSetEditable(true);
2155         poSetNeedSave();
2156         enablePoAttributes(new Boolean(true));
2157         realMainFrame.setCursor(new Cursor(Cursor.WAIT_CURSOR));
2158         try {
2159             pol = new Policy(Kadmin);
2160         } catch (Exception e) {
2161             showError(e.getMessage());
2162             realMainFrame.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
2163             return;
2164         }
2165         realMainFrame.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
2166         showPolicy(pol);
2167         ModeString = getString("Create New")+" ";
2168         OpString = getString("Policy");
2169         updateStatus();
2170         gui.cardpanel2.show("Details" /* NOI18N */);
2171         ((TextField)gui.PoName.getBody()).requestFocus();
2172     }
2173 
2174     /**
2175      * React to duplicate policy button
2176      *
2177      */
2178     public void poDuplicate() {
2179         enablePolicyPrinting();
2180         if (noLists)
2181             CurPolicy = (String)gui.PoListPattern.get("text" /* NOI18N */);
2182         realMainFrame.setCursor(new Cursor(Cursor.WAIT_CURSOR));
2183         try {
2184             pol = new Policy(Kadmin, CurPolicy);
2185         } catch (Exception e) {
2186             showError(e.getMessage());
2187             realMainFrame.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
2188             return;
2189         }
2190         realMainFrame.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
2191         setCurPolicy("");
2192         poSelValid = true;
2193         poSetEditable(true);
2194         poSetNeedSave();
2195         try {
2196             pol = new Policy(Kadmin, pol);
2197         } catch (Exception e) {
2198             showError(e.getMessage());
2199             return;
2200         }
2201         pol.PolicyName = "";
2202         showPolicy(pol);
2203         ModeString = getString("Duplicate")+" ";
2204         OpString = getString("Policy");
2205         updateStatus();
2206         gui.cardpanel2.show("Details" /* NOI18N */);
2207         ((TextField)gui.PoName.getBody()).requestFocus();
2208     }
2209 
2210     /**
2211      * React to delete policy button
2212      */
2213     public void poDelete() {
2214         String text[] = {getString("You are about to destroy data."),
2215 			 getString("Click OK to proceed or"
2216 				   +" Cancel to continue editing.")};
2217         String resp = confirmAction(realMainFrame, text);
2218         if (resp.equals(getString("Cancel")))
2219             return;
2220         boolean b;
2221         if (noLists)
2222             CurPolicy = (String)gui.PoListPattern.get("text" /* NOI18N */);
2223         realMainFrame.setCursor(new Cursor(Cursor.WAIT_CURSOR));
2224         try {
2225             b = Kadmin.deletePolicy(CurPolicy);
2226         } catch (Exception e) {
2227             showError(e.getMessage());
2228             realMainFrame.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
2229             return;
2230         }
2231         realMainFrame.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
2232         if (!b)
2233             return;
2234         policyList = delFromList(policyList, CurPolicy);
2235         refreshPolicyList();
2236         setPolicyChoice();
2237         setCurPolicy("");
2238         poSelValid = true;
2239         poSetEditable(true);
2240         if (curPoListPos == ((TextList)gui.Pollist.getBody()).countItems())
2241             curPoListPos--;
2242         showPolicyList(curPoPattern);
2243     }
2244 
2245     /**
2246      * React to save policy button
2247      *
2248      */
2249     public void poSave() {
2250         poDoSave();
2251     }
2252 
2253     /**
2254      * React to cancel policy button
2255      *
2256      */
2257     public void poCancel() {
2258         if (poNeedSave) {
2259             String text[] = {getString("You are about to lose changes."),
2260 			     getString("Click Save to commit changes, "
2261 				       +"Discard to discard changes, "
2262 				       +"or Cancel to continue editing.")};
2263             String resp = confirmSave(realMainFrame, text);
2264             if (resp.equals(getString("Cancel")))
2265                 return;
2266             if (resp.equals(getString("Save")))
2267                 if (!poDoSave())
2268 		    return;
2269         }
2270         poSetEditable(false);
2271         poSetCanSave(false);
2272         poNeedSave = false;
2273         lookAtPoList();
2274         SaveString = "";
2275         showPolicyList(curPoPattern);
2276     }
2277 
2278     /**
2279      * React to previous button on policy detail screen
2280      *
2281      */
2282     public void polPrevious() {
2283         poCancel();
2284     }
2285 
2286     /**
2287      * React to done button on policy detail screen
2288      *
2289      */
2290     public void polDone() {
2291         if (poNeedSave && poDoSave() == false)
2292             return;
2293         showPolicyList(curPoPattern);
2294     }
2295 
2296     /*
2297      * Methods for the policy details panel
2298      */
2299 
2300     public boolean setPolName() {
2301         if (!ponameEditable)
2302             return true;
2303 
2304         String p = (String)gui.PoName.get("text" /* NOI18N */);
2305         if (p.compareTo(getString("(no policy)")) == 0) {
2306             showError(getString("Policy name already exists. Please choose "
2307 				+"a different policy name or cancel"));
2308             gui.PoName.set("text" /* NOI18N */, "");
2309             ((TextField)gui.PoName.getBody()).requestFocus();
2310             return false;
2311         }
2312         if (p.compareTo("") == 0) {
2313             showError(getString("Please enter a policy name or cancel"));
2314             ((TextField)gui.PoName.getBody()).requestFocus();
2315             return false;
2316         }
2317 
2318         setCurPolicy(p);
2319         pol.setName(p);
2320         return true;
2321     }
2322 
2323     public void setPolPwLength() {
2324         if (pol == null)
2325                 return;
2326         try {
2327             pol.setPolPwLength((String)gui.PoMinPwLength.get("selectedItem"
2328 							 /* NOI18N */));
2329         } catch (Exception e) {};
2330     }
2331 
2332     public void setPolPwClasses() {
2333         if (pol == null)
2334                 return;
2335         try {
2336             pol.setPolPwClasses((String)gui.PoMinPwClass.get("selectedItem"
2337 							 /* NOI18N */));
2338         } catch (Exception e) {};
2339     }
2340 
2341     public void setPolPwHistory() {
2342         if (pol == null)
2343                 return;
2344         try {
2345             pol.setPolPwHistory((String)gui.PoSavedPasswords.get("selectedItem"
2346 							     /* NOI18N */));
2347         } catch (Exception e) {};
2348     }
2349 
2350     public boolean setPolMinlife() {
2351         if (pol.setPolMinlife((String)gui.PoMinTicketLifetime.get("text"
2352 							  /* NOI18N */))) {
2353             // visually delete any extraneous data that was ignored in the
2354             // parsing by resetting the gui data
2355             gui.PoMinTicketLifetime.set("text" /* NOI18N */,
2356 					showDuration(pol.PwMinLife));
2357             return true;
2358         } else {
2359             showDataFormatError(((TextField)gui.PoMinTicketLifetime.getBody()),
2360 				DURATION_DATA);
2361             return false;
2362         }
2363     }
2364 
2365     public boolean setPolMaxlife() {
2366         if (pol.setPolMaxlife((String)gui.PoMaxTicketLifetime.get(
2367 						  "text" /* NOI18N */))) {
2368             // visually delete any extraneous data that was ignored in the
2369             // parsing by resetting the gui data
2370             gui.PoMaxTicketLifetime.set("text" /* NOI18N */,
2371 					showDuration(pol.PwMaxLife));
2372             return true;
2373         } else {
2374             showDataFormatError(((TextField)gui.PoMaxTicketLifetime.getBody()),
2375 				DURATION_DATA);
2376             return false;
2377         }
2378     }
2379 
2380     /**
2381      * Update components to reflect data in this policy
2382      *
2383      */
2384     public void showPolicy(Policy p) {
2385         gui.PoName.set("text" /* NOI18N */, p.PolicyName);
2386         gui.PoMinPwLength.set("selectedItem" /* NOI18N */,
2387 			      nf.format(p.PwMinLength));
2388         gui.PoMinPwClass.set("selectedItem" /* NOI18N */,
2389 			     nf.format(p.PwMinClasses));
2390         gui.PoSavedPasswords.set("selectedItem" /* NOI18N */,
2391 				 nf.format(p.PwSaveCount));
2392         gui.PoMinTicketLifetime.set("text" /* NOI18N */,
2393 				    showDuration(p.PwMinLife));
2394         gui.PoMaxTicketLifetime.set("text" /* NOI18N */,
2395 				    showDuration(p.PwMaxLife));
2396         gui.PoReferences.set("text" /* NOI18N */, nf.format(p.RefCount));
2397     }
2398 
2399     /*
2400      * Methods for defaults tab
2401      */
2402 
2403     /**
2404      * React to save button
2405      *
2406      */
2407     public void glSave() {
2408         if (defaults.updateFromGui()) {
2409             glDoSave(true);
2410             glUpdate();
2411         }
2412     }
2413 
2414     /**
2415      * React to apply button
2416      *
2417      */
2418     public void glApply() {
2419         if (defaults.updateFromGui()) {
2420             glDoSave(false);
2421             glUpdate();
2422         }
2423     }
2424 
2425     /**
2426      * React to cancel button
2427      *
2428      */
2429     public void glCancel() {
2430         if (glNeedSave) {
2431             String text[] = {getString("You are about to lose changes."),
2432 			     getString("Click Save to commit changes, "
2433 				       +"Discard to discard changes, "
2434 				       +"or Cancel to continue editing.")};
2435             String resp = confirmSave(defaultsEditingFrame, text);
2436             if (resp.equals(getString("Cancel")))
2437                 return;
2438             if (resp.equals(getString("Discard")))
2439                 defaults.restoreValues(olddefaults);
2440             if (resp.equals(getString("Save"))) {
2441                 glDoSave(true);
2442                 glUpdate();
2443                 return;
2444             }
2445         }
2446         glDoSave(false);
2447     }
2448 
2449     public void glDoSave(boolean save) {
2450         defaults.close(save);
2451         glSetCanSave(false);
2452         glNeedSave = false;
2453         SaveString = "";
2454         updateStatus();
2455     }
2456 
2457     public void glUpdate() {
2458         noLists = ((privs & PRIV_LIST) == 0 || !defaults.getShowLists());
2459         fixHelpTags();
2460         fixListPanels();
2461         // Load principal list if we are in the principal tab and are not
2462         // editing a principal
2463         if (gui.tabbedfolder1.get("currentCard" /* NO18N */) ==
2464 	    getString("Principals") && prin == null)
2465 	    fillPrincipalList(curPrPattern);
2466         // Load policy list if we are in the policy tab and are not
2467         // editing a policy
2468         if (gui.tabbedfolder1.get("currentCard" /* NO18N */) ==
2469 	    getString("Policies") && pol == null)
2470 	    fillPolicyList(curPoPattern);
2471     }
2472 
2473     /**
2474      * This is a way for the data modification actions to note that
2475      * the principal has edits outstanding.
2476      *
2477      */
2478     public void glSetNeedSave() {
2479         glNeedSave = true;
2480         glSetCanSave(true);
2481     }
2482 
2483     /**
2484      * Make the Save button do the right thing.
2485      *
2486      */
2487     public void glSetCanSave(boolean ok) {
2488         defaults.saveButton.setEnabled(ok);
2489         defaults.applyButton.setEnabled(ok);
2490     }
2491 
2492     public boolean setGlobalMaxrenew() {
2493         boolean done = defaults.setMaxTicketRenewableLife();
2494         glSetNeedSave();
2495         return done;
2496     }
2497 
2498     public boolean setGlobalMaxlife() {
2499         boolean done = defaults.setMaxTicketLife();
2500         glSetNeedSave();
2501         return done;
2502     }
2503 
2504     public boolean setGlobalExpiry() {
2505         boolean done = defaults.setAccountExpiryDate();
2506         glSetNeedSave();
2507         return done;
2508     }
2509 
2510     public boolean setServerSide() {
2511         boolean done = defaults.setServerSide();
2512         glSetNeedSave();
2513         return done;
2514     }
2515 
2516     public boolean setShowLists() {
2517         boolean done = defaults.setShowLists();
2518         glSetNeedSave();
2519         return done;
2520     }
2521 
2522     public boolean setStaticLists() {
2523         boolean done = defaults.setStaticLists();
2524         glSetNeedSave();
2525         return done;
2526     }
2527 
2528     public boolean setCacheTime() {
2529         boolean done = defaults.setCacheTime();
2530         glSetNeedSave();
2531         return done;
2532     }
2533 
2534     public void setGlobalFlag(int bitfield) {
2535         defaults.toggleFlag(bitfield);
2536         glSetNeedSave();
2537     }
2538 
2539     /*
2540      * Miscellany
2541      */
2542     public void printPrList() {
2543         String title = getString("Principal List");
2544         if (curPrPattern.length() > 0)
2545             title = title.concat(" (" + getString("Filter Pattern:") + " "
2546 				 + curPrPattern + ")");
2547         if (principalList == null)
2548             fillPrincipalList(curPrPattern);
2549         printList((TextList)gui.Prlist.getBody(), title);
2550     }
2551 
2552     public void printCurPr() {
2553         Principal toPrint;
2554 
2555         if (prin == null) {
2556             // We are viewing the principal list. Instantiate a new
2557             // principal using the current name.
2558             toPrint =  new Principal(Kadmin, CurPrincipal);
2559         } else {
2560             // We are in the middle of editing a principal. Update the
2561             // current principal object with the current contents of the
2562             // gui. It's ok for the password to be null, we are not printing
2563             // it anyway.
2564             if (!prUpdateFromGui(true))
2565                 return;
2566             toPrint = prin;
2567         }
2568 
2569         PrintUtil.dump(realMainFrame, toPrint);
2570     }
2571 
2572     public void printPoList() {
2573         String title = getString("Policy List");
2574         if (curPoPattern.length() > 0)
2575             title = title.concat(" (" + getString("Filter Pattern:") + " "
2576 				 + curPoPattern + ")");
2577         if (policyList == null)
2578             fillPolicyList(curPoPattern);
2579         printList((TextList)gui.Pollist.getBody(), title);
2580     }
2581 
2582     public void printCurPol() {
2583         Policy toPrint;
2584 
2585         if (pol == null) {
2586             // We are viewing the policy list. Instantiate a new
2587             // policy using the current name.
2588             toPrint = new Policy(Kadmin, CurPolicy);
2589         } else {
2590             // We are in the middle of editing a policy. Update the current
2591             // policy object with the current contents of the gui.
2592             if (!poUpdateFromGui())
2593                 return;
2594             toPrint = pol;
2595         }
2596 
2597         PrintUtil.dump(realMainFrame, toPrint);
2598 
2599     }
2600 
2601     private void printList(TextList guiList, String title) {
2602         String[] list = getItemsFromTextList(guiList);
2603         StringBuffer sb = new StringBuffer(title).append('\n');
2604 
2605         for (int i = 0; i < list.length; i++) {
2606             sb.append(list[i]).append('\n');
2607         }
2608 
2609         PrintUtil.dump(realMainFrame, sb);
2610     }
2611 
2612     public void showHelpBrowser(Frame frame) {
2613         try {
2614 
2615             File file = new File("/usr/dt/bin/sdtwebclient");
2616             if (!file.exists()) {
2617                 showDialog(frame, getString("Error"),
2618 			   getString("Can't run /usr/dt/bin/sdtwebclient."));
2619                 return;
2620             }
2621             String url = kc.getHelpURL();
2622             if (url == null)
2623                 url = helpIndexFile;
2624             URL help = new URL(url);
2625             InputStream is = null;
2626             try {
2627                 is = help.openStream();
2628             } catch (IOException e) {}
2629             if (is == null) {
2630                 showDialog(frame, getString("Error"),
2631 			   getString("Invalid URL: ")+url);
2632                 return;
2633             }
2634 
2635             if (browserProcess != null) {
2636                 // Will throw IllegalThreadStateException if thread not exited
2637                 // yet
2638                 int i = browserProcess.exitValue();
2639             }
2640 
2641             // Thread has exited or never existed
2642             browserProcess =
2643 		Runtime.getRuntime().exec("/usr/dt/bin/sdtwebclient" +url);
2644 
2645         } catch (IOException e) {
2646             showDialog(frame, getString("Error"), e.getMessage());
2647         } catch (IllegalThreadStateException e) {
2648             // Ok. All this mean is that a previous instance of the browser
2649             // exists
2650         }
2651     }
2652 
2653     private void killHelpBrowser() {
2654         if (browserProcess != null) {
2655             browserProcess.destroy();
2656         }
2657     }
2658 
2659     private void setupDefaultsEditingFrame() {
2660         defaultsEditingFrame = defaults.getEditingFrame();
2661         glSetCanSave(false);
2662         setupDefaultsNormalListeners();
2663         defaults.csHelp.addActionListener
2664 	    (new DefaultsContextSensitiveHelpListener());
2665     }
2666 
2667     public void editPreferences() {
2668         olddefaults = new Defaults(defaults);
2669         defaults.updateGuiComponents();
2670         defaultsEditingFrame.setVisible(true);
2671     }
2672 
2673     static Frame getFrame(Component c) {
2674         Frame frame = null;
2675 
2676         while ((c = c.getParent()) != null)
2677             if (c instanceof Frame)
2678 		frame = (Frame)c;
2679         return frame;
2680     }
2681 
2682     /**
2683      * General purpose dialog with title and a label settable
2684      */
2685     public void showDialog(Frame frame, String title, String text) {
2686         String[] lines = new String[1];
2687         lines[0] = text;
2688         String[] buttons = new String[1];
2689         buttons[0] = getString("OK");
2690         ChoiceDialog cd = new ChoiceDialog(frame, title, lines, buttons);
2691     }
2692 
2693     public void showLoginWarning(String err) {
2694         showDialog(realLoginFrame, getString("Warning"), err);
2695     }
2696 
2697     public void showLoginError(String err) {
2698         showDialog(realLoginFrame, getString("Error"), err);
2699     }
2700 
2701     public void showWarning(String err) {
2702         showDialog(realMainFrame, getString("Warning"), err);
2703     }
2704 
2705     public void showError(String err) {
2706         showDialog(realMainFrame, getString("Error"), err);
2707     }
2708 
2709     public static void showDataFormatError(TextField tf, int dataType) {
2710 
2711         Frame parent = getFrame(tf);
2712 
2713         tf.selectAll();
2714         toolkit.beep();
2715 
2716         String title = getString("Error");
2717 
2718         String[] lines = null;
2719         String[] buttons = {getString("OK")};
2720 
2721         switch (dataType) {
2722 	case DURATION_DATA:
2723             lines = durationErrorText;
2724             break;
2725 	case DATE_DATA:
2726             lines = dateErrorText;
2727             break;
2728 	case NUMBER_DATA:
2729             lines = numberErrorText;
2730             break;
2731         }
2732 
2733         Point p = tf.getLocationOnScreen();
2734         ChoiceDialog cd = new ChoiceDialog(parent, title, lines,
2735 					   buttons, p.x, p.y);
2736 
2737         tf.requestFocus();
2738 
2739     }
2740 
2741     /**
2742      * Confirm a destructive user action
2743      */
2744     public String confirmAction(Frame frame, String[] text) {
2745         String title = getString("Confirm Action");
2746         String[] buttons = new String[2];
2747         buttons[0] = getString("OK");
2748         buttons[1] = getString("Cancel");
2749         ChoiceDialog cd = new ChoiceDialog(frame, title, text, buttons);
2750         return (cd.getSelection() == null? getString("Cancel")
2751 		:cd.getSelection());
2752     }
2753 
2754     /**
2755      * Confirm a destructive user action, offering choice of saving
2756      */
2757     public String confirmSave(Frame frame, String[] text) {
2758         String title = getString("Confirm Action");
2759         String[] buttons = new String[3];
2760         buttons[0] = getString("Save");
2761         buttons[1] = getString("Discard");
2762         buttons[2] = getString("Cancel");
2763         ChoiceDialog cd = new ChoiceDialog(frame, title, text, buttons);
2764         return (cd.getSelection() == null? getString("Cancel")
2765 		: cd.getSelection());
2766     }
2767 
2768     /**
2769      * Show version info
2770      */
2771     public void doAbout(Frame frame) {
2772         String title = getString("About SEAM Adminstration Tool");
2773         String[] text = new String[7];
2774         text[0] = getString("Sun Enterprise Authentication"
2775 			    +" Mechanism Administration Tool");
2776         text[1] = System.getProperty("SEAM_VERS" /* NOI18N */);
2777         text[2] = getString("Copyright 2005 Sun Microsystems, Inc.  "
2778 				+"All rights reserved.");
2779         text[3] = getString("Use is subject to license terms.");
2780         text[4] = System.getProperty("os.name" /* NOI18N */);
2781         text[5] = System.getProperty("os.arch" /* NOI18N */);
2782         text[6] = System.getProperty("os.version" /* NOI18N */);
2783         String[] button = new String[1];
2784         button[0] = getString("Dismiss");
2785         ChoiceDialog cd = new ChoiceDialog(frame, title, text, button);
2786     }
2787 
2788     private void getDateTimeFromDialogBox(TextField tf, Frame frame) {
2789         tf.select(0, 0);
2790         dateTimeDialog = new DateTimeDialog(frame, tf.getBackground(),
2791 					    tf.getForeground());
2792 
2793         if (!tf.getText().equalsIgnoreCase(neverString)) {
2794             try {
2795                 Date currVal = df.parse(tf.getText());
2796                 dateTimeDialog.setDate(currVal);
2797                 /*
2798                  * In case an exception occurs, let the dialog box be
2799                  * initialized to its default date (viz current time).
2800                  */
2801             } catch (ParseException e) {
2802             } catch (NullPointerException e) {
2803                 // gets thrown when parse string begins with text
2804                 // probable JDK bug
2805             }
2806             catch (StringIndexOutOfBoundsException e) {
2807                 // gets thrown when parse string contains only one number
2808                 // probable JDK bug
2809             }
2810         }
2811         dateTimeDialog.setVisible(true);
2812 
2813         // Modal dialog box so this is after dialog box disappers
2814         if (dateTimeDialog.isSaved()) {
2815             tf.setText(dateTimeDialog.toString());
2816             tf.dispatchEvent(new ActionEvent(tf, ActionEvent.ACTION_PERFORMED,
2817 				     "setFromDateTimeDialog" /* NOI18N */));
2818         }
2819     }
2820 
2821     private void getDurationFromDialogBox(TextField tf, Frame frame) {
2822         tf.select(0, 0);
2823         durationHelper = new DurationHelper(frame, tf.getBackground(),
2824 					    tf.getForeground());
2825         durationHelper.setVisible(true);
2826 
2827         // Modal dialog box so this is after dialog box disappers
2828         if (durationHelper.isSaved()) {
2829             tf.setText(durationHelper.toString());
2830             tf.dispatchEvent(new ActionEvent(tf, ActionEvent.ACTION_PERFORMED,
2831 				     "setFromDurationHelper" /* NOI18N */));
2832         }
2833     }
2834 
2835     private void getEncListFromDialogBox(TextField tf, Frame frame) {
2836 	tf.select(0, 0);
2837 	encListDialog = new EncListDialog(frame, tf.getBackground(),
2838 	    tf.getForeground(), Kadmin);
2839 
2840 	encListDialog.setEncTypes(tf.getText());
2841 	encListDialog.setVisible(true);
2842 
2843 	// Modal dialog box so this is after dialog box disappers
2844 	if (encListDialog.isSaved()) {
2845 		String e = encListDialog.toString();
2846 
2847 		if (e.compareTo("") != 0) {
2848 	    	    String p = (String)gui.PrPassword.get("text" /* NOI18N */);
2849 
2850 		    // In order to change the key encryption type(s) the admin
2851 		    // will have to supply a password.
2852 	    	    if (p.compareTo("") == 0) {
2853 			showWarning(getString(
2854 			"If changing the key encryption types then specify a" +
2855 			" new password for the principal whose keys are" +
2856 			" being changed"));
2857 			((TextField)gui.PrPassword.getBody()).requestFocus();
2858 	    	    }
2859 		}
2860 		tf.setText(e);
2861 		tf.dispatchEvent(new ActionEvent(tf,
2862 		    ActionEvent.ACTION_PERFORMED,
2863 		    "setFromEncListDialog" /* NOI18N */));
2864 	}
2865     }
2866 
2867     /**
2868      * By going into context-sensitive help mode, normal listeners will
2869      * be removed and replaced with help listeners, so that help will
2870      * be shown for the object.
2871      *
2872      */
2873     public void contextHelp(Frame frame) {
2874 
2875         if (cHelp == null) {
2876             cHelp = new ContextHelp(frame, this);
2877             cHelp.setVisible(true);
2878         }
2879 
2880         if (frame == realLoginFrame)
2881             setupLoginHelpListeners();
2882         else if (frame == realMainFrame)
2883             setupMainHelpListeners();
2884         else if (frame == defaultsEditingFrame)
2885             setupDefaultsHelpListeners();
2886 
2887         frame.setCursor(new Cursor(Cursor.CROSSHAIR_CURSOR));
2888     }
2889 
2890 
2891     /**
2892      * Enables the print menu for printing principal related info.
2893      */
2894     private void enablePrincipalPrinting() {
2895         ((MenuItem)gui.PrintCurPr.getBody()).setEnabled(true);
2896     }
2897 
2898     /**
2899      * Enables the print menu for printing policy related info.
2900      */
2901     private void enablePolicyPrinting() {
2902         ((MenuItem)gui.PrintCurPol.getBody()).setEnabled(true);
2903     }
2904 
2905     /**
2906      * Disables the print menu for printing principal related info.
2907      */
2908     private void disablePrincipalPrinting() {
2909         ((MenuItem)gui.PrintCurPr.getBody()).setEnabled(false);
2910     }
2911 
2912     /**
2913      * Disables the print menu for printing policy related info.
2914      */
2915     private void disablePolicyPrinting() {
2916         ((MenuItem)gui.PrintCurPol.getBody()).setEnabled(false);
2917     }
2918 
2919     /**
2920      * Set up the listeners for the objects on the login screen in normal mode
2921      *
2922      */
2923     public void setupLoginNormalListeners() {
2924         if (LoginNormal == null) {
2925             LoginNormal = new Vector(10, 10);
2926             ActionListener al;
2927             Association a;
2928             Object o;
2929 
2930             al = new LoginNameAction();
2931             o = gui.LoginName.getBody();
2932             a = new Association(o, al, TEXTFIELD_ACTION);
2933             LoginNormal.addElement(a);
2934 
2935             al = new LoginPassAction();
2936             o = gui.LoginPass.getBody();
2937             a = new Association(o, al, TEXTFIELD_ACTION);
2938             LoginNormal.addElement(a);
2939 
2940             al = new LoginRealmAction();
2941             o = gui.LoginRealm.getBody();
2942             a = new Association(o, al, TEXTFIELD_ACTION);
2943             LoginNormal.addElement(a);
2944 
2945             al = new LoginServerAction();
2946             o = gui.LoginServer.getBody();
2947             a = new Association(o, al, TEXTFIELD_ACTION);
2948             LoginNormal.addElement(a);
2949 
2950             al = new LoginOKAction();
2951             o = gui.LoginOK.getBody();
2952             a = new Association(o, al, BUTTON_ACTION);
2953             LoginNormal.addElement(a);
2954 
2955             al = new LoginStartOverAction();
2956             o = gui.LoginStartOver.getBody();
2957             a = new Association(o, al, BUTTON_ACTION);
2958             LoginNormal.addElement(a);
2959         }
2960         setListeners(LoginHelp, false);
2961         setListeners(LoginFixers, false);
2962         setListeners(LoginNormal, true);
2963         loginHelpMode = false;
2964     }
2965 
2966     /**
2967      * Set up the listeners for the objects on the login screen in help mode
2968      *
2969      */
2970     public void setupLoginHelpListeners() {
2971         if (LoginHelp == null) {
2972             LoginHelp = new Vector(10, 10);
2973             MouseListener ml = new HelpListener();
2974             Association a;
2975             Object o;
2976 
2977             o = gui.LoginName.getBody();
2978             a = new Association(o, ml, TEXTFIELD_MOUSE);
2979             LoginHelp.addElement(a);
2980             ((TextField)o).setName("LoginName" /* NOI18N */);
2981 
2982             o = gui.LoginNameLabel.getBody();
2983             a = new Association(o, ml, LABEL_MOUSE);
2984             LoginHelp.addElement(a);
2985             ((Label)o).setName("LoginName" /* NOI18N */);
2986 
2987             o = gui.LoginPass.getBody();
2988             a = new Association(o, ml, TEXTFIELD_MOUSE);
2989             LoginHelp.addElement(a);
2990             ((TextField)o).setName("LoginPass" /* NOI18N */);
2991 
2992             o = gui.LoginPassLabel.getBody();
2993             a = new Association(o, ml, LABEL_MOUSE);
2994             LoginHelp.addElement(a);
2995             ((Label)o).setName("LoginPass" /* NOI18N */);
2996 
2997             o = gui.LoginRealm.getBody();
2998             a = new Association(o, ml, TEXTFIELD_MOUSE);
2999             LoginHelp.addElement(a);
3000             ((TextField)o).setName("LoginRealm" /* NOI18N */);
3001 
3002             o = gui.LoginRealmLabel.getBody();
3003             a = new Association(o, ml, LABEL_MOUSE);
3004             LoginHelp.addElement(a);
3005             ((Label)o).setName("LoginRealm" /* NOI18N */);
3006 
3007             o = gui.LoginServer.getBody();
3008             a = new Association(o, ml, TEXTFIELD_MOUSE);
3009             LoginHelp.addElement(a);
3010             ((TextField)o).setName("LoginServer" /* NOI18N */);
3011 
3012             o = gui.LoginServerLabel.getBody();
3013             a = new Association(o, ml, LABEL_MOUSE);
3014             LoginHelp.addElement(a);
3015             ((Label)o).setName("LoginServer" /* NOI18N */);
3016 
3017             o = gui.LoginOK.getBody();
3018             a = new Association(o, ml, BUTTON_MOUSE);
3019             LoginHelp.addElement(a);
3020             ((Button)o).setName("LoginOK" /* NOI18N */);
3021 
3022             o = gui.LoginStartOver.getBody();
3023             a = new Association(o, ml, BUTTON_MOUSE);
3024             LoginHelp.addElement(a);
3025             ((Button)o).setName("LoginStartOver" /* NOI18N */);
3026         }
3027         setListeners(LoginNormal, false);
3028         setListeners(LoginHelp, true);
3029         setupLoginHelpFixers();
3030         loginHelpMode = true;
3031     }
3032 
3033     public void setupLoginHelpFixers() {
3034         LoginFixers = new Vector(10, 10);
3035         Object o;
3036         Association a;
3037         TextFixer tf;
3038 
3039         o = gui.LoginName.getBody();
3040         tf = new TextFixer((TextField)o);
3041         a = new Association(o, tf, TEXTFIELD_KEY);
3042         LoginFixers.addElement(a);
3043 
3044         o = gui.LoginPass.getBody();
3045         tf = new TextFixer((TextField)o);
3046         a = new Association(o, tf, TEXTFIELD_KEY);
3047         LoginFixers.addElement(a);
3048 
3049         o = gui.LoginRealm.getBody();
3050         tf = new TextFixer((TextField)o);
3051         a = new Association(o, tf, TEXTFIELD_KEY);
3052         LoginFixers.addElement(a);
3053 
3054         o = gui.LoginServer.getBody();
3055         tf = new TextFixer((TextField)o);
3056         a = new Association(o, tf, TEXTFIELD_KEY);
3057         LoginFixers.addElement(a);
3058 
3059         setListeners(LoginFixers, true);
3060     }
3061 
3062     /**
3063      * Set up the listeners for the objects on the main screen in normal mode
3064      *
3065      */
3066     public void setupMainNormalListeners() {
3067         if (MainNormal == null) {
3068             Frame fr = realMainFrame;
3069             MainNormal = new Vector(10, 10);
3070             ActionListener al;
3071             ItemListener il;
3072             DateTimeListener dtl;
3073             DurationListener dl;
3074             EncListListener ell;
3075             KeyListener kl1 = new KeystrokeDetector(PRINCIPAL_EDITING);
3076             KeyListener kl2 = new KeystrokeDetector(POLICY_EDITING);
3077             KeyListener kl3 = new KeystrokeDetector(PRINCIPAL_LIST);
3078             KeyListener kl4 = new KeystrokeDetector(POLICY_LIST);
3079             Association a;
3080             Object o;
3081 
3082             WindowListener wl = new MainWindowCloseAction();
3083             o = realMainFrame;
3084             a = new Association(o, wl, WINDOW_LISTENER);
3085             MainNormal.addElement(a);
3086 
3087             al = new PrListPatternAction();
3088             o = gui.PrListPattern.getBody();
3089             a = new Association(o, al, TEXTFIELD_ACTION);
3090             MainNormal.addElement(a);
3091             a = new Association(o, kl3, TEXTFIELD_KEY);
3092             MainNormal.addElement(a);
3093 
3094             al = new PrListClearAction();
3095             o = gui.PrListClear.getBody();
3096             a = new Association(o, al, BUTTON_ACTION);
3097             MainNormal.addElement(a);
3098 
3099             al = new PrListModifyAction();
3100             o = gui.PrListModify.getBody();
3101             a = new Association(o, al, BUTTON_ACTION);
3102             MainNormal.addElement(a);
3103 
3104             al = new PrListAddAction();
3105             o = gui.PrListAdd.getBody();
3106             a = new Association(o, al, BUTTON_ACTION);
3107             MainNormal.addElement(a);
3108 
3109             al = new PrListDeleteAction();
3110             o = gui.PrListDelete.getBody();
3111             a = new Association(o, al, BUTTON_ACTION);
3112             MainNormal.addElement(a);
3113 
3114             al = new PrListDuplicateAction();
3115             o = gui.PrListDuplicate.getBody();
3116             a = new Association(o, al, BUTTON_ACTION);
3117             MainNormal.addElement(a);
3118 
3119             al = new PrSaveAction();
3120             o = gui.PrBasicSave.getBody();
3121             a = new Association(o, al, BUTTON_ACTION);
3122             MainNormal.addElement(a);
3123             o = gui.PrDetailSave.getBody();
3124             a = new Association(o, al, BUTTON_ACTION);
3125             MainNormal.addElement(a);
3126             o = gui.PrFlagsSave.getBody();
3127             a = new Association(o, al, BUTTON_ACTION);
3128             MainNormal.addElement(a);
3129 
3130             al = new PrCancelAction();
3131             o = gui.PrBasicCancel.getBody();
3132             a = new Association(o, al, BUTTON_ACTION);
3133             MainNormal.addElement(a);
3134             o = gui.PrDetailCancel.getBody();
3135             a = new Association(o, al, BUTTON_ACTION);
3136             MainNormal.addElement(a);
3137             o = gui.PrFlagsCancel.getBody();
3138             a = new Association(o, al, BUTTON_ACTION);
3139             MainNormal.addElement(a);
3140 
3141             al = new PrCommentsAction();
3142             o = gui.PrComments.getBody();
3143             a = new Association(o, al, TEXTFIELD_ACTION);
3144             MainNormal.addElement(a);
3145             a = new Association(o, kl1, TEXTFIELD_KEY);
3146             MainNormal.addElement(a);
3147 
3148             il = new PrPolicyAction();
3149             o = gui.PrPolicy.getBody();
3150             a = new Association(o, il, CHOICE_ITEM);
3151             MainNormal.addElement(a);
3152 
3153             al = new PrPasswordAction();
3154             o = gui.PrPassword.getBody();
3155             a = new Association(o, al, TEXTFIELD_ACTION);
3156             MainNormal.addElement(a);
3157             a = new Association(o, kl1, TEXTFIELD_KEY);
3158             MainNormal.addElement(a);
3159 
3160             al = new PrRandomPwAction();
3161             o = gui.PrBasicRandomPw.getBody();
3162             a = new Association(o, al, BUTTON_ACTION);
3163             MainNormal.addElement(a);
3164 
3165             al = new EncListAction();
3166             o = gui.EncList.getBody();
3167             a = new Association(o, al, TEXTFIELD_ACTION);
3168             MainNormal.addElement(a);
3169             a = new Association(o, kl1, TEXTFIELD_KEY);
3170             MainNormal.addElement(a);
3171 
3172             ell = new EncListListener((TextField)gui.EncList.getBody(), fr);
3173             o = gui.EncListMoreButton.getBody();
3174             a = new Association(o, ell, BUTTON_ACTION);
3175             MainNormal.addElement(a);
3176 
3177             al = new PrExpiryAction();
3178             o = gui.PrExpiry.getBody();
3179             a = new Association(o, al, TEXTFIELD_ACTION);
3180             MainNormal.addElement(a);
3181             a = new Association(o, kl1, TEXTFIELD_KEY);
3182             MainNormal.addElement(a);
3183 
3184             dtl = new DateTimeListener((TextField)gui.PrExpiry.getBody(), fr);
3185             o = gui.PrExpiryMoreButton.getBody();
3186             a = new Association(o, dtl, BUTTON_ACTION);
3187             MainNormal.addElement(a);
3188 
3189             al = new PrBasicPreviousAction();
3190             o = gui.PrBasicPrevious.getBody();
3191             a = new Association(o, al, BUTTON_ACTION);
3192             MainNormal.addElement(a);
3193 
3194             al = new PrBasicNextAction();
3195             o = gui.PrBasicNext.getBody();
3196             a = new Association(o, al, BUTTON_ACTION);
3197             MainNormal.addElement(a);
3198 
3199             al = new PrPwExpiryAction();
3200             o = gui.PrPwExpiry.getBody();
3201             a = new Association(o, al, TEXTFIELD_ACTION);
3202             MainNormal.addElement(a);
3203             a = new Association(o, kl1, TEXTFIELD_KEY);
3204             MainNormal.addElement(a);
3205 
3206             dtl = new DateTimeListener((TextField)gui.PrPwExpiry.getBody(), fr);
3207             o = gui.PrPwExpiryMoreButton.getBody();
3208             a = new Association(o, dtl, BUTTON_ACTION);
3209             MainNormal.addElement(a);
3210 
3211             al = new PrKvnoAction();
3212             o = gui.PrKvno.getBody();
3213             a = new Association(o, al, TEXTFIELD_ACTION);
3214             MainNormal.addElement(a);
3215             a = new Association(o, kl1, TEXTFIELD_KEY);
3216             MainNormal.addElement(a);
3217 
3218             al = new PrMaxLifetimeAction();
3219             o = gui.PrMaxLifetime.getBody();
3220             a = new Association(o, al, TEXTFIELD_ACTION);
3221             MainNormal.addElement(a);
3222             a = new Association(o, kl1, TEXTFIELD_KEY);
3223             MainNormal.addElement(a);
3224 
3225             dl = new DurationListener((TextField)gui.PrMaxLifetime.getBody(),
3226 				      fr);
3227             o = gui.PrMaxLifetimeMoreButton.getBody();
3228             a = new Association(o, dl, BUTTON_ACTION);
3229             MainNormal.addElement(a);
3230 
3231             al = new PrMaxRenewalAction();
3232             o = gui.PrMaxRenewal.getBody();
3233             a = new Association(o, al, TEXTFIELD_ACTION);
3234             MainNormal.addElement(a);
3235             a = new Association(o, kl1, TEXTFIELD_KEY);
3236             MainNormal.addElement(a);
3237 
3238             dl = new DurationListener((TextField)gui.PrMaxRenewal.getBody(),
3239 				      fr);
3240             o = gui.PrMaxRenewalMoreButton.getBody();
3241             a = new Association(o, dl, BUTTON_ACTION);
3242             MainNormal.addElement(a);
3243 
3244             al = new PrDetailPreviousAction();
3245             o = gui.PrDetailPrevious.getBody();
3246             a = new Association(o, al, BUTTON_ACTION);
3247             MainNormal.addElement(a);
3248 
3249             al = new PrDetailNextAction();
3250             o = gui.PrDetailNext.getBody();
3251             a = new Association(o, al, BUTTON_ACTION);
3252             MainNormal.addElement(a);
3253 
3254             al = new PrFlagsPreviousAction();
3255             o = gui.PrFlagsPrevious.getBody();
3256             a = new Association(o, al, BUTTON_ACTION);
3257             MainNormal.addElement(a);
3258 
3259             al = new PrFlagsNextAction();
3260             o = gui.PrFlagsNext.getBody();
3261             a = new Association(o, al, BUTTON_ACTION);
3262             MainNormal.addElement(a);
3263 
3264             il = new PrLockAcctAction();
3265             o = gui.PrLockAcct.getBody();
3266             a = new Association(o, il, CHECKBOX_ITEM);
3267             MainNormal.addElement(a);
3268 
3269             il = new PrForcePwChangeAction();
3270             o = gui.PrForcePwChange.getBody();
3271             a = new Association(o, il, CHECKBOX_ITEM);
3272             MainNormal.addElement(a);
3273 
3274             il = new PrAllowPostdatedAction();
3275             o = gui.PrAllowPostdated.getBody();
3276             a = new Association(o, il, CHECKBOX_ITEM);
3277             MainNormal.addElement(a);
3278 
3279             il = new PrAllowForwardableAction();
3280             o = gui.PrAllowForwardable.getBody();
3281             a = new Association(o, il, CHECKBOX_ITEM);
3282             MainNormal.addElement(a);
3283 
3284             il = new PrAllowRenewableAction();
3285             o = gui.PrAllowRenewable.getBody();
3286             a = new Association(o, il, CHECKBOX_ITEM);
3287             MainNormal.addElement(a);
3288 
3289             il = new PrAllowProxiableAction();
3290             o = gui.PrAllowProxiable.getBody();
3291             a = new Association(o, il, CHECKBOX_ITEM);
3292             MainNormal.addElement(a);
3293 
3294             il = new PrAllowSvrAction();
3295             o = gui.PrAllowSvr.getBody();
3296             a = new Association(o, il, CHECKBOX_ITEM);
3297             MainNormal.addElement(a);
3298 
3299             il = new PrAllowTGTAction();
3300             o = gui.PrAllowTGT.getBody();
3301             a = new Association(o, il, CHECKBOX_ITEM);
3302             MainNormal.addElement(a);
3303 
3304             il = new PrAllowDupAuthAction();
3305             o = gui.PrAllowDupAuth.getBody();
3306             a = new Association(o, il, CHECKBOX_ITEM);
3307             MainNormal.addElement(a);
3308 
3309             il = new PrRequirePreAuthAction();
3310             o = gui.PrRequirePreAuth.getBody();
3311             a = new Association(o, il, CHECKBOX_ITEM);
3312             MainNormal.addElement(a);
3313 
3314             il = new PrRequireHwPreAuthAction();
3315             o = gui.PrRequireHwPreAuth.getBody();
3316             a = new Association(o, il, CHECKBOX_ITEM);
3317             MainNormal.addElement(a);
3318 
3319             al = new PoListPatternAction();
3320             o = gui.PoListPattern.getBody();
3321             a = new Association(o, al, TEXTFIELD_ACTION);
3322             MainNormal.addElement(a);
3323             a = new Association(o, kl4, TEXTFIELD_KEY);
3324             MainNormal.addElement(a);
3325 
3326             al = new PoListClearAction();
3327             o = gui.PoListClear.getBody();
3328             a = new Association(o, al, BUTTON_ACTION);
3329             MainNormal.addElement(a);
3330 
3331             al = new PoListModifyAction();
3332             o = gui.PoListModify.getBody();
3333             a = new Association(o, al, BUTTON_ACTION);
3334             MainNormal.addElement(a);
3335 
3336             al = new PoListAddAction();
3337             o = gui.PoListAdd.getBody();
3338             a = new Association(o, al, BUTTON_ACTION);
3339             MainNormal.addElement(a);
3340 
3341             al = new PoListDeleteAction();
3342             o = gui.PoListDelete.getBody();
3343             a = new Association(o, al, BUTTON_ACTION);
3344             MainNormal.addElement(a);
3345 
3346             al = new PoListDuplicateAction();
3347             o = gui.PoListDuplicate.getBody();
3348             a = new Association(o, al, BUTTON_ACTION);
3349             MainNormal.addElement(a);
3350 
3351             il = new PoMinPwLengthAction();
3352             o = gui.PoMinPwLength.getBody();
3353             a = new Association(o, il, CHOICE_ITEM);
3354             MainNormal.addElement(a);
3355 
3356             il = new PoMinPwClassAction();
3357             o = gui.PoMinPwClass.getBody();
3358             a = new Association(o, il, CHOICE_ITEM);
3359             MainNormal.addElement(a);
3360 
3361             il = new PoSavedPasswordsAction();
3362             o = gui.PoSavedPasswords.getBody();
3363             a = new Association(o, il, CHOICE_ITEM);
3364             MainNormal.addElement(a);
3365 
3366             al = new PoMinTicketLifetimeAction();
3367             o = gui.PoMinTicketLifetime.getBody();
3368             a = new Association(o, al, TEXTFIELD_ACTION);
3369             MainNormal.addElement(a);
3370             a = new Association(o, kl2, TEXTFIELD_KEY);
3371             MainNormal.addElement(a);
3372 
3373             dl = new DurationListener(
3374 			      (TextField)gui.PoMinTicketLifetime.getBody(), fr);
3375             o = gui.PoMinTicketLifetimeMoreButton.getBody();
3376             a = new Association(o, dl, BUTTON_ACTION);
3377             MainNormal.addElement(a);
3378 
3379             al = new PoMaxTicketLifetimeAction();
3380             o = gui.PoMaxTicketLifetime.getBody();
3381             a = new Association(o, al, TEXTFIELD_ACTION);
3382             MainNormal.addElement(a);
3383             a = new Association(o, kl2, TEXTFIELD_KEY);
3384             MainNormal.addElement(a);
3385 
3386             dl = new DurationListener(
3387 			      (TextField)gui.PoMaxTicketLifetime.getBody(), fr);
3388             o = gui.PoMaxTicketLifetimeMoreButton.getBody();
3389             a = new Association(o, dl, BUTTON_ACTION);
3390             MainNormal.addElement(a);
3391 
3392             al = new PoSaveAction();
3393             o = gui.PoDetailSave.getBody();
3394             a = new Association(o, al, BUTTON_ACTION);
3395             MainNormal.addElement(a);
3396 
3397             al = new PoCancelAction();
3398             o = gui.PoDetailCancel.getBody();
3399             a = new Association(o, al, BUTTON_ACTION);
3400             MainNormal.addElement(a);
3401 
3402             al = new PoPreviousAction();
3403             o = gui.PoDetailPrevious.getBody();
3404             a = new Association(o, al, BUTTON_ACTION);
3405             MainNormal.addElement(a);
3406 
3407             al = new PoDoneAction();
3408             o = gui.PoDetailDone.getBody();
3409             a = new Association(o, al, BUTTON_ACTION);
3410             MainNormal.addElement(a);
3411 
3412         }
3413         setListeners(MainHelp, false);
3414         setListeners(MainFixers, false);
3415         setListeners(MainNormal, true);
3416         mainHelpMode = false;
3417     }
3418 
3419     /**
3420      * Set up the listeners for the objects on the main screen in help mode
3421      *
3422      */
3423     public void setupMainHelpListeners() {
3424         if (MainHelp == null) {
3425             MainHelp = new Vector(10, 10);
3426             MouseListener ml = new HelpListener();
3427             Association a;
3428             Object o;
3429 
3430             o = gui.PrListPattern.getBody();
3431             a = new Association(o, ml, TEXTFIELD_MOUSE);
3432             MainHelp.addElement(a);
3433             ((TextField)o).setName("PrListPattern" /* NOI18N */);
3434 
3435             o = gui.PrSearchLab.getBody();
3436             a = new Association(o, ml, LABEL_MOUSE);
3437             MainHelp.addElement(a);
3438             ((Label)o).setName("PrListPattern" /* NOI18N */);
3439 
3440             o = gui.PrListClear.getBody();
3441             a = new Association(o, ml, BUTTON_MOUSE);
3442             MainHelp.addElement(a);
3443             ((Button)o).setName("PrListClear" /* NOI18N */);
3444 
3445             o = gui.PrListModify.getBody();
3446             a = new Association(o, ml, BUTTON_MOUSE);
3447             MainHelp.addElement(a);
3448             ((Button)o).setName("PrListModify" /* NOI18N */);
3449 
3450             o = gui.PrListAdd.getBody();
3451             a = new Association(o, ml, BUTTON_MOUSE);
3452             MainHelp.addElement(a);
3453             ((Button)o).setName("PrListAdd" /* NOI18N */);
3454 
3455             o = gui.PrListDelete.getBody();
3456             a = new Association(o, ml, BUTTON_MOUSE);
3457             MainHelp.addElement(a);
3458             ((Button)o).setName("PrListDelete" /* NOI18N */);
3459 
3460             o = gui.PrListDuplicate.getBody();
3461             a = new Association(o, ml, BUTTON_MOUSE);
3462             MainHelp.addElement(a);
3463             ((Button)o).setName("PrListDuplicate" /* NOI18N */);
3464 
3465             o = gui.PrBasicSave.getBody();
3466             a = new Association(o, ml, BUTTON_MOUSE);
3467             MainHelp.addElement(a);
3468             ((Button)o).setName("PrSave" /* NOI18N */);
3469 
3470             o = gui.PrDetailSave.getBody();
3471             a = new Association(o, ml, BUTTON_MOUSE);
3472             MainHelp.addElement(a);
3473             ((Button)o).setName("PrSave" /* NOI18N */);
3474 
3475             o = gui.PrFlagsSave.getBody();
3476             a = new Association(o, ml, BUTTON_MOUSE);
3477             MainHelp.addElement(a);
3478             ((Button)o).setName("PrSave" /* NOI18N */);
3479 
3480             o = gui.PrBasicCancel.getBody();
3481             a = new Association(o, ml, BUTTON_MOUSE);
3482             MainHelp.addElement(a);
3483             ((Button)o).setName("PrCancel" /* NOI18N */);
3484 
3485             o = gui.PrDetailCancel.getBody();
3486             a = new Association(o, ml, BUTTON_MOUSE);
3487             MainHelp.addElement(a);
3488             ((Button)o).setName("PrCancel" /* NOI18N */);
3489 
3490             o = gui.PrFlagsCancel.getBody();
3491             a = new Association(o, ml, BUTTON_MOUSE);
3492             MainHelp.addElement(a);
3493             ((Button)o).setName("PrCancel" /* NOI18N */);
3494 
3495             o = gui.PrName1.getBody();
3496             a = new Association(o, ml, TEXTFIELD_MOUSE);
3497             MainHelp.addElement(a);
3498             ((TextField)o).setName("PrName" /* NOI18N */);
3499 
3500             o = gui.PrNameLabel1.getBody();
3501             a = new Association(o, ml, LABEL_MOUSE);
3502             MainHelp.addElement(a);
3503             ((Label)o).setName("PrName" /* NOI18N */);
3504 
3505             o = gui.PrComments.getBody();
3506             a = new Association(o, ml, TEXTFIELD_MOUSE);
3507             MainHelp.addElement(a);
3508             ((TextField)o).setName("PrComments" /* NOI18N */);
3509 
3510             o = gui.PrCommentsLabel.getBody();
3511             a = new Association(o, ml, LABEL_MOUSE);
3512             MainHelp.addElement(a);
3513             ((Label)o).setName("PrComments" /* NOI18N */);
3514 
3515             o = gui.PrPolicy.getBody();
3516             a = new Association(o, ml, CHOICE_MOUSE);
3517             MainHelp.addElement(a);
3518             ((Choice)o).setName("PrPolicy" /* NOI18N */);
3519 
3520             o = gui.PrPolicyLabel.getBody();
3521             a = new Association(o, ml, LABEL_MOUSE);
3522             MainHelp.addElement(a);
3523             ((Label)o).setName("PrPolicy" /* NOI18N */);
3524 
3525             o = gui.PrPassword.getBody();
3526             a = new Association(o, ml, TEXTFIELD_MOUSE);
3527             MainHelp.addElement(a);
3528             ((TextField)o).setName("PrPassword" /* NOI18N */);
3529 
3530             o = gui.PrPasswordLabel.getBody();
3531             a = new Association(o, ml, LABEL_MOUSE);
3532             MainHelp.addElement(a);
3533             ((Label)o).setName("PrPassword" /* NOI18N */);
3534 
3535             o = gui.PrBasicRandomPw.getBody();
3536             a = new Association(o, ml, BUTTON_MOUSE);
3537             MainHelp.addElement(a);
3538             ((Button)o).setName("PrBasicRandomPw" /* NOI18N */);
3539 
3540             o = gui.EncList.getBody();
3541             a = new Association(o, ml, TEXTFIELD_MOUSE);
3542             MainHelp.addElement(a);
3543             ((TextField)o).setName("EncList" /* NOI18N */);
3544 
3545             o = gui.EncListLabel.getBody();
3546             a = new Association(o, ml, LABEL_MOUSE);
3547             MainHelp.addElement(a);
3548             ((Label)o).setName("EncList" /* NOI18N */);
3549 
3550             o = gui.EncListMoreButton.getBody();
3551             a = new Association(o, ml, BUTTON_MOUSE);
3552             MainHelp.addElement(a);
3553             ((Button)o).setName("EncListHelperButton" /* NOI18N */);
3554 
3555             o = gui.PrExpiry.getBody();
3556             a = new Association(o, ml, TEXTFIELD_MOUSE);
3557             MainHelp.addElement(a);
3558             ((TextField)o).setName("PrExpiry" /* NOI18N */);
3559 
3560             o = gui.PrExpiryLabel.getBody();
3561             a = new Association(o, ml, LABEL_MOUSE);
3562             MainHelp.addElement(a);
3563             ((Label)o).setName("PrExpiry" /* NOI18N */);
3564 
3565             o = gui.PrExpiryMoreButton.getBody();
3566             a = new Association(o, ml, BUTTON_MOUSE);
3567             MainHelp.addElement(a);
3568             ((Button)o).setName("DateHelperButton" /* NOI18N */);
3569 
3570             o = gui.PrLastChangedTime.getBody();
3571             a = new Association(o, ml, LABEL_MOUSE);
3572             MainHelp.addElement(a);
3573             ((Label)o).setName("PrinBasLastPrincipalChange" /* NOI18N */);
3574 
3575             o = gui.PrLastChangedTimeLabel.getBody();
3576             a = new Association(o, ml, LABEL_MOUSE);
3577             MainHelp.addElement(a);
3578             ((Label)o).setName("PrinBasLastPrincipalChange" /* NOI18N */);
3579 
3580             o = gui.PrLastChangedBy.getBody();
3581             a = new Association(o, ml, LABEL_MOUSE);
3582             MainHelp.addElement(a);
3583             ((Label)o).setName("PrinBasLastChangedBy" /* NOI18N */);
3584 
3585             o = gui.PrLastChangedByLabel.getBody();
3586             a = new Association(o, ml, LABEL_MOUSE);
3587             MainHelp.addElement(a);
3588             ((Label)o).setName("PrinBasLastChangedBy" /* NOI18N */);
3589 
3590             o = gui.PrBasicPrevious.getBody();
3591             a = new Association(o, ml, BUTTON_MOUSE);
3592             MainHelp.addElement(a);
3593             ((Button)o).setName("PrBasicPrevious" /* NOI18N */);
3594 
3595             o = gui.PrBasicNext.getBody();
3596             a = new Association(o, ml, BUTTON_MOUSE);
3597             MainHelp.addElement(a);
3598             ((Button)o).setName("PrBasicNext" /* NOI18N */);
3599 
3600             o = gui.PrLastSuccess.getBody();
3601             a = new Association(o, ml, LABEL_MOUSE);
3602             MainHelp.addElement(a);
3603             ((Label)o).setName("PrinDetLastSuccess" /* NOI18N */);
3604 
3605             o = gui.PrLastSuccessLabel.getBody();
3606             a = new Association(o, ml, LABEL_MOUSE);
3607             MainHelp.addElement(a);
3608             ((Label)o).setName("PrinDetLastSuccess" /* NOI18N */);
3609 
3610             o = gui.PrLastFailure.getBody();
3611             a = new Association(o, ml, LABEL_MOUSE);
3612             MainHelp.addElement(a);
3613             ((Label)o).setName("PrinDetLastFailure" /* NOI18N */);
3614 
3615             o = gui.PrLastFailureLabel.getBody();
3616             a = new Association(o, ml, LABEL_MOUSE);
3617             MainHelp.addElement(a);
3618             ((Label)o).setName("PrinDetLastFailure" /* NOI18N */);
3619 
3620             o = gui.PrFailCount.getBody();
3621             a = new Association(o, ml, LABEL_MOUSE);
3622             MainHelp.addElement(a);
3623             ((Label)o).setName("PrinDetFailureCount" /* NOI18N */);
3624 
3625             o = gui.PrFailureCountLabel.getBody();
3626             a = new Association(o, ml, LABEL_MOUSE);
3627             MainHelp.addElement(a);
3628             ((Label)o).setName("PrinDetFailureCount" /* NOI18N */);
3629 
3630             o = gui.PrLastPwChange.getBody();
3631             a = new Association(o, ml, LABEL_MOUSE);
3632             MainHelp.addElement(a);
3633             ((Label)o).setName("PrinDetLastPasswordChange" /* NOI18N */);
3634 
3635             o = gui.PrPwLastChangedLabel.getBody();
3636             a = new Association(o, ml, LABEL_MOUSE);
3637             MainHelp.addElement(a);
3638             ((Label)o).setName("PrinDetLastPasswordChange" /* NOI18N */);
3639 
3640             o = gui.PrPwExpiry.getBody();
3641             a = new Association(o, ml, TEXTFIELD_MOUSE);
3642             MainHelp.addElement(a);
3643             ((TextField)o).setName("PrPwExpiry" /* NOI18N */);
3644 
3645             o = gui.PrPwExpiryLabel.getBody();
3646             a = new Association(o, ml, LABEL_MOUSE);
3647             MainHelp.addElement(a);
3648             ((Label)o).setName("PrPwExpiry" /* NOI18N */);
3649 
3650             o = gui.PrPwExpiryMoreButton.getBody();
3651             a = new Association(o, ml, BUTTON_MOUSE);
3652             MainHelp.addElement(a);
3653             ((Button)o).setName("DateHelperButton" /* NOI18N */);
3654 
3655             o = gui.PrKvno.getBody();
3656             a = new Association(o, ml, TEXTFIELD_MOUSE);
3657             MainHelp.addElement(a);
3658             ((TextField)o).setName("PrKvno" /* NOI18N */);
3659 
3660             o = gui.PrKvnoLabel.getBody();
3661             a = new Association(o, ml, LABEL_MOUSE);
3662             MainHelp.addElement(a);
3663             ((Label)o).setName("PrKvno" /* NOI18N */);
3664 
3665             o = gui.PrMaxLifetime.getBody();
3666             a = new Association(o, ml, TEXTFIELD_MOUSE);
3667             MainHelp.addElement(a);
3668             ((TextField)o).setName("PrMaxLifetime" /* NOI18N */);
3669 
3670             o = gui.PrMaxTicketLifetimeLabel.getBody();
3671             a = new Association(o, ml, LABEL_MOUSE);
3672             MainHelp.addElement(a);
3673             ((Label)o).setName("PrMaxLifetime" /* NOI18N */);
3674 
3675             o = gui.PrMaxLifetimeMoreButton.getBody();
3676             a = new Association(o, ml, BUTTON_MOUSE);
3677             MainHelp.addElement(a);
3678             ((Button)o).setName("DurationHelperButton" /* NOI18N */);
3679 
3680             o = gui.PrMaxRenewal.getBody();
3681             a = new Association(o, ml, TEXTFIELD_MOUSE);
3682             MainHelp.addElement(a);
3683             ((TextField)o).setName("PrMaxRenewal" /* NOI18N */);
3684 
3685             o = gui.PrMaxTicketRenewalLabel.getBody();
3686             a = new Association(o, ml, LABEL_MOUSE);
3687             MainHelp.addElement(a);
3688             ((Label)o).setName("PrMaxRenewal" /* NOI18N */);
3689 
3690             o = gui.PrMaxRenewalMoreButton.getBody();
3691             a = new Association(o, ml, BUTTON_MOUSE);
3692             MainHelp.addElement(a);
3693             ((Button)o).setName("DurationHelperButton" /* NOI18N */);
3694 
3695             o = gui.PrDetailPrevious.getBody();
3696             a = new Association(o, ml, BUTTON_MOUSE);
3697             MainHelp.addElement(a);
3698             ((Button)o).setName("PrDetailPrevious" /* NOI18N */);
3699 
3700             o = gui.PrDetailNext.getBody();
3701             a = new Association(o, ml, BUTTON_MOUSE);
3702             MainHelp.addElement(a);
3703             ((Button)o).setName("PrDetailNext" /* NOI18N */);
3704 
3705             o = gui.PrFlagsPrevious.getBody();
3706             a = new Association(o, ml, BUTTON_MOUSE);
3707             MainHelp.addElement(a);
3708             ((Button)o).setName("PrFlagsPrevious" /* NOI18N */);
3709 
3710             o = gui.PrFlagsNext.getBody();
3711             a = new Association(o, ml, BUTTON_MOUSE);
3712             MainHelp.addElement(a);
3713             ((Button)o).setName("PrFlagsNext" /* NOI18N */);
3714 
3715             o = gui.PrLockAcct.getBody();
3716             a = new Association(o, ml, CHECKBOX_MOUSE);
3717             MainHelp.addElement(a);
3718             ((Checkbox)o).setName("PrLockAcct" /* NOI18N */);
3719 
3720             o = gui.PrForcePwChange.getBody();
3721             a = new Association(o, ml, CHECKBOX_MOUSE);
3722             MainHelp.addElement(a);
3723             ((Checkbox)o).setName("PrForcePwChange" /* NOI18N */);
3724 
3725             o = gui.PrAllowPostdated.getBody();
3726             a = new Association(o, ml, CHECKBOX_MOUSE);
3727             MainHelp.addElement(a);
3728             ((Checkbox)o).setName("PrAllowPostdated" /* NOI18N */);
3729 
3730             o = gui.PrAllowForwardable.getBody();
3731             a = new Association(o, ml, CHECKBOX_MOUSE);
3732             MainHelp.addElement(a);
3733             ((Checkbox)o).setName("PrAllowForwardable" /* NOI18N */);
3734 
3735             o = gui.PrAllowRenewable.getBody();
3736             a = new Association(o, ml, CHECKBOX_MOUSE);
3737             MainHelp.addElement(a);
3738             ((Checkbox)o).setName("PrAllowRenewable" /* NOI18N */);
3739 
3740             o = gui.PrAllowProxiable.getBody();
3741             a = new Association(o, ml, CHECKBOX_MOUSE);
3742             MainHelp.addElement(a);
3743             ((Checkbox)o).setName("PrAllowProxiable" /* NOI18N */);
3744 
3745             o = gui.PrAllowSvr.getBody();
3746             a = new Association(o, ml, CHECKBOX_MOUSE);
3747             MainHelp.addElement(a);
3748             ((Checkbox)o).setName("PrAllowSvr" /* NOI18N */);
3749 
3750             o = gui.PrAllowTGT.getBody();
3751             a = new Association(o, ml, CHECKBOX_MOUSE);
3752             MainHelp.addElement(a);
3753             ((Checkbox)o).setName("PrAllowTGT" /* NOI18N */);
3754 
3755             o = gui.PrAllowDupAuth.getBody();
3756             a = new Association(o, ml, CHECKBOX_MOUSE);
3757             MainHelp.addElement(a);
3758             ((Checkbox)o).setName("PrAllowDupAuth" /* NOI18N */);
3759 
3760             o = gui.PrRequirePreAuth.getBody();
3761             a = new Association(o, ml, CHECKBOX_MOUSE);
3762             MainHelp.addElement(a);
3763             ((Checkbox)o).setName("PrRequirePreAuth" /* NOI18N */);
3764 
3765             o = gui.PrRequireHwPreAuth.getBody();
3766             a = new Association(o, ml, CHECKBOX_MOUSE);
3767             MainHelp.addElement(a);
3768             ((Checkbox)o).setName("PrRequireHwPreAuth" /* NOI18N */);
3769 
3770             o = gui.PoListPattern.getBody();
3771             a = new Association(o, ml, TEXTFIELD_MOUSE);
3772             MainHelp.addElement(a);
3773             ((TextField)o).setName("PoListPattern" /* NOI18N */);
3774 
3775             o = gui.PoListPatternLabel.getBody();
3776             a = new Association(o, ml, LABEL_MOUSE);
3777             MainHelp.addElement(a);
3778             ((Label)o).setName("PoListPattern" /* NOI18N */);
3779 
3780             o = gui.PoListClear.getBody();
3781             a = new Association(o, ml, BUTTON_MOUSE);
3782             MainHelp.addElement(a);
3783             ((Button)o).setName("PoListClear" /* NOI18N */);
3784 
3785             o = gui.PoListModify.getBody();
3786             a = new Association(o, ml, BUTTON_MOUSE);
3787             MainHelp.addElement(a);
3788             ((Button)o).setName("PoListModify" /* NOI18N */);
3789 
3790             o = gui.PoListAdd.getBody();
3791             a = new Association(o, ml, BUTTON_MOUSE);
3792             MainHelp.addElement(a);
3793             ((Button)o).setName("PoListAdd" /* NOI18N */);
3794 
3795             o = gui.PoListDelete.getBody();
3796             a = new Association(o, ml, BUTTON_MOUSE);
3797             MainHelp.addElement(a);
3798             ((Button)o).setName("PoListDelete" /* NOI18N */);
3799 
3800             o = gui.PoListDuplicate.getBody();
3801             a = new Association(o, ml, BUTTON_MOUSE);
3802             MainHelp.addElement(a);
3803             ((Button)o).setName("PoListDuplicate" /* NOI18N */);
3804 
3805             o = gui.PoName.getBody();
3806             a = new Association(o, ml, TEXTFIELD_MOUSE);
3807             MainHelp.addElement(a);
3808             ((TextField)o).setName("PoName" /* NOI18N */);
3809 
3810             o = gui.PoNameLabel.getBody();
3811             a = new Association(o, ml, LABEL_MOUSE);
3812             MainHelp.addElement(a);
3813             ((Label)o).setName("PoName" /* NOI18N */);
3814 
3815             o = gui.PoMinPwLength.getBody();
3816             a = new Association(o, ml, CHOICE_MOUSE);
3817             MainHelp.addElement(a);
3818             ((Choice)o).setName("PoMinPwLength" /* NOI18N */);
3819 
3820             o = gui.PoMinPwLengthLabel.getBody();
3821             a = new Association(o, ml, LABEL_MOUSE);
3822             MainHelp.addElement(a);
3823             ((Label)o).setName("PoMinPwLength" /* NOI18N */);
3824 
3825             o = gui.PoMinPwClass.getBody();
3826             a = new Association(o, ml, CHOICE_MOUSE);
3827             MainHelp.addElement(a);
3828             ((Choice)o).setName("PoMinPwClass" /* NOI18N */);
3829 
3830             o = gui.PoMinPwClassLabel.getBody();
3831             a = new Association(o, ml, LABEL_MOUSE);
3832             MainHelp.addElement(a);
3833             ((Label)o).setName("PoMinPwClass" /* NOI18N */);
3834 
3835             o = gui.PoSavedPasswords.getBody();
3836             a = new Association(o, ml, CHOICE_MOUSE);
3837             MainHelp.addElement(a);
3838             ((Choice)o).setName("PoSavedPasswords" /* NOI18N */);
3839 
3840             o = gui.PoSavedPasswordsLabel.getBody();
3841             a = new Association(o, ml, LABEL_MOUSE);
3842             MainHelp.addElement(a);
3843             ((Label)o).setName("PoSavedPasswords" /* NOI18N */);
3844 
3845             o = gui.PoMinTicketLifetime.getBody();
3846             a = new Association(o, ml, TEXTFIELD_MOUSE);
3847             MainHelp.addElement(a);
3848             ((TextField)o).setName("PoMinTicketLifetime" /* NOI18N */);
3849 
3850             o = gui.PoMinTicketLifetimeLabel.getBody();
3851             a = new Association(o, ml, LABEL_MOUSE);
3852             MainHelp.addElement(a);
3853             ((Label)o).setName("PoMinTicketLifetime" /* NOI18N */);
3854 
3855             o = gui.PoMinTicketLifetimeMoreButton.getBody();
3856             a = new Association(o, ml, BUTTON_MOUSE);
3857             MainHelp.addElement(a);
3858             ((Button)o).setName("DurationHelperButton" /* NOI18N */);
3859 
3860             o = gui.PoMaxTicketLifetime.getBody();
3861             a = new Association(o, ml, TEXTFIELD_MOUSE);
3862             MainHelp.addElement(a);
3863             ((TextField)o).setName("PoMaxTicketLifetime" /* NOI18N */);
3864 
3865             o = gui.PoMaxTicketLifetimeLabel.getBody();
3866             a = new Association(o, ml, LABEL_MOUSE);
3867             MainHelp.addElement(a);
3868             ((Label)o).setName("PoMaxTicketLifetime" /* NOI18N */);
3869 
3870             o = gui.PoMaxTicketLifetimeMoreButton.getBody();
3871             a = new Association(o, ml, BUTTON_MOUSE);
3872             MainHelp.addElement(a);
3873             ((Button)o).setName("DurationHelperButton" /* NOI18N */);
3874 
3875             o = gui.PoReferences.getBody();
3876             a = new Association(o, ml, LABEL_MOUSE);
3877             MainHelp.addElement(a);
3878             ((Label)o).setName("PolDetPrincipalsUsingThisPolicy" /* NOI18N */);
3879 
3880             o = gui.PoReferencesLabel.getBody();
3881             a = new Association(o, ml, LABEL_MOUSE);
3882             MainHelp.addElement(a);
3883             ((Label)o).setName("PolDetPrincipalsUsingThisPolicy" /* NOI18N */);
3884 
3885             o = gui.PoDetailSave.getBody();
3886             a = new Association(o, ml, BUTTON_MOUSE);
3887             MainHelp.addElement(a);
3888             ((Button)o).setName("PoSave" /* NOI18N */);
3889 
3890             o = gui.PoDetailCancel.getBody();
3891             a = new Association(o, ml, BUTTON_MOUSE);
3892             MainHelp.addElement(a);
3893             ((Button)o).setName("PoCancel" /* NOI18N */);
3894 
3895             o = gui.PoDetailPrevious.getBody();
3896             a = new Association(o, ml, BUTTON_MOUSE);
3897             MainHelp.addElement(a);
3898             ((Button)o).setName("PoDetailPrevious" /* NOI18N */);
3899 
3900             o = gui.PoDetailDone.getBody();
3901             a = new Association(o, ml, BUTTON_MOUSE);
3902             MainHelp.addElement(a);
3903             ((Button)o).setName("PoDetailDone" /* NOI18N */);
3904 
3905             setupMainHelpFlagTogglers();
3906         }
3907 
3908         fixHelpTags();
3909         setListeners(MainNormal, false);
3910         setListeners(MainHelp, true);
3911         setupMainHelpFixers();
3912         mainHelpMode = true;
3913     }
3914 
3915     public void fixHelpTags() {
3916         if (noLists) {
3917             ((TextList)gui.Prlist.getBody()).setName("PrNoList" /* NOI18N */);
3918             ((TextField)gui.PrListPattern.getBody()).setName("PrNameNoList"
3919 							     /* NOI18N */);
3920             ((Button)gui.PrListClear.getBody()).setName("PrNoListClear"
3921 							/* NOI18N */);
3922             ((TextList)gui.Pollist.getBody()).setName("PolNoList" /* NOI18N */);
3923             ((TextField)gui.PoListPattern.getBody()).setName("PoNameNoList"
3924 							     /* NOI18N */);
3925             ((Button)gui.PoListClear.getBody()).setName("PoNoListClear"
3926 							/* NOI18N */);
3927         } else {
3928             ((TextList)gui.Prlist.getBody()).setName("PrList" /* NOI18N */);
3929             ((TextField)gui.PrListPattern.getBody()).setName("PrListPattern"
3930 							     /* NOI18N */);
3931             ((Button)gui.PrListClear.getBody()).setName("PrListClear"
3932 							/* NOI18N */);
3933             ((TextList)gui.Pollist.getBody()).setName("Pollist" /* NOI18N */);
3934             ((TextField)gui.PoListPattern.getBody()).setName("PoListPattern"
3935 							     /* NOI18N */);
3936             ((Button)gui.PoListClear.getBody()).setName("PoListClear"
3937 							/* NOI18N */);
3938         }
3939     }
3940 
3941     /**
3942      * Helper method to setupMainHelpListeners. Should be called from
3943      * only from there.
3944      */
3945     private void 	setupMainHelpFlagTogglers() {
3946 
3947         if (MainHelp == null)
3948             return;
3949 
3950         CheckboxToggler ml = new CheckboxToggler();
3951         Object o;
3952         Association a;
3953 
3954         o = gui.PrLockAcct.getBody();
3955         a = new Association(o, ml, CHECKBOX_MOUSE);
3956         MainHelp.addElement(a);
3957 
3958         o = gui.PrForcePwChange.getBody();
3959         a = new Association(o, ml, CHECKBOX_MOUSE);
3960         MainHelp.addElement(a);
3961 
3962         o = gui.PrAllowPostdated.getBody();
3963         a = new Association(o, ml, CHECKBOX_MOUSE);
3964         MainHelp.addElement(a);
3965 
3966         o = gui.PrAllowForwardable.getBody();
3967         a = new Association(o, ml, CHECKBOX_MOUSE);
3968         MainHelp.addElement(a);
3969 
3970         o = gui.PrAllowRenewable.getBody();
3971         a = new Association(o, ml, CHECKBOX_MOUSE);
3972         MainHelp.addElement(a);
3973 
3974         o = gui.PrAllowProxiable.getBody();
3975         a = new Association(o, ml, CHECKBOX_MOUSE);
3976         MainHelp.addElement(a);
3977 
3978         o = gui.PrAllowSvr.getBody();
3979         a = new Association(o, ml, CHECKBOX_MOUSE);
3980         MainHelp.addElement(a);
3981 
3982         o = gui.PrAllowTGT.getBody();
3983         a = new Association(o, ml, CHECKBOX_MOUSE);
3984         MainHelp.addElement(a);
3985 
3986         o = gui.PrAllowDupAuth.getBody();
3987         a = new Association(o, ml, CHECKBOX_MOUSE);
3988         MainHelp.addElement(a);
3989 
3990         o = gui.PrRequirePreAuth.getBody();
3991         a = new Association(o, ml, CHECKBOX_MOUSE);
3992         MainHelp.addElement(a);
3993 
3994         o = gui.PrRequireHwPreAuth.getBody();
3995         a = new Association(o, ml, CHECKBOX_MOUSE);
3996         MainHelp.addElement(a);
3997     }
3998 
3999     public void setupMainHelpFixers() {
4000         MainFixers = new Vector(10, 10);
4001         Object o;
4002         Association a;
4003         TextFixer tf;
4004         ChoiceFixer cf;
4005 
4006         o = gui.PrListPattern.getBody();
4007         tf = new TextFixer((TextField)o);
4008         a = new Association(o, tf, TEXTFIELD_KEY);
4009         MainFixers.addElement(a);
4010 
4011         o = gui.PrName1.getBody();
4012         tf = new TextFixer((TextField)o);
4013         a = new Association(o, tf, TEXTFIELD_KEY);
4014         MainFixers.addElement(a);
4015 
4016         o = gui.PrComments.getBody();
4017         tf = new TextFixer((TextField)o);
4018         a = new Association(o, tf, TEXTFIELD_KEY);
4019         MainFixers.addElement(a);
4020 
4021         o = gui.PrPolicy.getBody();
4022         cf = new ChoiceFixer((Choice)o);
4023         a = new Association(o, cf, CHOICE_ITEM);
4024         MainFixers.addElement(a);
4025 
4026         o = gui.PrPassword.getBody();
4027         tf = new TextFixer((TextField)o);
4028         a = new Association(o, tf, TEXTFIELD_KEY);
4029         MainFixers.addElement(a);
4030 
4031         o = gui.PrExpiry.getBody();
4032         tf = new TextFixer((TextField)o);
4033         a = new Association(o, tf, TEXTFIELD_KEY);
4034         MainFixers.addElement(a);
4035 
4036         o = gui.EncList.getBody();
4037         tf = new TextFixer((TextField)o);
4038         a = new Association(o, tf, TEXTFIELD_KEY);
4039         MainFixers.addElement(a);
4040 
4041         o = gui.PrPwExpiry.getBody();
4042         tf = new TextFixer((TextField)o);
4043         a = new Association(o, tf, TEXTFIELD_KEY);
4044         MainFixers.addElement(a);
4045 
4046         o = gui.PrKvno.getBody();
4047         tf = new TextFixer((TextField)o);
4048         a = new Association(o, tf, TEXTFIELD_KEY);
4049         MainFixers.addElement(a);
4050 
4051         o = gui.PrMaxLifetime.getBody();
4052         tf = new TextFixer((TextField)o);
4053         a = new Association(o, tf, TEXTFIELD_KEY);
4054         MainFixers.addElement(a);
4055 
4056         o = gui.PrMaxRenewal.getBody();
4057         tf = new TextFixer((TextField)o);
4058         a = new Association(o, tf, TEXTFIELD_KEY);
4059         MainFixers.addElement(a);
4060 
4061         o = gui.PoListPattern.getBody();
4062         tf = new TextFixer((TextField)o);
4063         a = new Association(o, tf, TEXTFIELD_KEY);
4064         MainFixers.addElement(a);
4065 
4066         o = gui.PoName.getBody();
4067         tf = new TextFixer((TextField)o);
4068         a = new Association(o, tf, TEXTFIELD_KEY);
4069         MainFixers.addElement(a);
4070 
4071         o = gui.PoMinPwLength.getBody();
4072         cf = new ChoiceFixer((Choice)o);
4073         a = new Association(o, cf, CHOICE_ITEM);
4074         MainFixers.addElement(a);
4075 
4076         o = gui.PoMinPwClass.getBody();
4077         cf = new ChoiceFixer((Choice)o);
4078         a = new Association(o, cf, CHOICE_ITEM);
4079         MainFixers.addElement(a);
4080 
4081         o = gui.PoSavedPasswords.getBody();
4082         cf = new ChoiceFixer((Choice)o);
4083         a = new Association(o, cf, CHOICE_ITEM);
4084         MainFixers.addElement(a);
4085 
4086         o = gui.PoMinTicketLifetime.getBody();
4087         tf = new TextFixer((TextField)o);
4088         a = new Association(o, tf, TEXTFIELD_KEY);
4089         MainFixers.addElement(a);
4090 
4091         o = gui.PoMaxTicketLifetime.getBody();
4092         tf = new TextFixer((TextField)o);
4093         a = new Association(o, tf, TEXTFIELD_KEY);
4094         MainFixers.addElement(a);
4095 
4096         setListeners(MainFixers, true);
4097     }
4098 
4099     public void setupDefaultsNormalListeners() {
4100 
4101         if (defaultsNormal == null) {
4102             defaultsNormal = new Vector(10, 10);
4103             ActionListener al;
4104             ItemListener il;
4105             KeyListener kl = new KeystrokeDetector(DEFAULTS_EDITING);
4106             Association a;
4107             Object o;
4108 
4109             // Action listeners for Defaults
4110 
4111             il = new GlobalLockAcctAction();
4112             o = defaults.disableAccount;
4113             a = new Association(o, il, CHECKBOX_ITEM);
4114             defaultsNormal.addElement(a);
4115 
4116             il = new GlobalForcePwChangeAction();
4117             o = defaults.forcePasswordChange;
4118             a = new Association(o, il, CHECKBOX_ITEM);
4119             defaultsNormal.addElement(a);
4120 
4121             il = new GlobalAllowPostdatedAction();
4122             o = defaults.allowPostdatedTix;
4123             a = new Association(o, il, CHECKBOX_ITEM);
4124             defaultsNormal.addElement(a);
4125 
4126             il = new GlobalAllowForwardableAction();
4127             o = defaults.allowForwardableTix;
4128             a = new Association(o, il, CHECKBOX_ITEM);
4129             defaultsNormal.addElement(a);
4130 
4131             il = new GlobalAllowRenewableAction();
4132             o = defaults.allowRenewableTix;
4133             a = new Association(o, il, CHECKBOX_ITEM);
4134             defaultsNormal.addElement(a);
4135 
4136             il = new GlobalAllowProxiableAction();
4137             o = defaults.allowProxiableTix;
4138             a = new Association(o, il, CHECKBOX_ITEM);
4139             defaultsNormal.addElement(a);
4140 
4141             il = new GlobalAllowSvrAction();
4142             o = defaults.allowServiceTix;
4143             a = new Association(o, il, CHECKBOX_ITEM);
4144             defaultsNormal.addElement(a);
4145 
4146             il = new GlobalAllowTGTAction();
4147             o = defaults.allowTGTAuth;
4148             a = new Association(o, il, CHECKBOX_ITEM);
4149             defaultsNormal.addElement(a);
4150 
4151             il = new GlobalAllowDupAuthAction();
4152             o = defaults.allowDupAuth;
4153             a = new Association(o, il, CHECKBOX_ITEM);
4154             defaultsNormal.addElement(a);
4155 
4156             il = new GlobalRequirePreAuthAction();
4157             o = defaults.requirePreauth;
4158             a = new Association(o, il, CHECKBOX_ITEM);
4159             defaultsNormal.addElement(a);
4160 
4161             il = new GlobalRequireHwPreAuthAction();
4162             o = defaults.requireHWAuth;
4163             a = new Association(o, il, CHECKBOX_ITEM);
4164             defaultsNormal.addElement(a);
4165 
4166             il = new GlobalDefaultServerSideAction();
4167             o = defaults.serverSide;
4168             a = new Association(o, il, CHECKBOX_ITEM);
4169             defaultsNormal.addElement(a);
4170 
4171             al = new GlobalDefaultRenewableLifeAction();
4172             o = defaults.maxTicketRenewableLife;
4173             a = new Association(o, al, TEXTFIELD_ACTION);
4174             defaultsNormal.addElement(a);
4175             a = new Association(o, kl, TEXTFIELD_KEY);
4176             defaultsNormal.addElement(a);
4177 
4178             al = new GlobalDefaultLifeAction();
4179             o = defaults.maxTicketLife;
4180             a = new Association(o, al, TEXTFIELD_ACTION);
4181             defaultsNormal.addElement(a);
4182             a = new Association(o, kl, TEXTFIELD_KEY);
4183             defaultsNormal.addElement(a);
4184 
4185             al = new GlobalDefaultExpiryAction();
4186             o = defaults.accountExpiryDate;
4187             a = new Association(o, al, TEXTFIELD_ACTION);
4188             defaultsNormal.addElement(a);
4189             a = new Association(o, kl, TEXTFIELD_KEY);
4190             defaultsNormal.addElement(a);
4191 
4192             il = new GlobalDefaultShowListsAction();
4193             o = defaults.showLists;
4194             a = new Association(o, il, CHECKBOX_ITEM);
4195             defaultsNormal.addElement(a);
4196 
4197             il = new GlobalDefaultStaticListsAction();
4198             o = defaults.staticLists;
4199             a = new Association(o, il, CHECKBOX_ITEM);
4200             defaultsNormal.addElement(a);
4201 
4202             al = new GlobalDefaultCacheTimeAction();
4203             o = defaults.cacheTime;
4204             a = new Association(o, al, TEXTFIELD_ACTION);
4205             defaultsNormal.addElement(a);
4206             a = new Association(o, kl, TEXTFIELD_KEY);
4207             defaultsNormal.addElement(a);
4208 
4209             al = new GlobalSaveAction();
4210             o = defaults.saveButton;
4211             a = new Association(o, al, BUTTON_ACTION);
4212             defaultsNormal.addElement(a);
4213 
4214             al = new GlobalApplyAction();
4215             o = defaults.applyButton;
4216             a = new Association(o, al, BUTTON_ACTION);
4217             defaultsNormal.addElement(a);
4218 
4219             al = new GlobalCancelAction();
4220             o = defaults.cancelButton;
4221             a = new Association(o, al, BUTTON_ACTION);
4222             defaultsNormal.addElement(a);
4223 
4224             DateTimeListener dtl = new DateTimeListener(
4225 			defaults.accountExpiryDate, defaultsEditingFrame);
4226             o = defaults.dateMoreButton;
4227             a = new Association(o, dtl, BUTTON_ACTION);
4228             defaultsNormal.addElement(a);
4229 
4230             DurationListener dl = new DurationListener(
4231 		       defaults.maxTicketRenewableLife, defaultsEditingFrame);
4232             o = defaults.renewalMoreButton;
4233             a = new Association(o, dl, BUTTON_ACTION);
4234             defaultsNormal.addElement(a);
4235 
4236             dl = new DurationListener(defaults.maxTicketLife,
4237 				      defaultsEditingFrame);
4238             o = defaults.lifeMoreButton;
4239             a = new Association(o, dl, BUTTON_ACTION);
4240             defaultsNormal.addElement(a);
4241 
4242             dl = new DurationListener(defaults.cacheTime, defaultsEditingFrame);
4243             o = defaults.cacheMoreButton;
4244             a = new Association(o, dl, BUTTON_ACTION);
4245             defaultsNormal.addElement(a);
4246 
4247         }
4248         setListeners(defaultsHelp, false);
4249         setListeners(defaultsFixers, false);
4250         setListeners(defaultsNormal, true);
4251         defaultsHelpMode = false;
4252     }
4253 
4254     public void setupDefaultsHelpListeners() {
4255         if (defaultsHelp == null) {
4256             defaultsHelp = new Vector(10, 10);
4257             MouseListener ml = new HelpListener();
4258             Association a;
4259             Object o;
4260 
4261             o = defaults.disableAccount;
4262             a = new Association(o, ml, CHECKBOX_MOUSE);
4263             defaultsHelp.addElement(a);
4264             defaults.disableAccount.setName("GlobalLockAcct" /* NOI18N */);
4265 
4266             o = defaults.forcePasswordChange;
4267             a = new Association(o, ml, CHECKBOX_MOUSE);
4268             defaultsHelp.addElement(a);
4269             defaults.forcePasswordChange.setName("GlobalForcePwChange"
4270 						 /* NOI18N */);
4271 
4272             o = defaults.allowPostdatedTix;
4273             a = new Association(o, ml, CHECKBOX_MOUSE);
4274             defaultsHelp.addElement(a);
4275             defaults.allowPostdatedTix.setName("GlobalAllowPostdated"
4276 					       /* NOI18N */);
4277 
4278             o = defaults.allowForwardableTix;
4279             a = new Association(o, ml, CHECKBOX_MOUSE);
4280             defaultsHelp.addElement(a);
4281             defaults.allowForwardableTix.setName("GlobalAllowForwardable"
4282 						 /* NOI18N */);
4283 
4284             o = defaults.allowRenewableTix;
4285             a = new Association(o, ml, CHECKBOX_MOUSE);
4286             defaultsHelp.addElement(a);
4287             defaults.allowRenewableTix.setName("GlobalAllowRenewable"
4288 					       /* NOI18N */);
4289 
4290             o = defaults.allowProxiableTix;
4291             a = new Association(o, ml, CHECKBOX_MOUSE);
4292             defaultsHelp.addElement(a);
4293             defaults.allowProxiableTix.setName("GlobalAllowProxiable"
4294 					       /* NOI18N */);
4295 
4296             o = defaults.allowServiceTix;
4297             a = new Association(o, ml, CHECKBOX_MOUSE);
4298             defaultsHelp.addElement(a);
4299             defaults.allowServiceTix.setName("GlobalAllowSvr" /* NOI18N */);
4300 
4301             o = defaults.allowTGTAuth;
4302             a = new Association(o, ml, CHECKBOX_MOUSE);
4303             defaultsHelp.addElement(a);
4304             defaults.allowTGTAuth.setName("GlobalAllowTGT" /* NOI18N */);
4305 
4306             o = defaults.allowDupAuth;
4307             a = new Association(o, ml, CHECKBOX_MOUSE);
4308             defaultsHelp.addElement(a);
4309             defaults.allowDupAuth.setName("GlobalAllowDupAuth" /* NOI18N */);
4310 
4311             o = defaults.requirePreauth;
4312             a = new Association(o, ml, CHECKBOX_MOUSE);
4313             defaultsHelp.addElement(a);
4314             defaults.requirePreauth.setName("GlobalRequirePreAuth"
4315 					    /* NOI18N */);
4316 
4317             o = defaults.requireHWAuth;
4318             a = new Association(o, ml, CHECKBOX_MOUSE);
4319             defaultsHelp.addElement(a);
4320             defaults.requireHWAuth.setName("GlobalRequireHwPreAuth"
4321 					   /* NOI18N */);
4322 
4323             o = defaults.serverSide;
4324             a = new Association(o, ml, CHECKBOX_MOUSE);
4325             defaultsHelp.addElement(a);
4326             defaults.serverSide.setName("GlDefServerSide" /* NOI18N */);
4327 
4328             o = defaults.maxTicketRenewableLife;
4329             a = new Association(o, ml, TEXTFIELD_MOUSE);
4330             defaultsHelp.addElement(a);
4331             defaults.maxTicketRenewableLife.setName("GlDefRenewableLife"
4332 						    /* NOI18N */);
4333 
4334             o = defaults.maxTicketRenewableLifeLabel;
4335             a = new Association(o, ml, LABEL_MOUSE);
4336             defaultsHelp.addElement(a);
4337             defaults.maxTicketRenewableLifeLabel.setName("GlDefRenewableLife"
4338 							 /* NOI18N */);
4339 
4340             o = defaults.maxTicketLife;
4341             a = new Association(o, ml, TEXTFIELD_MOUSE);
4342             defaultsHelp.addElement(a);
4343             defaults.maxTicketLife.setName("GlDefLife" /* NOI18N */);
4344 
4345             o = defaults.maxTicketLifeLabel;
4346             a = new Association(o, ml, LABEL_MOUSE);
4347             defaultsHelp.addElement(a);
4348             defaults.maxTicketLifeLabel.setName("GlDefLife" /* NOI18N */);
4349 
4350             o = defaults.accountExpiryDate;
4351             a = new Association(o, ml, TEXTFIELD_MOUSE);
4352             defaultsHelp.addElement(a);
4353             defaults.accountExpiryDate.setName("GlDefExpiry" /* NOI18N */);
4354 
4355             o = defaults.accountExpiryDateLabel;
4356             a = new Association(o, ml, LABEL_MOUSE);
4357             defaultsHelp.addElement(a);
4358             defaults.accountExpiryDateLabel.setName("GlDefExpiry" /* NOI18N */);
4359 
4360             o = defaults.showLists;
4361             a = new Association(o, ml, CHECKBOX_MOUSE);
4362             defaultsHelp.addElement(a);
4363             defaults.showLists.setName("GlDefShowLists" /* NOI18N */);
4364 
4365             o = defaults.staticLists;
4366             a = new Association(o, ml, CHECKBOX_MOUSE);
4367             defaultsHelp.addElement(a);
4368             defaults.staticLists.setName("GlDefStaticLists" /* NOI18N */);
4369 
4370             o = defaults.cacheTime;
4371             a = new Association(o, ml, TEXTFIELD_MOUSE);
4372             defaultsHelp.addElement(a);
4373             defaults.cacheTime.setName("GlDefCacheTime" /* NOI18N */);
4374 
4375             o = defaults.cacheTimeLabel;
4376             a = new Association(o, ml, LABEL_MOUSE);
4377             defaultsHelp.addElement(a);
4378             defaults.cacheTimeLabel.setName("GlDefCacheTime" /* NOI18N */);
4379 
4380             o = defaults.saveButton;
4381             a = new Association(o, ml, BUTTON_MOUSE);
4382             defaultsHelp.addElement(a);
4383             defaults.saveButton.setName("GlobalSave" /* NOI18N */);
4384 
4385             o = defaults.applyButton;
4386             a = new Association(o, ml, BUTTON_MOUSE);
4387             defaultsHelp.addElement(a);
4388             defaults.applyButton.setName("GlobalApply" /* NOI18N */);
4389 
4390             o = defaults.cancelButton;
4391             a = new Association(o, ml, BUTTON_MOUSE);
4392             defaultsHelp.addElement(a);
4393             defaults.cancelButton.setName("GlobalCancel" /* NOI18N */);
4394 
4395             o = defaults.dateMoreButton;
4396             a = new Association(o, ml, BUTTON_MOUSE);
4397             defaultsHelp.addElement(a);
4398             defaults.dateMoreButton.setName("DateHelperButton" /* NOI18N */);
4399 
4400             o = defaults.lifeMoreButton;
4401             a = new Association(o, ml, BUTTON_MOUSE);
4402             defaultsHelp.addElement(a);
4403             defaults.lifeMoreButton.setName("DurationHelperButton"
4404 					    /* NOI18N */);
4405 
4406             o = defaults.renewalMoreButton;
4407             a = new Association(o, ml, BUTTON_MOUSE);
4408             defaultsHelp.addElement(a);
4409             defaults.renewalMoreButton.setName("DurationHelperButton"
4410 					       /* NOI18N */);
4411 
4412             o = defaults.cacheMoreButton;
4413             a = new Association(o, ml, BUTTON_MOUSE);
4414             defaultsHelp.addElement(a);
4415             defaults.cacheMoreButton.setName("DurationHelperButton"
4416 					     /* NOI18N */);
4417 
4418             setupDefaultsHelpFlagTogglers();
4419         }
4420 
4421         setListeners(defaultsNormal, false);
4422         setListeners(defaultsHelp, true);
4423         setupDefaultsHelpFixers();
4424         defaultsHelpMode = true;
4425     }
4426 
4427     /**
4428      * Helper method to setupDefaultsHelpListeners. Should be called from
4429      * only from there.
4430      */
4431     private void 	setupDefaultsHelpFlagTogglers() {
4432 
4433         if (defaultsHelp == null)
4434             return;
4435 
4436         CheckboxToggler ml = new CheckboxToggler();
4437         Object o;
4438         Association a;
4439 
4440         o = defaults.disableAccount;
4441         a = new Association(o, ml, CHECKBOX_MOUSE);
4442         defaultsHelp.addElement(a);
4443 
4444         o = defaults.forcePasswordChange;
4445         a = new Association(o, ml, CHECKBOX_MOUSE);
4446         defaultsHelp.addElement(a);
4447 
4448         o = defaults.allowPostdatedTix;
4449         a = new Association(o, ml, CHECKBOX_MOUSE);
4450         defaultsHelp.addElement(a);
4451 
4452         o = defaults.allowForwardableTix;
4453         a = new Association(o, ml, CHECKBOX_MOUSE);
4454         defaultsHelp.addElement(a);
4455 
4456         o = defaults.allowRenewableTix;
4457         a = new Association(o, ml, CHECKBOX_MOUSE);
4458         defaultsHelp.addElement(a);
4459 
4460         o = defaults.allowProxiableTix;
4461         a = new Association(o, ml, CHECKBOX_MOUSE);
4462         defaultsHelp.addElement(a);
4463 
4464         o = defaults.allowServiceTix;
4465         a = new Association(o, ml, CHECKBOX_MOUSE);
4466         defaultsHelp.addElement(a);
4467 
4468         o = defaults.allowTGTAuth;
4469         a = new Association(o, ml, CHECKBOX_MOUSE);
4470         defaultsHelp.addElement(a);
4471 
4472         o = defaults.allowDupAuth;
4473         a = new Association(o, ml, CHECKBOX_MOUSE);
4474         defaultsHelp.addElement(a);
4475 
4476         o = defaults.requirePreauth;
4477         a = new Association(o, ml, CHECKBOX_MOUSE);
4478         defaultsHelp.addElement(a);
4479 
4480         o = defaults.requireHWAuth;
4481         a = new Association(o, ml, CHECKBOX_MOUSE);
4482         defaultsHelp.addElement(a);
4483 
4484         o = defaults.showLists;
4485         a = new Association(o, ml, CHECKBOX_MOUSE);
4486         defaultsHelp.addElement(a);
4487 
4488         o = defaults.serverSide;
4489         a = new Association(o, ml, CHECKBOX_MOUSE);
4490         defaultsHelp.addElement(a);
4491 
4492         o = defaults.staticLists;
4493         a = new Association(o, ml, CHECKBOX_MOUSE);
4494         defaultsHelp.addElement(a);
4495     }
4496 
4497     public void setupDefaultsHelpFixers() {
4498         defaultsFixers = new Vector(10, 10);
4499         Association a;
4500         Object o;
4501         TextFixer tf;
4502 
4503         o = defaults.maxTicketRenewableLife;
4504         tf = new TextFixer((TextField)o);
4505         a = new Association(o, tf, TEXTFIELD_KEY);
4506         defaultsFixers.addElement(a);
4507 
4508         o = defaults.maxTicketLife;
4509         tf = new TextFixer((TextField)o);
4510         a = new Association(o, tf, TEXTFIELD_KEY);
4511         defaultsFixers.addElement(a);
4512 
4513         o = defaults.accountExpiryDate;
4514         tf = new TextFixer((TextField)o);
4515         a = new Association(o, tf, TEXTFIELD_KEY);
4516         defaultsFixers.addElement(a);
4517 
4518         o = defaults.cacheTime;
4519         tf = new TextFixer((TextField)o);
4520         a = new Association(o, tf, TEXTFIELD_KEY);
4521         defaultsFixers.addElement(a);
4522 
4523         setListeners(defaultsFixers, true);
4524     }
4525 
4526     /**
4527      * Set up listeners from a vector of Associations objects
4528      *
4529      */
4530     public void setListeners(Vector associations, boolean install) {
4531         setListeners(associations, install, false);
4532     }
4533 
4534     public void setListeners(Vector associations, boolean install, boolean loud)
4535     {
4536         Association a;
4537         Button b;
4538         TextField t;
4539         Choice c;
4540         Checkbox x;
4541         Label z;
4542         Window w;
4543 
4544         if (associations != null) {
4545             for (int i = 0; i < associations.size(); i++) {
4546                 a = (Association)associations.elementAt(i);
4547                 int type = a.Type;
4548                 EventListener el = a.Listener;
4549                 if (loud) {
4550                     Object o = a.Object;
4551                     String flag = install ? "install" : "deinstall";
4552                     System.out.println(flag+
4553 				       "ing listener "+el+" on component "+o);
4554                 }
4555 
4556                 switch (type) {
4557 		case BUTTON_ACTION:
4558                     b = (Button)a.Object;
4559                     if (install)
4560                         b.addActionListener((ActionListener)el);
4561                     else
4562                         b.removeActionListener((ActionListener)el);
4563                     break;
4564 
4565 		case BUTTON_MOUSE:
4566                     b = (Button)a.Object;
4567                     if (install)
4568                         b.addMouseListener((MouseListener)el);
4569                     else
4570                         b.removeMouseListener((MouseListener)el);
4571                     break;
4572 
4573 		case TEXTFIELD_ACTION:
4574                     t = (TextField)a.Object;
4575                     if (install)
4576                         t.addActionListener((ActionListener)el);
4577                     else
4578                         t.removeActionListener((ActionListener)el);
4579                     break;
4580 
4581 		case TEXTFIELD_MOUSE:
4582                     t = (TextField)a.Object;
4583                     if (install)
4584                         t.addMouseListener((MouseListener)el);
4585                     else
4586                         t.removeMouseListener((MouseListener)el);
4587                     break;
4588 
4589 		case TEXTFIELD_KEY:
4590                     t = (TextField)a.Object;
4591                     if (install)
4592                         t.addKeyListener((KeyListener)el);
4593                     else
4594                         t.removeKeyListener((KeyListener)el);
4595                     break;
4596 
4597 		case CHOICE_ITEM:
4598                     c = (Choice)a.Object;
4599                     if (install)
4600                         c.addItemListener((ItemListener)el);
4601                     else
4602                         c.removeItemListener((ItemListener)el);
4603                     break;
4604 
4605 		case CHOICE_MOUSE:
4606                     c = (Choice)a.Object;
4607                     if (install)
4608                         c.addMouseListener((MouseListener)el);
4609                     else
4610                         c.removeMouseListener((MouseListener)el);
4611                     break;
4612 
4613 		case CHECKBOX_ITEM:
4614                     x = (Checkbox)a.Object;
4615                     if (install)
4616                         x.addItemListener((ItemListener)el);
4617                     else
4618                         x.removeItemListener((ItemListener)el);
4619                     break;
4620 
4621 		case CHECKBOX_MOUSE:
4622                     x = (Checkbox)a.Object;
4623                     if (install)
4624                         x.addMouseListener((MouseListener)el);
4625                     else
4626                         x.removeMouseListener((MouseListener)el);
4627                     break;
4628 
4629 		case LABEL_MOUSE:
4630                     z = (Label)a.Object;
4631                     if (install)
4632                         z.addMouseListener((MouseListener)el);
4633                     else
4634                         z.removeMouseListener((MouseListener)el);
4635                     break;
4636 
4637 		case WINDOW_LISTENER:
4638                     w = (Window)a.Object;
4639                     if (install)
4640                         w.addWindowListener((WindowListener)el);
4641                     else
4642                         w.removeWindowListener((WindowListener)el);
4643                     break;
4644                 }
4645             }
4646         }
4647     }
4648 
4649     /*
4650      * About a million actions here ...
4651      */
4652     private class LoginOKAction implements ActionListener {
4653         public void actionPerformed(ActionEvent e) {
4654             loginComplete();
4655         }
4656     }
4657 
4658     private class LoginStartOverAction implements ActionListener {
4659         public void actionPerformed(ActionEvent e) {
4660             setLoginDefaults();
4661         }
4662     }
4663 
4664     private class LoginNameAction implements ActionListener {
4665         public void actionPerformed(ActionEvent e) {
4666             nameComplete();
4667         }
4668     }
4669 
4670     private class LoginPassAction implements ActionListener {
4671         public void actionPerformed(ActionEvent e) {
4672             loginComplete();
4673         }
4674     }
4675 
4676     private class LoginRealmAction implements ActionListener {
4677         public void actionPerformed(ActionEvent e) {
4678             newRealm();
4679         }
4680     }
4681 
4682     private class LoginServerAction implements ActionListener {
4683         public void actionPerformed(ActionEvent e) {
4684             newServer();
4685         }
4686     }
4687 
4688     private class MainWindowCloseAction extends WindowAdapter {
4689         public void windowClosing(WindowEvent e) {
4690             checkLogout();
4691         }
4692     };
4693 
4694     private class PrListPatternAction implements ActionListener {
4695         public void actionPerformed(ActionEvent e) {
4696             prPatternComplete();
4697         }
4698     }
4699 
4700     private class PrListClearAction implements ActionListener {
4701         public void actionPerformed(ActionEvent e) {
4702             prPatternClear();
4703         }
4704     }
4705 
4706     private class PrListModifyAction implements ActionListener {
4707         public void actionPerformed(ActionEvent e) {
4708             prModify();
4709         }
4710     }
4711 
4712     private class PrListAddAction implements ActionListener {
4713         public void actionPerformed(ActionEvent e) {
4714             prAdd();
4715         }
4716     }
4717 
4718     private class PrListDeleteAction implements ActionListener {
4719         public void actionPerformed(ActionEvent e) {
4720             prDelete();
4721         }
4722     }
4723 
4724     private class PrListDuplicateAction implements ActionListener {
4725         public void actionPerformed(ActionEvent e) {
4726             prDuplicate();
4727         }
4728     }
4729 
4730     private class PrCommentsAction implements ActionListener {
4731         public void actionPerformed(ActionEvent e) {
4732             setPrComments();
4733             prSetNeedSave();
4734         }
4735     }
4736 
4737     private class PrPolicyAction implements ItemListener {
4738         public void itemStateChanged(ItemEvent e) {
4739             setPrPolicy();
4740             prSetNeedSave();
4741         }
4742     }
4743 
4744     private class PrPasswordAction implements ActionListener {
4745         public void actionPerformed(ActionEvent e) {
4746             setPrPassword(!prin.isNew);
4747             prSetNeedSave();
4748         }
4749     }
4750 
4751     private class PrRandomPwAction implements ActionListener {
4752         public void actionPerformed(ActionEvent e) {
4753             genRandomPassword();
4754             prSetNeedSave();
4755         }
4756     }
4757 
4758     private class EncListAction implements ActionListener {
4759         public void actionPerformed(ActionEvent e) {
4760             setEncType();
4761             prSetNeedSave();
4762         }
4763     }
4764 
4765     private class PrExpiryAction implements ActionListener {
4766         public void actionPerformed(ActionEvent e) {
4767             setPrExpiry();
4768             prSetNeedSave();
4769         }
4770     }
4771 
4772     private class PrSaveAction implements ActionListener {
4773         public void actionPerformed(ActionEvent e) {
4774             prSave();
4775         }
4776     }
4777 
4778     private class PrCancelAction implements ActionListener {
4779         public void actionPerformed(ActionEvent e) {
4780             prCancel();
4781         }
4782     }
4783 
4784     private class PrBasicPreviousAction implements ActionListener {
4785         public void actionPerformed(ActionEvent e) {
4786             prBasicPrevious();
4787         }
4788     }
4789 
4790     private class PrBasicNextAction implements ActionListener {
4791         public void actionPerformed(ActionEvent e) {
4792             prBasicNext();
4793         }
4794     }
4795 
4796     private class PrPwExpiryAction implements ActionListener {
4797         public void actionPerformed(ActionEvent e) {
4798             setPrPwExpiry();
4799             prSetNeedSave();
4800         }
4801     }
4802 
4803     private class PrKvnoAction implements ActionListener {
4804         public void actionPerformed(ActionEvent e) {
4805             setPrKvno();
4806             prSetNeedSave();
4807         }
4808     }
4809 
4810     private class PrMaxLifetimeAction implements ActionListener {
4811         public void actionPerformed(ActionEvent e) {
4812             setPrMaxlife();
4813             prSetNeedSave();
4814         }
4815     }
4816 
4817     private class PrMaxRenewalAction implements ActionListener {
4818         public void actionPerformed(ActionEvent e) {
4819             setPrMaxrenew();
4820             prSetNeedSave();
4821         }
4822     }
4823 
4824     private class PrDetailPreviousAction implements ActionListener {
4825         public void actionPerformed(ActionEvent e) {
4826             prDetailPrevious();
4827         }
4828     }
4829 
4830     private class PrDetailNextAction implements ActionListener {
4831         public void actionPerformed(ActionEvent e) {
4832             prDetailNext();
4833         }
4834     }
4835 
4836     private class PrFlagsPreviousAction implements ActionListener {
4837         public void actionPerformed(ActionEvent e) {
4838             prFlagsPrevious();
4839         }
4840     }
4841 
4842     private class PrLockAcctAction implements ItemListener {
4843         public void itemStateChanged(ItemEvent e) {
4844             setPrFlag(Flags.DISALLOW_ALL_TIX);
4845             prSetNeedSave();
4846         }
4847     }
4848 
4849     private class PrForcePwChangeAction implements ItemListener {
4850         public void itemStateChanged(ItemEvent e) {
4851             setPrFlag(Flags.REQUIRES_PWCHANGE);
4852             prSetNeedSave();
4853         }
4854     }
4855 
4856     private class PrAllowPostdatedAction implements ItemListener {
4857         public void itemStateChanged(ItemEvent e) {
4858             setPrFlag(Flags.DISALLOW_POSTDATED);
4859             prSetNeedSave();
4860         }
4861     }
4862 
4863     private class PrAllowForwardableAction implements ItemListener {
4864         public void itemStateChanged(ItemEvent e) {
4865             setPrFlag(Flags.DISALLOW_FORWARDABLE);
4866             prSetNeedSave();
4867         }
4868     }
4869 
4870     private class PrAllowRenewableAction implements ItemListener {
4871         public void itemStateChanged(ItemEvent e) {
4872             setPrFlag(Flags.DISALLOW_RENEWABLE);
4873             prSetNeedSave();
4874         }
4875     }
4876 
4877     private class PrAllowProxiableAction implements ItemListener {
4878         public void itemStateChanged(ItemEvent e) {
4879             setPrFlag(Flags.DISALLOW_PROXIABLE);
4880             prSetNeedSave();
4881         }
4882     }
4883 
4884     private class PrAllowSvrAction implements ItemListener {
4885         public void itemStateChanged(ItemEvent e) {
4886             setPrFlag(Flags.DISALLOW_SVR);
4887             prSetNeedSave();
4888         }
4889     }
4890 
4891     private class PrAllowTGTAction implements ItemListener {
4892         public void itemStateChanged(ItemEvent e) {
4893             setPrFlag(Flags.DISALLOW_TGT_BASED);
4894             prSetNeedSave();
4895         }
4896     }
4897 
4898     private class PrAllowDupAuthAction implements ItemListener {
4899         public void itemStateChanged(ItemEvent e) {
4900             setPrFlag(Flags.DISALLOW_DUP_SKEY);
4901             prSetNeedSave();
4902         }
4903     }
4904 
4905     private class PrRequirePreAuthAction implements ItemListener {
4906         public void itemStateChanged(ItemEvent e) {
4907             setPrFlag(Flags.REQUIRE_PRE_AUTH);
4908             prSetNeedSave();
4909         }
4910     }
4911 
4912     private class PrRequireHwPreAuthAction implements ItemListener {
4913         public void itemStateChanged(ItemEvent e) {
4914             setPrFlag(Flags.REQUIRE_HW_AUTH);
4915             prSetNeedSave();
4916         }
4917     }
4918 
4919     private class PrFlagsNextAction implements ActionListener {
4920         public void actionPerformed(ActionEvent e) {
4921             prFlagsDone();
4922         }
4923     }
4924 
4925     private class PoListPatternAction implements ActionListener {
4926         public void actionPerformed(ActionEvent e) {
4927             poPatternComplete();
4928         }
4929     }
4930 
4931     private class PoListClearAction implements ActionListener {
4932         public void actionPerformed(ActionEvent e) {
4933             poPatternClear();
4934         }
4935     }
4936 
4937     private class PoListModifyAction implements ActionListener {
4938         public void actionPerformed(ActionEvent e) {
4939             poSelected();
4940         }
4941     }
4942 
4943     private class PoListAddAction implements ActionListener {
4944         public void actionPerformed(ActionEvent e) {
4945             poAdd();
4946         }
4947     }
4948 
4949     private class PoListDeleteAction implements ActionListener {
4950         public void actionPerformed(ActionEvent e) {
4951             poDelete();
4952         }
4953     }
4954 
4955     private class PoListDuplicateAction implements ActionListener {
4956         public void actionPerformed(ActionEvent e) {
4957             poDuplicate();
4958         }
4959     }
4960 
4961     private class PoMinPwLengthAction implements ItemListener {
4962         public void itemStateChanged(ItemEvent e) {
4963             setPolPwLength();
4964             poSetNeedSave();
4965         }
4966     }
4967 
4968     private class PoMinPwClassAction implements ItemListener {
4969         public void itemStateChanged(ItemEvent e) {
4970             setPolPwClasses();
4971             poSetNeedSave();
4972         }
4973     }
4974 
4975     private class PoSavedPasswordsAction implements ItemListener {
4976         public void itemStateChanged(ItemEvent e) {
4977             setPolPwHistory();
4978             poSetNeedSave();
4979         }
4980     }
4981 
4982     private class PoMinTicketLifetimeAction implements ActionListener {
4983         public void actionPerformed(ActionEvent e) {
4984             setPolMinlife();
4985             poSetNeedSave();
4986         }
4987     }
4988 
4989     private class PoMaxTicketLifetimeAction implements ActionListener {
4990         public void actionPerformed(ActionEvent e) {
4991             setPolMaxlife();
4992             poSetNeedSave();
4993         }
4994     }
4995 
4996     private class PoSaveAction implements ActionListener {
4997         public void actionPerformed(ActionEvent e) {
4998             poSave();
4999         }
5000     }
5001 
5002     private class PoCancelAction implements ActionListener {
5003         public void actionPerformed(ActionEvent e) {
5004             poCancel();
5005         }
5006     }
5007 
5008     private class PoPreviousAction implements ActionListener {
5009         public void actionPerformed(ActionEvent e) {
5010             polPrevious();
5011         }
5012     }
5013 
5014     private class PoDoneAction implements ActionListener {
5015         public void actionPerformed(ActionEvent e) {
5016             polDone();
5017         }
5018     }
5019 
5020     private class GlobalLockAcctAction implements ItemListener {
5021         public void itemStateChanged(ItemEvent e) {
5022             setGlobalFlag(Flags.DISALLOW_ALL_TIX);
5023         }
5024     }
5025 
5026     private class GlobalForcePwChangeAction implements ItemListener {
5027         public void itemStateChanged(ItemEvent e) {
5028             setGlobalFlag(Flags.REQUIRES_PWCHANGE);
5029         }
5030     }
5031 
5032     private class GlobalAllowPostdatedAction implements ItemListener {
5033         public void itemStateChanged(ItemEvent e) {
5034             setGlobalFlag(Flags.DISALLOW_POSTDATED);
5035         }
5036     }
5037 
5038     private class GlobalAllowForwardableAction implements ItemListener {
5039         public void itemStateChanged(ItemEvent e) {
5040             setGlobalFlag(Flags.DISALLOW_FORWARDABLE);
5041         }
5042     }
5043 
5044     private class GlobalAllowRenewableAction implements ItemListener {
5045         public void itemStateChanged(ItemEvent e) {
5046             setGlobalFlag(Flags.DISALLOW_RENEWABLE);
5047         }
5048     }
5049 
5050     private class GlobalAllowProxiableAction implements ItemListener {
5051         public void itemStateChanged(ItemEvent e) {
5052             setGlobalFlag(Flags.DISALLOW_PROXIABLE);
5053         }
5054     }
5055 
5056     private class GlobalAllowSvrAction implements ItemListener {
5057         public void itemStateChanged(ItemEvent e) {
5058             setGlobalFlag(Flags.DISALLOW_SVR);
5059         }
5060     }
5061 
5062     private class GlobalAllowTGTAction implements ItemListener {
5063         public void itemStateChanged(ItemEvent e) {
5064             setGlobalFlag(Flags.DISALLOW_TGT_BASED);
5065         }
5066     }
5067 
5068     private class GlobalAllowDupAuthAction implements ItemListener {
5069         public void itemStateChanged(ItemEvent e) {
5070             setGlobalFlag(Flags.DISALLOW_DUP_SKEY);
5071         }
5072     }
5073 
5074     private class GlobalRequirePreAuthAction implements ItemListener {
5075         public void itemStateChanged(ItemEvent e) {
5076             setGlobalFlag(Flags.REQUIRE_PRE_AUTH);
5077         }
5078     }
5079 
5080     private class GlobalRequireHwPreAuthAction implements ItemListener {
5081         public void itemStateChanged(ItemEvent e) {
5082             setGlobalFlag(Flags.REQUIRE_HW_AUTH);
5083         }
5084     }
5085 
5086     private class GlobalDefaultServerSideAction implements ItemListener {
5087         public void itemStateChanged(ItemEvent e) {
5088             setServerSide();
5089         }
5090     }
5091 
5092     private class GlobalDefaultRenewableLifeAction implements ActionListener {
5093         public void actionPerformed(ActionEvent e) {
5094             if (!setGlobalMaxrenew()) {
5095                 ((TextField)e.getSource()).requestFocus();
5096             }
5097         }
5098     }
5099 
5100     private class GlobalDefaultLifeAction implements ActionListener {
5101         public void actionPerformed(ActionEvent e) {
5102             if (!setGlobalMaxlife()) {
5103                 ((TextField)e.getSource()).requestFocus();
5104             }
5105         }
5106     }
5107 
5108     private class GlobalDefaultExpiryAction implements ActionListener {
5109         public void actionPerformed(ActionEvent e) {
5110             if (!setGlobalExpiry())
5111                 ((TextField)e.getSource()).requestFocus();
5112         }
5113     }
5114 
5115     private class GlobalDefaultShowListsAction implements ItemListener {
5116         public void itemStateChanged(ItemEvent e) {
5117             setShowLists();
5118         }
5119     }
5120 
5121     private class GlobalDefaultStaticListsAction implements ItemListener {
5122         public void itemStateChanged(ItemEvent e) {
5123             setStaticLists();
5124         }
5125     }
5126 
5127     private class GlobalDefaultCacheTimeAction implements ActionListener {
5128         public void actionPerformed(ActionEvent e) {
5129             setCacheTime();
5130         }
5131     }
5132 
5133     private class GlobalSaveAction implements ActionListener {
5134         public void actionPerformed(ActionEvent e) {
5135             glSave();
5136         }
5137     }
5138 
5139     private class GlobalApplyAction implements ActionListener {
5140         public void actionPerformed(ActionEvent e) {
5141             glApply();
5142         }
5143     }
5144 
5145     private class GlobalCancelAction implements ActionListener {
5146         public void actionPerformed(ActionEvent e) {
5147             glCancel();
5148         }
5149     }
5150 
5151     private class HelpListener extends MouseAdapter {
5152         public void mouseClicked(MouseEvent e) {
5153             showHelp(e.getComponent().getName());
5154         }
5155     }
5156 
5157     private class CheckboxToggler extends MouseAdapter {
5158         public void mouseClicked(MouseEvent e) {
5159             if (e.getComponent() instanceof Checkbox) {
5160                 Checkbox cb = (Checkbox)e.getComponent();
5161                 cb.setState(!cb.getState());
5162             }
5163         }
5164     }
5165 
5166     private class ChoiceFixer implements ItemListener {
5167         private Choice c;
5168         private String s;
5169 
5170         ChoiceFixer(Choice c) {
5171             this.c = c;
5172             s = c.getSelectedItem();
5173             // System.out.println("CF: Saving string "+s);
5174         }
5175 
5176         public void itemStateChanged(ItemEvent e) {
5177             if (e.getSource() == c && !c.getSelectedItem().equals(s))
5178                 c.select(s);
5179             // System.out.println("CF: Restoring string "+s);
5180         }
5181     }
5182 
5183     private class TextFixer extends KeyAdapter {
5184         private TextField t;
5185         private String s;
5186 
5187         TextFixer(TextField t) {
5188             this.t = t;
5189             s = t.getText();
5190             // System.out.println("TF: Saving string "+s);
5191         }
5192 
5193         public void keyTyped(KeyEvent e) {
5194             if (e.getSource() == t)
5195                 t.setText(s);
5196             // System.out.println("TF: Restoring string "+s);
5197         }
5198     }
5199 
5200     /*
5201      * End of the million listeners
5202      */
5203 
5204     /**
5205      * Call rb.getString(), but catch exception and returns English
5206      * key so that small spelling errors don't cripple the GUI
5207      *
5208      */
5209     private static final String getString(String key) {
5210         try {
5211             String res = rb.getString(key);
5212             return res;
5213         } catch (MissingResourceException e) {
5214             System.out.println("Missing resource "+key+", using English.");
5215             return key;
5216         }
5217     }
5218 
5219     private static final String getHelpString(String key) {
5220         String res;
5221         try {
5222             res = hrb.getString(key);
5223         } catch (MissingResourceException e) {
5224             res = "Missing help on key "+key;
5225         }
5226         return res;
5227     }
5228 
5229 
5230     /**
5231      * Check the privileges this principal has to see what we should not try.
5232      */
5233     private boolean checkPrivs() {
5234         boolean okay = true;
5235         String lpriv = (((privs & PRIV_ADD) == 0) ? "A" : "a")
5236 	    + (((privs & PRIV_DELETE) == 0) ? "D" : "d")
5237 	    + (((privs & PRIV_MODIFY) == 0) ? "M" : "m")
5238 	    + (((privs & PRIV_CHANGEPW) == 0) ? "C" : "c")
5239 	    + (((privs & PRIV_INQUIRE) == 0) ? "I" : "i")
5240 	    + (((privs & PRIV_LIST) == 0) ? "L" : "l");
5241         // System.out.println("Privileges are "+lpriv+" "
5242         // 			+(new Integer(privs).toString()));
5243         /**
5244          * Having modify is not useful if we can't either add or see
5245          * old values
5246          */
5247         if ((privs & (PRIV_MODIFY | PRIV_INQUIRE | PRIV_ADD)) == PRIV_MODIFY)
5248             okay = false;
5249         /* Having changepw without inquire is not useful */
5250         if (privs == PRIV_CHANGEPW)
5251             okay = false;
5252         if (!okay) {
5253             showLoginError(
5254 		   getString("Insufficient privileges to use gkadmin: ")+lpriv
5255 			   +getString(" Please try using another principal."));
5256             return false;
5257         }
5258         return true;
5259     }
5260 
5261     /*
5262      * Try to cope with the privileges we have.
5263      */
5264     private void reactToPrivs() {
5265         Boolean off = new Boolean(false);
5266 
5267         /*
5268          * If we don't have the Add privilege, we turn off "Create New"
5269          * and "Duplicate".  "Duplicate" is also handled in prSelValid/
5270          * poSelValid because it's sensitive to selection from the lists.
5271          */
5272         if ((privs & PRIV_ADD) == 0) {
5273             // System.out.println("Disabling Create New buttons");
5274             gui.PrListAdd.set("enabled" /* NOI18N */, off);
5275             gui.PoListAdd.set("enabled" /* NOI18N */, off);
5276             gui.PrListDuplicate.set("enabled" /* NOI18N */, off);
5277             gui.PoListDuplicate.set("enabled" /* NOI18N */, off);
5278         }
5279 
5280         /*
5281          * If we don't have the Delete privilege, we turn off "Delete".
5282          * This is also done in prSelValid/poSelValid because it is
5283          * thought about when a list item is selected.
5284          */
5285         if ((privs & PRIV_DELETE) == 0) {
5286             // System.out.println("Disabling Delete buttons");
5287             gui.PrListDelete.set("enabled" /* NOI18N */, off);
5288             gui.PoListDelete.set("enabled" /* NOI18N */, off);
5289         }
5290 
5291         /*
5292          * If we don't have changepw, disable textfield and random button.
5293          * Add needs to turn this on again for an add operation only.
5294          */
5295         if ((privs & PRIV_CHANGEPW) == 0) {
5296             // System.out.println("Disabling password components");
5297             gui.PrPassword.set("enabled" /* NOI18N */, off);
5298             gui.PrBasicRandomPw.set("enabled" /* NOI18N */, off);
5299             gui.EncList.set("enabled" /* NOI18N */, off);
5300         }
5301 
5302         /*
5303          * If we don't have inquire, we can't get an existing principal
5304          * to duplicate, and permitting modification seems a bad idea.
5305          * We can still use the panels if we can add.  These will also
5306          * get dealt with in prSelValid/poSelValid.
5307          */
5308         if ((privs & PRIV_INQUIRE) == 0) {
5309             // System.out.println("Disabling Modify buttons");
5310             gui.PrListModify.set("enabled" /* NOI18N */, off);
5311             gui.PoListModify.set("enabled" /* NOI18N */, off);
5312             gui.PrListDuplicate.set("enabled" /* NOI18N */, off);
5313             gui.PoListDuplicate.set("enabled" /* NOI18N */, off);
5314         }
5315 
5316         /*
5317          * If we don't have Modify or Add but do have Inquire, we want to
5318          * turn off save and cancel buttons, as well as all principal and
5319          * policy components to prevent any changes.
5320          */
5321         if ((privs & (PRIV_MODIFY | PRIV_ADD)) == 0) {
5322             // System.out.println("Disabling attribute components");
5323             enablePrAttributes(off);
5324             enablePoAttributes(off);
5325         }
5326 
5327         /*
5328          * We may have no list privs, or we may have turned off lists.
5329          * Set things up accordingly.
5330          */
5331         noLists = ((privs & PRIV_LIST) == 0 || !defaults.getShowLists());
5332         fixListPanels();
5333     }
5334 
5335     private void fixListPanels() {
5336         /*
5337          * If we can't use lists, we won't fetch lists, which means the
5338          * only way to get a principal is to type something into the
5339          * list pattern field.  Relabel those so they work better.
5340          */
5341         String s;
5342         Boolean yes = new Boolean(true);
5343         Boolean no = new Boolean(false);
5344         if (noLists) {
5345             // System.out.println("Hijacking list pattern stuff");
5346             gui.PrListLabel.set("enabled" /* NOI18N */, no);
5347             gui.PoListLabel.set("enabled" /* NOI18N */, no);
5348             s = getString("Principal Name:");
5349             gui.PrSearchLab.set("text" /* NOI18N */, s);
5350             s = getString("Policy Name:");
5351             gui.PoListPatternLabel.set("text" /* NOI18N */, s);
5352             s = getString("Clear Name");
5353             gui.PrListClear.set("text" /* NOI18N */, s);
5354             gui.PoListClear.set("text" /* NOI18N */, s);
5355             gui.Prlist.set("enabled", no);
5356             gui.Pollist.set("enabled", no);
5357             gui.refreshPrincipals.set("enabled", no);
5358             gui.refreshPolicies.set("enabled", no);
5359             gui.Prlist.set("selectedItem" /* NOI18N */, null);
5360             gui.Pollist.set("selectedItem" /* NOI18N */, null);
5361             gui.PrintPrlist.set("enabled" /* NOI18N */, no);
5362             gui.PrintPollist.set("enabled" /* NOI18N */, no);
5363         } else {
5364             gui.PrListLabel.set("enabled" /* NOI18N */, yes);
5365             gui.PoListLabel.set("enabled" /* NOI18N */, yes);
5366             s = getString("Filter Pattern:");
5367             gui.PrSearchLab.set("text" /* NOI18N */, s);
5368             gui.PoListPatternLabel.set("text" /* NOI18N */, s);
5369             s = getString("Clear Filter");
5370             gui.PrListClear.set("text" /* NOI18N */, s);
5371             gui.PoListClear.set("text" /* NOI18N */, s);
5372             gui.Prlist.set("enabled", yes);
5373             gui.Pollist.set("enabled", yes);
5374             gui.refreshPrincipals.set("enabled", yes);
5375             gui.refreshPolicies.set("enabled", yes);
5376             gui.PrintPrlist.set("enabled", yes);
5377             gui.PrintPollist.set("enabled", yes);
5378         }
5379     }
5380 
5381     private void enablePrAttributes(Boolean sense) {
5382         // Basics
5383         gui.PrPolicy.set("enabled" /* NOI18N */, sense);
5384         gui.PrExpiry.set("enabled" /* NOI18N */, sense);
5385         gui.EncList.set("enabled" /* NOI18N */, sense);
5386         gui.PrComments.set("enabled" /* NOI18N */, sense);
5387         // Details
5388         gui.PrPwExpiry.set("enabled" /* NOI18N */, sense);
5389         gui.PrKvno.set("enabled" /* NOI18N */, sense);
5390         gui.PrMaxLifetime.set("enabled" /* NOI18N */, sense);
5391         gui.PrMaxRenewal.set("enabled" /* NOI18N */, sense);
5392         // Flags
5393         gui.PrLockAcct.set("enabled" /* NOI18N */, sense);
5394         gui.PrForcePwChange.set("enabled" /* NOI18N */, sense);
5395         gui.PrAllowPostdated.set("enabled" /* NOI18N */, sense);
5396         gui.PrAllowForwardable.set("enabled" /* NOI18N */, sense);
5397         gui.PrAllowRenewable.set("enabled" /* NOI18N */, sense);
5398         gui.PrAllowProxiable.set("enabled" /* NOI18N */, sense);
5399         gui.PrAllowSvr.set("enabled" /* NOI18N */, sense);
5400         gui.PrAllowTGT.set("enabled" /* NOI18N */, sense);
5401         gui.PrAllowDupAuth.set("enabled" /* NOI18N */, sense);
5402         gui.PrRequirePreAuth.set("enabled" /* NOI18N */, sense);
5403         gui.PrRequireHwPreAuth.set("enabled" /* NOI18N */, sense);
5404     }
5405 
5406     private void enablePoAttributes(Boolean sense) {
5407         // Policy
5408         gui.PoMinPwLength.set("enabled" /* NOI18N */, sense);
5409         gui.PoMinPwClass.set("enabled" /* NOI18N */, sense);
5410         gui.PoSavedPasswords.set("enabled" /* NOI18N */, sense);
5411         gui.PoMinTicketLifetime.set("enabled" /* NOI18N */, sense);
5412         gui.PoMaxTicketLifetime.set("enabled" /* NOI18N */, sense);
5413     }
5414 
5415     /**
5416      * Show context-sensitive help from HelpData class
5417      *
5418      */
5419     public void showHelp(String what) {
5420         String res;
5421 
5422         // System.out.println("Help on "+what);
5423         if (cHelp == null) {
5424             // System.out.println("showHelp called without context.");
5425             return;
5426         }
5427         res = getHelpString(what);
5428         cHelp.setText(res);
5429         cHelp.setVisible(true);
5430     }
5431 
5432     /**
5433      * Holds an association between an object and a listener, keeping
5434      * track of the types so that they can be assigned en masse later
5435      *
5436      */
5437     private class Association extends Object {
5438         Object Object;
5439         EventListener Listener;
5440         int Type;
5441 
5442         public Association(Object obj, EventListener list, int type) {
5443             Object = obj;
5444             Listener = list;
5445             Type = type;
5446         }
5447     }
5448 
5449     /**
5450      * Action listeners for the defaults editing frame.
5451      */
5452 
5453     private class DefaultsContextSensitiveHelpListener
5454 	implements ActionListener {
5455         public void actionPerformed(ActionEvent e) {
5456             if (defaultsHelpMode)
5457                 showHelp("ContextSensitiveHelp");
5458             else
5459                 contextHelp(defaultsEditingFrame);
5460         }
5461     }
5462 
5463     /**
5464      * This class launches the dateTimeDialog box when the user presses
5465      * the "..." button. An instance of this is shared by all the
5466      * buttons that are meant to do this.
5467      */
5468     private class DateTimeListener  implements ActionListener {
5469 
5470         private TextField tf;
5471         private Frame frame;
5472 
5473         DateTimeListener(TextField tf, Frame frame) {
5474             this.tf = tf;
5475             this.frame = frame;
5476         }
5477 
5478         public void actionPerformed(ActionEvent e) {
5479             if (mainHelpMode && frame == realMainFrame)
5480                 showHelp("DateTime...");
5481             else
5482                 if (defaultsHelpMode && frame == defaultsEditingFrame)
5483 		    showHelp("DateTime...");
5484 		else
5485 		    getDateTimeFromDialogBox(tf, frame);
5486         } // actionPerformed
5487     } // class DateTimeListener
5488 
5489     /**
5490      * This class launches the EncListDialog box when the user presses
5491      * the "..." button. An instance of this is shared by all the
5492      * buttons that are meant to do this.
5493      */
5494     private class EncListListener implements ActionListener {
5495 
5496         private TextField tf;
5497         private Frame frame;
5498 
5499         EncListListener(TextField tf, Frame frame) {
5500             this.tf = tf;
5501             this.frame = frame;
5502         }
5503 
5504         public void actionPerformed(ActionEvent e) {
5505             if (mainHelpMode && frame == realMainFrame)
5506                 showHelp("EncList...");
5507             else
5508                 if (defaultsHelpMode && frame == defaultsEditingFrame)
5509 		    showHelp("EncList...");
5510 		else
5511 		    getEncListFromDialogBox(tf, frame);
5512         } // actionPerformed
5513     } // class EncListListener
5514 
5515     /**
5516      * This class launches the durrationHelper dialog box when the user presses
5517      * the "..." button. An instance of this is shared by all the
5518      * buttons that are meant to do this.
5519      */
5520     private class DurationListener implements ActionListener {
5521 
5522         private TextField tf;
5523         private Frame frame;
5524 
5525         DurationListener(TextField tf, Frame frame) {
5526             this.tf = tf;
5527             this.frame = frame;
5528         }
5529 
5530         public void actionPerformed(ActionEvent e) {
5531             if (mainHelpMode && frame == realMainFrame)
5532                 showHelp("Duration...");
5533             else
5534                 if (defaultsHelpMode && frame == defaultsEditingFrame)
5535 		    showHelp("Duration...");
5536 		else
5537 		    getDurationFromDialogBox(tf, frame);
5538         }
5539     }
5540 
5541 
5542     private class KeystrokeDetector extends KeyAdapter {
5543 
5544         private int changeType; // principal or policy change
5545 
5546         public KeystrokeDetector(int type) {
5547             changeType = type;
5548         }
5549 
5550         public void keyTyped(KeyEvent e) {
5551             reactToKey(changeType);
5552             ((TextField)e.getComponent()).requestFocus();
5553         }
5554     }
5555 
5556     private void reactToKey(int changeType) {
5557         switch (changeType) {
5558 	case PRINCIPAL_EDITING:
5559             prSetNeedSave();
5560             break;
5561 
5562 	case POLICY_EDITING:
5563             poSetNeedSave();
5564             break;
5565 
5566 	case DEFAULTS_EDITING:
5567             glSetNeedSave();
5568             break;
5569 
5570 	case PRINCIPAL_LIST:
5571             if (noLists)
5572                 prSelValid(true);
5573             break;
5574 
5575 	case POLICY_LIST:
5576             if (noLists)
5577                 poSelValid(true);
5578             break;
5579         }
5580     }
5581 
5582     private static String enclose(String value) {
5583         return new StringBuffer("\"").append(value).append("\"").toString();
5584     }
5585 
5586     private static String constructDurationExample() {
5587         StringBuffer result = new StringBuffer(getString("Example: "));
5588         result.append(enclose(nf.format(28800)));
5589         return result.toString();
5590     }
5591 
5592     private static String constructDateExample() {
5593         StringBuffer result = new StringBuffer(getString("Example: "));
5594         result.append(enclose(df.format(new Date())));
5595         result.append(' ').append(getString("or")).append(' ');
5596         result.append(enclose(neverString));
5597         return result.toString();
5598     }
5599 
5600     private static String constructNumberExample() {
5601         StringBuffer result =  new StringBuffer(getString("Example: "));
5602         result.append(enclose(nf.format(4)));
5603         return result.toString();
5604     }
5605 
5606     static {
5607         rb = ResourceBundle.getBundle("GuiResource" /* NOI18N */);
5608         hrb = ResourceBundle.getBundle("HelpData" /* NOI18N */);
5609         df = DateFormat.getDateTimeInstance(DateFormat.MEDIUM,
5610 					    DateFormat.MEDIUM);
5611         nf = NumberFormat.getInstance();
5612 
5613         neverString = getString("Never");
5614 
5615         toolkit = Toolkit.getDefaultToolkit();
5616 
5617         durationErrorText = new String[] {getHelpString("Bad Duration"),
5618 					  constructDurationExample()};
5619         dateErrorText = new String[] {getHelpString("Bad Date"),
5620 				      constructDateExample()};
5621         numberErrorText = new String[] {getHelpString("Bad Number"),
5622 					constructNumberExample()};
5623     }
5624 
5625 }
5626