Search in sources :

Example 1 with CeresVerifyApduCommand

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

the class Ceres method verifyPin.

@Override
public void verifyPin(final PasswordCallback pinPc) throws ApduConnectionException, PinException {
    if (pinPc == null) {
        // $NON-NLS-1$
        throw new PinException("No se ha establecido un PasswordCallback");
    }
    final CommandApdu chv = new CeresVerifyApduCommand(CLA, pinPc);
    final ResponseApdu verifyResponse = sendArbitraryApdu(chv);
    if (!verifyResponse.isOk()) {
        if (verifyResponse.getStatusWord().getMsb() == ERROR_PIN_SW1 || verifyResponse.getStatusWord().getMsb() == ERROR_PIN_SW2) {
            if (AUTO_RETRY) {
                this.passwordCallback = null;
                verifyPin(getInternalPasswordCallback());
                return;
            }
            throw new BadPinException(verifyResponse.getStatusWord().getLsb() - (byte) 0xC0);
        } else if (new StatusWord((byte) 0x69, (byte) 0x83).equals(verifyResponse.getStatusWord())) {
            throw new AuthenticationModeLockedException();
        }
        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) CommandApdu(es.gob.jmulticard.apdu.CommandApdu) CeresVerifyApduCommand(es.gob.jmulticard.apdu.ceres.CeresVerifyApduCommand) BadPinException(es.gob.jmulticard.card.BadPinException) StatusWord(es.gob.jmulticard.apdu.StatusWord) ResponseApdu(es.gob.jmulticard.apdu.ResponseApdu) BadPinException(es.gob.jmulticard.card.BadPinException) PinException(es.gob.jmulticard.card.PinException) ApduConnectionException(es.gob.jmulticard.apdu.connection.ApduConnectionException)

Aggregations

CommandApdu (es.gob.jmulticard.apdu.CommandApdu)1 ResponseApdu (es.gob.jmulticard.apdu.ResponseApdu)1 StatusWord (es.gob.jmulticard.apdu.StatusWord)1 CeresVerifyApduCommand (es.gob.jmulticard.apdu.ceres.CeresVerifyApduCommand)1 ApduConnectionException (es.gob.jmulticard.apdu.connection.ApduConnectionException)1 AuthenticationModeLockedException (es.gob.jmulticard.card.AuthenticationModeLockedException)1 BadPinException (es.gob.jmulticard.card.BadPinException)1 PinException (es.gob.jmulticard.card.PinException)1 Iso7816FourCardException (es.gob.jmulticard.card.iso7816four.Iso7816FourCardException)1