Example #1
0
 private static java.lang.String transform(java.lang.String s, java.lang.String s1)
     throws java.lang.Exception {
   if (s1 == null) {
     return s;
   }
   s1 = com.dragonflow.SiteView.Platform.getRoot() + "/" + s1;
   java.io.CharArrayWriter chararraywriter = new CharArrayWriter();
   try {
     java.lang.StringBuffer stringbuffer = com.dragonflow.Utils.FileUtils.readFile(s1);
     com.dragonflow.Utils.XSLUtils.convert(
         s, stringbuffer.toString(), new PrintWriter(chararraywriter));
   } catch (java.io.IOException ioexception) {
     ioexception.printStackTrace();
     throw new Exception("Failed to read XSL file: " + s1);
   } catch (java.lang.Exception exception) {
     exception.printStackTrace();
     throw new Exception("Exception: " + exception);
   }
   return chararraywriter.toString();
 }
Example #2
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;
  }
Example #3
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>");
   }
 }