54 import sun.security.provider.*;
55 import sun.security.util.PolicyUtil;
56 import javax.security.auth.x500.X500Principal;
57 import javax.swing.*;
58 import javax.swing.border.EmptyBorder;
59
60 /**
61 * PolicyTool may be used by users and administrators to configure the
62 * overall java security policy (currently stored in the policy file).
63 * Using PolicyTool administrators may add and remove policies from
64 * the policy file. <p>
65 *
66 * @see java.security.Policy
67 * @since 1.2
68 * @deprecated {@code policytool} has been deprecated for removal because it
69 * is rarely used, and it provides little value over editing policy
70 * files using a text editor.
71 */
72
73 @Deprecated(since="9", forRemoval=true)
74 public class PolicyTool {
75
76 // for i18n
77 static final java.util.ResourceBundle rb =
78 java.util.ResourceBundle.getBundle(
79 "sun.security.tools.policytool.Resources");
80 static final Collator collator = Collator.getInstance();
81 static {
82 // this is for case insensitive string comparisons
83 collator.setStrength(Collator.PRIMARY);
84
85 // Support for Apple menu bar
86 if (System.getProperty("apple.laf.useScreenMenuBar") == null) {
87 System.setProperty("apple.laf.useScreenMenuBar", "true");
88 }
89 System.setProperty("apple.awt.application.name", getMessage("Policy.Tool"));
90
91 // Apply the system L&F if not specified with a system property.
92 if (System.getProperty("swing.defaultlaf") == null) {
93 try {
862 }
863 return s.toString();
864 }
865 }
866
867 /**
868 * Each entry in the policy configuration file is represented by a
869 * PolicyEntry object.
870 *
871 * A PolicyEntry is a (CodeSource,Permission) pair. The
872 * CodeSource contains the (URL, PublicKey) that together identify
873 * where the Java bytecodes come from and who (if anyone) signed
874 * them. The URL could refer to localhost. The URL could also be
875 * null, meaning that this policy entry is given to all comers, as
876 * long as they match the signer field. The signer could be null,
877 * meaning the code is not signed.
878 *
879 * The Permission contains the (Type, Name, Action) triplet.
880 *
881 */
882 @SuppressWarnings("deprecation")
883 class PolicyEntry {
884
885 private CodeSource codesource;
886 private PolicyTool tool;
887 private PolicyParser.GrantEntry grantEntry;
888 private boolean testing = false;
889
890 /**
891 * Create a PolicyEntry object from the information read in
892 * from a policy file.
893 */
894 PolicyEntry(PolicyTool tool, PolicyParser.GrantEntry ge)
895 throws MalformedURLException, NoSuchMethodException,
896 ClassNotFoundException, InstantiationException, IllegalAccessException,
897 InvocationTargetException, CertificateException,
898 IOException, NoSuchAlgorithmException, UnrecoverableKeyException {
899
900 this.tool = tool;
901
902 URL location = null;
1002 PolicyParser.PermissionEntry toPermissionEntry(Permission perm) {
1003
1004 String actions = null;
1005
1006 // get the actions
1007 if (perm.getActions() != null &&
1008 perm.getActions().trim() != "")
1009 actions = perm.getActions();
1010
1011 PolicyParser.PermissionEntry pe = new PolicyParser.PermissionEntry
1012 (perm.getClass().getName(),
1013 perm.getName(),
1014 actions);
1015 return pe;
1016 }
1017 }
1018
1019 /**
1020 * The main window for the PolicyTool
1021 */
1022 @SuppressWarnings("deprecation")
1023 class ToolWindow extends JFrame {
1024 // use serialVersionUID from JDK 1.2.2 for interoperability
1025 private static final long serialVersionUID = 5682568601210376777L;
1026
1027 /* ESCAPE key */
1028 static final KeyStroke escKey = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
1029
1030 /* external paddings */
1031 public static final Insets TOP_PADDING = new Insets(25,0,0,0);
1032 public static final Insets BOTTOM_PADDING = new Insets(0,0,25,0);
1033 public static final Insets LITE_BOTTOM_PADDING = new Insets(0,0,10,0);
1034 public static final Insets LR_PADDING = new Insets(0,10,0,10);
1035 public static final Insets TOP_BOTTOM_PADDING = new Insets(15, 0, 15, 0);
1036 public static final Insets L_TOP_BOTTOM_PADDING = new Insets(5,10,15,0);
1037 public static final Insets LR_TOP_BOTTOM_PADDING = new Insets(15, 4, 15, 4);
1038 public static final Insets LR_BOTTOM_PADDING = new Insets(0,10,5,10);
1039 public static final Insets L_BOTTOM_PADDING = new Insets(0,10,5,0);
1040 public static final Insets R_BOTTOM_PADDING = new Insets(0, 0, 25, 5);
1041 public static final Insets R_PADDING = new Insets(0, 0, 0, 5);
1042
1536
1537 addNewComponent(tw, panel, 1,
1538 0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.VERTICAL);
1539
1540 tw.pack();
1541 tw.setLocationRelativeTo(w);
1542 tw.setVisible(true);
1543 if (chooseResult.length() > 0) {
1544 return chooseResult.charAt(0);
1545 } else {
1546 // I did encounter this once, don't why.
1547 return 'N';
1548 }
1549 }
1550
1551 }
1552
1553 /**
1554 * General dialog window
1555 */
1556 @SuppressWarnings("deprecation")
1557 class ToolDialog extends JDialog {
1558 // use serialVersionUID from JDK 1.2.2 for interoperability
1559 private static final long serialVersionUID = -372244357011301190L;
1560
1561 /* ESCAPE key */
1562 static final KeyStroke escKey = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
1563
1564 /* necessary constants */
1565 public static final int NOACTION = 0;
1566 public static final int QUIT = 1;
1567 public static final int NEW = 2;
1568 public static final int OPEN = 3;
1569
1570 /* popup menus */
1571 public static final String PERM =
1572 PolicyTool.getMessage
1573 ("Permission.");
1574
1575 public static final String PRIN_TYPE =
1576 PolicyTool.getMessage("Principal.Type.");
2900 if (pppe.action != null) {
2901 result += ", \"" + pppe.action + "\"";
2902 }
2903 if (pppe.signedBy != null) {
2904 result += ", signedBy " + pppe.signedBy;
2905 }
2906 return result;
2907 }
2908
2909 static String PrincipalEntryToUserFriendlyString(PolicyParser.PrincipalEntry pppe) {
2910 StringWriter sw = new StringWriter();
2911 PrintWriter pw = new PrintWriter(sw);
2912 pppe.write(pw);
2913 return sw.toString();
2914 }
2915 }
2916
2917 /**
2918 * Event handler for the PolicyTool window
2919 */
2920 @SuppressWarnings("deprecation")
2921 class ToolWindowListener implements WindowListener {
2922
2923 private PolicyTool tool;
2924 private ToolWindow tw;
2925
2926 ToolWindowListener(PolicyTool tool, ToolWindow tw) {
2927 this.tool = tool;
2928 this.tw = tw;
2929 }
2930
2931 public void windowOpened(WindowEvent we) {
2932 }
2933
2934 public void windowClosing(WindowEvent we) {
2935 // Closing the window acts the same as choosing Menu->Exit.
2936
2937 // ask user if they want to save changes
2938 ToolDialog td = new ToolDialog(PolicyTool.getMessage("Save.Changes"), tool, tw, true);
2939 td.displayUserSave(ToolDialog.QUIT);
2940
2945 public void windowClosed(WindowEvent we) {
2946 System.exit(0);
2947 }
2948
2949 public void windowIconified(WindowEvent we) {
2950 }
2951
2952 public void windowDeiconified(WindowEvent we) {
2953 }
2954
2955 public void windowActivated(WindowEvent we) {
2956 }
2957
2958 public void windowDeactivated(WindowEvent we) {
2959 }
2960 }
2961
2962 /**
2963 * Event handler for the Policy List
2964 */
2965 @SuppressWarnings("deprecation")
2966 class PolicyListListener extends MouseAdapter implements ActionListener {
2967
2968 private PolicyTool tool;
2969 private ToolWindow tw;
2970
2971 PolicyListListener(PolicyTool tool, ToolWindow tw) {
2972 this.tool = tool;
2973 this.tw = tw;
2974
2975 }
2976
2977 public void actionPerformed(ActionEvent e) {
2978
2979 // display the permission list for a policy entry
2980 ToolDialog td = new ToolDialog
2981 (PolicyTool.getMessage("Policy.Entry"), tool, tw, true);
2982 td.displayPolicyEntryDialog(true);
2983 }
2984
2985 public void mouseClicked(MouseEvent evt) {
2986 if (evt.getClickCount() == 2) {
2987 actionPerformed(null);
2988 }
2989 }
2990 }
2991
2992 /**
2993 * Event handler for the File Menu
2994 */
2995 @SuppressWarnings("deprecation")
2996 class FileMenuListener implements ActionListener {
2997
2998 private PolicyTool tool;
2999 private ToolWindow tw;
3000
3001 FileMenuListener(PolicyTool tool, ToolWindow tw) {
3002 this.tool = tool;
3003 this.tw = tw;
3004 }
3005
3006 public void actionPerformed(ActionEvent e) {
3007
3008 if (PolicyTool.collator.compare(e.getActionCommand(),
3009 ToolWindow.QUIT) == 0) {
3010
3011 // ask user if they want to save changes
3012 ToolDialog td = new ToolDialog
3013 (PolicyTool.getMessage("Save.Changes"), tool, tw, true);
3014 td.displayUserSave(ToolDialog.QUIT);
3015
3074 }
3075 }
3076 } else if (PolicyTool.collator.compare(e.getActionCommand(),
3077 ToolWindow.SAVE_AS_POLICY_FILE) == 0) {
3078
3079 // user wants to SAVE AS
3080 ToolDialog td = new ToolDialog
3081 (PolicyTool.getMessage("Save.As"), tool, tw, true);
3082 td.displaySaveAsDialog(ToolDialog.NOACTION);
3083
3084 } else if (PolicyTool.collator.compare(e.getActionCommand(),
3085 ToolWindow.VIEW_WARNINGS) == 0) {
3086 tw.displayWarningLog(null);
3087 }
3088 }
3089 }
3090
3091 /**
3092 * Event handler for the main window buttons and Edit Menu
3093 */
3094 @SuppressWarnings("deprecation")
3095 class MainWindowListener implements ActionListener {
3096
3097 private PolicyTool tool;
3098 private ToolWindow tw;
3099
3100 MainWindowListener(PolicyTool tool, ToolWindow tw) {
3101 this.tool = tool;
3102 this.tw = tw;
3103 }
3104
3105 public void actionPerformed(ActionEvent e) {
3106
3107 if (PolicyTool.collator.compare(e.getActionCommand(),
3108 ToolWindow.ADD_POLICY_ENTRY) == 0) {
3109
3110 // display a dialog box for the user to enter policy info
3111 ToolDialog td = new ToolDialog
3112 (PolicyTool.getMessage("Policy.Entry"), tool, tw, true);
3113 td.displayPolicyEntryDialog(false);
3114
3150
3151 } else if (PolicyTool.collator.compare(e.getActionCommand(),
3152 ToolWindow.EDIT_KEYSTORE) == 0) {
3153
3154 // display a dialog box for the user to enter keystore info
3155 ToolDialog td = new ToolDialog
3156 (PolicyTool.getMessage("KeyStore"), tool, tw, true);
3157 td.keyStoreDialog(ToolDialog.EDIT_KEYSTORE);
3158 }
3159 }
3160 }
3161
3162 /**
3163 * Event handler for AddEntryDoneButton button
3164 *
3165 * -- if edit is TRUE, then we are EDITing an existing PolicyEntry
3166 * and we need to update both the policy and the GUI listing.
3167 * if edit is FALSE, then we are ADDing a new PolicyEntry,
3168 * so we only need to update the GUI listing.
3169 */
3170 @SuppressWarnings("deprecation")
3171 class AddEntryDoneButtonListener implements ActionListener {
3172
3173 private PolicyTool tool;
3174 private ToolWindow tw;
3175 private ToolDialog td;
3176 private boolean edit;
3177
3178 AddEntryDoneButtonListener(PolicyTool tool, ToolWindow tw,
3179 ToolDialog td, boolean edit) {
3180 this.tool = tool;
3181 this.tw = tw;
3182 this.td = td;
3183 this.edit = edit;
3184 }
3185
3186 public void actionPerformed(ActionEvent e) {
3187
3188 try {
3189 // get a PolicyEntry object from the dialog policy info
3190 PolicyEntry newEntry = td.getPolicyEntryFromDialog();
3217 (newCodeBaseStr, policyList.getModel().getElementAt(listIndex)) != 0)
3218 tool.modified = true;
3219 ((DefaultListModel<String>)policyList.getModel()).set(listIndex, newCodeBaseStr);
3220 } else {
3221 tool.addEntry(newEntry, -1);
3222 ((DefaultListModel<String>)policyList.getModel()).addElement(newEntry.headerToString());
3223 tool.modified = true;
3224 }
3225 td.setVisible(false);
3226 td.dispose();
3227
3228 } catch (Exception eee) {
3229 tw.displayErrorDialog(td, eee);
3230 }
3231 }
3232 }
3233
3234 /**
3235 * Event handler for ChangeKeyStoreOKButton button
3236 */
3237 @SuppressWarnings("deprecation")
3238 class ChangeKeyStoreOKButtonListener implements ActionListener {
3239
3240 private PolicyTool tool;
3241 private ToolWindow tw;
3242 private ToolDialog td;
3243
3244 ChangeKeyStoreOKButtonListener(PolicyTool tool, ToolWindow tw,
3245 ToolDialog td) {
3246 this.tool = tool;
3247 this.tw = tw;
3248 this.td = td;
3249 }
3250
3251 public void actionPerformed(ActionEvent e) {
3252
3253 String URLString = ((JTextField)td.getComponent(
3254 ToolDialog.KSD_NAME_TEXTFIELD)).getText().trim();
3255 String type = ((JTextField)td.getComponent(
3256 ToolDialog.KSD_TYPE_TEXTFIELD)).getText().trim();
3257 String provider = ((JTextField)td.getComponent(
3264 ((URLString.length() == 0 ? null : URLString),
3265 (type.length() == 0 ? null : type),
3266 (provider.length() == 0 ? null : provider),
3267 (pwdURL.length() == 0 ? null : pwdURL));
3268 tool.modified = true;
3269 } catch (Exception ex) {
3270 MessageFormat form = new MessageFormat(PolicyTool.getMessage
3271 ("Unable.to.open.KeyStore.ex.toString."));
3272 Object[] source = {ex.toString()};
3273 tw.displayErrorDialog(td, form.format(source));
3274 return;
3275 }
3276
3277 td.dispose();
3278 }
3279 }
3280
3281 /**
3282 * Event handler for AddPrinButton button
3283 */
3284 @SuppressWarnings("deprecation")
3285 class AddPrinButtonListener implements ActionListener {
3286
3287 private PolicyTool tool;
3288 private ToolWindow tw;
3289 private ToolDialog td;
3290 private boolean editPolicyEntry;
3291
3292 AddPrinButtonListener(PolicyTool tool, ToolWindow tw,
3293 ToolDialog td, boolean editPolicyEntry) {
3294 this.tool = tool;
3295 this.tw = tw;
3296 this.td = td;
3297 this.editPolicyEntry = editPolicyEntry;
3298 }
3299
3300 public void actionPerformed(ActionEvent e) {
3301
3302 // display a dialog box for the user to enter principal info
3303 td.displayPrincipalDialog(editPolicyEntry, false);
3304 }
3305 }
3306
3307 /**
3308 * Event handler for AddPermButton button
3309 */
3310 @SuppressWarnings("deprecation")
3311 class AddPermButtonListener implements ActionListener {
3312
3313 private PolicyTool tool;
3314 private ToolWindow tw;
3315 private ToolDialog td;
3316 private boolean editPolicyEntry;
3317
3318 AddPermButtonListener(PolicyTool tool, ToolWindow tw,
3319 ToolDialog td, boolean editPolicyEntry) {
3320 this.tool = tool;
3321 this.tw = tw;
3322 this.td = td;
3323 this.editPolicyEntry = editPolicyEntry;
3324 }
3325
3326 public void actionPerformed(ActionEvent e) {
3327
3328 // display a dialog box for the user to enter permission info
3329 td.displayPermissionDialog(editPolicyEntry, false);
3330 }
3331 }
3332
3333 /**
3334 * Event handler for AddPrinOKButton button
3335 */
3336 @SuppressWarnings("deprecation")
3337 class NewPolicyPrinOKButtonListener implements ActionListener {
3338
3339 private PolicyTool tool;
3340 private ToolWindow tw;
3341 private ToolDialog listDialog;
3342 private ToolDialog infoDialog;
3343 private boolean edit;
3344
3345 NewPolicyPrinOKButtonListener(PolicyTool tool,
3346 ToolWindow tw,
3347 ToolDialog listDialog,
3348 ToolDialog infoDialog,
3349 boolean edit) {
3350 this.tool = tool;
3351 this.tw = tw;
3352 this.listDialog = listDialog;
3353 this.infoDialog = infoDialog;
3354 this.edit = edit;
3355 }
3356
3380 String prinString = ToolDialog.PrincipalEntryToUserFriendlyString(pppe);
3381 if (edit) {
3382 // if editing, replace the original principal
3383 int index = prinList.getSelectedIndex();
3384 prinList.replaceTaggedItem(prinString, pppe, index);
3385 } else {
3386 // if adding, just add it to the end
3387 prinList.addTaggedItem(prinString, pppe);
3388 }
3389 }
3390 infoDialog.dispose();
3391 } catch (Exception ee) {
3392 tw.displayErrorDialog(infoDialog, ee);
3393 }
3394 }
3395 }
3396
3397 /**
3398 * Event handler for AddPermOKButton button
3399 */
3400 @SuppressWarnings("deprecation")
3401 class NewPolicyPermOKButtonListener implements ActionListener {
3402
3403 private PolicyTool tool;
3404 private ToolWindow tw;
3405 private ToolDialog listDialog;
3406 private ToolDialog infoDialog;
3407 private boolean edit;
3408
3409 NewPolicyPermOKButtonListener(PolicyTool tool,
3410 ToolWindow tw,
3411 ToolDialog listDialog,
3412 ToolDialog infoDialog,
3413 boolean edit) {
3414 this.tool = tool;
3415 this.tw = tw;
3416 this.listDialog = listDialog;
3417 this.infoDialog = infoDialog;
3418 this.edit = edit;
3419 }
3420
3444 // if editing, replace the original permission
3445 int which = permList.getSelectedIndex();
3446 permList.replaceTaggedItem(permString, pppe, which);
3447 } else {
3448 // if adding, just add it to the end
3449 permList.addTaggedItem(permString, pppe);
3450 }
3451 infoDialog.dispose();
3452
3453 } catch (InvocationTargetException ite) {
3454 tw.displayErrorDialog(infoDialog, ite.getTargetException());
3455 } catch (Exception ee) {
3456 tw.displayErrorDialog(infoDialog, ee);
3457 }
3458 }
3459 }
3460
3461 /**
3462 * Event handler for RemovePrinButton button
3463 */
3464 @SuppressWarnings("deprecation")
3465 class RemovePrinButtonListener implements ActionListener {
3466
3467 private PolicyTool tool;
3468 private ToolWindow tw;
3469 private ToolDialog td;
3470 private boolean edit;
3471
3472 RemovePrinButtonListener(PolicyTool tool, ToolWindow tw,
3473 ToolDialog td, boolean edit) {
3474 this.tool = tool;
3475 this.tw = tw;
3476 this.td = td;
3477 this.edit = edit;
3478 }
3479
3480 public void actionPerformed(ActionEvent e) {
3481
3482 // get the Principal selected from the Principal List
3483 TaggedList prinList = (TaggedList)td.getComponent(
3484 ToolDialog.PE_PRIN_LIST);
3485 int prinIndex = prinList.getSelectedIndex();
3486
3487 if (prinIndex < 0) {
3488 tw.displayErrorDialog(td, new Exception
3489 (PolicyTool.getMessage("No.principal.selected")));
3490 return;
3491 }
3492 // remove the principal from the display
3493 prinList.removeTaggedItem(prinIndex);
3494 }
3495 }
3496
3497 /**
3498 * Event handler for RemovePermButton button
3499 */
3500 @SuppressWarnings("deprecation")
3501 class RemovePermButtonListener implements ActionListener {
3502
3503 private PolicyTool tool;
3504 private ToolWindow tw;
3505 private ToolDialog td;
3506 private boolean edit;
3507
3508 RemovePermButtonListener(PolicyTool tool, ToolWindow tw,
3509 ToolDialog td, boolean edit) {
3510 this.tool = tool;
3511 this.tw = tw;
3512 this.td = td;
3513 this.edit = edit;
3514 }
3515
3516 public void actionPerformed(ActionEvent e) {
3517
3518 // get the Permission selected from the Permission List
3519 TaggedList permList = (TaggedList)td.getComponent(
3520 ToolDialog.PE_PERM_LIST);
3523 if (permIndex < 0) {
3524 tw.displayErrorDialog(td, new Exception
3525 (PolicyTool.getMessage("No.permission.selected")));
3526 return;
3527 }
3528 // remove the permission from the display
3529 permList.removeTaggedItem(permIndex);
3530
3531 }
3532 }
3533
3534 /**
3535 * Event handler for Edit Principal button
3536 *
3537 * We need the editPolicyEntry boolean to tell us if the user is
3538 * adding a new PolicyEntry at this time, or editing an existing entry.
3539 * If the user is adding a new PolicyEntry, we ONLY update the
3540 * GUI listing. If the user is editing an existing PolicyEntry, we
3541 * update both the GUI listing and the actual PolicyEntry.
3542 */
3543 @SuppressWarnings("deprecation")
3544 class EditPrinButtonListener extends MouseAdapter implements ActionListener {
3545
3546 private PolicyTool tool;
3547 private ToolWindow tw;
3548 private ToolDialog td;
3549 private boolean editPolicyEntry;
3550
3551 EditPrinButtonListener(PolicyTool tool, ToolWindow tw,
3552 ToolDialog td, boolean editPolicyEntry) {
3553 this.tool = tool;
3554 this.tw = tw;
3555 this.td = td;
3556 this.editPolicyEntry = editPolicyEntry;
3557 }
3558
3559 public void actionPerformed(ActionEvent e) {
3560
3561 // get the Principal selected from the Principal List
3562 TaggedList list = (TaggedList)td.getComponent(
3563 ToolDialog.PE_PRIN_LIST);
3570 }
3571 td.displayPrincipalDialog(editPolicyEntry, true);
3572 }
3573
3574 public void mouseClicked(MouseEvent evt) {
3575 if (evt.getClickCount() == 2) {
3576 actionPerformed(null);
3577 }
3578 }
3579 }
3580
3581 /**
3582 * Event handler for Edit Permission button
3583 *
3584 * We need the editPolicyEntry boolean to tell us if the user is
3585 * adding a new PolicyEntry at this time, or editing an existing entry.
3586 * If the user is adding a new PolicyEntry, we ONLY update the
3587 * GUI listing. If the user is editing an existing PolicyEntry, we
3588 * update both the GUI listing and the actual PolicyEntry.
3589 */
3590 @SuppressWarnings("deprecation")
3591 class EditPermButtonListener extends MouseAdapter implements ActionListener {
3592
3593 private PolicyTool tool;
3594 private ToolWindow tw;
3595 private ToolDialog td;
3596 private boolean editPolicyEntry;
3597
3598 EditPermButtonListener(PolicyTool tool, ToolWindow tw,
3599 ToolDialog td, boolean editPolicyEntry) {
3600 this.tool = tool;
3601 this.tw = tw;
3602 this.td = td;
3603 this.editPolicyEntry = editPolicyEntry;
3604 }
3605
3606 public void actionPerformed(ActionEvent e) {
3607
3608 // get the Permission selected from the Permission List
3609 @SuppressWarnings("unchecked")
3610 JList<String> list = (JList<String>)td.getComponent(ToolDialog.PE_PERM_LIST);
3611 int permIndex = list.getSelectedIndex();
3612
3613 if (permIndex < 0) {
3614 tw.displayErrorDialog(td, new Exception
3615 (PolicyTool.getMessage("No.permission.selected")));
3616 return;
3617 }
3618 td.displayPermissionDialog(editPolicyEntry, true);
3619 }
3620
3621 public void mouseClicked(MouseEvent evt) {
3622 if (evt.getClickCount() == 2) {
3623 actionPerformed(null);
3624 }
3625 }
3626 }
3627
3628 /**
3629 * Event handler for Principal Popup Menu
3630 */
3631 @SuppressWarnings("deprecation")
3632 class PrincipalTypeMenuListener implements ItemListener {
3633
3634 private ToolDialog td;
3635
3636 PrincipalTypeMenuListener(ToolDialog td) {
3637 this.td = td;
3638 }
3639
3640 public void itemStateChanged(ItemEvent e) {
3641 if (e.getStateChange() == ItemEvent.DESELECTED) {
3642 // We're only interested in SELECTED events
3643 return;
3644 }
3645
3646 @SuppressWarnings("unchecked")
3647 JComboBox<String> prin = (JComboBox<String>)td.getComponent(ToolDialog.PRD_PRIN_CHOICE);
3648 JTextField prinField = (JTextField)td.getComponent(
3649 ToolDialog.PRD_PRIN_TEXTFIELD);
3650 JTextField nameField = (JTextField)td.getComponent(
3651 ToolDialog.PRD_NAME_TEXTFIELD);
3663 }
3664
3665 // if you change the principal, clear the name
3666 if (prinField.getText().indexOf((String)e.getItem()) == -1) {
3667 nameField.setText("");
3668 }
3669
3670 // set the text in the textfield and also modify the
3671 // pull-down choice menus to reflect the correct possible
3672 // set of names and actions
3673 Prin inputPrin = ToolDialog.getPrin((String)e.getItem(), false);
3674 if (inputPrin != null) {
3675 prinField.setText(inputPrin.getName());
3676 }
3677 }
3678 }
3679
3680 /**
3681 * Event handler for Permission Popup Menu
3682 */
3683 @SuppressWarnings("deprecation")
3684 class PermissionMenuListener implements ItemListener {
3685
3686 private ToolDialog td;
3687
3688 PermissionMenuListener(ToolDialog td) {
3689 this.td = td;
3690 }
3691
3692 public void itemStateChanged(ItemEvent e) {
3693 if (e.getStateChange() == ItemEvent.DESELECTED) {
3694 // We're only interested in SELECTED events
3695 return;
3696 }
3697
3698 @SuppressWarnings("unchecked")
3699 JComboBox<String> perms = (JComboBox<String>)td.getComponent(
3700 ToolDialog.PD_PERM_CHOICE);
3701 @SuppressWarnings("unchecked")
3702 JComboBox<String> names = (JComboBox<String>)td.getComponent(
3703 ToolDialog.PD_NAME_CHOICE);
3738 }
3739
3740 // set the text in the textfield and also modify the
3741 // pull-down choice menus to reflect the correct possible
3742 // set of names and actions
3743
3744 Perm inputPerm = ToolDialog.getPerm((String)e.getItem(), false);
3745 if (inputPerm == null) {
3746 permField.setText("");
3747 } else {
3748 permField.setText(inputPerm.getName());
3749 }
3750 td.setPermissionNames(inputPerm, names, nameField);
3751 td.setPermissionActions(inputPerm, actions, actionsField);
3752 }
3753 }
3754
3755 /**
3756 * Event handler for Permission Name Popup Menu
3757 */
3758 @SuppressWarnings("deprecation")
3759 class PermissionNameMenuListener implements ItemListener {
3760
3761 private ToolDialog td;
3762
3763 PermissionNameMenuListener(ToolDialog td) {
3764 this.td = td;
3765 }
3766
3767 public void itemStateChanged(ItemEvent e) {
3768 if (e.getStateChange() == ItemEvent.DESELECTED) {
3769 // We're only interested in SELECTED events
3770 return;
3771 }
3772
3773 @SuppressWarnings("unchecked")
3774 JComboBox<String> names = (JComboBox<String>)td.getComponent(ToolDialog.PD_NAME_CHOICE);
3775 names.getAccessibleContext().setAccessibleName(
3776 PolicyTool.splitToWords((String)e.getItem()));
3777
3778 if (((String)e.getItem()).indexOf(ToolDialog.PERM_NAME) != -1)
3892 /**
3893 * Event handler for StatusOKButton button
3894 */
3895 class StatusOKButtonListener implements ActionListener {
3896
3897 private ToolDialog sd;
3898
3899 StatusOKButtonListener(ToolDialog sd) {
3900 this.sd = sd;
3901 }
3902
3903 public void actionPerformed(ActionEvent e) {
3904 sd.setVisible(false);
3905 sd.dispose();
3906 }
3907 }
3908
3909 /**
3910 * Event handler for UserSaveYes button
3911 */
3912 @SuppressWarnings("deprecation")
3913 class UserSaveYesButtonListener implements ActionListener {
3914
3915 private ToolDialog us;
3916 private PolicyTool tool;
3917 private ToolWindow tw;
3918 private int select;
3919
3920 UserSaveYesButtonListener(ToolDialog us, PolicyTool tool,
3921 ToolWindow tw, int select) {
3922 this.us = us;
3923 this.tool = tool;
3924 this.tw = tw;
3925 this.select = select;
3926 }
3927
3928 public void actionPerformed(ActionEvent e) {
3929
3930 // first get rid of the window
3931 us.setVisible(false);
3932 us.dispose();
3947 MessageFormat form = new MessageFormat
3948 (PolicyTool.getMessage
3949 ("Policy.successfully.written.to.filename"));
3950 Object[] source = {filename};
3951 tw.displayStatusDialog(null, form.format(source));
3952
3953 // now continue with the originally requested command
3954 // (QUIT, NEW, or OPEN)
3955 us.userSaveContinue(tool, tw, us, select);
3956 }
3957 } catch (Exception ee) {
3958 // error -- just report it and bail
3959 tw.displayErrorDialog(null, ee);
3960 }
3961 }
3962 }
3963
3964 /**
3965 * Event handler for UserSaveNoButton
3966 */
3967 @SuppressWarnings("deprecation")
3968 class UserSaveNoButtonListener implements ActionListener {
3969
3970 private PolicyTool tool;
3971 private ToolWindow tw;
3972 private ToolDialog us;
3973 private int select;
3974
3975 UserSaveNoButtonListener(ToolDialog us, PolicyTool tool,
3976 ToolWindow tw, int select) {
3977 this.us = us;
3978 this.tool = tool;
3979 this.tw = tw;
3980 this.select = select;
3981 }
3982
3983 public void actionPerformed(ActionEvent e) {
3984 us.setVisible(false);
3985 us.dispose();
3986
3987 // now continue with the originally requested command
3996 class UserSaveCancelButtonListener implements ActionListener {
3997
3998 private ToolDialog us;
3999
4000 UserSaveCancelButtonListener(ToolDialog us) {
4001 this.us = us;
4002 }
4003
4004 public void actionPerformed(ActionEvent e) {
4005 us.setVisible(false);
4006 us.dispose();
4007
4008 // do NOT continue with the originally requested command
4009 // (QUIT, NEW, or OPEN)
4010 }
4011 }
4012
4013 /**
4014 * Event handler for ConfirmRemovePolicyEntryOKButtonListener
4015 */
4016 @SuppressWarnings("deprecation")
4017 class ConfirmRemovePolicyEntryOKButtonListener implements ActionListener {
4018
4019 private PolicyTool tool;
4020 private ToolWindow tw;
4021 private ToolDialog us;
4022
4023 ConfirmRemovePolicyEntryOKButtonListener(PolicyTool tool,
4024 ToolWindow tw, ToolDialog us) {
4025 this.tool = tool;
4026 this.tw = tw;
4027 this.us = us;
4028 }
4029
4030 public void actionPerformed(ActionEvent e) {
4031 // remove the entry
4032 @SuppressWarnings("unchecked")
4033 JList<String> list = (JList<String>)tw.getComponent(ToolWindow.MW_POLICY_LIST);
4034 int index = list.getSelectedIndex();
4035 PolicyEntry entries[] = tool.getEntry();
4036 tool.removeEntry(entries[index]);
4152 }
4153 }
4154
4155 class AllPerm extends Perm {
4156 AllPerm() {
4157 super(java.security.AllPermission.class, null, null);
4158 }
4159 }
4160
4161 class AudioPerm extends Perm {
4162 AudioPerm() {
4163 super(javax.sound.sampled.AudioPermission.class,
4164 new String[] {
4165 "play",
4166 "record"
4167 },
4168 null);
4169 }
4170 }
4171
4172 @SuppressWarnings("deprecation")
4173 class AuthPerm extends Perm {
4174 AuthPerm() {
4175 super(javax.security.auth.AuthPermission.class,
4176 new String[] {
4177 "doAs",
4178 "doAsPrivileged",
4179 "getSubject",
4180 "getSubjectFromDomainCombiner",
4181 "setReadOnly",
4182 "modifyPrincipals",
4183 "modifyPublicCredentials",
4184 "modifyPrivateCredentials",
4185 "refreshCredential",
4186 "destroyCredential",
4187 "createLoginContext.<" + PolicyTool.getMessage("name") + ">",
4188 "getLoginConfiguration",
4189 "setLoginConfiguration",
4190 "createLoginConfiguration.<" +
4191 PolicyTool.getMessage("configuration.type") + ">",
4192 "refreshLoginConfiguration"
4225 },
4226 null);
4227 }
4228 }
4229
4230 class FilePerm extends Perm {
4231 FilePerm() {
4232 super(java.io.FilePermission.class,
4233 new String[] {
4234 "<<ALL FILES>>"
4235 },
4236 new String[] {
4237 "read",
4238 "write",
4239 "delete",
4240 "execute"
4241 });
4242 }
4243 }
4244
4245 @SuppressWarnings("deprecation")
4246 class URLPerm extends Perm {
4247 URLPerm() {
4248 super(java.net.URLPermission.class,
4249 new String[] {
4250 "<"+ PolicyTool.getMessage("url") + ">",
4251 },
4252 new String[] {
4253 "<" + PolicyTool.getMessage("method.list") + ">:<"
4254 + PolicyTool.getMessage("request.headers.list") + ">",
4255 });
4256 }
4257 }
4258
4259 class InqSecContextPerm extends Perm {
4260 InqSecContextPerm() {
4261 super(com.sun.security.jgss.InquireSecContextPermission.class,
4262 new String[] {
4263 "KRB5_GET_SESSION_KEY",
4264 "KRB5_GET_TKT_FLAGS",
4265 "KRB5_GET_AUTHZ_DATA",
4390 new String[] {
4391 // allow user input
4392 },
4393 new String[] {
4394 "read",
4395 "write"
4396 });
4397 }
4398 }
4399
4400 class ReflectPerm extends Perm {
4401 ReflectPerm() {
4402 super(java.lang.reflect.ReflectPermission.class,
4403 new String[] {
4404 "suppressAccessChecks"
4405 },
4406 null);
4407 }
4408 }
4409
4410 @SuppressWarnings("deprecation")
4411 class RuntimePerm extends Perm {
4412 RuntimePerm() {
4413 super(java.lang.RuntimePermission.class,
4414 new String[] {
4415 "createClassLoader",
4416 "getClassLoader",
4417 "setContextClassLoader",
4418 "enableContextClassLoaderOverride",
4419 "setSecurityManager",
4420 "createSecurityManager",
4421 "getenv.<" +
4422 PolicyTool.getMessage("environment.variable.name") + ">",
4423 "exitVM",
4424 "shutdownHooks",
4425 "setFactory",
4426 "setIO",
4427 "modifyThread",
4428 "stopThread",
4429 "modifyThreadGroup",
4430 "getProtectionDomain",
4431 "readFileDescriptor",
4432 "writeFileDescriptor",
4433 "loadLibrary.<" +
4434 PolicyTool.getMessage("library.name") + ">",
4435 "accessClassInPackage.<" +
4436 PolicyTool.getMessage("package.name")+">",
4437 "defineClassInPackage.<" +
4438 PolicyTool.getMessage("package.name")+">",
4439 "accessDeclaredMembers",
4440 "queuePrintJob",
4441 "getStackTrace",
4442 "setDefaultUncaughtExceptionHandler",
4443 "preferences",
4444 "usePolicy",
4445 // "inheritedChannel"
4446 },
4447 null);
4448 }
4449 }
4450
4451 @SuppressWarnings("deprecation")
4452 class SecurityPerm extends Perm {
4453 SecurityPerm() {
4454 super(java.security.SecurityPermission.class,
4455 new String[] {
4456 "createAccessControlContext",
4457 "getDomainCombiner",
4458 "getPolicy",
4459 "setPolicy",
4460 "createPolicy.<" +
4461 PolicyTool.getMessage("policy.type") + ">",
4462 "getProperty.<" +
4463 PolicyTool.getMessage("property.name") + ">",
4464 "setProperty.<" +
4465 PolicyTool.getMessage("property.name") + ">",
4466 "insertProvider.<" +
4467 PolicyTool.getMessage("provider.name") + ">",
4468 "removeProvider.<" +
4469 PolicyTool.getMessage("provider.name") + ">",
4470 //"setSystemScope",
4471 //"setIdentityPublicKey",
|
54 import sun.security.provider.*;
55 import sun.security.util.PolicyUtil;
56 import javax.security.auth.x500.X500Principal;
57 import javax.swing.*;
58 import javax.swing.border.EmptyBorder;
59
60 /**
61 * PolicyTool may be used by users and administrators to configure the
62 * overall java security policy (currently stored in the policy file).
63 * Using PolicyTool administrators may add and remove policies from
64 * the policy file. <p>
65 *
66 * @see java.security.Policy
67 * @since 1.2
68 * @deprecated {@code policytool} has been deprecated for removal because it
69 * is rarely used, and it provides little value over editing policy
70 * files using a text editor.
71 */
72
73 @Deprecated(since="9", forRemoval=true)
74 @SuppressWarnings("removal")
75 public class PolicyTool {
76
77 // for i18n
78 static final java.util.ResourceBundle rb =
79 java.util.ResourceBundle.getBundle(
80 "sun.security.tools.policytool.Resources");
81 static final Collator collator = Collator.getInstance();
82 static {
83 // this is for case insensitive string comparisons
84 collator.setStrength(Collator.PRIMARY);
85
86 // Support for Apple menu bar
87 if (System.getProperty("apple.laf.useScreenMenuBar") == null) {
88 System.setProperty("apple.laf.useScreenMenuBar", "true");
89 }
90 System.setProperty("apple.awt.application.name", getMessage("Policy.Tool"));
91
92 // Apply the system L&F if not specified with a system property.
93 if (System.getProperty("swing.defaultlaf") == null) {
94 try {
863 }
864 return s.toString();
865 }
866 }
867
868 /**
869 * Each entry in the policy configuration file is represented by a
870 * PolicyEntry object.
871 *
872 * A PolicyEntry is a (CodeSource,Permission) pair. The
873 * CodeSource contains the (URL, PublicKey) that together identify
874 * where the Java bytecodes come from and who (if anyone) signed
875 * them. The URL could refer to localhost. The URL could also be
876 * null, meaning that this policy entry is given to all comers, as
877 * long as they match the signer field. The signer could be null,
878 * meaning the code is not signed.
879 *
880 * The Permission contains the (Type, Name, Action) triplet.
881 *
882 */
883 @SuppressWarnings({"deprecation",
884 "removal"}) // PolicyTool
885 class PolicyEntry {
886
887 private CodeSource codesource;
888 private PolicyTool tool;
889 private PolicyParser.GrantEntry grantEntry;
890 private boolean testing = false;
891
892 /**
893 * Create a PolicyEntry object from the information read in
894 * from a policy file.
895 */
896 PolicyEntry(PolicyTool tool, PolicyParser.GrantEntry ge)
897 throws MalformedURLException, NoSuchMethodException,
898 ClassNotFoundException, InstantiationException, IllegalAccessException,
899 InvocationTargetException, CertificateException,
900 IOException, NoSuchAlgorithmException, UnrecoverableKeyException {
901
902 this.tool = tool;
903
904 URL location = null;
1004 PolicyParser.PermissionEntry toPermissionEntry(Permission perm) {
1005
1006 String actions = null;
1007
1008 // get the actions
1009 if (perm.getActions() != null &&
1010 perm.getActions().trim() != "")
1011 actions = perm.getActions();
1012
1013 PolicyParser.PermissionEntry pe = new PolicyParser.PermissionEntry
1014 (perm.getClass().getName(),
1015 perm.getName(),
1016 actions);
1017 return pe;
1018 }
1019 }
1020
1021 /**
1022 * The main window for the PolicyTool
1023 */
1024 @SuppressWarnings({"deprecation",
1025 "removal"}) // PolicyTool
1026 class ToolWindow extends JFrame {
1027 // use serialVersionUID from JDK 1.2.2 for interoperability
1028 private static final long serialVersionUID = 5682568601210376777L;
1029
1030 /* ESCAPE key */
1031 static final KeyStroke escKey = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
1032
1033 /* external paddings */
1034 public static final Insets TOP_PADDING = new Insets(25,0,0,0);
1035 public static final Insets BOTTOM_PADDING = new Insets(0,0,25,0);
1036 public static final Insets LITE_BOTTOM_PADDING = new Insets(0,0,10,0);
1037 public static final Insets LR_PADDING = new Insets(0,10,0,10);
1038 public static final Insets TOP_BOTTOM_PADDING = new Insets(15, 0, 15, 0);
1039 public static final Insets L_TOP_BOTTOM_PADDING = new Insets(5,10,15,0);
1040 public static final Insets LR_TOP_BOTTOM_PADDING = new Insets(15, 4, 15, 4);
1041 public static final Insets LR_BOTTOM_PADDING = new Insets(0,10,5,10);
1042 public static final Insets L_BOTTOM_PADDING = new Insets(0,10,5,0);
1043 public static final Insets R_BOTTOM_PADDING = new Insets(0, 0, 25, 5);
1044 public static final Insets R_PADDING = new Insets(0, 0, 0, 5);
1045
1539
1540 addNewComponent(tw, panel, 1,
1541 0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.VERTICAL);
1542
1543 tw.pack();
1544 tw.setLocationRelativeTo(w);
1545 tw.setVisible(true);
1546 if (chooseResult.length() > 0) {
1547 return chooseResult.charAt(0);
1548 } else {
1549 // I did encounter this once, don't why.
1550 return 'N';
1551 }
1552 }
1553
1554 }
1555
1556 /**
1557 * General dialog window
1558 */
1559 @SuppressWarnings({"deprecation",
1560 "removal"}) // PolicyTool
1561 class ToolDialog extends JDialog {
1562 // use serialVersionUID from JDK 1.2.2 for interoperability
1563 private static final long serialVersionUID = -372244357011301190L;
1564
1565 /* ESCAPE key */
1566 static final KeyStroke escKey = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
1567
1568 /* necessary constants */
1569 public static final int NOACTION = 0;
1570 public static final int QUIT = 1;
1571 public static final int NEW = 2;
1572 public static final int OPEN = 3;
1573
1574 /* popup menus */
1575 public static final String PERM =
1576 PolicyTool.getMessage
1577 ("Permission.");
1578
1579 public static final String PRIN_TYPE =
1580 PolicyTool.getMessage("Principal.Type.");
2904 if (pppe.action != null) {
2905 result += ", \"" + pppe.action + "\"";
2906 }
2907 if (pppe.signedBy != null) {
2908 result += ", signedBy " + pppe.signedBy;
2909 }
2910 return result;
2911 }
2912
2913 static String PrincipalEntryToUserFriendlyString(PolicyParser.PrincipalEntry pppe) {
2914 StringWriter sw = new StringWriter();
2915 PrintWriter pw = new PrintWriter(sw);
2916 pppe.write(pw);
2917 return sw.toString();
2918 }
2919 }
2920
2921 /**
2922 * Event handler for the PolicyTool window
2923 */
2924 @SuppressWarnings({"deprecation",
2925 "removal"}) // PolicyTool
2926 class ToolWindowListener implements WindowListener {
2927
2928 private PolicyTool tool;
2929 private ToolWindow tw;
2930
2931 ToolWindowListener(PolicyTool tool, ToolWindow tw) {
2932 this.tool = tool;
2933 this.tw = tw;
2934 }
2935
2936 public void windowOpened(WindowEvent we) {
2937 }
2938
2939 public void windowClosing(WindowEvent we) {
2940 // Closing the window acts the same as choosing Menu->Exit.
2941
2942 // ask user if they want to save changes
2943 ToolDialog td = new ToolDialog(PolicyTool.getMessage("Save.Changes"), tool, tw, true);
2944 td.displayUserSave(ToolDialog.QUIT);
2945
2950 public void windowClosed(WindowEvent we) {
2951 System.exit(0);
2952 }
2953
2954 public void windowIconified(WindowEvent we) {
2955 }
2956
2957 public void windowDeiconified(WindowEvent we) {
2958 }
2959
2960 public void windowActivated(WindowEvent we) {
2961 }
2962
2963 public void windowDeactivated(WindowEvent we) {
2964 }
2965 }
2966
2967 /**
2968 * Event handler for the Policy List
2969 */
2970 @SuppressWarnings({"deprecation",
2971 "removal"}) // PolicyTool
2972 class PolicyListListener extends MouseAdapter implements ActionListener {
2973
2974 private PolicyTool tool;
2975 private ToolWindow tw;
2976
2977 PolicyListListener(PolicyTool tool, ToolWindow tw) {
2978 this.tool = tool;
2979 this.tw = tw;
2980
2981 }
2982
2983 public void actionPerformed(ActionEvent e) {
2984
2985 // display the permission list for a policy entry
2986 ToolDialog td = new ToolDialog
2987 (PolicyTool.getMessage("Policy.Entry"), tool, tw, true);
2988 td.displayPolicyEntryDialog(true);
2989 }
2990
2991 public void mouseClicked(MouseEvent evt) {
2992 if (evt.getClickCount() == 2) {
2993 actionPerformed(null);
2994 }
2995 }
2996 }
2997
2998 /**
2999 * Event handler for the File Menu
3000 */
3001 @SuppressWarnings({"deprecation",
3002 "removal"}) // PolicyTool
3003 class FileMenuListener implements ActionListener {
3004
3005 private PolicyTool tool;
3006 private ToolWindow tw;
3007
3008 FileMenuListener(PolicyTool tool, ToolWindow tw) {
3009 this.tool = tool;
3010 this.tw = tw;
3011 }
3012
3013 public void actionPerformed(ActionEvent e) {
3014
3015 if (PolicyTool.collator.compare(e.getActionCommand(),
3016 ToolWindow.QUIT) == 0) {
3017
3018 // ask user if they want to save changes
3019 ToolDialog td = new ToolDialog
3020 (PolicyTool.getMessage("Save.Changes"), tool, tw, true);
3021 td.displayUserSave(ToolDialog.QUIT);
3022
3081 }
3082 }
3083 } else if (PolicyTool.collator.compare(e.getActionCommand(),
3084 ToolWindow.SAVE_AS_POLICY_FILE) == 0) {
3085
3086 // user wants to SAVE AS
3087 ToolDialog td = new ToolDialog
3088 (PolicyTool.getMessage("Save.As"), tool, tw, true);
3089 td.displaySaveAsDialog(ToolDialog.NOACTION);
3090
3091 } else if (PolicyTool.collator.compare(e.getActionCommand(),
3092 ToolWindow.VIEW_WARNINGS) == 0) {
3093 tw.displayWarningLog(null);
3094 }
3095 }
3096 }
3097
3098 /**
3099 * Event handler for the main window buttons and Edit Menu
3100 */
3101 @SuppressWarnings({"deprecation",
3102 "removal"}) // PolicyTool
3103 class MainWindowListener implements ActionListener {
3104
3105 private PolicyTool tool;
3106 private ToolWindow tw;
3107
3108 MainWindowListener(PolicyTool tool, ToolWindow tw) {
3109 this.tool = tool;
3110 this.tw = tw;
3111 }
3112
3113 public void actionPerformed(ActionEvent e) {
3114
3115 if (PolicyTool.collator.compare(e.getActionCommand(),
3116 ToolWindow.ADD_POLICY_ENTRY) == 0) {
3117
3118 // display a dialog box for the user to enter policy info
3119 ToolDialog td = new ToolDialog
3120 (PolicyTool.getMessage("Policy.Entry"), tool, tw, true);
3121 td.displayPolicyEntryDialog(false);
3122
3158
3159 } else if (PolicyTool.collator.compare(e.getActionCommand(),
3160 ToolWindow.EDIT_KEYSTORE) == 0) {
3161
3162 // display a dialog box for the user to enter keystore info
3163 ToolDialog td = new ToolDialog
3164 (PolicyTool.getMessage("KeyStore"), tool, tw, true);
3165 td.keyStoreDialog(ToolDialog.EDIT_KEYSTORE);
3166 }
3167 }
3168 }
3169
3170 /**
3171 * Event handler for AddEntryDoneButton button
3172 *
3173 * -- if edit is TRUE, then we are EDITing an existing PolicyEntry
3174 * and we need to update both the policy and the GUI listing.
3175 * if edit is FALSE, then we are ADDing a new PolicyEntry,
3176 * so we only need to update the GUI listing.
3177 */
3178 @SuppressWarnings({"deprecation",
3179 "removal"}) // PolicyTool
3180 class AddEntryDoneButtonListener implements ActionListener {
3181
3182 private PolicyTool tool;
3183 private ToolWindow tw;
3184 private ToolDialog td;
3185 private boolean edit;
3186
3187 AddEntryDoneButtonListener(PolicyTool tool, ToolWindow tw,
3188 ToolDialog td, boolean edit) {
3189 this.tool = tool;
3190 this.tw = tw;
3191 this.td = td;
3192 this.edit = edit;
3193 }
3194
3195 public void actionPerformed(ActionEvent e) {
3196
3197 try {
3198 // get a PolicyEntry object from the dialog policy info
3199 PolicyEntry newEntry = td.getPolicyEntryFromDialog();
3226 (newCodeBaseStr, policyList.getModel().getElementAt(listIndex)) != 0)
3227 tool.modified = true;
3228 ((DefaultListModel<String>)policyList.getModel()).set(listIndex, newCodeBaseStr);
3229 } else {
3230 tool.addEntry(newEntry, -1);
3231 ((DefaultListModel<String>)policyList.getModel()).addElement(newEntry.headerToString());
3232 tool.modified = true;
3233 }
3234 td.setVisible(false);
3235 td.dispose();
3236
3237 } catch (Exception eee) {
3238 tw.displayErrorDialog(td, eee);
3239 }
3240 }
3241 }
3242
3243 /**
3244 * Event handler for ChangeKeyStoreOKButton button
3245 */
3246 @SuppressWarnings({"deprecation",
3247 "removal"}) // PolicyTool
3248 class ChangeKeyStoreOKButtonListener implements ActionListener {
3249
3250 private PolicyTool tool;
3251 private ToolWindow tw;
3252 private ToolDialog td;
3253
3254 ChangeKeyStoreOKButtonListener(PolicyTool tool, ToolWindow tw,
3255 ToolDialog td) {
3256 this.tool = tool;
3257 this.tw = tw;
3258 this.td = td;
3259 }
3260
3261 public void actionPerformed(ActionEvent e) {
3262
3263 String URLString = ((JTextField)td.getComponent(
3264 ToolDialog.KSD_NAME_TEXTFIELD)).getText().trim();
3265 String type = ((JTextField)td.getComponent(
3266 ToolDialog.KSD_TYPE_TEXTFIELD)).getText().trim();
3267 String provider = ((JTextField)td.getComponent(
3274 ((URLString.length() == 0 ? null : URLString),
3275 (type.length() == 0 ? null : type),
3276 (provider.length() == 0 ? null : provider),
3277 (pwdURL.length() == 0 ? null : pwdURL));
3278 tool.modified = true;
3279 } catch (Exception ex) {
3280 MessageFormat form = new MessageFormat(PolicyTool.getMessage
3281 ("Unable.to.open.KeyStore.ex.toString."));
3282 Object[] source = {ex.toString()};
3283 tw.displayErrorDialog(td, form.format(source));
3284 return;
3285 }
3286
3287 td.dispose();
3288 }
3289 }
3290
3291 /**
3292 * Event handler for AddPrinButton button
3293 */
3294 @SuppressWarnings({"deprecation",
3295 "removal"}) // PolicyTool
3296 class AddPrinButtonListener implements ActionListener {
3297
3298 private PolicyTool tool;
3299 private ToolWindow tw;
3300 private ToolDialog td;
3301 private boolean editPolicyEntry;
3302
3303 AddPrinButtonListener(PolicyTool tool, ToolWindow tw,
3304 ToolDialog td, boolean editPolicyEntry) {
3305 this.tool = tool;
3306 this.tw = tw;
3307 this.td = td;
3308 this.editPolicyEntry = editPolicyEntry;
3309 }
3310
3311 public void actionPerformed(ActionEvent e) {
3312
3313 // display a dialog box for the user to enter principal info
3314 td.displayPrincipalDialog(editPolicyEntry, false);
3315 }
3316 }
3317
3318 /**
3319 * Event handler for AddPermButton button
3320 */
3321 @SuppressWarnings({"deprecation",
3322 "removal"}) // PolicyTool
3323 class AddPermButtonListener implements ActionListener {
3324
3325 private PolicyTool tool;
3326 private ToolWindow tw;
3327 private ToolDialog td;
3328 private boolean editPolicyEntry;
3329
3330 AddPermButtonListener(PolicyTool tool, ToolWindow tw,
3331 ToolDialog td, boolean editPolicyEntry) {
3332 this.tool = tool;
3333 this.tw = tw;
3334 this.td = td;
3335 this.editPolicyEntry = editPolicyEntry;
3336 }
3337
3338 public void actionPerformed(ActionEvent e) {
3339
3340 // display a dialog box for the user to enter permission info
3341 td.displayPermissionDialog(editPolicyEntry, false);
3342 }
3343 }
3344
3345 /**
3346 * Event handler for AddPrinOKButton button
3347 */
3348 @SuppressWarnings({"deprecation",
3349 "removal"}) // PolicyTool
3350 class NewPolicyPrinOKButtonListener implements ActionListener {
3351
3352 private PolicyTool tool;
3353 private ToolWindow tw;
3354 private ToolDialog listDialog;
3355 private ToolDialog infoDialog;
3356 private boolean edit;
3357
3358 NewPolicyPrinOKButtonListener(PolicyTool tool,
3359 ToolWindow tw,
3360 ToolDialog listDialog,
3361 ToolDialog infoDialog,
3362 boolean edit) {
3363 this.tool = tool;
3364 this.tw = tw;
3365 this.listDialog = listDialog;
3366 this.infoDialog = infoDialog;
3367 this.edit = edit;
3368 }
3369
3393 String prinString = ToolDialog.PrincipalEntryToUserFriendlyString(pppe);
3394 if (edit) {
3395 // if editing, replace the original principal
3396 int index = prinList.getSelectedIndex();
3397 prinList.replaceTaggedItem(prinString, pppe, index);
3398 } else {
3399 // if adding, just add it to the end
3400 prinList.addTaggedItem(prinString, pppe);
3401 }
3402 }
3403 infoDialog.dispose();
3404 } catch (Exception ee) {
3405 tw.displayErrorDialog(infoDialog, ee);
3406 }
3407 }
3408 }
3409
3410 /**
3411 * Event handler for AddPermOKButton button
3412 */
3413 @SuppressWarnings({"deprecation",
3414 "removal"}) // PolicyTool
3415 class NewPolicyPermOKButtonListener implements ActionListener {
3416
3417 private PolicyTool tool;
3418 private ToolWindow tw;
3419 private ToolDialog listDialog;
3420 private ToolDialog infoDialog;
3421 private boolean edit;
3422
3423 NewPolicyPermOKButtonListener(PolicyTool tool,
3424 ToolWindow tw,
3425 ToolDialog listDialog,
3426 ToolDialog infoDialog,
3427 boolean edit) {
3428 this.tool = tool;
3429 this.tw = tw;
3430 this.listDialog = listDialog;
3431 this.infoDialog = infoDialog;
3432 this.edit = edit;
3433 }
3434
3458 // if editing, replace the original permission
3459 int which = permList.getSelectedIndex();
3460 permList.replaceTaggedItem(permString, pppe, which);
3461 } else {
3462 // if adding, just add it to the end
3463 permList.addTaggedItem(permString, pppe);
3464 }
3465 infoDialog.dispose();
3466
3467 } catch (InvocationTargetException ite) {
3468 tw.displayErrorDialog(infoDialog, ite.getTargetException());
3469 } catch (Exception ee) {
3470 tw.displayErrorDialog(infoDialog, ee);
3471 }
3472 }
3473 }
3474
3475 /**
3476 * Event handler for RemovePrinButton button
3477 */
3478 @SuppressWarnings({"deprecation",
3479 "removal"}) // PolicyTool
3480 class RemovePrinButtonListener implements ActionListener {
3481
3482 private PolicyTool tool;
3483 private ToolWindow tw;
3484 private ToolDialog td;
3485 private boolean edit;
3486
3487 RemovePrinButtonListener(PolicyTool tool, ToolWindow tw,
3488 ToolDialog td, boolean edit) {
3489 this.tool = tool;
3490 this.tw = tw;
3491 this.td = td;
3492 this.edit = edit;
3493 }
3494
3495 public void actionPerformed(ActionEvent e) {
3496
3497 // get the Principal selected from the Principal List
3498 TaggedList prinList = (TaggedList)td.getComponent(
3499 ToolDialog.PE_PRIN_LIST);
3500 int prinIndex = prinList.getSelectedIndex();
3501
3502 if (prinIndex < 0) {
3503 tw.displayErrorDialog(td, new Exception
3504 (PolicyTool.getMessage("No.principal.selected")));
3505 return;
3506 }
3507 // remove the principal from the display
3508 prinList.removeTaggedItem(prinIndex);
3509 }
3510 }
3511
3512 /**
3513 * Event handler for RemovePermButton button
3514 */
3515 @SuppressWarnings({"deprecation",
3516 "removal"}) // PolicyTool
3517 class RemovePermButtonListener implements ActionListener {
3518
3519 private PolicyTool tool;
3520 private ToolWindow tw;
3521 private ToolDialog td;
3522 private boolean edit;
3523
3524 RemovePermButtonListener(PolicyTool tool, ToolWindow tw,
3525 ToolDialog td, boolean edit) {
3526 this.tool = tool;
3527 this.tw = tw;
3528 this.td = td;
3529 this.edit = edit;
3530 }
3531
3532 public void actionPerformed(ActionEvent e) {
3533
3534 // get the Permission selected from the Permission List
3535 TaggedList permList = (TaggedList)td.getComponent(
3536 ToolDialog.PE_PERM_LIST);
3539 if (permIndex < 0) {
3540 tw.displayErrorDialog(td, new Exception
3541 (PolicyTool.getMessage("No.permission.selected")));
3542 return;
3543 }
3544 // remove the permission from the display
3545 permList.removeTaggedItem(permIndex);
3546
3547 }
3548 }
3549
3550 /**
3551 * Event handler for Edit Principal button
3552 *
3553 * We need the editPolicyEntry boolean to tell us if the user is
3554 * adding a new PolicyEntry at this time, or editing an existing entry.
3555 * If the user is adding a new PolicyEntry, we ONLY update the
3556 * GUI listing. If the user is editing an existing PolicyEntry, we
3557 * update both the GUI listing and the actual PolicyEntry.
3558 */
3559 @SuppressWarnings({"deprecation",
3560 "removal"}) // PolicyTool
3561 class EditPrinButtonListener extends MouseAdapter implements ActionListener {
3562
3563 private PolicyTool tool;
3564 private ToolWindow tw;
3565 private ToolDialog td;
3566 private boolean editPolicyEntry;
3567
3568 EditPrinButtonListener(PolicyTool tool, ToolWindow tw,
3569 ToolDialog td, boolean editPolicyEntry) {
3570 this.tool = tool;
3571 this.tw = tw;
3572 this.td = td;
3573 this.editPolicyEntry = editPolicyEntry;
3574 }
3575
3576 public void actionPerformed(ActionEvent e) {
3577
3578 // get the Principal selected from the Principal List
3579 TaggedList list = (TaggedList)td.getComponent(
3580 ToolDialog.PE_PRIN_LIST);
3587 }
3588 td.displayPrincipalDialog(editPolicyEntry, true);
3589 }
3590
3591 public void mouseClicked(MouseEvent evt) {
3592 if (evt.getClickCount() == 2) {
3593 actionPerformed(null);
3594 }
3595 }
3596 }
3597
3598 /**
3599 * Event handler for Edit Permission button
3600 *
3601 * We need the editPolicyEntry boolean to tell us if the user is
3602 * adding a new PolicyEntry at this time, or editing an existing entry.
3603 * If the user is adding a new PolicyEntry, we ONLY update the
3604 * GUI listing. If the user is editing an existing PolicyEntry, we
3605 * update both the GUI listing and the actual PolicyEntry.
3606 */
3607 @SuppressWarnings({"deprecation",
3608 "removal"}) // PolicyTool
3609 class EditPermButtonListener extends MouseAdapter implements ActionListener {
3610
3611 private PolicyTool tool;
3612 private ToolWindow tw;
3613 private ToolDialog td;
3614 private boolean editPolicyEntry;
3615
3616 EditPermButtonListener(PolicyTool tool, ToolWindow tw,
3617 ToolDialog td, boolean editPolicyEntry) {
3618 this.tool = tool;
3619 this.tw = tw;
3620 this.td = td;
3621 this.editPolicyEntry = editPolicyEntry;
3622 }
3623
3624 public void actionPerformed(ActionEvent e) {
3625
3626 // get the Permission selected from the Permission List
3627 @SuppressWarnings("unchecked")
3628 JList<String> list = (JList<String>)td.getComponent(ToolDialog.PE_PERM_LIST);
3629 int permIndex = list.getSelectedIndex();
3630
3631 if (permIndex < 0) {
3632 tw.displayErrorDialog(td, new Exception
3633 (PolicyTool.getMessage("No.permission.selected")));
3634 return;
3635 }
3636 td.displayPermissionDialog(editPolicyEntry, true);
3637 }
3638
3639 public void mouseClicked(MouseEvent evt) {
3640 if (evt.getClickCount() == 2) {
3641 actionPerformed(null);
3642 }
3643 }
3644 }
3645
3646 /**
3647 * Event handler for Principal Popup Menu
3648 */
3649 @SuppressWarnings({"deprecation",
3650 "removal"}) // PolicyTool
3651 class PrincipalTypeMenuListener implements ItemListener {
3652
3653 private ToolDialog td;
3654
3655 PrincipalTypeMenuListener(ToolDialog td) {
3656 this.td = td;
3657 }
3658
3659 public void itemStateChanged(ItemEvent e) {
3660 if (e.getStateChange() == ItemEvent.DESELECTED) {
3661 // We're only interested in SELECTED events
3662 return;
3663 }
3664
3665 @SuppressWarnings("unchecked")
3666 JComboBox<String> prin = (JComboBox<String>)td.getComponent(ToolDialog.PRD_PRIN_CHOICE);
3667 JTextField prinField = (JTextField)td.getComponent(
3668 ToolDialog.PRD_PRIN_TEXTFIELD);
3669 JTextField nameField = (JTextField)td.getComponent(
3670 ToolDialog.PRD_NAME_TEXTFIELD);
3682 }
3683
3684 // if you change the principal, clear the name
3685 if (prinField.getText().indexOf((String)e.getItem()) == -1) {
3686 nameField.setText("");
3687 }
3688
3689 // set the text in the textfield and also modify the
3690 // pull-down choice menus to reflect the correct possible
3691 // set of names and actions
3692 Prin inputPrin = ToolDialog.getPrin((String)e.getItem(), false);
3693 if (inputPrin != null) {
3694 prinField.setText(inputPrin.getName());
3695 }
3696 }
3697 }
3698
3699 /**
3700 * Event handler for Permission Popup Menu
3701 */
3702 @SuppressWarnings({"deprecation",
3703 "removal"}) // PolicyTool
3704 class PermissionMenuListener implements ItemListener {
3705
3706 private ToolDialog td;
3707
3708 PermissionMenuListener(ToolDialog td) {
3709 this.td = td;
3710 }
3711
3712 public void itemStateChanged(ItemEvent e) {
3713 if (e.getStateChange() == ItemEvent.DESELECTED) {
3714 // We're only interested in SELECTED events
3715 return;
3716 }
3717
3718 @SuppressWarnings("unchecked")
3719 JComboBox<String> perms = (JComboBox<String>)td.getComponent(
3720 ToolDialog.PD_PERM_CHOICE);
3721 @SuppressWarnings("unchecked")
3722 JComboBox<String> names = (JComboBox<String>)td.getComponent(
3723 ToolDialog.PD_NAME_CHOICE);
3758 }
3759
3760 // set the text in the textfield and also modify the
3761 // pull-down choice menus to reflect the correct possible
3762 // set of names and actions
3763
3764 Perm inputPerm = ToolDialog.getPerm((String)e.getItem(), false);
3765 if (inputPerm == null) {
3766 permField.setText("");
3767 } else {
3768 permField.setText(inputPerm.getName());
3769 }
3770 td.setPermissionNames(inputPerm, names, nameField);
3771 td.setPermissionActions(inputPerm, actions, actionsField);
3772 }
3773 }
3774
3775 /**
3776 * Event handler for Permission Name Popup Menu
3777 */
3778 @SuppressWarnings({"deprecation",
3779 "removal"}) // PolicyTool
3780 class PermissionNameMenuListener implements ItemListener {
3781
3782 private ToolDialog td;
3783
3784 PermissionNameMenuListener(ToolDialog td) {
3785 this.td = td;
3786 }
3787
3788 public void itemStateChanged(ItemEvent e) {
3789 if (e.getStateChange() == ItemEvent.DESELECTED) {
3790 // We're only interested in SELECTED events
3791 return;
3792 }
3793
3794 @SuppressWarnings("unchecked")
3795 JComboBox<String> names = (JComboBox<String>)td.getComponent(ToolDialog.PD_NAME_CHOICE);
3796 names.getAccessibleContext().setAccessibleName(
3797 PolicyTool.splitToWords((String)e.getItem()));
3798
3799 if (((String)e.getItem()).indexOf(ToolDialog.PERM_NAME) != -1)
3913 /**
3914 * Event handler for StatusOKButton button
3915 */
3916 class StatusOKButtonListener implements ActionListener {
3917
3918 private ToolDialog sd;
3919
3920 StatusOKButtonListener(ToolDialog sd) {
3921 this.sd = sd;
3922 }
3923
3924 public void actionPerformed(ActionEvent e) {
3925 sd.setVisible(false);
3926 sd.dispose();
3927 }
3928 }
3929
3930 /**
3931 * Event handler for UserSaveYes button
3932 */
3933 @SuppressWarnings({"deprecation",
3934 "removal"}) // PolicyTool
3935 class UserSaveYesButtonListener implements ActionListener {
3936
3937 private ToolDialog us;
3938 private PolicyTool tool;
3939 private ToolWindow tw;
3940 private int select;
3941
3942 UserSaveYesButtonListener(ToolDialog us, PolicyTool tool,
3943 ToolWindow tw, int select) {
3944 this.us = us;
3945 this.tool = tool;
3946 this.tw = tw;
3947 this.select = select;
3948 }
3949
3950 public void actionPerformed(ActionEvent e) {
3951
3952 // first get rid of the window
3953 us.setVisible(false);
3954 us.dispose();
3969 MessageFormat form = new MessageFormat
3970 (PolicyTool.getMessage
3971 ("Policy.successfully.written.to.filename"));
3972 Object[] source = {filename};
3973 tw.displayStatusDialog(null, form.format(source));
3974
3975 // now continue with the originally requested command
3976 // (QUIT, NEW, or OPEN)
3977 us.userSaveContinue(tool, tw, us, select);
3978 }
3979 } catch (Exception ee) {
3980 // error -- just report it and bail
3981 tw.displayErrorDialog(null, ee);
3982 }
3983 }
3984 }
3985
3986 /**
3987 * Event handler for UserSaveNoButton
3988 */
3989 @SuppressWarnings({"deprecation",
3990 "removal"}) // PolicyTool
3991 class UserSaveNoButtonListener implements ActionListener {
3992
3993 private PolicyTool tool;
3994 private ToolWindow tw;
3995 private ToolDialog us;
3996 private int select;
3997
3998 UserSaveNoButtonListener(ToolDialog us, PolicyTool tool,
3999 ToolWindow tw, int select) {
4000 this.us = us;
4001 this.tool = tool;
4002 this.tw = tw;
4003 this.select = select;
4004 }
4005
4006 public void actionPerformed(ActionEvent e) {
4007 us.setVisible(false);
4008 us.dispose();
4009
4010 // now continue with the originally requested command
4019 class UserSaveCancelButtonListener implements ActionListener {
4020
4021 private ToolDialog us;
4022
4023 UserSaveCancelButtonListener(ToolDialog us) {
4024 this.us = us;
4025 }
4026
4027 public void actionPerformed(ActionEvent e) {
4028 us.setVisible(false);
4029 us.dispose();
4030
4031 // do NOT continue with the originally requested command
4032 // (QUIT, NEW, or OPEN)
4033 }
4034 }
4035
4036 /**
4037 * Event handler for ConfirmRemovePolicyEntryOKButtonListener
4038 */
4039 @SuppressWarnings({"deprecation",
4040 "removal"}) // PolicyTool
4041 class ConfirmRemovePolicyEntryOKButtonListener implements ActionListener {
4042
4043 private PolicyTool tool;
4044 private ToolWindow tw;
4045 private ToolDialog us;
4046
4047 ConfirmRemovePolicyEntryOKButtonListener(PolicyTool tool,
4048 ToolWindow tw, ToolDialog us) {
4049 this.tool = tool;
4050 this.tw = tw;
4051 this.us = us;
4052 }
4053
4054 public void actionPerformed(ActionEvent e) {
4055 // remove the entry
4056 @SuppressWarnings("unchecked")
4057 JList<String> list = (JList<String>)tw.getComponent(ToolWindow.MW_POLICY_LIST);
4058 int index = list.getSelectedIndex();
4059 PolicyEntry entries[] = tool.getEntry();
4060 tool.removeEntry(entries[index]);
4176 }
4177 }
4178
4179 class AllPerm extends Perm {
4180 AllPerm() {
4181 super(java.security.AllPermission.class, null, null);
4182 }
4183 }
4184
4185 class AudioPerm extends Perm {
4186 AudioPerm() {
4187 super(javax.sound.sampled.AudioPermission.class,
4188 new String[] {
4189 "play",
4190 "record"
4191 },
4192 null);
4193 }
4194 }
4195
4196 @SuppressWarnings({"deprecation",
4197 "removal"}) // PolicyTool
4198 class AuthPerm extends Perm {
4199 AuthPerm() {
4200 super(javax.security.auth.AuthPermission.class,
4201 new String[] {
4202 "doAs",
4203 "doAsPrivileged",
4204 "getSubject",
4205 "getSubjectFromDomainCombiner",
4206 "setReadOnly",
4207 "modifyPrincipals",
4208 "modifyPublicCredentials",
4209 "modifyPrivateCredentials",
4210 "refreshCredential",
4211 "destroyCredential",
4212 "createLoginContext.<" + PolicyTool.getMessage("name") + ">",
4213 "getLoginConfiguration",
4214 "setLoginConfiguration",
4215 "createLoginConfiguration.<" +
4216 PolicyTool.getMessage("configuration.type") + ">",
4217 "refreshLoginConfiguration"
4250 },
4251 null);
4252 }
4253 }
4254
4255 class FilePerm extends Perm {
4256 FilePerm() {
4257 super(java.io.FilePermission.class,
4258 new String[] {
4259 "<<ALL FILES>>"
4260 },
4261 new String[] {
4262 "read",
4263 "write",
4264 "delete",
4265 "execute"
4266 });
4267 }
4268 }
4269
4270 @SuppressWarnings({"deprecation",
4271 "removal"}) // PolicyTool
4272 class URLPerm extends Perm {
4273 URLPerm() {
4274 super(java.net.URLPermission.class,
4275 new String[] {
4276 "<"+ PolicyTool.getMessage("url") + ">",
4277 },
4278 new String[] {
4279 "<" + PolicyTool.getMessage("method.list") + ">:<"
4280 + PolicyTool.getMessage("request.headers.list") + ">",
4281 });
4282 }
4283 }
4284
4285 class InqSecContextPerm extends Perm {
4286 InqSecContextPerm() {
4287 super(com.sun.security.jgss.InquireSecContextPermission.class,
4288 new String[] {
4289 "KRB5_GET_SESSION_KEY",
4290 "KRB5_GET_TKT_FLAGS",
4291 "KRB5_GET_AUTHZ_DATA",
4416 new String[] {
4417 // allow user input
4418 },
4419 new String[] {
4420 "read",
4421 "write"
4422 });
4423 }
4424 }
4425
4426 class ReflectPerm extends Perm {
4427 ReflectPerm() {
4428 super(java.lang.reflect.ReflectPermission.class,
4429 new String[] {
4430 "suppressAccessChecks"
4431 },
4432 null);
4433 }
4434 }
4435
4436 @SuppressWarnings({"deprecation",
4437 "removal"}) // PolicyTool
4438 class RuntimePerm extends Perm {
4439 RuntimePerm() {
4440 super(java.lang.RuntimePermission.class,
4441 new String[] {
4442 "createClassLoader",
4443 "getClassLoader",
4444 "setContextClassLoader",
4445 "enableContextClassLoaderOverride",
4446 "setSecurityManager",
4447 "createSecurityManager",
4448 "getenv.<" +
4449 PolicyTool.getMessage("environment.variable.name") + ">",
4450 "exitVM",
4451 "shutdownHooks",
4452 "setFactory",
4453 "setIO",
4454 "modifyThread",
4455 "stopThread",
4456 "modifyThreadGroup",
4457 "getProtectionDomain",
4458 "readFileDescriptor",
4459 "writeFileDescriptor",
4460 "loadLibrary.<" +
4461 PolicyTool.getMessage("library.name") + ">",
4462 "accessClassInPackage.<" +
4463 PolicyTool.getMessage("package.name")+">",
4464 "defineClassInPackage.<" +
4465 PolicyTool.getMessage("package.name")+">",
4466 "accessDeclaredMembers",
4467 "queuePrintJob",
4468 "getStackTrace",
4469 "setDefaultUncaughtExceptionHandler",
4470 "preferences",
4471 "usePolicy",
4472 // "inheritedChannel"
4473 },
4474 null);
4475 }
4476 }
4477
4478 @SuppressWarnings({"deprecation",
4479 "removal"}) // PolicyTool
4480 class SecurityPerm extends Perm {
4481 SecurityPerm() {
4482 super(java.security.SecurityPermission.class,
4483 new String[] {
4484 "createAccessControlContext",
4485 "getDomainCombiner",
4486 "getPolicy",
4487 "setPolicy",
4488 "createPolicy.<" +
4489 PolicyTool.getMessage("policy.type") + ">",
4490 "getProperty.<" +
4491 PolicyTool.getMessage("property.name") + ">",
4492 "setProperty.<" +
4493 PolicyTool.getMessage("property.name") + ">",
4494 "insertProvider.<" +
4495 PolicyTool.getMessage("provider.name") + ">",
4496 "removeProvider.<" +
4497 PolicyTool.getMessage("provider.name") + ">",
4498 //"setSystemScope",
4499 //"setIdentityPublicKey",
|