Class PolicyPanel

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible

public class PolicyPanel extends NamedBorderPanel
Implements a Policy Settings panel for the itweb-settings control panel. This gives the user information about custom user-level JNLP Policy files, as well as offering a way to launch a policy file editor with the correct file path to the user's personal policy file location presupplied.
See Also:
  • Field Details

  • Constructor Details

  • Method Details

    • launchPolicyTool

      private static void launchPolicyTool(Component parentComponent, String filePath)
      Launch the policytool for a specified file path
      Parameters:
      parentComponent - a Component to act as parent to warning dialogs which may appear
      filePath - a String representing the path to the file to be opened
    • launchSimplePolicyEditor

      private void launchSimplePolicyEditor(String filePath)
      Launch the simplified PolicyEditor for a specified file path.
      Parameters:
      filePath - a String representing the path to the file to be opened
    • policyToolLaunchHelper

      private static void policyToolLaunchHelper(Component parentComponent, String filePath)
      This executes a new process for policytool using ProcessBuilder, with the new process' working directory set to the user's home directory. policytool then attempts to open the provided policy file path, if policytool can be run. ProcessBuilder does some verification to ensure that the built command can be executed - if not, it throws an IOException. In this event, we try our reflective fallback launch. We do this in a new Thread to ensure that the fallback launch does not block the AWT thread, and neither does ProcessBuilder#start() in case it happens to be synchronous on the current system.
      Parameters:
      parentComponent - a Component to act as parent to warning dialogs which may appear
      filePath - a String representing the path to the file to be opened
    • reflectivePolicyToolLaunch

      private static void reflectivePolicyToolLaunch(String filePath) throws Exception
      This is used as a fallback in case launching the policytool by executing a new process fails. This probably happens because we are running on a system where the policytool executable is not on the PATH, or because we are running on a non-POSIX compliant system. We do this reflectively to avoid needing to add PolicyTool as build dependency simply for this small edge case.
      Parameters:
      filePath - a String representing the path of the file to attempt to open
      Throws:
      Exception - if any sort of exception occurs during reflective launch of policytool
    • isPolicyToolAvailable

      private static boolean isPolicyToolAvailable()
    • localFilePathFromUrlString

      private static String localFilePathFromUrlString(String url)
      Loosely attempt to get the path part of a file URL string. If this fails, simply return back the input. This is only intended to be used for displaying GUI elements such as the CPPolicyTooltip.
      Parameters:
      url - the String representing the URL whose path is desired
      Returns:
      a String representing the local filepath of the given file:/ URL
    • getParentComponentOfSource

      private Component getParentComponentOfSource(ActionEvent event)