Esempio n. 1
0
 /**
  * Sets the user's answer and notifies waitForAnswer and ends the form.
  *
  * @param theAnswer user's answer or CANCEL if system cancelled the screen
  */
 private void setAnswer(int theAnswer) {
   synchronized (this) {
     answer = theAnswer;
     displayEventHandler.donePreempting(preemptToken);
     notify();
   }
 }
Esempio n. 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);
  }