Beispiel #1
0
    /** Saves the data in the following format: Label:value e.g. Password Retries:3 */
    protected void saveData() {
      StringBuffer sbData = new StringBuffer();
      Component[] comps = getComponents();
      String strLabel = null;
      String strValue = null;
      String strCmd = null;

      for (int i = 0; i < comps.length; i++) {
        Component comp = comps[i];
        boolean bCmd = false;
        if (comp instanceof JLabel) {
          strLabel = ((JLabel) comp).getText();
          sbData.append(strLabel);
          sbData.append(":");

          // append to the cmd string
          if (strLabel.equalsIgnoreCase("Password Retries")) strCmd = RETRIES;
          else if (strLabel.indexOf("Default Expiration") >= 0) strCmd = MAXWEEKS;
          else if (strLabel.indexOf("Minimum Length") >= 0) strCmd = PASSLENGTH;
          else strCmd = "";
        } else if (comp instanceof JTextField) {
          strValue = ((JTextField) comp).getText();
          if (strValue == null) strValue = "";
          sbData.append(strValue);
          sbData.append("\n");

          // append to the cmd string
          if ((strCmd.indexOf(RETRIES) >= 0)
              || (strCmd.indexOf(MAXWEEKS) >= 0)
              || (strCmd.indexOf(PASSLENGTH) >= 0)) {
            strCmd = strCmd + "= " + strValue;
            bCmd = true;
          }
        } else if (comp instanceof JCheckBox) {
          strValue = ((JCheckBox) comp).isSelected() ? "yes" : "no";
          sbData.append(strValue);
          sbData.append("\n");
        }

        // call the unix script that can set these values
        if (bCmd) {
          String[] cmd = {
            WGlobal.SHTOOLCMD,
            WGlobal.SHTOOLOPTION,
            WGlobal.SUDO + WGlobal.SBIN + "auredt" + " " + strCmd
          };
          WUtil.runScript(cmd);
        }
      }
      // write to the file
      BufferedWriter writer = WFileUtil.openWriteFile(m_strPath);
      WFileUtil.writeAndClose(writer, sbData);
    }
Beispiel #2
0
    protected String getChecksum() {
      String strValue = (String) m_cmbPath.getSelectedItem();
      String strChecksum = "";
      if (strValue == null || strValue.equals("")) return strChecksum;

      String[] cmd = {
        WGlobal.SHTOOLCMD,
        WGlobal.SHTOOLOPTION,
        WGlobal.SUDO + WGlobal.SBIN + "makeP11checksums " + strValue
      };
      WMessage msg = WUtil.runScript(cmd);
      strChecksum = msg.getMsg();
      m_txaChecksum.append("Generated Checksum: " + strChecksum + "\n");

      return strChecksum;
    }
Beispiel #3
0
  protected static boolean unixPassword(String strUser, char[] password) {
    password = getPassword(password);
    boolean bSu = true;
    String strSu;
    PrintWriter fout = null;

    if (!Util.iswindows()) {
      String filepath = FileUtil.savePath("USER/PERSISTENCE/passwd");
      if (filepath == null) {
        filepath = FileUtil.savePath("USER/PERSISTENCE/tmp_passwd");
      }
      try {
        fout = new PrintWriter(new FileWriter(filepath));
        if (fout != null) fout.println(String.valueOf(password));
      } catch (IOException er) {
      } finally {
        try {
          if (fout != null) fout.close();
        } catch (Exception e) {
        }
      }

      /**
       * ******** String strPath = new StringBuffer().append(LOGIN).append(" ").append(
       * strUser).append(" \"").append(String.valueOf( password)).append("\"").toString(); ********
       */
      String strPath =
          new StringBuffer()
              .append(LOGIN)
              .append(" ")
              .append(strUser)
              .append(" \"")
              .append(filepath)
              .append("\"")
              .toString();
      String[] cmd = {WGlobal.SHTOOLCMD, WGlobal.SHTOOLOPTION, strPath};
      WMessage objMessage = WUtil.runScript(cmd, false);
      bSu = objMessage.isNoError();
      strSu = objMessage.getMsg();
    } else {
      String strQuotes = "\"\"";
      if (password.length == 0) strQuotes = "\"";
      String cmd =
          new StringBuffer()
              .append(LOGIN_WIN)
              .append(" ")
              .append(strUser)
              .append(" ")
              .append(strQuotes)
              .append(String.valueOf(password))
              .append(strQuotes)
              .toString();
      WMessage objMessage = WUtil.runScript(cmd, false);
      bSu = objMessage.isNoError();
      strSu = objMessage.getMsg();
    }
    if (bSu) {
      if (strSu != null) strSu = strSu.toLowerCase();
      if (strSu == null
          || strSu.trim().equals("")
          || strSu.indexOf("killed") >= 0
          || strSu.indexOf("error") >= 0) bSu = false;
    }

    return bSu;
  }