Exemplo n.º 1
0
  private void startXmlElement(String s, jgl.HashMap hashmap) {
    boolean flag = false;
    java.util.Vector vector = null;
    xmlResponse.append("<" + s);
    if (hashmap != null) {
      java.util.Enumeration enumeration = hashmap.keys();
      while (enumeration.hasMoreElements()) {
        String s1 = enumeration.nextElement().toString();
        Object obj = hashmap.get(s1);
        if (obj instanceof String[]) {
          flag = true;
          if (vector == null) {
            vector = new Vector();
          }
          vector.addElement(s1);
        } else if (obj instanceof String) {
          if (com.dragonflow.Utils.I18N.isNullEncoding(obj.toString())) {
            xmlResponse.append(
                " "
                    + s1
                    + "=\""
                    + com.dragonflow.Utils.TextUtils.escapeHTML(
                        com.dragonflow.Utils.I18N.toDefaultEncoding(obj.toString()))
                    + "\"");
          } else {
            xmlResponse.append(
                " "
                    + s1
                    + "=\""
                    + com.dragonflow.Utils.TextUtils.escapeHTML(obj.toString())
                    + "\"");
          }
        }
      }
      xmlResponse.append(">\r\n");
      if (flag) {
        for (int i = 0; i < vector.size(); i++) {
          String s2 = (String) vector.elementAt(i);
          String as[] = (String[]) hashmap.get(s2);
          xmlResponse.append("<property>\r\n");
          xmlResponse.append(s2 + "\r\n");
          for (int j = 0; j < as.length; j++) {
            if (as[j] == null) {
              continue;
            }
            if (encodeValues) {
              String s3 = com.dragonflow.XmlApi.XmlApiRequestXML.escapeXML(as[j]);
              xmlResponse.append("<value>" + s3 + "</value>\r\n");
            } else {
              xmlResponse.append("<value>" + as[j] + "</value>\r\n");
            }
          }

          xmlResponse.append("</property>\r\n");
        }
      }
    }
  }
Exemplo n.º 2
0
 void printDeleteForm(String s) throws Exception {
   String s1 = getMachineID();
   String s2 = "ID " + s1;
   jgl.Array array = readMachines(getRemoteName());
   jgl.HashMap hashmap = findMachine(array, s1);
   if (hashmap != null) {
     s2 = com.dragonflow.Utils.TextUtils.getValue(hashmap, "_name");
     if (s2.length() == 0) {
       s2 = com.dragonflow.Utils.TextUtils.getValue(hashmap, "_host");
     }
   }
   if (request.isPost()) {
     try {
       com.dragonflow.SSH.SSHManager.getInstance().deleteRemote(getRemoteUniqueId());
       array.remove(hashmap);
       saveMachines(array, getRemoteName());
       autoFollowPortalRefresh = false;
       printRefreshPage(
           getPageLink(getPage(), "List") + getReturnLink(false, request.getValue("storeID")), 0);
     } catch (Exception exception) {
       printError(
           "There was a problem deleting the remote server.",
           exception.toString(),
           "/SiteView/" + request.getAccountDirectory() + "/SiteView.html");
     }
   } else {
     printBodyHeader("Delete Confirmation");
     outputStream.println(
         "<FONT SIZE=+1>Are you sure you want to delete the remote server <B>"
             + s2
             + "</B>?</FONT>"
             + "<p>"
             + getPagePOST(getPage(), s)
             + "<input type=hidden name="
             + getIDName()
             + " value=\""
             + s1
             + "\">"
             + getReturnLink(true, request.getValue("storeID"))
             + "<TABLE WIDTH=100% BORDER=0><TR>"
             + "<TD WIDTH=6%></TD><TD WIDTH=41%><input type=submit value=\""
             + s
             + "\"></TD>"
             + "<TD WIDTH=6%></TD><TD ALIGN=RIGHT WIDTH=41%><A HREF="
             + getPageLink(getPage(), "List")
             + ">Return to Detail</A></TD><TD WIDTH=6%></TD>"
             + "</TR></TABLE></FORM>");
     printFooter(outputStream);
   }
 }
Exemplo n.º 3
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;
  }
Exemplo n.º 4
0
  /**
   * CAUTION: Decompiled by hand.
   *
   * @param s
   * @param s1
   * @return
   */
  public static String UnicodeToString(String s, String s1) {
    try {
      if (s == null) return "";
      if (!isI18N(s)) /* change by dingbing.xu from isI18N */ {
        return s;
      }

      if (s1 == com.dragonflow.Utils.I18N.nullEncoding()) {
        com.dragonflow.Utils.I18N.test(s, 1);
      } else if (s1.length() == 0) {
        com.dragonflow.Utils.I18N.test(s, 0);
      }
      String s2;
      byte abyte0[] = s1 != null && s1.length() != 0 ? s.getBytes(s1) : s.getBytes();
      char ac[] = new char[abyte0.length];
      for (int i = 0; i < abyte0.length; i++) {
        ac[i] = (char) (abyte0[i] & 0xff);
      }

      s2 = new String(ac);
      com.dragonflow.Utils.I18N.test(s2, 2);
      return s2;
    } catch (Exception exception) {
      if (s1 != null && s1.length() > 0) {
        com.dragonflow.Log.LogManager.log(
            "Error", "I18N: Bad Encoding(" + s1 + ") " + exception.getMessage());
        com.dragonflow.Utils.TextUtils.debugPrint(
            "I18N: Bad Encoding(" + s1 + ") " + exception.getMessage());
        exception.printStackTrace();
      }
      return s;
    }
  }
Exemplo n.º 5
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.");
  }
Exemplo n.º 6
0
 private jgl.Array parseHosts(String s) {
   jgl.Array array = new Array();
   if (s.indexOf(",") != -1) {
     array = com.dragonflow.Utils.TextUtils.splitArray(s, ",");
   } else {
     array.add(s.trim());
   }
   return array;
 }
Exemplo n.º 7
0
 String getNextMachineID(jgl.HashMap hashmap) {
   String s = null;
   if (hashmap != null) {
     s = com.dragonflow.Utils.TextUtils.getValue(hashmap, getNextMachineName());
   } else {
     s = request.getValue(getNextMachineName());
   }
   return s;
 }
Exemplo n.º 8
0
 protected String getSSHCommandLine(jgl.HashMap hashmap) {
   String s =
       com.dragonflow.Utils.TextUtils.getValue(
           hashmap, com.dragonflow.SiteView.Machine.pSSHCommandLine.getName());
   if (s.length() == 0) {
     s = com.dragonflow.SiteView.Machine.pSSHCommandLine.getDefault();
   }
   return field(
       "Custom Commandline",
       "<input type=text name=sshCommandLine size=50 value=\"" + s + "\">",
       "Enter the command for execution of external ssh client.  For substituion with above options use $host$, $user$ and $password$ respectivly. <b> This setting is for only for connections using an external process.</b>");
 }
Exemplo n.º 9
0
 protected String getNumConnectionseHtml(jgl.HashMap hashmap) {
   String s =
       com.dragonflow.Utils.TextUtils.getValue(
           hashmap, com.dragonflow.SiteView.Machine.pSSHConnectionsLimit.getName());
   if (s.length() == 0) {
     s = com.dragonflow.SiteView.Machine.pSSHConnectionsLimit.getDefault();
   }
   return field(
       "Connection Limit",
       "<input type=text name=sshConnectionsLimit size=2 value=\"" + s + "\">",
       "Enter the maximum number of open connections allowed for this remote.");
 }
Exemplo n.º 10
0
 protected String getPortNumberHtml(jgl.HashMap hashmap) {
   String s =
       com.dragonflow.Utils.TextUtils.getValue(
           hashmap, com.dragonflow.SiteView.Machine.pSSHPort.getName());
   if (s.length() == 0) {
     s = com.dragonflow.SiteView.Machine.pSSHPort.getDefault();
   }
   return field(
       "Port Number",
       "<input type=text name=sshPort size=2 value=\"" + s + "\">",
       "Enter the port number that the ssh server is running on. <b> Default is 22. </b>");
 }
Exemplo n.º 11
0
 protected String getSSHForceVersion2Html(jgl.HashMap hashmap) {
   String s =
       com.dragonflow.Utils.TextUtils.getValue(
           hashmap, com.dragonflow.SiteView.Machine.pSSHForceVersion2.getName());
   if (s.length() > 0) {
     s = " CHECKED";
   }
   return field(
       "SSH Version 2 Only",
       "<input type=checkbox name=version2" + s + ">",
       "Check this box to force SSH to only use SSH protocol version 2. <b> ( This SSH option is only supported using the internal java libraries connection method) </b>");
 }
Exemplo n.º 12
0
 protected String getDisableCacheHtml(jgl.HashMap hashmap) {
   String s =
       com.dragonflow.Utils.TextUtils.getValue(
           hashmap, com.dragonflow.SiteView.Machine.pSSHConnectionCaching.getName());
   if (s.length() > 0) {
     s = " CHECKED";
   }
   return field(
       "Disable Connection Caching",
       "<input type=checkbox name=disableCache" + s + ">",
       "Check this box to disable caching of SSH connections. ");
 }
Exemplo n.º 13
0
 protected String getSSHKeyFileHtml(jgl.HashMap hashmap) {
   String s =
       com.dragonflow.Utils.TextUtils.getValue(
           hashmap, com.dragonflow.SiteView.Machine.pSshKeyFile.getName());
   if (s.length() == 0) {
     s = com.dragonflow.SiteView.Machine.pSshKeyFile.getDefault();
   }
   return field(
       "Key File for SSH connections",
       "<input type=text name=keyFile size=50 value=\"" + s + "\">",
       "Enter the path to the file containing the private key for this SSH connection. <b> Only valid if authentication method is \"Key File\".");
 }
Exemplo n.º 14
0
 protected String getSshAuthMethodHtml(jgl.HashMap hashmap) {
   String s =
       com.dragonflow.Utils.TextUtils.getValue(
           hashmap, com.dragonflow.SiteView.Machine.pSshAuthMethod.getName());
   if (s.length() == 0) {
     s = PASSWORD_FORM_VARIABLE;
   }
   return field(
       "SSH Authentication Method",
       "<select name=sshAuthMethod size=1>"
           + com.dragonflow.Page.remoteBase.getOptionsHTML(
               com.dragonflow.SiteView.Machine.getAllowedSshAuthMethods(), s),
       "Select the method to use to authenticate to the remote server.");
 }
Exemplo n.º 15
0
  void printErrorPage(String s) {
    printBodyHeader("Generate Preferences");
    outputStream.println(
        "<p><CENTER><H2></H2></CENTER>\n<HR>There were errors in the entered information.  Use your browser's back button to return\nthe General Preferences form\n");
    String as[] = com.dragonflow.Utils.TextUtils.split(s, "\t");
    outputStream.print("<UL>\n");
    for (int i = 0; i < as.length; i++) {
      if (as[i].length() > 0) {
        outputStream.print("<LI><B>" + as[i] + "</B>\n");
      }
    }

    outputStream.print("</UL><HR></BODY>\n");
  }
Exemplo n.º 16
0
  private void processNode(org.w3c.dom.Node node, com.dragonflow.XmlApi.XmlApiObject xmlapiobject) {
    if (node.getNodeType() == 1) {
      String s = node.getNodeName();
      if (s != null && s.length() > 0) {
        jgl.HashMap hashmap = new HashMap();
        org.w3c.dom.NamedNodeMap namednodemap = node.getAttributes();
        for (int i = 0; i < namednodemap.getLength(); i++) {
          org.w3c.dom.Attr attr = (org.w3c.dom.Attr) namednodemap.item(i);
          if (attr.getName() != null
              && attr.getName().equals("encodeValues")
              && attr.getValue() != null
              && (attr.getValue().equals("false") || attr.getValue().equals("true"))) {
            encodeValues = (new Boolean(attr.getValue())).booleanValue();
            continue;
          }
          String s1 = attr.getValue();
          if (s1 != null) {
            s1 = com.dragonflow.Utils.TextUtils.enlighten(s1);
          }
          hashmap.put(attr.getName(), s1);
        }

        org.w3c.dom.NodeList nodelist = node.getChildNodes();
        java.util.Vector vector = findPropNodes(nodelist);
        for (int j = 0; j < vector.size(); j++) {
          org.w3c.dom.Node node1 = (org.w3c.dom.Node) vector.elementAt(j);
          org.w3c.dom.NodeList nodelist1 = node1.getChildNodes();
          String s2 = findPropertyName(nodelist1);
          String as[] = findValueNodes(nodelist1);
          if (as.length > 1) {
            hashmap.put(s2, as);
            continue;
          }
          if (as.length == 1) {
            hashmap.put(s2, as[0]);
          } else {
            hashmap.put(s2, "");
          }
        }

        xmlapiobject.setProperties(hashmap);
        xmlapiobject.setName(s);
        java.util.Vector vector1 = findChildrenNodes(nodelist);
        for (int k = 0; k < vector1.size(); k++) {
          org.w3c.dom.Node node2 = (org.w3c.dom.Node) vector1.elementAt(k);
          processNode(node2, xmlapiobject.add());
        }
      }
    }
  }
Exemplo n.º 17
0
  void printErrorPage(String s) {
    printBodyHeader("Database Driven Configuration");
    outputStream.println(
        "<p><CENTER><H2>Database Driven Configuration: Error</H2></CENTER>\n<HR><p>There were errors in information or connection.  Use your browser's back button to return\n  to the Configuration Database Preferences form. <hr>\n");
    String as[] = com.dragonflow.Utils.TextUtils.split(s, "\t");
    outputStream.print("<UL>\n");
    for (int i = 0; i < as.length; i++) {
      if (as[i].length() > 0) {
        outputStream.print("<LI><B>" + as[i] + "</B>\n");
      }
    }

    outputStream.print("</UL><HR></BODY>\n");
  }
Exemplo n.º 18
0
 void formLogin(jgl.HashMap hashmap) {
   String s = getPage();
   String s1 = "";
   if (s.indexOf("ntmachine") != -1) {
     s1 =
         "Enter the login for the remote server. <br>For a domain login, include the domain name before the user login (example: <i>domainname\\user</i>). <br>For a local or standalone login, include the machine name before the user login  (example: <i>machinename\\user</i>).";
   } else if (s.indexOf("machine") != -1) {
     s1 = "Enter the login to use for connecting to the remote server";
   } else {
     s1 = "Enter the login for the remote server";
   }
   outputStream.println(
       field(
           "Login",
           "<input type=text name=login size=50 value=\""
               + com.dragonflow.Utils.TextUtils.getValue(hashmap, "_login")
               + "\">",
           s1));
   String s2 = "";
   if (com.dragonflow.Utils.TextUtils.getValue(
           hashmap, com.dragonflow.SiteView.Machine.pPassword.getName())
       != "") {
     s2 = DEFAULT_PASSWORD;
   }
   outputStream.println(
       field(
           "Password",
           "<input type=password name=password size=50 value=\"" + s2 + "\">",
           "The password for the remote server or the passphrase for the SSH key file."));
   outputStream.println(
       field(
           "Title",
           "<input type=text name=title size=50 value=\""
               + com.dragonflow.Page.remoteBase.getValue(hashmap, "_name")
               + "\">",
           "Optional title describing the remote server. The default title is the server address"));
 }
Exemplo n.º 19
0
  void printErrorPage(String s) {
    //        outputStream.print("<HEAD><TITLE>" + com.dragonflow.SiteView.TopazInfo.getTopazName()
    // + "/ActiveWatch Console Connection</TITLE>\n" + com.dragonflow.Page.CGI.nocacheHeader +
    // com.dragonflow.SiteView.Platform.charSetTag + "</HEAD>\n" + "<BODY BGCOLOR=#FFFFFF>\n");
    outputStream.println(
        "<p><CENTER><H2></H2></CENTER>\n<HR>There were errors in the entered information.  Use your browser's back button to return\nthe previous form\n");
    String as[] = com.dragonflow.Utils.TextUtils.split(s, "\t");
    outputStream.print("<UL>\n");
    for (int i = 0; i < as.length; i++) {
      if (as[i].length() > 0) {
        outputStream.print("<LI><B>" + as[i] + "</B>\n");
      }
    }

    outputStream.print("</UL><HR></BODY>\n");
  }
Exemplo n.º 20
0
  /**
   * CAUTION: Decompiled by hand.
   *
   * @param abyte0
   * @return
   */
  public static String byteString(byte abyte0[]) {
    if (!isI18N) {
      return new String(abyte0);
    }
    try {
      String s;
      char ac[] = new char[abyte0.length];
      for (int i = 0; i < abyte0.length; i++) {
        ac[i] = (char) (abyte0[i] & 0xff);
      }

      s = new String(ac);
      return s;
    } catch (Exception exception) {
      com.dragonflow.Log.LogManager.log("Error", "I18N: Cannot Encode " + exception.getMessage());
      com.dragonflow.Utils.TextUtils.debugPrint("I18N: Cannot Encode " + exception.getMessage());
      exception.printStackTrace();
      return "";
    }
  }
Exemplo n.º 21
0
 public static String escapeHTMLPlusSpaces(String s) {
   String s1 = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-.:/";
   StringBuffer stringbuffer = new StringBuffer(s.length());
   int i = 0;
   do {
     if (i >= s.length()) {
       break;
     }
     for (int j = 0;
         (j = com.dragonflow.XmlApi.XmlApiRequestXML.isEscaped(stringbuffer, s, i)) > 0
             && i < s.length();
         i += j) {}
     if (i >= s.length()) {
       break;
     }
     char c = s.charAt(i++);
     if (s1.indexOf(c) >= 0) {
       stringbuffer.append(c);
     } else {
       com.dragonflow.Utils.TextUtils.escapeChar(c, stringbuffer);
     }
   } while (true);
   return stringbuffer.toString();
 }
Exemplo n.º 22
0
  /**
   * CAUTION: Decompiled by hand.
   *
   * @param s
   * @param s1
   * @return
   */
  public static String StringToUnicode(String s, String s1) {
    if (s == null || s.length() == 0) {
      return "";
    }

    if (!isI18N(s)) /*change By dingbing.xu*/ {
      return s;
    }
    String s2 = "";
    com.dragonflow.Utils.I18N.test(s, 2);
    String s3;

    try {
      byte abyte0[] = new byte[s.length()];
      for (int i = 0; i < s.length(); i++) {
        abyte0[i] = (byte) (s.charAt(i) & 0xff);
      }

      s3 = s1 != null && s1.length() != 0 ? new String(abyte0, s1) : new String(abyte0);
      if (s1 == com.dragonflow.Utils.I18N.nullEncoding()) {
        com.dragonflow.Utils.I18N.test(s3, 1);
      } else if (s1.length() == 0) {
        com.dragonflow.Utils.I18N.test(s3, 0);
      }
      return s3;
    } catch (Exception exception) {
      if (s1 != null && s1.length() > 0) {
        com.dragonflow.Log.LogManager.log(
            "Error", "I18N: Bad Encoding(" + s1 + ") " + exception.getMessage());
        com.dragonflow.Utils.TextUtils.debugPrint(
            "I18N: Bad Encoding(" + s1 + ") " + exception.getMessage());
        exception.printStackTrace();
      }
      return s;
    }
  }
Exemplo n.º 23
0
 public void printBody() throws Exception {
   if (!request.actionAllowed("_tools")) {
     throw new HTTPRequestException(557);
   }
   String s = request.getValue("host");
   String s1 = request.getValue("location");
   s =
       com.dragonflow.Utils.TextUtils.keepChars(
           s, ".-_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789");
   printBodyHeader("Ping");
   if (!request.getValue("AWRequest").equals("yes")) {
     printButtonBar("Ping.htm", "");
   }
   String s2 = "";
   if (s1.length() != 0) {
     s2 = "&location=" + s1;
     for (s2 = s2.trim();
         s2.indexOf(" ") >= 0;
         s2 = s2.substring(0, s2.indexOf(" ")) + s2.substring(s2.indexOf(" ") + 1)) {}
   }
   if (!request.getValue("AWRequest").equals("yes")) {
     outputStream.println(
         "<center><b>Ping</b> | <a href="
             + getPageLink("trace", "")
             + "&host="
             + s
             + s2
             + "&group="
             + request.getValue("group")
             + ">TraceRoute</a></center><P>");
   } else {
     outputStream.println(
         "<center><b>Ping</b> | <a href="
             + getPageLink("trace", "")
             + "&host="
             + s
             + s2
             + "&AWRequest=yes"
             + ">TraceRoute</a>"
             + " | "
             + " <a href=/SiteView/cgi/go.exe/SiteView?page=monitor&operation=Tools&account="
             + request.getAccount()
             + "&AWRequest=yes>Diagnostic Tools</a>"
             + "</center><P>");
   }
   outputStream.println(
       "<p>\n<CENTER><H2>Ping</H2></CENTER><P>\n<p>\n"
           + getPagePOST("ping", "")
           + "Ping is a tool that sends a packet to another location and back to the sender.\n"
           + "It shows you the roundtrip time along the path.\n"
           + "When there is a problem with the network, ping can tell you if another\n"
           + "location is reachable.\n"
           + "<p>This form will do a ping from this server to another location.  Enter\n"
           + "the domain name or ip address of the other location.\n"
           + "<p>\n"
           + "Domain Name or IP address: <input type=text name=host value=\""
           + s
           + "\" size=60>\n"
           + "<p>\n");
   boolean flag = !isPortalServerRequest();
   try {
     Class.forName("com.dragonflow.StandardMonitor.URLRemoteMonitor");
   } catch (ClassNotFoundException classnotfoundexception) {
     flag = false;
   }
   if (flag) {
     outputStream.print(com.dragonflow.Utils.HTTPUtils.locationsHTML(s1, request));
   }
   outputStream.print("<input type=submit value=\"Ping\" class=\"VerBl8\">\n</FORM>\n");
   if (s.length() > 0) {
     if (!isPortalServerRequest()) {
       printContentStartComment();
       String s3 = "";
       String s4 = "";
       if (s1.length() > 0) {
         s3 = com.dragonflow.Utils.HTTPUtils.getPingURLByID(s1);
         s4 = com.dragonflow.Utils.HTTPUtils.getLocationNameByID(s1);
       }
       if (s4.length() > 0) {
         s4 = " from " + s4;
       }
       outputStream.println("<PRE>Pinging " + s + s4 + "...\n\n");
       outputStream.flush();
       if (s3.length() == 0) {
         String s6 = com.dragonflow.SiteView.Platform.pingCommand(s, 5000, 5, 64);
         boolean flag1 = false;
         try {
           Process process = com.dragonflow.Utils.CommandLine.execSync(s6);
           boolean flag2 = false;
           java.io.BufferedReader bufferedreader =
               com.dragonflow.Utils.FileUtils.MakeInputReader(process.getInputStream());
           String s9;
           while ((s9 = bufferedreader.readLine()) != null) {
             if (s9.length() > 0) {
               flag1 = true;
               outputStream.println(com.dragonflow.Utils.TextUtils.escapeHTML(s9));
               outputStream.flush();
               flag2 = false;
             } else if (flag2) {
               flag1 = true;
               outputStream.println();
               flag2 = false;
             } else {
               flag2 = true;
             }
           }
           bufferedreader.close();
         } catch (java.io.IOException ioexception) {
           if (!flag1) {
             outputStream.println("Could not perform ping command: " + s6);
           }
         }
       } else {
         StringBuffer stringbuffer = new StringBuffer();
         String s7 = "";
         String s8 = "";
         String s10 = "";
         String s11 = "";
         String s12 = "";
         String s13 = "";
         String s14 = "";
         String s15 = "";
         long l = 50000L;
         jgl.Array array = null;
         StringBuffer stringbuffer1 = new StringBuffer(s);
         com.dragonflow.Utils.SocketSession socketsession =
             com.dragonflow.Utils.SocketSession.getSession(null);
         long al[] =
             com.dragonflow.StandardMonitor.URLMonitor.checkURL(
                 socketsession,
                 s,
                 s8,
                 s10,
                 s12,
                 s13,
                 s14,
                 array,
                 s7,
                 s11,
                 s3,
                 stringbuffer,
                 l,
                 s15,
                 0,
                 0x1d4c0,
                 stringbuffer1);
         socketsession.close();
         long l1 = al[0];
         String s16;
         if (l1 != 200L) {
           s16 = stringbuffer.toString();
           outputStream.print(
               "Error, " + com.dragonflow.StandardMonitor.URLMonitor.lookupStatus(l1) + "\n\n");
         } else {
           s16 = com.dragonflow.StandardMonitor.URLMonitor.getHTTPContent(stringbuffer.toString());
         }
         if (stringbuffer != null) {
           outputStream.print(com.dragonflow.Utils.TextUtils.escapeHTML(s16));
         }
       }
       outputStream.println("</PRE>");
       printContentEndComment();
     } else {
       com.dragonflow.SiteView.PortalSiteView portalsiteview =
           (com.dragonflow.SiteView.PortalSiteView) getSiteView();
       if (portalsiteview != null) {
         String s5 =
             portalsiteview.getURLContentsFromRemoteSiteView(request, "_centrascopeToolMatch");
         outputStream.println(s5);
       }
     }
   }
   if (!request.getValue("AWRequest").equals("yes")) {
     printFooter(outputStream);
   } else {
     outputStream.println("</BODY>");
   }
 }
Exemplo n.º 24
0
 public static String escapeString(String s, String s1) {
   return com.dragonflow.Utils.TextUtils.escapeHTML(
       com.dragonflow.Utils.I18N.StringToUnicode(
           com.dragonflow.Utils.I18N.UnicodeToString(s, com.dragonflow.Utils.I18N.nullEncoding()),
           s1));
 }
Exemplo n.º 25
0
  void savePreferences() {
    String s = "";
    try {
      jgl.HashMap hashmap = getMasterConfig();
      // add by hailong.yi 2008/8/20
      jgl.HashMap hashmapSave = new jgl.HashMap();

      String s1 = com.dragonflow.Page.portalGeneralPrefsPage.getValue(hashmap, "_httpPort");
      String s2 = request.getValue("httpPort").trim();
      if (!s1.equals(s2) && s2.length() > 0) {
        int i = com.dragonflow.Properties.StringProperty.toInteger(s2);
        if (i == 0) {
          s = s + "\tHTTP Port must be a number greater than 0";
        } else {
          try {
            java.net.ServerSocket serversocket = new ServerSocket(i);
            serversocket.close();
          } catch (java.io.IOException ioexception1) {
            s = s + "\tPort " + i + " could not be opened: " + ioexception1.getMessage();
          }
        }
      }
      String s3 = request.getValue("authorizedIP");
      if (s3.length() > 0 && !com.dragonflow.Utils.TextUtils.onlyChars(s3, "0123456789,.*")) {
        s = s + "\tThe IP Address allowed access contained illegal characters";
      }
      if (s3.length() == 0 && request.getValue("checkAddressAndLogin").length() > 0) {
        s =
            s
                + "\tTo enable <B>Require both IP address and Login</B> you must fill in authorized IP address(es)";
      }
      String s4 = request.getValue("license").trim();

      if (!com.dragonflow.Utils.LUtils.setLicenseKey(s4, hashmap, hashmapSave))
      //            if(!com.dragonflow.Utils.LUtils.setLicenseKey(s4, hashmap))
      {
        s = s + com.dragonflow.Utils.LUtils.getLicenseErrorString(s4);
      }
      /*            hashmap.put("_httpPort", s2);
                  hashmap.put("_authorizedIP", s3);
                  hashmap.put("_checkAddressAndLogin", request.getValue("checkAddressAndLogin"));
                  hashmap.put("_localeEnabled", request.getValue("localeEnabled"));
      */
      hashmapSave.put("_httpPort", s2);
      hashmapSave.put("_authorizedIP", s3);
      hashmapSave.put("_checkAddressAndLogin", request.getValue("checkAddressAndLogin"));
      hashmapSave.put("_localeEnabled", request.getValue("localeEnabled"));
      if (s.length() == 0) {
        // saveMasterConfig(hashmap);
        Config.configPut(hashmapSave);
        if (!s1.equals(s2)) {
          byte byte0 = 15;
          String s5 =
              "Waiting 15 seconds for "
                  + com.dragonflow.SiteView.Platform.productName
                  + "'s web server to restart...";
          if (s2.length() == 0) {
            s5 = "";
            byte0 = 0;
          } else if (s1.length() == 0) {
            s5 =
                "Waiting 15 seconds for "
                    + com.dragonflow.SiteView.Platform.productName
                    + "'s web server to start...";
          }
          String s6 =
              com.dragonflow.Page.portalGeneralPrefsPage.getValue(hashmap, "_webserverAddress");
          String s7 = "http://" + s6 + ":" + s2 + "/";
          printPreferencesSaved(s7, "<H2>Preferences have been saved</H2><P>" + s5, byte0);
        } else {
          printPreferencesSaved();
        }
      } else {
        printErrorPage(s);
      }
    } catch (Exception ioexception) {
      printError(
          "The preferences could not be saved", "master.config file could not be saved", "10");
    }
  }
Exemplo n.º 26
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;
  }
Exemplo n.º 27
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());
    }
  }
Exemplo n.º 28
0
 void printForm() {
   jgl.HashMap hashmap = getMasterConfig();
   StringBuffer stringbuffer = new StringBuffer();
   StringBuffer stringbuffer1 = new StringBuffer();
   com.dragonflow.Properties.StringProperty.getPrivate(
       com.dragonflow.Page.jdbcConfigPrefsPage.getValue(hashmap, "_configJdbcPassword"),
       "configJdbcPassword",
       "jdbcSuff",
       stringbuffer,
       stringbuffer1);
   printBodyHeader("Database Driven Configuration");
   printButtonBar("DBDrivenConfigs.htm", "", getSecondNavItems(request));
   printPrefsBar("DDC");
   String s = "";
   if (com.dragonflow.Utils.TextUtils.getValue(hashmap, "_configJdbcURL").length() == 0) {
     s = "CHECKED";
   }
   outputStream.print(
       getPagePOST("jdbcConfigPrefs", "save")
           + "<HR><CENTER><H2>Database Driven Configuration</H2></CENTER><BR>\n"
           + "SiteView can optionally read monitor settings and configurations "
           + " from a database, and save configurations"
           + " to a database. Any database which supports the ODBC or JDBC standards can be used, including Microsoft SQL Server and Oracle.\n"
           + "<p>For additional information on this feature go to our Customer Support <a href=\"http://support.dragonflow.com/\">Knowledge Base</a> and   "
           + " search for Storing monitor configurations in a database. "
           + "<p><b>(note:</b> changes to Configuration Database preferences do not take effect until the next time SiteView is restarted)\n"
           + "<hr><TABLE border=0 width=100% cellspacing=0 cellpadding=5>"
           + "<TR><TD ALIGN=LEFT VALIGN=TOP WIDTH=20%>Database Connection URL:</TD>"
           + "<TD VALIGN=TOP><input type=text name=configJdbcURL size=40 value=\""
           + com.dragonflow.Page.jdbcConfigPrefsPage.getValue(hashmap, "_configJdbcURL")
           + "\">\n"
           + "</TD><TD VALIGN=TOP>"
           + "Enter the URL to the database connection</TD></TR>"
           + "<tr><td>&nbsp;</td><td spancol=2>If you're using an ODBC connection: use - <b><i>jdbc:odbc:myDSNName</i></b><br>"
           + "If you're using a SQL connection: use - <b><i>jdbc:inetdae:myserver.mycompany.com:1433?database=master</i></b></TD></TR>"
           + "<tr><td colspan=3><hr></td></tr>"
           + "<TR><TD ALIGN=LEFT VALIGN=TOP WIDTH=20%>Database Driver:</TD>"
           + "<TD VALIGN=TOP><input type=text name=configJdbcDriver size=40 value=\""
           + com.dragonflow.Page.jdbcConfigPrefsPage.getValue(hashmap, "_configJdbcDriver")
           + "\">\n"
           + "</TD><TD VALIGN=TOP>"
           + "Driver used to connect to the database</TD></TR>"
           + "<tr><td>&nbsp;</td><td spancol=2>If you're using an ODBC connection: use - <b><i>sun.jdbc.odbc.JdbcOdbcDriver</i></b><br>"
           + "If you're using a SQL connection: use - <b><i>com.inet.tds.TdsDriver</i></b><br>"
           + "For all other DBs, go to their web site and install their JDBC thin driver.</TD></TR>"
           + "<tr><td colspan=3><hr></td></tr>"
           + "<TR><TD ALIGN=LEFT VALIGN=TOP WIDTH=20%>Database Username:</TD>"
           + "<TD VALIGN=TOP><input type=text name=configJdbcUser size=40 value=\""
           + com.dragonflow.Page.jdbcConfigPrefsPage.getValue(hashmap, "_configJdbcUser")
           + "\">\n"
           + "</TD><TD VALIGN=TOP>"
           + "Enter the username used to connect to the database.</TD></TR>"
           + "<tr><td colspan=3><hr></td></tr>"
           + "<TR><TD ALIGN=LEFT VALIGN=TOP WIDTH=20%>Database Password:</TD>"
           + "<TD VALIGN=TOP>"
           + stringbuffer.toString()
           + " size=40>\n"
           + stringbuffer1.toString()
           + "</TD><TD VALIGN=TOP>"
           + "Enter the password used to connect to the database.</TD></TR>"
           + "<tr><td colspan=3><hr></td></tr>"
           + "</table>\n"
           + "<p><table><tr><td><input type=submit name=submit value=\"Save Changes\"></td>\n");
   if (com.dragonflow.Page.jdbcConfigPrefsPage.getValue(hashmap, "_configJdbcURL").length() > 0
       && com.dragonflow.Page.jdbcConfigPrefsPage.getValue(hashmap, "_configJdbcDriver").length()
           > 0) {
     outputStream.print(
         "<td><input type=submit name=submit value=\"Remove DataBase Connection\"></td>");
     outputStream.print(
         "<td><input type=submit name=submit value=\"Sync SiteView From DB\"></td>");
     if (com.dragonflow.Page.jdbcConfigPrefsPage
             .getValue(hashmap, "_configJdbcSyncDBFromFiles")
             .length()
         > 0) {
       outputStream.print(
           "<td><input type=submit name=submit value=\"Sync DB From SiteView\"></td>");
     }
   }
   outputStream.print("</tr></table>");
   String s1 = com.dragonflow.Utils.TextUtils.getValue(hashmap, "_jdbcConfigdisabled");
   String s2 = "";
   if (s1.length() > 0) {
     s2 = "CHECKED";
   }
   outputStream.print(
       "<p><HR><CENTER><H3>Advanced Options</H3></CENTER><DL><P><DT><input type=checkbox name=jdbcConfigdisabled "
           + s2
           + ">Disable syncing configuration files from database.<P>\n"
           + "<P><DT><input type=checkbox name=initializeDatabaseFromFiles "
           + s
           + ">Initialize database from current configuration files<P>\n"
           + "<DD>If you would like the database initialized with the current contents of the configuration files, check this box.\n"
           + "<B>Warning: checking this box will delete the current configurations stored in the database for this server - we advise using this feature\n"
           + "only when initially setting up database configuration.</B>"
           + "</DL>"
           + "<P><DT>Configuration Update Frequency: <input type=text name=configJdbcCheckFrequency size=40 value=\""
           + com.dragonflow.Page.jdbcConfigPrefsPage.getValue(hashmap, "_configJdbcCheckFrequency")
           + "\"><P>\n"
           + "<DD>Enter the configuration update frequnce (seconds).\n"
           + "</FORM>\n"
           + "<br>\n"
           + "<CENTER><B>Version "
           + com.dragonflow.SiteView.Platform.getVersion()
           + "</B><p>\n");
   printFooter(outputStream);
 }