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