Class PolicyEditor
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
net.adoptopenjdk.icedteaweb.client.policyeditor.PolicyEditor
- All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible
This class provides a policy editing tool as a simpler alternate to
the JDK PolicyTool.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static classprivate static classprivate static classstatic interfaceprivate static classNested classes/interfaces inherited from class JPanel
JPanel.AccessibleJPanelNested classes/interfaces inherited from class JComponent
JComponent.AccessibleJComponentNested classes/interfaces inherited from class Container
Container.AccessibleAWTContainerNested classes/interfaces inherited from class Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ActionListenerprivate final ActionListenerprivate final JButtonprivate final ActionListenerprivate final Map<PolicyEditorPermissions, JCheckBox> private final JButtonprivate final ActionListenerprivate booleanprivate final ActionListenerprivate CustomPolicyViewerprivate final JFileChooserprivate final List<PolicyEditor.JCheckBoxWithGroup> private final JList<PolicyIdentifier> private final DefaultListModel<PolicyIdentifier> private static final Loggerprivate final ActionListenerprivate final ActionListenerprivate final ActionListenerprivate final ActionListenerprivate final JButtonprivate final ActionListenerprivate final ActionListenerprivate final ActionListenerprivate final WeakReference<PolicyEditor> See showChangesSavedDialog/showCouldNotSaveDialog.private final ActionListenerfinal PolicyEditorControllerprivate final ActionListenerprivate final JButtonprivate final ActionListenerprivate final ActionListenerprivate final JScrollPaneprivate final ActionListenerFields inherited from class JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOWFields inherited from class Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTFields inherited from interface ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddCustomPermission(PolicyIdentifier identifier, PolicyParser.PermissionEntry permission) private voidvoidaddNewEntry(PolicyIdentifier identifier) Add a new identifier to the editor's model.voidDisplay an input dialog, which will disappear when the user enters a valid entry or when the user presses cancel.private intDetect if the policy settings have changed, either on-disk or in-app.private static StringcleanFilePathArgument(String filepath) voidclearCustomPermissions(PolicyIdentifier identifier) voidcopyEntry(PolicyIdentifier identifier) Copy an entry to the system clipboardstatic PolicyEditorcreateInstance(String filepath) Create a new PolicyEditor instance without passing argv.private static JMenuBarcreateMenuBar(PolicyEditor editor) (package private) voidCalled by the Custom Policy Viewer on its parent Policy Editor when the Custom Policy Viewer is closing(package private) static StringgetCodebaseArgument(CommandLineOptionsParser optionParser) getCustomPermissions(PolicyIdentifier identifier) private static StringgetFile()(package private) static StringgetFilePathArgument(CommandLineOptionsParser optionParser) private booleangetPermissions(PolicyIdentifier identifier) getPolicyEditorDialog(String filepath) getPolicyEditorFrame(String filepath) (package private) static Set<PolicyParser.PrincipalEntry> getPrincipalsArgument(CommandLineOptionsParser optionParser) private PolicyIdentifier(package private) static StringgetSignedByArgument(CommandLineOptionsParser optionParser) private String(package private) static PolicyIdentifieridentifierFromCodebase(String codebase) booleanisClosed()Check if the PolicyEditor instance has been visually closed(package private) static booleanisCodeBaseIdentifier(PolicyIdentifier identifier) booleanstatic voidStart a Policy Editor instance.voidmodifyCodebase(PolicyIdentifier identifier, String newCodebase) voidmodifyPrincipals(PolicyIdentifier identifier, List<PolicyParser.PrincipalEntry> principalEntries) voidmodifySignedBy(PolicyIdentifier identifier, String newSignedBy) voidvoidvoidpasteEntry(PolicyIdentifier identifier) Paste a grant entry from the system clipboard with a new identifierprivate static voidpolicyEditorWindowQuit(Window window) private static voidprivate PolicyIdentifierpromptForPolicyIdentifier(PolicyIdentifier initialValues) private booleanpromptOnSaveChangesMade(boolean async) voidremoveIdentifier(PolicyIdentifier identifier) Remove an identifier from the editor's modelprivate voidreplaceIdentifier(PolicyIdentifier oldIdentifier, PolicyIdentifier newIdentifier) private voidprivate voidSave the policy model into the file pointed to by the filePath field.private static voidsetButtonMnemonic(AbstractButton button, String mnemonic) Set a mnemonic key for a menu item or button(package private) voidsetChangesMade(boolean b) private voidvoidprivate static voidsetMenuItemAccelerator(JMenuItem menuItem, String accelerator) private voidsetParentWindowTitle(String title) voidsetPermission(PolicyIdentifier identifier, PolicyEditorPermissions permission, boolean state) private voidLay out all controls, tooltips, etc.private static voidsetupPolicyEditorWindow(Window window, PolicyEditor editor) private voidShow a dialog informing the user that their changes have been saved.private voidprivate voidprivate voidShow a dialog informing the user that their changes could not be saved.private voidshowInvalidPolicyExceptionDialog(PolicyIdentifier identifier) private voidtoggleExpandedCheckboxGroupPanel(JPanel groupPanel) private voidupdateCheckboxes(PolicyIdentifier identifier) Update the checkboxes to show the permissions granted to the specified identifierprivate voidupdateCheckboxesImpl(PolicyIdentifier identifier) private static booleanvalidateCodebase(String codebase) Methods inherited from class JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUIMethods inherited from class JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, updateMethods inherited from class Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTreeMethods inherited from class Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
Field Details
-
LOG
-
closed
private boolean closed -
checkboxMap
-
groupBoxList
-
scrollPane
-
listModel
-
list
-
okButton
-
closeButton
-
addEntryButton
-
removeEntryButton
-
fileChooser
-
cpViewer
-
parentPolicyEditor
See showChangesSavedDialog/showCouldNotSaveDialog. This weak reference is needed because there is a modal child dialog which can sometimes appear after the editor has been closed and disposed. In this case, its parent should be set to 'null', but otherwise the parent should be the editor so that the dialog is modal. -
policyEditorController
-
okButtonAction
-
addEntryButtonAction
-
removeEntryButtonAction
-
newButtonAction
-
openButtonAction
-
openDefaultButtonAction
-
saveAsButtonAction
-
viewCustomButtonAction
-
modifyCodebaseButtonAction
-
modifyPrincipalsButtonAction
-
modifySignedByButtonAction
-
copyEntryButtonAction
-
pasteEntryButtonAction
-
policyEditorHelpButtonAction
-
aboutPolicyEditorButtonAction
-
aboutItwButtonAction
-
closeButtonAction
-
-
Constructor Details
-
PolicyEditor
-
-
Method Details
-
getDefaultPolicyFilePath
-
addDefaultAllAppletsIdentifier
private void addDefaultAllAppletsIdentifier() -
getModality
private boolean getModality() -
promptOnSaveChangesMade
private boolean promptOnSaveChangesMade(boolean async) - Parameters:
async- use asynchronous saving, which displays a progress dialog, or use synchronous, which blocks the EDT but allows for eg the on-disk file to be changed without resorting to a busy-wait loop- Returns:
- false iff the user wishes to cancel the operation and keep the current editor state
-
setFile
-
setParentWindowTitle
-
getWindowTitleForStatus
-
getSelectedPolicyIdentifier
-
preparePolicyEditorWindow
-
setupPolicyEditorWindow
-
policyEditorWindowQuit
-
getPolicyEditorFrame
-
getPolicyEditorDialog
-
setClosed
private void setClosed() -
isClosed
public boolean isClosed()Check if the PolicyEditor instance has been visually closed- Returns:
- if the PolicyEditor instance has been closed
-
customPolicyViewerClosing
void customPolicyViewerClosing()Called by the Custom Policy Viewer on its parent Policy Editor when the Custom Policy Viewer is closing -
addNewEntry
Add a new identifier to the editor's model.- Parameters:
identifier- to be added
-
identifierFromCodebase
-
validateCodebase
-
getFile
-
addNewIdentifierInteractive
public void addNewIdentifierInteractive()Display an input dialog, which will disappear when the user enters a valid entry or when the user presses cancel. -
promptForPolicyIdentifier
-
removeIdentifier
Remove an identifier from the editor's model- Parameters:
identifier- to be removed
-
modifyCodebase
-
modifyPrincipals
public void modifyPrincipals(PolicyIdentifier identifier, List<PolicyParser.PrincipalEntry> principalEntries) -
modifySignedBy
-
replaceIdentifier
-
copyEntry
Copy an entry to the system clipboard- Parameters:
identifier- the identifier to copy
-
pasteEntry
public void pasteEntry(PolicyIdentifier identifier) throws UnsupportedFlavorException, PolicyParser.ParsingException, IOException Paste a grant entry from the system clipboard with a new identifier -
getCodebases
-
isCodeBaseIdentifier
-
setPermission
public void setPermission(PolicyIdentifier identifier, PolicyEditorPermissions permission, boolean state) -
getPermissions
-
addCustomPermission
public void addCustomPermission(PolicyIdentifier identifier, PolicyParser.PermissionEntry permission) -
getCustomPermissions
-
clearCustomPermissions
-
updateCheckboxes
Update the checkboxes to show the permissions granted to the specified identifier- Parameters:
identifier- whose permissions to display
-
updateCheckboxesImpl
-
setButtonMnemonic
Set a mnemonic key for a menu item or button- Parameters:
button- the component for which to set a mnemonicmnemonic- the mnemonic to set
-
setMenuItemAccelerator
-
createMenuBar
-
setupLayout
private void setupLayout()Lay out all controls, tooltips, etc. -
setChangesMade
void setChangesMade(boolean b) -
resetEntries
private void resetEntries() -
isPerformingIO
public boolean isPerformingIO()- Returns:
- whether this PolicyEditor is currently opening or saving a policy file to disk
-
openPolicyFileSynchronously
public void openPolicyFileSynchronously() -
openAndParsePolicyFile
public void openAndParsePolicyFile() -
savePolicyFile
private void savePolicyFile()Save the policy model into the file pointed to by the filePath field. -
showChangesSavedDialog
private void showChangesSavedDialog()Show a dialog informing the user that their changes have been saved. -
showCouldNotSaveDialog
private void showCouldNotSaveDialog()Show a dialog informing the user that their changes could not be saved. -
showClipboardErrorDialog
private void showClipboardErrorDialog() -
showInvalidPolicyExceptionDialog
-
showCouldNotAccessClipboardDialog
private void showCouldNotAccessClipboardDialog() -
checkPolicyChangesWithDialog
private int checkPolicyChangesWithDialog()Detect if the policy settings have changed, either on-disk or in-app. If an on-disk change has occurred, update the Md5.- Returns:
- The user's choice (Yes/No/Cancel - see JOptionPane constants). "Cancel" if the file hasn't changed but the user has made modifications to the settings. "No" otherwise
-
toggleExpandedCheckboxGroupPanel
-
main
Start a Policy Editor instance.- Parameters:
args- "-file $FILENAME" and/or "-codebase $CODEBASE" are accepted flag/value pairs. -file specifies a file path to be opened by the editor. If none is provided, the default policy file location for the user is opened. -help will print a help message and immediately return (no editor instance opens)
-
getCodebaseArgument
-
getSignedByArgument
-
getPrincipalsArgument
static Set<PolicyParser.PrincipalEntry> getPrincipalsArgument(CommandLineOptionsParser optionParser) -
getFilePathArgument
-
cleanFilePathArgument
-
createInstance
Create a new PolicyEditor instance without passing argv. The returned instance is not yet set visible.- Parameters:
filepath- a policy file to open at start, or null if no file to load- Returns:
- a reference to a new PolicyEditor instance
-