Search in sources :

Example 1 with ReadRecordApduCommand

use of es.gob.jmulticard.apdu.iso7816four.ReadRecordApduCommand in project jmulticard by ctt-gob-es.

the class Iso7816FourCard method readAllRecords.

/**
 * Lee todos los registros del binario actualmente seleccionado.
 * @return Lista de registros leidos del binario actualmente seleccionado.
 * @throws ApduConnectionException Si hay problemas en el envío de la APDU.
 * @throws Iso7816FourCardException SI ocurren problemas durante la lectura de los registros.
 */
public List<byte[]> readAllRecords() throws ApduConnectionException, Iso7816FourCardException {
    final List<byte[]> ret = new ArrayList<>();
    StatusWord readedResponseSw;
    final CommandApdu readRecordApduCommand = new ReadRecordApduCommand(getCla());
    do {
        final ResponseApdu readedResponse = sendArbitraryApdu(readRecordApduCommand);
        readedResponseSw = readedResponse.getStatusWord();
        if (!readedResponse.isOk() && !ReadRecordApduCommand.RECORD_NOT_FOUND.equals(readedResponseSw)) {
            throw new Iso7816FourCardException(// $NON-NLS-1$
            "Error en la lectura de registro", // $NON-NLS-1$
            readedResponseSw);
        }
        ret.add(readedResponse.getData());
    } while (!ReadRecordApduCommand.RECORD_NOT_FOUND.equals(readedResponseSw));
    return ret;
}
Also used : CommandApdu(es.gob.jmulticard.apdu.CommandApdu) ReadRecordApduCommand(es.gob.jmulticard.apdu.iso7816four.ReadRecordApduCommand) StatusWord(es.gob.jmulticard.apdu.StatusWord) ArrayList(java.util.ArrayList) ResponseApdu(es.gob.jmulticard.apdu.ResponseApdu)

Aggregations

CommandApdu (es.gob.jmulticard.apdu.CommandApdu)1 ResponseApdu (es.gob.jmulticard.apdu.ResponseApdu)1 StatusWord (es.gob.jmulticard.apdu.StatusWord)1 ReadRecordApduCommand (es.gob.jmulticard.apdu.iso7816four.ReadRecordApduCommand)1 ArrayList (java.util.ArrayList)1