Exemplo n.º 1
0
  private void btnFirmarMouseClicked(
      java.awt.event.MouseEvent evt) { // GEN-FIRST:event_btnFirmarMouseClicked

    btnFirmar.setEnabled(false);
    this.setCursor(Cursor.WAIT_CURSOR);
    try {
      if (cbxCardReaders.getSelectedIndex() != 0) {
        EncryptedData encryptedData = new EncryptedData();
        int slotIndex = (cbxCardReaders.getSelectedIndex() - 1);
        byte[] textoaFirmar = tbTextoAFirmar.getText().getBytes("UTF-8");
        if (!m_Controller.Firmar(
            slotIndex, new String(tbPassword.getPassword()), textoaFirmar, encryptedData)) {
          String msg = "PIN Incorrecto";
          statusStrip1.setText(msg);
        } else {
          tbTextFirmado.setText(encryptedData.ToString());
          statusStrip1.setText("Texto Firmado Correctamente");
        }
      } else {
        String msg = "Debe Seleccionar un Card Reader";
        statusStrip1.setText(msg);
      }
    } catch (Exception ex) {
      System.out.println(ex);
      statusStrip1.setText("Ha ocurrido un error: " + ex.getMessage());
    } finally {
      btnFirmar.setEnabled(true);
      this.setCursor(Cursor.DEFAULT_CURSOR);
    }
  } // GEN-LAST:event_btnFirmarMouseClicked