/**
   * Determines password tries left.
   *
   * @return array of integers with number of password tries left - array[0] = PIN1; array[1] =
   *     PUK1; array[2] = PIN2; array[3] = PUK2.
   */
  public int[] numberOfPasswordTriesLeftArray() {
    int[] numberOfPasswordTriesLeft = new int[4];
    byte[] response = null;

    try {
      response = worker.getResponse(worker.select(DatabaseOfEF.MF.getFID()));

      for (int i = 0; i < 4; i++) {
        String binaryForm;
        int j = response[18 + i]; // position of PIN1/PUK1/PIN2/PUK2
        binaryForm = Integer.toBinaryString(j).substring(24);
        numberOfPasswordTriesLeft[i] = Integer.parseInt(binaryForm.substring(4), 2);
      }
    } catch (Exception ex) {
      Logger.getLogger(CardManager.class.getName()).log(Level.SEVERE, null, ex);
    }

    return numberOfPasswordTriesLeft;
  }
  /**
   * Determines if passwords are initialized. If password is initialized, returns true.
   *
   * @return array of booleans - array[0] = PIN1; array[1] = PUK1; array[2] = PIN2; array[3] = PUK2.
   *     If password is initialized, it has value true.
   */
  public boolean[] arePasswordsInitialised() {
    boolean[] arePasswordsInitialised = new boolean[4];
    byte[] response = null;

    try {
      response = worker.getResponse(worker.select(DatabaseOfEF.MF.getFID()));

      for (int i = 0; i < 4; i++) {
        String binaryForm;
        int j = response[18 + i]; // position of PIN1/PUK1/PIN2/PUK2
        binaryForm = Integer.toBinaryString(j).substring(24);
        if (binaryForm.charAt(0) == '0') {
          arePasswordsInitialised[i] = false;
        } else {
          arePasswordsInitialised[i] = true;
        }
      }
    } catch (Exception ex) {
      Logger.getLogger(CardManager.class.getName()).log(Level.SEVERE, null, ex);
    }

    return arePasswordsInitialised;
  }