Java Reference
In-Depth Information
L ISTING 5.5 Continued
* @param length the length in bytes of the parameter data in byteArray
*/
public static void install(byte[] byteArray, short offset, byte length) {
new CardTest();
}
/**
* Implementation of the standard method for processing an incoming APDU.
* @param apdu the incoming APDU
* @exception ISOException with ISO 7816-4 response bytes
*/
public void process(APDU apdu) {
byte buffer[] = apdu.getBuffer();
if (buffer[ISO7816.OFFSET_CLA] == THIS_CLA) {
switch (buffer[ISO7816.OFFSET_INS])
{
case INITIALIZE_TRANSACTION:
writeBack(apdu, INIT_SEQUENCE);
break;
case COMPLETE_TRANSACTION:
writeBack(apdu, COMPLETE_SEQUENCE);
break;
case INITIALIZE_UPDATE:
writeBack(apdu, INIT_UPDATE_SEQUENCE);
break;
case COMPLETE_UPDATE:
writeBack(apdu, COMPLETE_UPDATE_SEQUENCE);
break;
default:
ISOException.throwIt(ISO7816.SW_INS_NOT_SUPPORTED);
}
}
}
/**
* An example method that writes back a given byte array through the apdu.
*/
protected void writeBack(APDU apdu, byte[] bytes) {
byte buffer[] = apdu.getBuffer();
5
// set apdu for data output
apdu.setOutgoing();
Search WWH ::




Custom Search