int blockNumber = mfAccess.getCard().getBlockNumber(mfAccess.getSector(), mfAccess.getBlock())
+ currentBlock;
if (mfAccess.getCard().isTrailerBlock(mfAccess.getSector(), mfAccess.getBlock() + currentBlock)) {
if (!(mfBlock[currentBlock] instanceof TrailerBlock))
throw new MfException("invalid block for trailer");
}
CommandAPDU writeBlock = new CommandAPDU(Apdu.CLS_PTS, Apdu.INS_UPDATE_BINARY, 0x00, blockNumber,
mfBlock[currentBlock].getData());
ResponseAPDU writeBlockResponse;
try {
writeBlockResponse = cardChannel.transmit(writeBlock);
if (!ApduUtils.isSuccess(writeBlockResponse)) {
throw new MfException("Writing block failed. Sector: " + mfAccess.getSector() + ", Block: "
+ mfAccess.getBlock() + " Key: " + mfAccess.getKey().name() + ", Response: "
+ writeBlockResponse);
}
}