Search in sources :

Example 6 with StatusWord

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

the class Iso7816FourCard method selectFileByName.

/**
 * Selecciona un fichero por nombre.
 * @param name Nombre del fichero en hexadecimal
 * @throws FileNotFoundException Si el fichero no existe
 * @throws ApduConnectionException Si ocurre algún problema durante la selección
 * @throws Iso7816FourCardException Si el fichero no se puede seleccionar por cualquier otra causa
 */
public void selectFileByName(final byte[] name) throws ApduConnectionException, FileNotFoundException, Iso7816FourCardException {
    final CommandApdu selectCommand = new SelectDfByNameApduCommand(getCla(), name);
    final ResponseApdu response = sendArbitraryApdu(selectCommand);
    if (response.isOk()) {
        return;
    }
    final StatusWord sw = response.getStatusWord();
    if (sw.equals(new StatusWord((byte) 0x6A, (byte) 0x82))) {
        throw new FileNotFoundException(name);
    }
    throw new Iso7816FourCardException(sw, selectCommand);
}
Also used : SelectDfByNameApduCommand(es.gob.jmulticard.apdu.iso7816four.SelectDfByNameApduCommand) CommandApdu(es.gob.jmulticard.apdu.CommandApdu) StatusWord(es.gob.jmulticard.apdu.StatusWord) ResponseApdu(es.gob.jmulticard.apdu.ResponseApdu)

Example 7 with StatusWord

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

the class TestStatusWord method testEqualsObject.

/**
 * Prueba el funcionamiento de equals
 */
public static final void testEqualsObject() {
    final StatusWord sw1 = new StatusWord((byte) 0x90, (byte) 0x00);
    final StatusWord sw2 = new StatusWord((byte) 0x90, (byte) 0x00);
    Assert.assertTrue(sw1.equals(sw2));
    Assert.assertFalse(sw1.equals(new StatusWord((byte) 0x60, (byte) 0x84)));
    Assert.assertFalse(sw1.equals(String.valueOf(true)));
}
Also used : StatusWord(es.gob.jmulticard.apdu.StatusWord)

Example 8 with StatusWord

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

the class TestStatusWord method testHashCode.

/**
 * Prueba el funcionamiento de hashCode
 */
public static final void testHashCode() {
    final StatusWord sw = new StatusWord((byte) 0x90, (byte) 0x00);
    Assert.assertEquals(HexUtils.getShort(new byte[] { (byte) 0x90, (byte) 0x00 }, 0), sw.hashCode());
}
Also used : StatusWord(es.gob.jmulticard.apdu.StatusWord)

Aggregations

StatusWord (es.gob.jmulticard.apdu.StatusWord)8 CommandApdu (es.gob.jmulticard.apdu.CommandApdu)5 ResponseApdu (es.gob.jmulticard.apdu.ResponseApdu)5 SelectFileApduResponse (es.gob.jmulticard.apdu.iso7816four.SelectFileApduResponse)2 SelectFileByIdApduCommand (es.gob.jmulticard.apdu.iso7816four.SelectFileByIdApduCommand)2 Iso7816FourCardException (es.gob.jmulticard.card.iso7816four.Iso7816FourCardException)2 CeresVerifyApduCommand (es.gob.jmulticard.apdu.ceres.CeresVerifyApduCommand)1 ApduConnectionException (es.gob.jmulticard.apdu.connection.ApduConnectionException)1 ReadRecordApduCommand (es.gob.jmulticard.apdu.iso7816four.ReadRecordApduCommand)1 SelectDfByNameApduCommand (es.gob.jmulticard.apdu.iso7816four.SelectDfByNameApduCommand)1 AuthenticationModeLockedException (es.gob.jmulticard.card.AuthenticationModeLockedException)1 BadPinException (es.gob.jmulticard.card.BadPinException)1 PinException (es.gob.jmulticard.card.PinException)1 FileNotFoundException (es.gob.jmulticard.card.iso7816four.FileNotFoundException)1 ArrayList (java.util.ArrayList)1