Пример #1
0
  /**
   * Get the complete ConnectInfo
   *
   * @param ConnectInfo the user
   * @return the complete ConnectInfo
   */
  private ConnectInfo getCompleteConnectInfo(ConnectInfo ci) {
    Iterator i = this.connections.iterator();

    while (i.hasNext()) {
      ConnectInfo tmp = (ConnectInfo) i.next();
      if (ci.getName().equals(tmp.getName())) return tmp;
    }

    return ci;
  }
Пример #2
0
  /**
   * Check if a user is already known
   *
   * @param ConnectInfo the user
   * @return true or false
   */
  private boolean isAlreadyKnown(ConnectInfo ci) {
    boolean result = false;
    Iterator i = this.connections.iterator();

    while (i.hasNext() && !result) {
      ConnectInfo tmp = (ConnectInfo) i.next();
      result = ci.getName().equals(tmp.getName());
    }

    return result;
  }
Пример #3
0
  /** Loads internal services */
  private void loadInternalServices() {
    try {
      Iterator services;
      String servicename;
      String baseURL = System.getProperty("user.dir") + "/" + APPLICATIONS_DIRECTORY;

      LucaneClassLoader loader = LucaneClassLoader.getInstance();
      services = store.getServiceStore().getAllServices();

      while (services.hasNext()) {
        ServiceConcept service = (ServiceConcept) services.next();
        servicename = service.getName();
        try {
          loader.addUrl(new URL("jar:file:///" + baseURL + servicename + ".jar!/"));
          String className =
              (new JarFile(baseURL + servicename + ".jar"))
                  .getManifest()
                  .getMainAttributes()
                  .getValue("Service-Class");

          if (className == null) continue;

          Service serv = (Service) Class.forName(className, true, loader).newInstance();
          this.services.add(serv);
          serv.init(this);

          if (!service.isInstalled()) {
            serv.install();
            service.setInstalled();
            store.getServiceStore().updateService(service);
          }

          Logging.getLogger().info("Service '" + servicename + "' loaded.");
          this.connections.add(
              new ConnectInfo(servicename, serverIp, serverIp, port, "nokey", "service"));
        } catch (Exception e) {
          Logging.getLogger().warning("Unable to load service '" + servicename);
        }
      }
    } catch (Exception e) {
      Logging.getLogger().warning("Unable to load internal services : " + e);
      e.printStackTrace();
    }
  }
Пример #4
0
  /**
   * Send the plugin list to a client. The list depends of the client's groups
   *
   * @param source the user that asked this command
   */
  private void sendPluginList(ObjectConnection oc, String source) {
    Vector plist = new Vector();
    Iterator plugins;
    String line = "";

    try {
      UserConcept user = store.getUserStore().getUser(source);
      plugins = store.getPluginStore().getAuthorizedPlugins(user);

      while (plugins.hasNext()) {
        PluginConcept plugin = (PluginConcept) plugins.next();
        line = plugin.getName();
        line += " " + plugin.getVersion();
        plist.add(line);
      }
      oc.write(plist);
    } catch (Exception e) {
      Logging.getLogger().warning("Unable to send the plugin list.");
      e.printStackTrace();
    }
  }