private boolean _assignValues(File fle) {
    String strMethod = "_assignValues(fle)";

    if (fle == null) {
      MySystem.s_printOutError(this, strMethod, "nil fle");
      return false;
    }

    if (!fle.exists()) {
      MySystem.s_printOutWarning(
          this, strMethod, "! fle.exists(), fle.getAbsolutePath()=" + fle.getAbsolutePath());

      String strBody = fle.getAbsolutePath();
      strBody += ":\nDirectory not found.";

      OPAbstract.s_showDialogWarning(super._frmParent_, strBody);

      return true;
    }

    if (!fle.isDirectory()) // statement should never be reached!!!
    {
      MySystem.s_printOutWarning(
          this, strMethod, "! fle.isDirectory(), fle.getAbsolutePath()=" + fle.getAbsolutePath());

      String strBody = fle.getAbsolutePath();
      strBody += ":\n  not a directory.";

      OPAbstract.s_showDialogWarning(super._frmParent_, strBody);

      return true;
    }

    if (super._tfdCurSelection_ == null) {
      MySystem.s_printOutError(this, strMethod, "nil super._tfdCurSelection_");
      return false;
    }

    super._tfdCurSelection_.setText(fle.getAbsolutePath());
    super._setSelectedValue_(true);

    if (!_enableButtonsSelectionDone_()) {
      MySystem.s_printOutError(this, strMethod, "failed");
      return false;
    }

    // --
    // ending
    return true;
  }
Beispiel #2
0
  /* transform manifest in an array of byte
      if any code error, exit
      else if any error, show dialog, then return nil
  */
  public static byte[] s_toByteArray(Manifest man, Frame frmOwner) {
    String strMethod = _f_s_strClass + "s_toByteArray(...)";

    if (man == null) {
      MySystem.s_printOutExit(strMethod, "nil man");
    }

    ByteArrayOutputStream baoBuffer = new ByteArrayOutputStream();

    try {
      man.write(baoBuffer);
      baoBuffer.flush();
      baoBuffer.close();
    } catch (IOException excIO) {
      excIO.printStackTrace();
      MySystem.s_printOutExit(strMethod, "excIO caught");

      String strBody = "Got IO exception";

      OPAbstract.s_showDialogError(frmOwner, strBody);

      return null;
    }

    return baoBuffer.toByteArray();
  }
  private String[] _getStrsAliasSourceToKpr(KeyStore kstOpenToSource) {
    String strMethod = "_getStrsAliasSourceToKpr(kstOpenToSource)";

    String[] strsAliasSourceAll = UtilKstAbs.s_getStrsAlias(super._frmOwner_, kstOpenToSource);

    if (strsAliasSourceAll == null) {
      MySystem.s_printOutError(this, strMethod, "nil strsAliasSourceAll");
      return null;
    }

    if (strsAliasSourceAll.length < 1) {
      MySystem.s_printOutWarning(this, strMethod, "strsAliasSourceAll.length < 1");

      String strBody = "No aliases found in " + UtilKstBks.f_s_strKeystoreType + " keystore:";

      strBody += "\n" + "  ";
      strBody += super._strPathAbsKstSource_;

      OPAbstract.s_showDialogWarning(super._frmOwner_, strBody);

      return null;
    }

    Vector<String> vec = new Vector<String>();

    try {
      for (int i = 0; i < strsAliasSourceAll.length; i++) {
        if (!kstOpenToSource.isKeyEntry(strsAliasSourceAll[i])) continue;

        Certificate[] certs = kstOpenToSource.getCertificateChain(strsAliasSourceAll[i]);

        if (certs == null) continue;

        if (certs.length < 1) continue;

        vec.addElement(strsAliasSourceAll[i]);
      }
    } catch (KeyStoreException excKeystore) {
      excKeystore.printStackTrace();
      MySystem.s_printOutError(this, strMethod, "excKeystore caught");

      // show dialog
      String strBody =
          "Got keystore Exception while reading " + UtilKstBks.f_s_strKeystoreType + " keystore:";

      strBody += "\n" + "  ";
      strBody += super._strPathAbsKstSource_;

      OPAbstract.s_showDialogWarning(super._frmOwner_, strBody);
    }

    // --

    if (vec.size() < 1) {
      MySystem.s_printOutWarning(this, strMethod, "vec.size() < 1");

      // show dialog
      String strBody =
          "No aliases pointing to keypair found in "
              + UtilKstBks.f_s_strKeystoreType
              + " keystore:";

      strBody += "\n" + "  ";
      strBody += super._strPathAbsKstSource_;

      OPAbstract.s_showDialogWarning(super._frmOwner_, strBody);

      return null;
    }

    // ---

    String[] strsAliasSourceToKpr = new String[vec.size()];

    for (int i = 0; i < vec.size(); i++) strsAliasSourceToKpr[i] = (String) vec.elementAt(i);

    return strsAliasSourceToKpr;
  }