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

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

    // --
    // allow overwriting
    // --

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

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

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

    super._btnClearSelection_.setEnabled(true);

    // --
    // ending
    return true;
  }
Пример #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();
  }
Пример #3
0
  @Override
  public boolean init() {
    String strMethod = "init()";

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

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

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

    if (this._btnHelpTrack_ != null) {
      if (!((BESHelpJHAbstract) this._btnHelpTrack_).init()) {
        MySystem.s_printOutError(this, strMethod, "failed");
        return false;
      }
    }

    // ending
    return true;
  }
  protected void _showDialog_() {
    String strMethod = "_showDialog_()";

    String[] strsTypeFileShkCur = _getTypeFileShkCur();

    if (strsTypeFileShkCur == null)
      MySystem.s_printOutExit(this, strMethod, "nil strsTypeFileShkCur");

    String strFileDesc = _getDescFileShkCur();

    if (strFileDesc == null) MySystem.s_printOutExit(this, strMethod, "nil strFileDesc");

    // ----

    File fle = null;

    String strButtonTextOk = "Save file";

    fle =
        S_FileChooserUI.s_getSaveFile(
            super._frmParent_,
            strButtonTextOk,
            strsTypeFileShkCur,
            strFileDesc,
            com.google.code.p.keytooliui.ktl.io.S_FileExtensionUI.f_s_strDirNameDefaultShk);

    if (fle == null) {
      // cancelled
      return;
    }

    if (!_assignValues(fle))
      MySystem.s_printOutExit(this, strMethod, "failed, fle.getName()=" + fle.getName());
  }
  /**
   * if any code error, exit else if any other error, show warning-error dialog, then return false
   * else return true
   */
  public boolean doJob() {
    String strMethod = "doJob()";

    // x) if pathAbsKeystore != nil, load keystore of type "JKS"
    java.security.KeyStore kstOpen = null;

    if (super._strPathAbsKst_ != null) {
      if (super._strProviderKst_ == null) {
        MySystem.s_printOutExit(this, strMethod, "nil super._strProviderKst_");
      }

      // if
      // (super._strProviderKst_.toLowerCase().compareTo(KTLAbs._f_s_strSecurityProviderSun_.toLowerCase()) != 0)
      //  MySystem.s_printOutExit(this, strMethod, "wrong value, super._strProviderKst_=" +
      // super._strProviderKst_);
      // MySystem.s_printOutWarning(this, strMethod, "should check for keystore of type JKS,
      // provider named SUN");

      // memo: keystore should be of type "JKS", provided by "SUN"
      File fleOpen = UtilJsrFile.s_getFileOpen(super._frmOwner_, super._strPathAbsKst_);

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

      kstOpen =
          UtilKstJks.s_getKeystoreOpen(
              super._frmOwner_,
              fleOpen,
              (char[]) null // keystore's Password, not in use for verifying signed jarred file
              );

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

    super._setEnabledCursorWait_(true);

    if (!super._doJob_(kstOpen)) {
      super._setEnabledCursorWait_(false);
      MySystem.s_printOutError(this, strMethod, "failed");
      return false;
    }

    super._setEnabledCursorWait_(false);

    // ----
    return true;
  }
Пример #6
0
  public static boolean s_isUSun() {
    String strMethod = _f_s_strClass + "s_isUSun()";

    if (_s_strOsName == null) _s_strOsName = System.getProperty("os.name");

    if (_s_strOsName == null) MySystem.s_printOutExit(strMethod, "nil _s_strOsName");

    if (_s_strOsName.toLowerCase().startsWith(_f_s_strOsUnixSunOS)) {
      MySystem.s_printOutTrace(strMethod, "got:" + _s_strOsName);
      return true;
    }

    return false;
  }
  /**
   * if any error in code, exiting in case of trbrl: open up a warning dialog, and return false;
   *
   * <p>algo: . get fileOpen keystore . open keystore . fill in table entries . show dialog keystore
   * . enter new alias for trusted certificate entry candidate . create new tcr from crt file .
   * assign new entry to open keystore . save keystore
   */
  public boolean doJob() {
    String strMethod = "doJob()";

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

    super._setEnabledCursorWait_(true);

    // ---
    // get file keystore

    // memo: keystore should be of type "Uber", provided by "?"
    File fleOpenKst = UtilJsrFile.s_getFileOpen(super._frmOwner_, super._strPathAbsKst_);

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

    // ----
    // open keystore

    if (super._chrsPasswdKst_ == null) {
      super._setEnabledCursorWait_(false);
      MySystem.s_printOutExit(this, strMethod, "nil super._chrsPasswdKst_");
    }

    KeyStore kstOpen =
        UtilKstUber.s_getKeystoreOpen(super._frmOwner_, fleOpenKst, super._chrsPasswdKst_);

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

    if (!super._doJob_(fleOpenKst, kstOpen)) {
      super._setEnabledCursorWait_(false);
      MySystem.s_printOutError(this, strMethod, "failed");
      return false;
    }

    super._setEnabledCursorWait_(false);

    // ending
    return true;
  }
  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;
  }
  public boolean init() {
    String f_strMethod = "init()";

    if (!super._init_()) {
      MySystem.s_printOutError(this, f_strMethod, "failed");
      return false;
    }

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

    return true;
  }
Пример #10
0
  /*
      meaning all Unix, including linux
  */
  public static boolean s_isUnix() {
    String strMethod = _f_s_strClass + "s_isUnix()";

    if (s_isWindows()) return false;

    if (s_isMac()) return false;

    // --

    if (s_isULinux()) return true;

    if (s_isUSun()) return true;

    if (s_isUIbm()) return true;

    if (s_isUHp()) return true;

    if (s_isUSgi()) return true;

    if (s_isUOther()) return true;

    // assuming this is Unix
    MySystem.s_printOutTrace(
        strMethod,
        "not windows, not mac, not linux, not unixSun, assuming this is UNIX, _s_strOsName="
            + _s_strOsName);

    return true;
  }
Пример #11
0
  public static boolean s_isUOther() {
    String strMethod = _f_s_strClass + "s_isUOther()";

    if (_s_strOsName == null) _s_strOsName = System.getProperty("os.name");

    if (_s_strOsName == null) MySystem.s_printOutExit(strMethod, "nil _s_strOsName");

    for (int i = 0; i < _f_s_strsOsUnixOther.length; i++) {
      if (_s_strOsName.toLowerCase().startsWith(_f_s_strsOsUnixOther[i])) {
        MySystem.s_printOutTrace(strMethod, "got:" + _s_strOsName);
        return true;
      }
    }

    return false;
  }
  private boolean _loadResourceBundle() {
    String f_strMethod = "_loadResourceBundle()";

    /* MEMO: trim() not necessary
     */
    try {
      String strValue = null;

      // TEXTS
      strValue = _s_rbeResources.getString("text_this");
      setText(strValue);
      strValue = _s_rbeResources.getString("text_left");
      this._mimLeft.setText(strValue);
      strValue = _s_rbeResources.getString("text_center");
      this._mimCenter.setText(strValue);
      strValue = _s_rbeResources.getString("text_right");
      this._mimRight.setText(strValue);
    } catch (java.util.MissingResourceException excMissingResource) {
      excMissingResource.printStackTrace();
      MySystem.s_printOutError(
          this, f_strMethod, "excMissingResource caught," + _f_s_strBundleFileLong);
      return false;
    }

    return true;
  }
Пример #13
0
  protected TBMainAbstract(
      String strHelpID,
      ActionListener actListenerParent,
      // javax.help.HelpBroker hbrHelpStandard,
      int intOrientation,
      javax.swing.ImageIcon
          iinFrameFloatable, // should be used once bug fixed "setFloatable(true), see below
      boolean blnDoHelpOnItem,
      boolean blnFloatable) {
    super(intOrientation, iinFrameFloatable, strHelpID, blnFloatable);

    String strMethod = "TBMainAbstract(...)";

    try {
      this._btnHelpSource_ = new BESHelpJHSource();

      if (blnDoHelpOnItem) {
        this._btnHelpTrack_ = new BESHelpJHTrack();
      }
    } catch (NullPointerException excNullPointer) {
      excNullPointer.printStackTrace();
      MySystem.s_printOutExit(this, strMethod, "excNullPointerCaught");
    }

    this._btnExit_ = new BESExit24(actListenerParent);

    if (actListenerParent != null) super._btnPrint_ = new BESPrint24(actListenerParent);
  }
  /** should be X509Cert, either RSA or DSA */
  private Boolean[] _getBoosElligibleSource(
      String[] strsAlgoKeyPublSource, Boolean[] boosTypeCertX509Source) {
    String strMethod = "_getBoosElligibleSource(...)";

    if (strsAlgoKeyPublSource == null || boosTypeCertX509Source == null)
      MySystem.s_printOutExit(this, strMethod, "nil arg");

    Boolean[] boosElligibleSource = new Boolean[strsAlgoKeyPublSource.length];

    for (int i = 0; i < strsAlgoKeyPublSource.length; i++) {
      boolean blnOk = true;

      String str = strsAlgoKeyPublSource[i].toLowerCase();

      // should be of type DSA OR RSA
      if ((str.compareTo(KTLAbs.f_s_strTypeKeypairDsa.toLowerCase()) != 0)
          && (str.compareTo(KTLAbs.f_s_strTypeKeypairRsa.toLowerCase()) != 0)) {
        blnOk = false;
      }

      // certificate should be of type X509
      else if (boosTypeCertX509Source[i].booleanValue() == false) {
        blnOk = false;
      }

      // --

      boosElligibleSource[i] = new Boolean(blnOk);
    }

    // ----
    return boosElligibleSource;
  }
  /** grouping PKCS7-[XXX]-[XXX] files */
  private boolean _addGroup() {
    String strMethod = "_addGroup()";

    // adding radioButtons/labelChecks for selecting in between JAR, and JHR, and RCR files

    if (this._btnTypeFileShkDer == null) {
      MySystem.s_printOutError(this, strMethod, "nil this._btnTypeFileShk[xxx]");
      return false;
    }

    // ----

    ButtonGroup bgp = new ButtonGroup();
    // bgp.add(this._btnTypeFileShkPkcs7);

    if (this._btnTypeFileShkPem != null) bgp.add(this._btnTypeFileShkPem);

    bgp.add(this._btnTypeFileShkDer);

    if (bgp.getButtonCount() < 2) {
      this._btnTypeFileShkDer.setEnabled(false);
    }

    // selecting first button
    this._btnTypeFileShkDer.setSelected(true);

    // else label: done at construction time

    // --
    JPanel pnlTypeFileShk = new JPanel();
    pnlTypeFileShk.setLayout(new BoxLayout(pnlTypeFileShk, BoxLayout.Y_AXIS));
    pnlTypeFileShk.add(this._btnTypeFileShkDer); // default

    if (this._btnTypeFileShkPem != null) pnlTypeFileShk.add(this._btnTypeFileShkPem);

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

    super._pnl_.add(pnlTypeFileShk);

    // ending
    return true;
  }
Пример #16
0
  public boolean isDefault() {
    String strMethod = "isDefault()";

    if (getText() == null) MySystem.s_printOutExit(this, strMethod, "getText() == null");

    if (getText().compareTo(Tfd10x30SelString._f_s_strDefault) == 0) return true;

    return false;
  }
Пример #17
0
  public static boolean s_isWinPro() {
    String strMethod = _f_s_strClass + "s_isWinPro()";

    if (!s_isWindows()) return false;

    if (s_isWinPub()) return false;

    if (_s_strOsName == null) MySystem.s_printOutExit(strMethod, "nil _s_strOsName");

    if (_s_strOsName.toLowerCase().endsWith("nt")
        || _s_strOsName.toLowerCase().endsWith("2000")
        || _s_strOsName.toLowerCase().endsWith("xp")) return true;

    MySystem.s_printOutWarning(
        strMethod, "unknown OS, assuming WinPro, _s_strOsName=" + _s_strOsName);

    return true;
  }
Пример #18
0
  public static boolean s_isWindows() {
    String strMethod = _f_s_strClass + "s_isWindows()";

    if (_s_strOsName == null) _s_strOsName = System.getProperty("os.name");

    if (_s_strOsName == null) MySystem.s_printOutExit(strMethod, "nil _s_strOsName");

    if (_s_strOsName.toLowerCase().startsWith(_f_s_strOsWindows)) return true;

    return false;
  }
  // could be redefined in subclasses
  protected boolean _enableButtonsSelectionDone_() {
    String strMethod = "_enableButtonsSelectionDone_()";

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

    super._btnClearSelection_.setEnabled(true);

    return true;
  }
Пример #20
0
  protected boolean _addButtonAboutAppli_() {
    String strMethod = "_addButtonAboutAppli_()";

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

    add(this._btnAboutAppli_);

    // ending
    return true;
  }
  public boolean init() {
    String strMethod = "init()";

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

    if (this._btnTypeFileShkPem != null) {
      if (!this._btnTypeFileShkPem.init()) return false;
    }

    if (!this._btnTypeFileShkDer.init()) return false;

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

    // ending
    return true;
  }
Пример #22
0
  public static boolean s_isWinPub() {
    String strMethod = _f_s_strClass + "s_isWinPub()";

    if (!s_isWindows()) return false;

    if (_s_strOsName == null) MySystem.s_printOutExit(strMethod, "nil _s_strOsName");

    if (_s_strOsName.toLowerCase().endsWith("95")
        || _s_strOsName.toLowerCase().endsWith("98")
        || _s_strOsName.toLowerCase().endsWith("me")) return true;

    return false;
  }
  static {
    final String f_strWhere =
        "com.google.code.p.keytooliui.shared.swing.menu.METextAlignmentEditorText";

    try {
      _s_rbeResources =
          java.util.ResourceBundle.getBundle(
              _f_s_strBundleFileShort, java.util.Locale.getDefault());
    } catch (java.util.MissingResourceException excMissingResource) {
      excMissingResource.printStackTrace();
      MySystem.s_printOutExit(f_strWhere, _f_s_strBundleFileLong + "excMissingResource caught");
    }
  }
  protected void _showDialog_() {
    String strMethod = "_showDialog_()";
    String strButtonTextOk = "Open directory";

    File fle = S_FileChooserAbs.s_getOpenDir(super._frmParent_, strButtonTextOk);

    if (fle == null) {
      // cancelled
      return;
    }

    if (!_assignValues(fle))
      MySystem.s_printOutExit(this, strMethod, "failed, fle.getName()=" + fle.getName());
  }
Пример #25
0
  protected boolean _addButtonExit_() {
    String strMethod = "_addButtonExit_()";

    add(Box.createHorizontalGlue());
    add(Box.createVerticalGlue());

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

    add(this._btnExit_);
    // this._addSeparator_();
    return true;
  }
Пример #26
0
  /** MEMO: bln alaways true, method called once the help frame has been successfully loaded */
  public boolean setEnabledHelpOffline(boolean bln) {
    String strMethod = "setEnabledHelpOffline(bln)";

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

    this._btnHelpSource_.setEnabled(bln);

    if (this._btnHelpTrack_ != null) {
      this._btnHelpTrack_.setEnabled(bln);
    }

    return true;
  }
  public boolean init() {
    String f_strMethod = "init()";
    // 0) context
    // getAccessibleContext().setAccessibleDescription("Notepad Text Alignment options: select one
    // of several different text alignments for the notepad");

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

    _addChildren();
    _disableChildrenAtInit();

    // ending
    return true;
  }
Пример #28
0
  public static void s_fill(Manifest man) {
    String strMethod = _f_s_strClass + "s_fill(man)";

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

    Attributes attAttributes = man.getMainAttributes();

    attAttributes.putValue(
        S_Manifest._f_s_strsDefaultEntryManifVersion[0],
        S_Manifest._f_s_strsDefaultEntryManifVersion[1]);

    attAttributes.putValue(
        S_Manifest._f_s_strsDefaultEntryManifCreator[0],
        S_Manifest._f_s_strsDefaultEntryManifCreator[1]);
  }
  private String _getDescFileShkCur() {
    String strMethod = "_getDescFileShkCur()";

    if (this._btnTypeFileShkPem != null) {
      if (this._btnTypeFileShkPem.isSelected()) {
        return this._btnTypeFileShkPem.getFileDesc();
      }
    }

    if (this._btnTypeFileShkDer.isSelected()) {
      return this._btnTypeFileShkDer.getFileDesc();
    }

    // ----
    // error
    MySystem.s_printOutError(this, strMethod, "failed");
    return null;
  }
Пример #30
0
  public CBIcon(ActionListener actListenerParent, ImageIcon iin, String strTip) {
    super(actListenerParent, strTip);

    String strMethod = "CBIcon(...)";

    if (iin == null) MySystem.s_printOutExit(this, strMethod, "nil iin");

    setIcon(iin);
    // FIXING UP BUG jdk1.3.0-final (not in jdk1.2.2 or in jdk1.3.0beta) ...
    setSelectedIcon(iin);
    setDisabledIcon(null);
    setDisabledSelectedIcon(null);
    // ... if disabled & selected, icon not shown as grayed

    setBorderPainted(true);

    setHorizontalAlignment(CENTER);
    setVerticalAlignment(CENTER);
  }