loginIntoSector(access);
for (int currentBlock = 0; currentBlock < mfBlock.length; currentBlock++) {
int blockNumber = memoryLayout.getBlockNumber(access.getSector(), access.getBlock()) + currentBlock;
if (memoryLayout.isTrailerBlock(access.getSector(), access.getBlock() + currentBlock)) {
if (!(mfBlock[currentBlock] instanceof TrailerBlock))
throw new MfException("invalid block for trailer");
}
Command writeBlock = new Command(Apdu.INS_UPDATE_BINARY, 0x00, blockNumber, mfBlock[currentBlock].getData());
Response writeBlockResponse;
writeBlockResponse = apduTag.transmit(writeBlock);
if (!writeBlockResponse.isSuccess()) {
throw new MfException("Writing block failed. Sector: " + access.getSector() + ", Block: "
+ access.getBlock() + " Key: " + access.getKeyValue().getKey().name() + ", Response: "
+ writeBlockResponse);
}
}
}