/**
   * Sets the java.security.policy system property to point at the location of the security policy
   * file, which is assumed to be at "provided\rmiUtils\server.policy" (file separators adjusted to
   * match operating system). the security manager is then started. This method must be called
   * before starting the class server.
   */
  private void configSecurityManager() {
    // file.separator is "\" in Windows and "/" in Unix/Linux/Mac.
    String sep = System.getProperty("file.separator");

    System.setProperty(
        "java.security.policy", "provided" + sep + "rmiUtils" + sep + "server.policy");
    outputCmd.apply("java.security.policy: " + System.getProperty("java.security.policy"));

    // Start the security manager
    if (System.getSecurityManager() == null) {
      outputCmd.apply("Installing new Security Manager...\n");
      System.setSecurityManager(new SecurityManager());
      outputCmd.apply("Security Manager = " + System.getSecurityManager());
    }
  }
  /**
   * Sets the java.rmi.server.hostname and java.rmi.server.codebase system properties which control
   * the automatic remote dynamic class loading. This must be called before starting the class
   * server.
   *
   * @param classServerPort The port the class server will use.
   */
  private void configRMIProperties(int classServerPort) {
    // Logs all RMI activity to System.err
    System.setProperty("java.rmi.server.logCalls", "true");

    try {
      // Try to get figure out this server's IP address and save it as the
      // RMI server hostname.
      System.setProperty("java.rmi.server.hostname", getLocalAddress());

      System.setProperty(
          "java.rmi.server.codebase",
          "http://" + System.getProperty("java.rmi.server.hostname") + ":" + classServerPort + "/");
      System.setProperty(
          "java.rmi.server.useCodebaseOnly",
          "false"); // Must be false to allow remote class dynamic loading (defaults to true for JDK
                    // 1.7+)
      outputCmd.apply(
          "java.rmi.server.hostname: " + System.getProperty("java.rmi.server.hostname") + "\n",
          "java.rmi.server.codebase: " + System.getProperty("java.rmi.server.codebase") + "\n",
          "java.rmi.server.useCodebaseOnly: "
              + System.getProperty("java.rmi.server.useCodebaseOnly")
              + "\n");

    } catch (Exception e) {
      outputCmd.apply("Error getting local host address: " + e + "\n");
    }
  }