Example #1
0
  static {
    String algorithm = JiveGlobals.getProperty("xmpp.socket.ssl.algorithm", "TLS");
    String storeType = JiveGlobals.getProperty("xmpp.socket.ssl.storeType", "jks");

    // Get the keystore location. The default location is security/keystore
    keyStoreLocation =
        JiveGlobals.getProperty(
            "xmpp.socket.ssl.keystore",
            "resources" + File.separator + "security" + File.separator + "keystore");
    keyStoreLocation = JiveGlobals.getHomeDirectory() + File.separator + keyStoreLocation;

    // Get the keystore password. The default password is "changeit".
    keypass = JiveGlobals.getProperty("xmpp.socket.ssl.keypass", "changeit");
    keypass = keypass.trim();

    // Get the truststore location; default at security/truststore
    trustStoreLocation =
        JiveGlobals.getProperty(
            "xmpp.socket.ssl.truststore",
            "resources" + File.separator + "security" + File.separator + "truststore");
    trustStoreLocation = JiveGlobals.getHomeDirectory() + File.separator + trustStoreLocation;

    // Get the truststore passwprd; default is "changeit".
    trustpass = JiveGlobals.getProperty("xmpp.socket.ssl.trustpass", "changeit");
    trustpass = trustpass.trim();

    try {
      keyStore = KeyStore.getInstance(storeType);
      keyStore.load(new FileInputStream(keyStoreLocation), keypass.toCharArray());

      trustStore = KeyStore.getInstance(storeType);
      trustStore.load(new FileInputStream(trustStoreLocation), trustpass.toCharArray());

      sslFactory =
          (SSLJiveServerSocketFactory)
              SSLJiveServerSocketFactory.getInstance(algorithm, keyStore, trustStore);
    } catch (Exception e) {
      Log.error(
          "SSLConfig startup problem.\n"
              + "  storeType: ["
              + storeType
              + "]\n"
              + "  keyStoreLocation: ["
              + keyStoreLocation
              + "]\n"
              + "  keypass: ["
              + keypass
              + "]\n"
              + "  trustStoreLocation: ["
              + trustStoreLocation
              + "]\n"
              + "  trustpass: ["
              + trustpass
              + "]",
          e);
      keyStore = null;
      trustStore = null;
      sslFactory = null;
    }
  }
  public void initializePlugin(PluginManager manager, File pluginDirectory) {
    System.out.println("Starting Client Control Plugin");

    // Check if we Enterprise is installed and stop loading this plugin if found
    File pluginDir = new File(JiveGlobals.getHomeDirectory(), "plugins");
    File[] jars =
        pluginDir.listFiles(
            new FileFilter() {
              public boolean accept(File pathname) {
                String fileName = pathname.getName().toLowerCase();
                return (fileName.equalsIgnoreCase("enterprise.jar"));
              }
            });
    if (jars.length > 0) {
      // Do not load this plugin since Enterprise is still installed
      System.out.println("Enterprise plugin found. Stopping Client Control Plugin");
      throw new IllegalStateException("This plugin cannot run next to the Enterprise plugin");
    }

    taskEngine = TaskEngine.getInstance();
    sparkManager = new SparkManager(taskEngine);
    sparkManager.start();

    // Create and start the Spark version manager
    sparkVersionManager = new SparkVersionManager();
    sparkVersionManager.start();

    fileTransferFilterManager = new FileTransferFilterManager();
    fileTransferFilterManager.start();
  }
Example #3
0
  /**
   * Handles a request for other web items (images, flash, applets, etc.)
   *
   * @param pathInfo the extra path info.
   * @param response the response object.
   * @throws IOException if an IOException occurs while handling the request.
   */
  private void handleOtherRequest(String pathInfo, HttpServletResponse response)
      throws IOException {
    String[] parts = pathInfo.split("/");
    // Image request must be in correct format.
    if (parts.length < 3) {
      response.setStatus(HttpServletResponse.SC_NOT_FOUND);
      return;
    }

    String contextPath = "";
    int index = pathInfo.indexOf(parts[1]);
    if (index != -1) {
      contextPath = pathInfo.substring(index + parts[1].length());
    }

    File pluginDirectory = new File(JiveGlobals.getHomeDirectory(), "plugins");
    File file = new File(pluginDirectory, parts[1] + File.separator + "web" + contextPath);

    // When using dev environment, the images dir may be under something other that web.
    Plugin plugin = pluginManager.getPlugin(parts[1]);
    PluginDevEnvironment environment = pluginManager.getDevEnvironment(plugin);

    if (environment != null) {
      file = new File(environment.getWebRoot(), contextPath);
    }
    if (!file.exists()) {
      response.setStatus(HttpServletResponse.SC_NOT_FOUND);
      return;
    } else {
      // Content type will be GIF or PNG.
      String contentType = "image/gif";
      if (pathInfo.endsWith(".png")) {
        contentType = "image/png";
      } else if (pathInfo.endsWith(".swf")) {
        contentType = "application/x-shockwave-flash";
      } else if (pathInfo.endsWith(".css")) {
        contentType = "text/css";
      } else if (pathInfo.endsWith(".js")) {
        contentType = "text/javascript";
      } else if (pathInfo.endsWith(".html") || pathInfo.endsWith(".htm")) {
        contentType = "text/html";
      }

      // setting the content-disposition header breaks IE when downloading CSS
      // response.setHeader("Content-disposition", "filename=\"" + file + "\";");
      response.setContentType(contentType);
      // Write out the resource to the user.
      InputStream in = null;
      ServletOutputStream out = null;
      try {
        in = new BufferedInputStream(new FileInputStream(file));
        out = response.getOutputStream();

        // Set the size of the file.
        response.setContentLength((int) file.length());

        // Use a 1K buffer.
        byte[] buf = new byte[1024];
        int len;
        while ((len = in.read(buf)) != -1) {
          out.write(buf, 0, len);
        }
      } finally {
        try {
          in.close();
        } catch (Exception ignored) {
          // Ignore.
        }
        try {
          out.close();
        } catch (Exception ignored) {
          // Ignore.
        }
      }
    }
  }
 public String getHomeDirectory() {
   return JiveGlobals.getHomeDirectory();
 }