Search in sources :

Example 1 with VerifyApduCommand

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

the class SmartCafePkcs15Applet method verifyPin.

@Override
public void verifyPin(final PasswordCallback psc) throws ApduConnectionException, PinException {
    if (psc == null) {
        throw new IllegalArgumentException(// $NON-NLS-1$
        "No se puede verificar el titular con un PasswordCallback nulo");
    }
    VerifyApduCommand verifyCommandApdu = new VerifyApduCommand(psc);
    final ResponseApdu verifyResponse = getConnection().transmit(verifyCommandApdu);
    verifyCommandApdu = null;
    if (!verifyResponse.isOk()) {
        if (verifyResponse.getStatusWord().getMsb() == ERROR_PIN_SW1) {
            throw new BadPinException(verifyResponse.getStatusWord().getLsb() - (byte) 0xC0);
        } else if (verifyResponse.getStatusWord().getMsb() == (byte) 0x69 && verifyResponse.getStatusWord().getLsb() == (byte) 0x83) {
            throw new AuthenticationModeLockedException();
        } else {
            throw new ApduConnectionException(new Iso7816FourCardException(// $NON-NLS-1$ //$NON-NLS-2$
            "Error en la verificacion de PIN (" + verifyResponse.getStatusWord() + ")", verifyResponse.getStatusWord()));
        }
    }
}
Also used : AuthenticationModeLockedException(es.gob.jmulticard.card.AuthenticationModeLockedException) Iso7816FourCardException(es.gob.jmulticard.card.iso7816four.Iso7816FourCardException) BadPinException(es.gob.jmulticard.card.BadPinException) ResponseApdu(es.gob.jmulticard.apdu.ResponseApdu) VerifyApduCommand(es.gob.jmulticard.apdu.gide.VerifyApduCommand) ApduConnectionException(es.gob.jmulticard.apdu.connection.ApduConnectionException)

Aggregations

ResponseApdu (es.gob.jmulticard.apdu.ResponseApdu)1 ApduConnectionException (es.gob.jmulticard.apdu.connection.ApduConnectionException)1 VerifyApduCommand (es.gob.jmulticard.apdu.gide.VerifyApduCommand)1 AuthenticationModeLockedException (es.gob.jmulticard.card.AuthenticationModeLockedException)1 BadPinException (es.gob.jmulticard.card.BadPinException)1 Iso7816FourCardException (es.gob.jmulticard.card.iso7816four.Iso7816FourCardException)1