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