Java Card Application Development

By Darryl Barnes

Dr. Dobb's Journal February 1999

public void process(APDU _apdu)
{
    // get reference to apdu buffer
      byte[] baBuffer = _apdu.getBuffer();
    // verify class
      if(baBuffer[ISO.OFFSET_CLA] != CLA_LOYALTY)
            ISOException.throwIt(ISO.SW_CLA_NOT_SUPPORTED);
    // branch to each instruction
      switch(baBuffer[ISO.OFFSET_INS])
      {
          case INS_VALIDATE_PIN:
              this.validatePIN(_apdu);
              break;
          case INS_DEBIT:
              this.debit(_apdu);
              break;
          case INS_CREDIT:
              this.credit(_apdu);
              break;
          case INS_GETBALANCE:
              this.getBalance(_apdu);
              break;
        }
}

Example 3: The process() method.

Back to Article


Copyright © 1999, Dr. Dobb's Journal