Example #1
0
  public static void readCard(IsoDep tech, Card card)
      throws InstantiationException, IllegalAccessException, IOException {

    final Iso7816.StdTag tag = new Iso7816.StdTag(tech);

    tag.connect();

    for (final Class<?> g[] : readers) {
      HINT hint = HINT.RESETANDGONEXT;

      for (final Class<?> r : g) {

        final StandardPboc reader = (StandardPboc) r.newInstance();

        switch (hint) {
          case RESETANDGONEXT:
            if (!reader.resetTag(tag)) continue;

          case GONEXT:
            hint = reader.readCard(tag, card);
            break;

          default:
            break;
        }

        if (hint == HINT.STOP) break;
      }
    }

    tag.close();
  }
Example #2
0
  protected ArrayList<byte[]> readLog24(Iso7816.StdTag tag, int sfi) throws IOException {
    final ArrayList<byte[]> ret = new ArrayList<byte[]>(MAX_LOG);
    final Iso7816.Response rsp = tag.readRecord(sfi);
    if (rsp.isOkey()) {
      addLog24(rsp, ret);
    } else {
      for (int i = 1; i <= MAX_LOG; ++i) {
        if (!addLog24(tag.readRecord(sfi, i), ret)) break;
      }
    }

    return ret;
  }
Example #3
0
  protected HINT readCard(Iso7816.StdTag tag, Card card) throws IOException {

    /*--------------------------------------------------------------*/
    // select Main Application
    /*--------------------------------------------------------------*/
    if (!selectMainApplication(tag)) return HINT.GONEXT;

    Iso7816.Response INFO, BALANCE;

    /*--------------------------------------------------------------*/
    // read card info file, binary (21)
    /*--------------------------------------------------------------*/
    INFO = tag.readBinary(SFI_EXTRA);

    /*--------------------------------------------------------------*/
    // read balance
    /*--------------------------------------------------------------*/
    BALANCE = tag.getBalance(0, true);

    /*--------------------------------------------------------------*/
    // read log file, record (24)
    /*--------------------------------------------------------------*/
    ArrayList<byte[]> LOG = readLog24(tag, SFI_LOG);

    /*--------------------------------------------------------------*/
    // build result
    /*--------------------------------------------------------------*/
    final Application app = createApplication();

    parseBalance(app, BALANCE);

    parseInfo21(app, INFO, 4, true);

    parseLog24(app, LOG);

    configApplication(app);

    card.addApplication(app);

    return HINT.STOP;
  }
Example #4
0
 protected boolean resetTag(Iso7816.StdTag tag) throws IOException {
   return tag.selectByID(DFI_MF).isOkey() || tag.selectByName(DFN_PSE).isOkey();
 }
Example #5
0
 protected boolean selectMainApplication(Iso7816.StdTag tag) throws IOException {
   final byte[] aid = getMainApplicationId();
   return ((aid.length == 2) ? tag.selectByID(aid) : tag.selectByName(aid)).isOkey();
 }