Example #1
0
  protected String getSshClientHtml(jgl.HashMap hashmap) {
    String s =
        com.dragonflow.Utils.TextUtils.getValue(
            hashmap, com.dragonflow.SiteView.Machine.pSSHClient.getName());
    if (request.getValue("operation").equals("Add")) {
      s = "java";
    } else if (s.length() == 0) {
      s = "plink";
    }
    jgl.Array array = com.dragonflow.SiteView.Machine.getAllowedSshConnectionMethods();
    boolean flag = false;
    for (int i = 0; i < array.size(); i++) {
      if (array.at(i).equals(s)) {
        flag = true;
        break;
      }
    }

    if (!flag) {
      s = "";
    }
    return field(
        "SSH Client",
        "<select name=sshClient size=1>" + com.dragonflow.Page.remoteBase.getOptionsHTML(array, s),
        "Select the client to use to connect to the remote server.");
  }
Example #2
0
 void execute(java.sql.PreparedStatement preparedstatement, jgl.Array array, jgl.Array array1)
     throws java.sql.SQLException {
   array.add(array1);
   if (array.size() > autoCommit) {
     flush(preparedstatement, array);
   }
   autoCommitCounter++;
 }
Example #3
0
  public static java.lang.String getNameFromArray(jgl.Array array) {
    java.lang.String s = "";
    int i = array.size();
    int j;
    if (array.at(0).equals("All SQL")) {
      j = 1;
    } else {
      j = 0;
    }
    for (int k = i; k > j; k--) {
      if (k < array.size()) {
        s = s + '/';
      }
      s = s + J2EEConnection.escapeString((java.lang.String) array.at(k - 1));
    }

    return s;
  }
Example #4
0
  void flush(java.sql.PreparedStatement preparedstatement, jgl.Array array)
      throws java.sql.SQLException {
    if (debug) {
      COM.dragonflow.Log.LogManager.log("RunMonitor", "jdbc logger commit start");
    }
    int i = array.size();
    java.sql.SQLException sqlexception = null;
    while (array.size() > 0) {
      jgl.Array array1 = (jgl.Array) array.popFront();
      int j = array1.size();
      try {
        for (int k = 0; k < j; k++) {
          preparedstatement.setObject(k + 1, array1.at(k), 12);
        }

        preparedstatement.executeUpdate();
        continue;
      } catch (java.sql.SQLException sqlexception1) {
        sqlexception = sqlexception1;
        String s = "";
        for (int l = 0; l < j; l++) {
          if (l != 0) {
            s = s + ",";
          }
          s = s + array1.at(l);
        }

        COM.dragonflow.Log.LogManager.log(
            "Error", "jdbc logger error: exec, " + sqlexception1 + ", record=" + s);
        clearParameters(preparedstatement);
      }
    }
    connection.commit();
    if (debug) {
      COM.dragonflow.Log.LogManager.log(
          "RunMonitor", "jdbc logger commit complete, " + i + " records");
    }
    if (sqlexception != null) {
      throw sqlexception;
    } else {
      return;
    }
  }
Example #5
0
  public static jgl.Array toDefaultArray(jgl.Array array) {
    if (!isI18N) {
      return array;
    }
    jgl.Array array1 = new Array();
    for (int i = 0; i < array.size(); i++) {
      String s = (String) array.at(i);
      com.dragonflow.Utils.I18N.test(s, 1);
      array1.add(com.dragonflow.Utils.I18N.toDefaultEncoding((String) array.at(i)));
    }

    return array1;
  }
Example #6
0
  private int getIndex(jgl.Array array, jgl.HashMap hashmap) {
    if (com.dragonflow.Utils.TextUtils.getValue(hashmap, "_id").length() == 0) {
      return -1;
    }
    for (int i = 0; i < array.size(); i++) {
      jgl.HashMap hashmap1 = (jgl.HashMap) array.at(i);
      if (com.dragonflow.Utils.TextUtils.getValue(hashmap, "_id")
          .equals(com.dragonflow.Utils.TextUtils.getValue(hashmap1, "_id"))) {
        return i;
      }
    }

    return -1;
  }
Example #7
0
  public static java.util.Vector getScriptList(
      java.lang.String s, com.dragonflow.HTTP.HTTPRequest httprequest) {
    java.util.Vector vector = new Vector();
    if (com.dragonflow.SiteView.Platform.isCommandLineRemote(s)) {
      com.dragonflow.Utils.RemoteFile remotefile = new RemoteFile(s, "scripts");
      int i = com.dragonflow.SiteView.Machine.getOS(s);
      jgl.Array array = remotefile.listFiles();
      for (int k = 0; k < array.size(); k++) {
        java.lang.String s2 = (java.lang.String) array.at(k);
        if (!s2.endsWith(".txt")
            && (!com.dragonflow.SiteView.Platform.isUnix(i) || !s2.startsWith("."))) {
          vector.addElement(s2);
          vector.addElement(s2);
        }
      }

    } else {
      java.io.File file =
          new File(
              com.dragonflow.SiteView.Platform.getUsedDirectoryPath(
                  "scripts", httprequest.getAccount()));
      java.lang.String as[] = file.list();
      for (int j = 0; j < as.length; j++) {
        java.lang.String s1 = as[j];
        if (s1.endsWith(".txt")
            || com.dragonflow.SiteView.Platform.isUnix() && s1.startsWith(".")) {
          continue;
        }
        java.io.File file1 = new File(file, as[j]);
        if (!file1.isDirectory()) {
          vector.addElement(s1);
          vector.addElement(s1);
        }
      }
    }
    return vector;
  }
Example #8
0
  public void printBody() throws java.lang.Exception {
    if (!request.actionAllowed("_file")) {
      throw new HTTPRequestException(557);
    }
    java.lang.String s = request.getValue("operation");
    try {
      if (s.equals("run")) {
        java.lang.String s1 = request.getValue("command");
        java.lang.String s4 = request.getValue("machineID");
        jgl.HashMap hashmap = null;
        java.lang.String s6 = com.dragonflow.SiteView.Machine.getCommandString(s1, s4, hashmap);
        com.dragonflow.Utils.CommandLine commandline = new CommandLine();
        jgl.Array array2 = commandline.exec(s6, s4, com.dragonflow.SiteView.Platform.getLock(s4));
        outputStream.println("<PRE>");
        for (int k1 = 0; k1 < array2.size(); k1++) {
          outputStream.println(array2.at(k1));
        }

        outputStream.println("</PRE>");
      } else if (s.equals("scripts")) {
        java.lang.String s2 = request.getValue("machineID");
        outputStream.println("<PRE>");
        java.util.Vector vector1 = com.dragonflow.Page.remoteOpPage.getScriptList(s2, request);
        for (int k = 0; k < vector1.size(); k++) {
          outputStream.println(vector1.elementAt(k));
        }

        outputStream.println("</PRE>");
      } else if (s.equals("updateStaticPages")) {
        java.lang.String s3 =
            com.dragonflow.Utils.I18N.toDefaultEncoding(request.getValue("group"));
        if (s3.length() == 0) {
          com.dragonflow.SiteView.SiteViewGroup.updateStaticPages();
        } else {
          com.dragonflow.SiteView.SiteViewGroup.updateStaticPages(s3);
        }
      } else if (s.equals("getServers")) {
        java.util.Vector vector = com.dragonflow.SiteView.Platform.getServers();
        outputStream.println("<PRE>");
        for (int i = 0; i < vector.size(); i += 2) {
          outputStream.println(vector.elementAt(i));
        }

        outputStream.println("</PRE>");
      } else if (s.equals("monitorClasses")) {
        outputStream.println("<PRE>");
        jgl.Array array = com.dragonflow.Page.monitorPage.getMonitorClasses();
        for (int j = 0; j < array.size(); j++) {
          java.lang.String s5 = ((java.lang.Class) array.at(j)).getName();
          int i1 = s5.lastIndexOf(".");
          if (i1 >= 0) {
            s5 = s5.substring(i1 + 1);
          }
          outputStream.println(s5);
        }

        outputStream.println("</PRE>");
      } else if (s.equals("actionClasses")) {
        com.dragonflow.Page.alertPage alertpage = new alertPage();
        outputStream.println("<PRE>");
        jgl.Array array1 = alertpage.getActionClasses();
        for (int l = 0; l < array1.size(); l++) {
          java.lang.String s7 = ((java.lang.Class) array1.at(l)).getName();
          int j1 = s7.lastIndexOf(".");
          if (j1 >= 0) {
            s7 = s7.substring(j1 + 1);
          }
          outputStream.println(s7);
        }

        outputStream.println("</PRE>");
      } else if (s.equals("platform")) {
        outputStream.println("<PRE>");
        outputStream.println("os.name=" + java.lang.System.getProperty("os.name"));
        outputStream.println("os.version=" + java.lang.System.getProperty("os.version"));
        outputStream.println("version=" + com.dragonflow.SiteView.Platform.getVersion());
        outputStream.println("</PRE>");
      } else {
        throw new Exception("unknown operation, " + s);
      }
    } catch (java.lang.Exception exception) {
      outputStream.println("error: " + exception + ", " + s);
    }
  }
Example #9
0
  void printAddForm(String s) throws Exception {
    jgl.Array array = getFrames();
    if (request.isPost()) {
      if (dependentCheck()) {
        return;
      }
      String s1 = null;
      Object obj = null;
      jgl.HashMap hashmap1 = null;
      int i = -1;
      jgl.Array array1 = parseHosts(request.getValue("host"));
      boolean flag = array1.size() > 1;
      for (int j = 0; j < array1.size(); j++) {
        jgl.HashMap hashmap;
        if (s.equals("Add")) {
          if (hashmap1 == null) {
            hashmap1 = getMasterConfig();
          }
          s1 = getNextMachineID(hashmap1);
          hashmap = new HashMap();
          if (s1.length() == 0) {
            s1 = "10";
          }
          // hashmap1.put(getNextMachineName(),
          //        com.dragonflow.Utils.TextUtils.increment(s1));
          Config.configPut(getNextMachineName(), com.dragonflow.Utils.TextUtils.increment(s1));
        } else {
          s1 = getMachineID();
          hashmap = findMachine(array, s1);
          i = getIndex(array, hashmap);
          array.remove(hashmap);
        }
        hashmap.put("_host", array1.at(j).toString().trim());
        if (request.getValue("title").length() == 0) {
          hashmap.put("_name", hashmap.get("_host"));
        } else if (flag) {
          hashmap.put("_name", request.getValue("title") + " - " + hashmap.get("_host"));
        } else {
          hashmap.put("_name", request.getValue("title"));
        }
        saveAddProperties(s, hashmap, s1);
        if (s.equals("Add")) {
          array.add(hashmap);
        } else {
          array.insert(i, hashmap);
        }
      }

      saveMachines(array, getRemoteName());
      String s2 = "";
      if (request.getValue("addtest").indexOf("add") != -1 || array1.size() > 1) {
        s2 =
            getPageLink(getPage(), "List")
                + "&"
                + getIDName()
                + "="
                + s1
                + "&backURL="
                + request.getValue("backURL")
                + "&backLabel="
                + java.net.URLEncoder.encode(request.getValue("backLabel"))
                + "&backDescription="
                + java.net.URLEncoder.encode(request.getValue("backDescription"))
                + getReturnLink(false, request.getValue("storeID"));
      } else {
        s2 =
            getPageLink(getPage(), "Test")
                + "&"
                + getIDName()
                + "="
                + s1
                + "&backURL="
                + request.getValue("backURL")
                + "&backLabel="
                + java.net.URLEncoder.encode(request.getValue("backLabel"))
                + "&backDescription="
                + java.net.URLEncoder.encode(request.getValue("backDescription"))
                + getReturnLink(false, request.getValue("storeID"));
      }
      autoFollowPortalRefresh = false;
      printRefreshPage(s2, 0);
    } else {
      printForm(s, array, new HashMap());
    }
  }
Example #10
0
  void printListForm(String s) throws Exception {
    String s1 = request.getValue("backURL");
    String s3 = request.getValue("storeURL");
    String s4 = request.getValue("storeID");
    if (s1.length() > 0) {
      com.dragonflow.Page.serverPage.clientID++;
      com.dragonflow.Page.serverPage.setReturnURL(
          com.dragonflow.Page.serverPage.storeReturnURL, s3);
      com.dragonflow.Page.serverPage.setReturnURL(com.dragonflow.Page.serverPage.thisURL, s1);
      s4 = String.valueOf(com.dragonflow.Page.serverPage.clientID);
    }
    String s5 = getListTitle();
    String s6 = getListSubtitle();
    printBodyHeader(s5);
    printButtonBar(getHelpPage(), "", getSecondNavItems(request));
    if (s4.length() == 0) {
      printPrefsBar(getPrefTitle());
    }
    jgl.Array array = getListTableHeaders(s4);
    outputStream.println(
        "<H2>"
            + s5
            + "</H2> "
            + "<p>"
            + s6
            + "</p>"
            + "<TABLE WIDTH=100% BORDER=2 cellspacing=0><TR CLASS=\"tabhead\">");
    for (int i = 0; i < array.size(); i++) {
      outputStream.println("<TH align=left>" + array.at(i) + "</TH>");
    }

    outputStream.println("</TR>");
    jgl.Array array1 = readMachines(getRemoteName());
    if (array1.size() == 0) {
      outputStream.println(
          "<TR><TD> </TD><TD align=center>no remote servers defined</TD><TD> </TD></TR>\n");
    } else {
      for (java.util.Enumeration enumeration = array1.elements();
          enumeration.hasMoreElements();
          outputStream.println("</TR>")) {
        jgl.HashMap hashmap = (jgl.HashMap) enumeration.nextElement();
        jgl.Array array2 = getListTableRow(hashmap, s4);
        outputStream.println("<TR>");
        for (int j = 0; j < array2.size(); j++) {
          outputStream.println("<TD align=left>" + array2.at(j) + "</TD>");
        }
      }
    }
    outputStream.println("</TABLE><BR>");
    if (request.actionAllowed("_preference") || s4.length() > 0) {
      outputStream.println(
          "<A HREF="
              + getPageLink(getPage(), "Add")
              + getReturnLink(false, s4)
              + ">Add</A> a Remote Machine\n"
              + "<br><br>\n");
    }
    if (s4.length() > 0) {
      String s2 =
          new String(
              com.dragonflow.Page.serverPage.getReturnURL(
                  com.dragonflow.Page.serverPage.thisURL, s4));
      outputStream.println(
          "<a href=\"" + s2 + "&pop=true&storeID=" + s4 + "\">Return to Choose Server</a>");
    }
    printFooter(outputStream);
  }
Example #11
0
  public jgl.Array exec(String s, com.dragonflow.SiteView.Machine machine, boolean flag) {
    super.exec(s, machine, flag);
    long l =
        com.dragonflow.Properties.StringProperty.toLong(
            machine.getProperty(com.dragonflow.SiteView.Machine.pTimeout));
    if (l == 0L) {
      l = 60000L;
    } else {
      l *= 1000L;
    }
    java.net.Socket socket = null;
    Object obj = null;
    java.io.PrintWriter printwriter = null;
    java.io.BufferedInputStream bufferedinputstream = null;
    String s1 = machine.getProperty(com.dragonflow.SiteView.Machine.pHost);
    int i = 513;
    int j = s1.indexOf(':');
    if (j != -1) {
      i = com.dragonflow.Utils.TextUtils.readInteger(s1, j + 1);
      s1 = s1.substring(0, j);
    }
    String s2 = machine.getProperty(com.dragonflow.SiteView.Machine.pLogin);
    String s3 = machine.getProperty(com.dragonflow.SiteView.Machine.pPassword);
    String s4 = machine.getProperty(com.dragonflow.SiteView.Machine.pLocalUser);
    String s5 = machine.getProperty(com.dragonflow.SiteView.Machine.pPasswordPrompt);
    String s6 = machine.getProperty(com.dragonflow.SiteView.Machine.pPrompt);
    String s7 = "";
    String s8 = "tty/9600";
    int k = com.dragonflow.StandardMonitor.URLMonitor.kURLok;
    byte abyte0[] = new byte[s2.length() + s4.length() + s8.length() + 4];
    int i1 = 0;
    abyte0[i1++] = 0;
    for (int j1 = 0; j1 < s4.length(); j1++) {
      abyte0[i1++] = (byte) s4.charAt(j1);
    }

    abyte0[i1++] = 0;
    for (int k1 = 0; k1 < s2.length(); k1++) {
      abyte0[i1++] = (byte) s2.charAt(k1);
    }

    abyte0[i1++] = 0;
    for (int l1 = 0; l1 < s8.length(); l1++) {
      abyte0[i1++] = (byte) s8.charAt(l1);
    }

    abyte0[i1++] = 0;
    traceMessage(s2 + "," + s4 + "," + s8, machine, TO_REMOTE);
    StringBuffer stringbuffer = new StringBuffer();
    progressMessage("Connecting to " + s1 + "...");
    try {
      socket = com.dragonflow.Utils.RloginCommandLine.getReservedPort(s1, i);
      progressMessage("Logging In...");
      java.io.OutputStream outputstream = socket.getOutputStream();
      outputstream.write(abyte0);
      outputstream.flush();
      printwriter = com.dragonflow.Utils.FileUtils.MakeOutputWriter(outputstream, "Cp1252");
      bufferedinputstream = new BufferedInputStream(socket.getInputStream());
      long l2 = com.dragonflow.SiteView.Platform.timeMillis() + l * 1000L;
      int j2 = 0;
      boolean flag1 = false;
      boolean flag2 = false;
      do {
        if (j2 == -1) {
          break;
        }
        j2 = readChar(bufferedinputstream, socket, l2);
        if (j2 == 65535) {
          for (int k2 = 0; k2 < 11; k2++) {
            j2 = readChar(bufferedinputstream, socket, l2);
          }

          byte abyte1[] = new byte[12];
          abyte1[0] = -1;
          abyte1[1] = -1;
          abyte1[2] = 115;
          abyte1[3] = 115;
          abyte1[4] = 0;
          abyte1[5] = 24;
          abyte1[6] = 0;
          abyte1[7] = 80;
          abyte1[8] = 4;
          abyte1[9] = 0;
          abyte1[10] = 4;
          abyte1[11] = 0;
          outputstream.write(abyte1);
          outputstream.flush();
          continue;
        }
        if (j2 == -1) {
          continue;
        }
        stringbuffer.append(j2);
        String s10 = toEncoding(stringbuffer.toString());
        if (detail && progressStream != null) {
          progressStream.print(j2);
        }
        if (s7.length() > 0 && s10.endsWith(s7)) {
          progressMessage("Login Failed");
          k = 401;
          break;
        }
        if (!flag2 && stringbuffer.length() < 15) {
          if (s10.endsWith(s5)) {
            traceMessage(
                "Password: "******"Sending Password...");
            printwriter.print(s3 + '\n');
            printwriter.flush();
            stringbuffer = new StringBuffer();
            s7 = machine.getProperty("_loginIncorrectPrompt");
            if (s7.length() == 0) {
              s7 = "ogin incorrect";
            }
          }
          continue;
        }
        if (!s10.endsWith(s6)) {
          continue;
        }
        if (flag1) {
          progressMessage("Command completed...");
          break;
        }
        progressMessage("Running command...");
        traceMessage(s, machine, TO_REMOTE);
        printwriter.print(s + '\n');
        printwriter.flush();
        stringbuffer = new StringBuffer();
        resetBuffer();
        flag1 = true;
        flag2 = true;
        s7 = "";
      } while (true);
    } catch (java.net.UnknownHostException unknownhostexception) {
      k = com.dragonflow.StandardMonitor.URLMonitor.kURLBadHostNameError;
    } catch (java.net.SocketException socketexception) {
      if (com.dragonflow.SiteView.Platform.noRoute(socketexception)) {
        k = com.dragonflow.StandardMonitor.URLMonitor.kURLNoRouteToHostError;
      } else {
        k = com.dragonflow.StandardMonitor.URLMonitor.kURLNoConnectionError;
      }
    } catch (java.io.InterruptedIOException interruptedioexception) {
      k = com.dragonflow.StandardMonitor.URLMonitor.kURLTimeoutError;
    } catch (Exception exception) {
      exception.printStackTrace();
      System.err.println(exception + " error: " + exception.getMessage());
      k = com.dragonflow.StandardMonitor.URLMonitor.kURLUnknownError;
    } finally {
      try {
        if (printwriter != null) {
          printwriter.close();
        }
        if (bufferedinputstream != null) {
          bufferedinputstream.close();
        }
        if (socket != null) {
          socket.close();
        }
      } catch (java.io.IOException ioexception) {
        System.err.println("Could not close FTP streams");
      }
    }
    jgl.Array array = null;
    if (k == com.dragonflow.StandardMonitor.URLMonitor.kURLok) {
      array = com.dragonflow.SiteView.Platform.split('\n', toEncoding(stringbuffer.toString()));
      if (!flag) {
        if (array.size() > 0) {
          array.popFront();
        }
        int i2 =
            com.dragonflow.SiteView.Machine.stringToOS(
                machine.getProperty(com.dragonflow.SiteView.Machine.pOS));
        if ((com.dragonflow.SiteView.Platform.isSGI(i2)
                || com.dragonflow.SiteView.Platform.isSolaris(i2))
            && array.size() > 0) {
          String s9 = (String) array.at(0);
          if (s9.trim().length() == 0) {
            array.popFront();
          }
        }
        if (array.size() > 0) {
          array.popBack();
        }
      }
      traceMessage(array, machine, FROM_REMOTE);
    } else {
      progressMessage("Connection failed: " + com.dragonflow.SiteView.Monitor.lookupStatus(k));
      array = new Array();
      traceMessage("ERROR - STATUS = " + k, machine, FROM_REMOTE);
      exitValue = k;
    }
    return array;
  }