Example #1
0
  /**
   * Verifies that the values entered are acceptable.
   *
   * @return true if the values entered are acceptable.
   */
  private boolean checkInput() {

    if (tf1.getString().trim().equals("")) {
      return false;
    }

    data1 = pin1.transform(tf1.getString());
    if (data1 == null) {
      // PIN can't be formatted, pass empty PIN to update counter
      data1 = new byte[8];
    }

    if (pin2 != null) {
      data2 = pin2.transform(tf2.getString());
      if (data2 == null) {
        tf2.setString("");
        return false;
      }
    } else {
      data2 = null;
    }
    return true;
  }
Example #2
0
  /**
   * Construct PIN dialog.
   *
   * @param token security token with the permission to peempt the foreground display
   * @param action PIN entry operation identifier.
   * @param attr1 1st PIN attributes.
   * @param attr2 2nd PIN attributes.
   * @exception InterruptedException if another thread interrupts the calling thread while this
   *     method is waiting to preempt the display.
   */
  public PINEntryDialog(SecurityToken token, int action, PINAttributes attr1, PINAttributes attr2)
      throws InterruptedException {

    String title = null;

    String label1 = attr1.label;
    String label2 = null;
    pin1 = attr1;
    pin2 = null;

    switch (action) {
      case ACLPermissions.CMD_VERIFY:
        {
          // "PIN verification"
          title = Resource.getString(ResourceConstants.JSR177_PINDIALOG_TITLE_VERIFY);
          break;
        }
      case ACLPermissions.CMD_CHANGE:
        {
          // "Change PIN"
          title = Resource.getString(ResourceConstants.JSR177_PINDIALOG_TITLE_CHANGE);
          // "New value" -> "Enter new PIN"
          label2 = Resource.getString(ResourceConstants.JSR177_PINDIALOG_ENTERPIN);
          pin2 = attr1;
          break;
        }
      case ACLPermissions.CMD_DISABLE:
        {
          // "Disable PIN"
          title = Resource.getString(ResourceConstants.JSR177_PINDIALOG_TITLE_DISABLE);
          break;
        }
      case ACLPermissions.CMD_ENABLE:
        {
          // "Enable PIN";
          title = Resource.getString(ResourceConstants.JSR177_PINDIALOG_TITLE_ENABLE);
          break;
        }
      case ACLPermissions.CMD_UNBLOCK:
        {
          // "Unblock PIN"
          title = Resource.getString(ResourceConstants.JSR177_PINDIALOG_TITLE_UNBLOCK);
          label1 = attr2.label;
          label2 =
              attr1.label
                  + " - "
                  +
                  // "new value"
                  Resource.getString(ResourceConstants.JSR177_PINDIALOG_NEWVALUE);
          pin1 = attr2;
          pin2 = attr1;
          break;
        }
    }

    Form form = new Form(title);

    int flags = TextField.PASSWORD;
    if (pin1.isNumeric()) {
      flags |= TextField.NUMERIC;
    }
    tf1 = new TextField(label1, "", pin1.getMaxLength(), flags);
    form.append(tf1);

    if (pin2 != null) {

      flags = TextField.SENSITIVE | TextField.NON_PREDICTIVE;
      if (pin2.isNumeric()) {
        flags |= TextField.NUMERIC;
      }
      tf2 = new TextField(label2, "", pin2.getMaxLength(), flags);
      form.append(tf2);
    }

    form.addCommand(cancelCmd);
    form.addCommand(okCmd);
    form.setCommandListener(this);
    if (displayEventHandler == null) {
      displayEventHandler = DisplayEventHandlerFactory.getDisplayEventHandler(token);
    }
    preemptToken = displayEventHandler.preemptDisplay(form, true);
  }