/hg/icedtea-web: Refactored copy, paste to use System Clipboard ...
ldracz at icedtea.classpath.org
ldracz at icedtea.classpath.org
Tue Aug 5 15:14:22 UTC 2014
changeset c6e06c9b4bfb in /hg/icedtea-web
details: http://icedtea.classpath.org/hg/icedtea-web?cmd=changeset;node=c6e06c9b4bfb
author: Lukasz Dracz <ldracz at redhat.com>
date: Tue Aug 05 11:13:20 2014 -0400
Refactored copy, paste to use System Clipboard in PolicyEditor
2014-08-05 Andrew Azores <aazores at redhat.com>
Lukasz Dracz <ldracz at redhat.com>
Refactored copy paste to use System Clipboard in PolicyEditor.
Parsing refactored to use Strings instead of requiring a file.
* netx/net/sourceforge/jnlp/resources/Messages.properties
(PEClipboardError, PEInvalidPolicy, PEClipboardAccessError): added
* netx/net/sourceforge/jnlp/security/policyeditor/PolicyEditor.java
(renameCodebaseButtonAction, copyCodebaseButtonAction, pasteCodebaseButtonAction):
changed functionality to call methods from PolicyEditorController
that use system clipboard
* netx/net/sourceforge/jnlp/security/policyeditor/PolicyEditorController.java
(addPolicyEntry): added
(openAndParsePolicyFile): throws new exception InvalidPolicyException
(copyCodebaseToClipboard, getClipboardContentAsString, getPolicyEntryFromClipboard,
getCodebaseFromClipboard, getPermissionsFromClipboard,
getCustomPermissionsFromClipboard): new methods
* netx/net/sourceforge/jnlp/security/policyeditor/PolicyEntry.java
(getCodebase, getPermissions, getCustomPermissions, fromString,
validatePolicy): new overloaded methods
* netx/net/sourceforge/jnlp/security/policyeditor/PolicyFileModel.java
all methods made synchronized (openAndParsePolicyFile): extracted and modified
parsing logic
(parsePolicyString): new method
(clearPermissions): also clears Custom Permissions now
* netx/net/sourceforge/jnlp/security/policyeditor/InvalidPolicyException.java:
added new exception
* netx/net/sourceforge/jnlp/security/policyeditor/CustomPermission.java
(equals, hashCode): Override these methods to be able to compare custom permissions.
New constructors for custom permission, one of the constructors takes only PermissionType, PermissionTarget
and the other takes an additional PermissionActions
* tests/netx/unit/net/sourceforge/jnlp/security/policyeditor/CustomPermissionTest.java,
* tests/netx/unit/net/sourceforge/jnlp/security/policyeditor/PolicyEditorParsingTest.java,
* tests/netx/unit/net/sourceforge/jnlp/security/policyeditor/PolicyEditorTest.java,
* tests/netx/unit/net/sourceforge/jnlp/security/policyeditor/PolicyEditorControllerTest.java,
* tests/netx/unit/net/sourceforge/jnlp/security/policyeditor/PolicyEntryTest.java,
* tests/netx/unit/net/sourceforge/jnlp/security/policyeditor/PolicyFileModelTest.java:
added new unit tests
diffstat:
ChangeLog | 39 +
netx/net/sourceforge/jnlp/resources/Messages.properties | 4 +-
netx/net/sourceforge/jnlp/security/policyeditor/CustomPermission.java | 30 +
netx/net/sourceforge/jnlp/security/policyeditor/InvalidPolicyException.java | 40 +
netx/net/sourceforge/jnlp/security/policyeditor/PolicyEditor.java | 179 +++-
netx/net/sourceforge/jnlp/security/policyeditor/PolicyEditorController.java | 58 +-
netx/net/sourceforge/jnlp/security/policyeditor/PolicyEntry.java | 95 ++
netx/net/sourceforge/jnlp/security/policyeditor/PolicyFileModel.java | 144 ++--
tests/netx/unit/net/sourceforge/jnlp/security/policyeditor/CustomPermissionTest.java | 26 +
tests/netx/unit/net/sourceforge/jnlp/security/policyeditor/PolicyEditorControllerTest.java | 342 ++++++++++
tests/netx/unit/net/sourceforge/jnlp/security/policyeditor/PolicyEditorParsingTest.java | 1 -
tests/netx/unit/net/sourceforge/jnlp/security/policyeditor/PolicyEditorTest.java | 19 +-
tests/netx/unit/net/sourceforge/jnlp/security/policyeditor/PolicyEntryTest.java | 191 +++++
tests/netx/unit/net/sourceforge/jnlp/security/policyeditor/PolicyFileModelTest.java | 231 ++++++
14 files changed, 1258 insertions(+), 141 deletions(-)
diffs (truncated from 1811 to 500 lines):
diff -r 2833fae52261 -r c6e06c9b4bfb ChangeLog
--- a/ChangeLog Tue Aug 05 10:07:27 2014 -0400
+++ b/ChangeLog Tue Aug 05 11:13:20 2014 -0400
@@ -1,3 +1,42 @@
+2014-08-05 Andrew Azores <aazores at redhat.com>
+ Lukasz Dracz <ldracz at redhat.com>
+
+ Refactored copy paste to use System Clipboard in PolicyEditor.
+ Parsing refactored to use Strings instead of requiring a file.
+ * netx/net/sourceforge/jnlp/resources/Messages.properties
+ (PEClipboardError, PEInvalidPolicy, PEClipboardAccessError): added
+ * netx/net/sourceforge/jnlp/security/policyeditor/PolicyEditor.java
+ (renameCodebaseButtonAction, copyCodebaseButtonAction, pasteCodebaseButtonAction):
+ changed functionality to call methods from PolicyEditorController
+ that use system clipboard
+ * netx/net/sourceforge/jnlp/security/policyeditor/PolicyEditorController.java
+ (addPolicyEntry): added
+ (openAndParsePolicyFile): throws new exception InvalidPolicyException
+ (copyCodebaseToClipboard, getClipboardContentAsString, getPolicyEntryFromClipboard,
+ getCodebaseFromClipboard, getPermissionsFromClipboard,
+ getCustomPermissionsFromClipboard): new methods
+ * netx/net/sourceforge/jnlp/security/policyeditor/PolicyEntry.java
+ (getCodebase, getPermissions, getCustomPermissions, fromString,
+ validatePolicy): new overloaded methods
+ * netx/net/sourceforge/jnlp/security/policyeditor/PolicyFileModel.java
+ all methods made synchronized (openAndParsePolicyFile): extracted and modified
+ parsing logic
+ (parsePolicyString): new method
+ (clearPermissions): also clears Custom Permissions now
+ * netx/net/sourceforge/jnlp/security/policyeditor/InvalidPolicyException.java:
+ added new exception
+ * netx/net/sourceforge/jnlp/security/policyeditor/CustomPermission.java
+ (equals, hashCode): Override these methods to be able to compare custom permissions.
+ New constructors for custom permission, one of the constructors takes only PermissionType, PermissionTarget
+ and the other takes an additional PermissionActions
+ * tests/netx/unit/net/sourceforge/jnlp/security/policyeditor/CustomPermissionTest.java,
+ * tests/netx/unit/net/sourceforge/jnlp/security/policyeditor/PolicyEditorParsingTest.java,
+ * tests/netx/unit/net/sourceforge/jnlp/security/policyeditor/PolicyEditorTest.java,
+ * tests/netx/unit/net/sourceforge/jnlp/security/policyeditor/PolicyEditorControllerTest.java,
+ * tests/netx/unit/net/sourceforge/jnlp/security/policyeditor/PolicyEntryTest.java,
+ * tests/netx/unit/net/sourceforge/jnlp/security/policyeditor/PolicyFileModelTest.java:
+ added new unit tests
+
2014-08-05 Andrew Azores <aazores at redhat.com>
Small bug fix (security hole) for previous PR1769 patch. This patch closes
diff -r 2833fae52261 -r c6e06c9b4bfb netx/net/sourceforge/jnlp/resources/Messages.properties
--- a/netx/net/sourceforge/jnlp/resources/Messages.properties Tue Aug 05 10:07:27 2014 -0400
+++ b/netx/net/sourceforge/jnlp/resources/Messages.properties Tue Aug 05 11:13:20 2014 -0400
@@ -571,7 +571,6 @@
PERenameCodebaseItem=Rename
PECopyCodebaseItem=Copy
PEPasteCodebaseItem=Paste...
-PECopyCodebaseToClipboardItem=Copy URL to clipboard
PERenameCodebase=Rename codebase to:
PEPasteCodebase=Paste copied codebase as:
PEViewMenu=View
@@ -584,6 +583,9 @@
PEGrightClick = right click to fold/unfold
PEGReadFileSystem = Read from system
PEGWriteFileSystem = Write to system
+PEClipboardError=Clipboard does not appear to contain properly formatted policy entries
+PEInvalidPolicy=Paste Failed: Could not read policy entry for codebase {0} from system clipboard
+PEClipboardAccessError=Could not read from clipboard
PEHelpMenu=Help
PEAboutPolicyEditorItem=About PolicyEditor
diff -r 2833fae52261 -r c6e06c9b4bfb netx/net/sourceforge/jnlp/security/policyeditor/CustomPermission.java
--- a/netx/net/sourceforge/jnlp/security/policyeditor/CustomPermission.java Tue Aug 05 10:07:27 2014 -0400
+++ b/netx/net/sourceforge/jnlp/security/policyeditor/CustomPermission.java Tue Aug 05 11:13:20 2014 -0400
@@ -82,6 +82,14 @@
this.actions = actions;
}
+ public CustomPermission(final PermissionType type, final PermissionTarget target) {
+ this(type, target, PermissionActions.NONE);
+ }
+
+ public CustomPermission(final PermissionType type, final PermissionTarget target, final PermissionActions actions) {
+ this(type.type, target.target, actions.rawString());
+ }
+
/**
* Get a CustomPermission from a policy file permission entry string. This is the full
* entry string, eg `permission java.io.FilePermission "${user.home}${/}* "read";`
@@ -130,6 +138,28 @@
}
@Override
+ public boolean equals(final Object o) {
+ if (this == o) return true;
+ if (!(o instanceof CustomPermission)) return false;
+
+ final CustomPermission that = (CustomPermission) o;
+
+ if (!actions.equals(that.actions)) return false;
+ if (!target.equals(that.target)) return false;
+ if (!type.equals(that.type)) return false;
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ int result = type.hashCode();
+ result = 31 * result + target.hashCode();
+ result = 31 * result + actions.hashCode();
+ return result;
+ }
+
+ @Override
public int compareTo(final CustomPermission o) {
if (this == o) {
return 0;
diff -r 2833fae52261 -r c6e06c9b4bfb netx/net/sourceforge/jnlp/security/policyeditor/InvalidPolicyException.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/netx/net/sourceforge/jnlp/security/policyeditor/InvalidPolicyException.java Tue Aug 05 11:13:20 2014 -0400
@@ -0,0 +1,40 @@
+/*Copyright (C) 2014 Red Hat, Inc.
+
+This file is part of IcedTea.
+
+IcedTea is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License as published by
+the Free Software Foundation, version 2.
+
+IcedTea is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with IcedTea; see the file COPYING. If not, write to
+the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version.
+ */
+
+package net.sourceforge.jnlp.security.policyeditor;
+
+public class InvalidPolicyException extends Exception {
+}
diff -r 2833fae52261 -r c6e06c9b4bfb netx/net/sourceforge/jnlp/security/policyeditor/PolicyEditor.java
--- a/netx/net/sourceforge/jnlp/security/policyeditor/PolicyEditor.java Tue Aug 05 10:07:27 2014 -0400
+++ b/netx/net/sourceforge/jnlp/security/policyeditor/PolicyEditor.java Tue Aug 05 11:13:20 2014 -0400
@@ -47,11 +47,11 @@
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.StringSelection;
import java.awt.datatransfer.Transferable;
+import java.awt.datatransfer.UnsupportedFlavorException;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyAdapter;
-import java.awt.event.KeyListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.WindowAdapter;
@@ -66,9 +66,7 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
-import java.util.Collections;
import java.util.HashMap;
-import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
@@ -179,13 +177,11 @@
* should be the editor so that the dialog is modal.
*/
private final WeakReference<PolicyEditor> parentPolicyEditor = new WeakReference<>(this);
- private final PolicyEditorController policyEditorController = new PolicyEditorController();
- private Map<PolicyEditorPermissions, Boolean> editorPermissionsClipboard = null;
- private Set<CustomPermission> customPermissionsClipboard = null;
+ public final PolicyEditorController policyEditorController = new PolicyEditorController();
private final ActionListener okButtonAction, addCodebaseButtonAction,
removeCodebaseButtonAction, newButtonAction, openButtonAction, saveAsButtonAction, viewCustomButtonAction,
- renameCodebaseButtonAction, copyCodebaseButtonAction, pasteCodebaseButtonAction, copyCodebaseToClipboardButtonAction,
+ renameCodebaseButtonAction, copyCodebaseButtonAction, pasteCodebaseButtonAction,
policyEditorHelpButtonAction, aboutPolicyEditorButtonAction;
private ActionListener closeButtonAction;
@@ -240,7 +236,37 @@
setFile(filepath);
if (filepath != null) {
- openAndParsePolicyFile();
+ try {
+ policyEditorController.openAndParsePolicyFile();
+ } catch (final FileNotFoundException fnfe) {
+ OutputController.getLogger().log(fnfe);
+ FileUtils.showCouldNotOpenDialog(PolicyEditor.this, R("PECouldNotOpen"));
+ } catch (final IOException | InvalidPolicyException e) {
+ OutputController.getLogger().log(e);
+ OutputController.getLogger().log(OutputController.Level.ERROR_ALL, R("RCantOpenFile", policyEditorController.getFile().getPath()));
+ FileUtils.showCouldNotOpenDialog(PolicyEditor.this, R("PECouldNotOpen"));
+ }
+ try {
+ invokeRunnableOrEnqueueAndWait(new Runnable() {
+ @Override
+ public void run() {
+ for (final String codebase : policyEditorController.getCodebases()) {
+ final String model;
+ if (codebase.isEmpty()) {
+ model = R("PEGlobalSettings");
+ } else {
+ model = codebase;
+ }
+ if (!listModel.contains(model)) {
+ listModel.addElement(model);
+ }
+ }
+ addNewCodebase("");
+ }
+ });
+ } catch (final InvocationTargetException | InterruptedException e) {
+ OutputController.getLogger().log(e);
+ }
}
setChangesMade(false);
@@ -345,27 +371,35 @@
pasteCodebaseButtonAction = new ActionListener() {
@Override
public void actionPerformed(final ActionEvent e) {
- String newCodebase = "";
- while (!validateCodebase(newCodebase) || policyEditorController.getCopyOfPermissions().containsKey(newCodebase)) {
- newCodebase = JOptionPane.showInputDialog(PolicyEditor.this, R("PEPasteCodebase"), "http://");
- if (newCodebase == null) {
- return;
+ String clipboardCodebase = null;
+ try {
+ clipboardCodebase = policyEditorController.getCodebaseFromClipboard();
+ final String newCodebase;
+ if (getCodebases().contains(clipboardCodebase)) {
+ String cb = "";
+ while (!validateCodebase(cb) || policyEditorController.getCopyOfPermissions().containsKey(cb)) {
+ cb = JOptionPane.showInputDialog(PolicyEditor.this, R("PEPasteCodebase"), "http://");
+ if (cb == null) {
+ return;
+ }
+ }
+ newCodebase = cb;
+ } else {
+ newCodebase = clipboardCodebase;
}
+ if (validateCodebase(newCodebase)) {
+ pasteCodebase(newCodebase);
+ }
+ } catch (final UnsupportedFlavorException ufe) {
+ OutputController.getLogger().log(ufe);
+ showClipboardErrorDialog();
+ } catch (final InvalidPolicyException ipe) {
+ OutputController.getLogger().log(ipe);
+ showInvalidPolicyExceptionDialog(clipboardCodebase);
+ } catch (final IOException ioe) {
+ OutputController.getLogger().log(ioe);
+ showCouldNotAccessClipboardDialog();
}
- pasteCodebase(newCodebase);
- }
- };
-
- copyCodebaseToClipboardButtonAction = new ActionListener() {
- @Override
- public void actionPerformed(final ActionEvent e) {
- final String selectedCodebase = getSelectedCodebase();
- if (selectedCodebase.isEmpty()) {
- return;
- }
- final Transferable clipboardContents = new StringSelection(selectedCodebase);
- final Clipboard clip = Toolkit.getDefaultToolkit().getSystemClipboard();
- clip.setContents(clipboardContents, null);
}
};
@@ -811,49 +845,45 @@
* @param newCodebase the new name for the codebase
*/
public void renameCodebase(final String oldCodebase, final String newCodebase) {
- // Renaming a codebase shouldn't overwrite a previously copied clipboard
- final Map<PolicyEditorPermissions, Boolean> editorPermissionsClipboardBackup = editorPermissionsClipboard;
- final Set<CustomPermission> customPermissionsClipboardBackup = customPermissionsClipboard;
+ final Map<PolicyEditorPermissions, Boolean> permissions = getPermissions(oldCodebase);
+ final Collection<CustomPermission> customPermissions = getCustomPermissions(oldCodebase);
- copyCodebase(oldCodebase);
- pasteCodebase(newCodebase);
removeCodebase(oldCodebase);
+ addNewCodebase(newCodebase);
- editorPermissionsClipboard = editorPermissionsClipboardBackup;
- customPermissionsClipboard = customPermissionsClipboardBackup;
+ for (final Map.Entry<PolicyEditorPermissions, Boolean> entry : permissions.entrySet()) {
+ setPermission(newCodebase, entry.getKey(), entry.getValue());
+ }
+
+ for (final CustomPermission permission : customPermissions) {
+ addCustomPermission(newCodebase, permission);
+ }
+
+ updateCheckboxes(newCodebase);
}
/**
- * Copy a codebase to the editor's "clipboard" (not the system clipboard), preserving its permissions
+ * Copy a codebase to the system clipboard, preserving its permissions
* @param codebase the codebase to copy
*/
public void copyCodebase(final String codebase) {
if (!getCodebases().contains(codebase)) {
return;
}
- editorPermissionsClipboard = new HashMap<>(policyEditorController.getCopyOfPermissions().get(codebase));
-
- final Set<CustomPermission> customPermissions = policyEditorController.getCustomPermissions(codebase);
- if (customPermissions == null) {
- customPermissionsClipboard = Collections.emptySet();
- } else {
- customPermissionsClipboard = new HashSet<>(policyEditorController.getCustomPermissions(codebase));
- }
+ policyEditorController.copyCodebaseToClipboard(codebase);
}
/**
- * Paste a codebase from the editor's "clipboard" (not the system clipboard)
- * @param newCodebase the name to paste the codebase with
+ * Paste a codebase entry from the system clipboard with a new codebase name
*/
- public void pasteCodebase(final String newCodebase) {
- if (editorPermissionsClipboard == null || customPermissionsClipboard == null) {
- return;
- }
+ public void pasteCodebase(final String newCodebase) throws UnsupportedFlavorException, InvalidPolicyException, IOException {
+ final Map<PolicyEditorPermissions, Boolean> permissions = policyEditorController.getPermissionsFromClipboard();
+ final Set<CustomPermission> customPermissions = policyEditorController.getCustomPermissionsFromClipboard();
addNewCodebase(newCodebase);
- for (final Map.Entry<PolicyEditorPermissions, Boolean> entry : editorPermissionsClipboard.entrySet()) {
+ for (final Map.Entry<PolicyEditorPermissions, Boolean> entry : permissions.entrySet()) {
policyEditorController.setPermission(newCodebase, entry.getKey(), entry.getValue());
}
- policyEditorController.addCustomPermissions(newCodebase, customPermissionsClipboard);
+ policyEditorController.addCustomPermissions(newCodebase, customPermissions);
setChangesMade(true);
updateCheckboxes(newCodebase);
}
@@ -918,15 +948,18 @@
}
private void updateCheckboxesImpl(final String codebase) {
+ if (!getCodebases().contains(codebase)) {
+ return;
+ }
+ final Map<PolicyEditorPermissions, Boolean> map = policyEditorController.getCopyOfPermissions().get(codebase);
for (final PolicyEditorPermissions perm : PolicyEditorPermissions.values()) {
final JCheckBox box = checkboxMap.get(perm);
for (final ActionListener l : box.getActionListeners()) {
box.removeActionListener(l);
}
- policyEditorController.addCodebase(codebase);
final boolean state = policyEditorController.getPermission(codebase, perm);
for (final JCheckBoxWithGroup jg : groupBoxList) {
- jg.setState(policyEditorController.getCopyOfPermissions().get(codebase));
+ jg.setState(map);
}
box.setSelected(state);
box.addActionListener(new ActionListener() {
@@ -935,7 +968,7 @@
setChangesMade(true);
policyEditorController.setPermission(codebase, perm, box.isSelected());
for (JCheckBoxWithGroup jg : groupBoxList) {
- jg.setState(policyEditorController.getCopyOfPermissions().get(codebase));
+ jg.setState(map);
}
}
});
@@ -1026,12 +1059,6 @@
setMenuItemAccelerator(copyCodebaseItem, R("PECopyCodebaseItemAccelerator"));
copyCodebaseItem.addActionListener(editor.copyCodebaseButtonAction);
codebaseMenu.add(copyCodebaseItem);
-
- final JMenuItem copyCodebaseToClipboardItem = new JMenuItem(R("PECopyCodebaseToClipboardItem"));
- setButtonMnemonic(copyCodebaseToClipboardItem, R("PECopyCodebaseToClipboardItemMnemonic"));
- setMenuItemAccelerator(copyCodebaseToClipboardItem, R("PECopyCodebaseToClipboardItemAccelerator"));
- copyCodebaseToClipboardItem.addActionListener(editor.copyCodebaseToClipboardButtonAction);
- codebaseMenu.add(copyCodebaseToClipboardItem);
menuBar.add(codebaseMenu);
final JMenuItem pasteCodebaseItem = new JMenuItem(R("PEPasteCodebaseItem"));
@@ -1311,6 +1338,7 @@
FileUtils.showReadOnlyDialog(PolicyEditor.this);
}
+
final Window parentWindow = SwingUtilities.getWindowAncestor(this);
final JDialog progressIndicator = new IndeterminateProgressDialog(parentWindow, "Loading...");
final SwingWorker<Void, Void> openPolicyFileWorker = new SwingWorker<Void, Void>() {
@@ -1330,8 +1358,8 @@
} catch (final FileNotFoundException fnfe) {
OutputController.getLogger().log(fnfe);
FileUtils.showCouldNotOpenDialog(PolicyEditor.this, R("PECouldNotOpen"));
- } catch (final IOException ioe) {
- OutputController.getLogger().log(ioe);
+ } catch (final IOException | InvalidPolicyException e) {
+ OutputController.getLogger().log(e);
OutputController.getLogger().log(OutputController.Level.ERROR_ALL, R("RCantOpenFile", policyEditorController.getFile().getPath()));
FileUtils.showCouldNotOpenDialog(PolicyEditor.this, R("PECouldNotOpen"));
}
@@ -1441,6 +1469,33 @@
});
}
+ private void showClipboardErrorDialog() {
+ invokeRunnableOrEnqueueLater(new Runnable() {
+ @Override
+ public void run() {
+ JOptionPane.showMessageDialog(parentPolicyEditor.get(), R("PEClipboardError"), R("Error"), JOptionPane.ERROR_MESSAGE);
+ }
+ });
+ }
+
+ private void showInvalidPolicyExceptionDialog(final String codebase) {
+ invokeRunnableOrEnqueueLater(new Runnable() {
+ @Override
+ public void run() {
+ JOptionPane.showMessageDialog(parentPolicyEditor.get(), R("PEInvalidPolicy", codebase), R("Error"), JOptionPane.ERROR_MESSAGE);
+ }
+ });
+ }
+
+ private void showCouldNotAccessClipboardDialog() {
+ invokeRunnableOrEnqueueLater(new Runnable() {
+ @Override
+ public void run() {
+ JOptionPane.showMessageDialog(parentPolicyEditor.get(), R("PEClipboardAccessError"), R("Error"), JOptionPane.ERROR_MESSAGE);
+ }
+ });
+ }
+
/**
* Detect if the policy settings have changed, either on-disk or in-app.
* If an on-disk change has occurred, update the Md5.
diff -r 2833fae52261 -r c6e06c9b4bfb netx/net/sourceforge/jnlp/security/policyeditor/PolicyEditorController.java
--- a/netx/net/sourceforge/jnlp/security/policyeditor/PolicyEditorController.java Tue Aug 05 10:07:27 2014 -0400
+++ b/netx/net/sourceforge/jnlp/security/policyeditor/PolicyEditorController.java Tue Aug 05 11:13:20 2014 -0400
@@ -36,6 +36,11 @@
package net.sourceforge.jnlp.security.policyeditor;
+import java.awt.Toolkit;
+import java.awt.datatransfer.DataFlavor;
+import java.awt.datatransfer.StringSelection;
+import java.awt.datatransfer.Transferable;
+import java.awt.datatransfer.UnsupportedFlavorException;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
@@ -50,7 +55,7 @@
public class PolicyEditorController {
- private final PolicyFileModel policyFile = new PolicyFileModel();
+ public final PolicyFileModel policyFile = new PolicyFileModel();
private volatile boolean changesMade = false;
private volatile boolean performingIO = false;
@@ -145,6 +150,14 @@
return new HashSet<>(policyFile.getCopyOfCustomPermissions().get(codebase));
}
+ public void addPolicyEntry(final PolicyEntry policyEntry) {
+ addCodebase(policyEntry.getCodebase());
+ for (final PolicyEditorPermissions permission : policyEntry.getPermissions()) {
+ setPermission(policyEntry.getCodebase(), permission, true);
+ }
+ addCustomPermissions(policyEntry.getCodebase(), policyEntry.getCustomPermissions());
+ }
+
public void clearCustomPermissions() {
setChangesMade(true);
policyFile.clearCustomPermissions();
@@ -155,7 +168,7 @@
More information about the distro-pkg-dev
mailing list