Search in sources :

Example 6 with AuthDataResponse

use of org.openecard.common.anytype.AuthDataResponse in project open-ecard by ecsec.

the class PINStepAction method performPACEWithCAN.

private EstablishChannelResponse performPACEWithCAN(Map<String, ExecutionResults> oldResults) {
    DIDAuthenticationDataType paceInput = new DIDAuthenticationDataType();
    paceInput.setProtocol(ECardConstants.Protocol.PACE);
    AuthDataMap tmp;
    try {
        tmp = new AuthDataMap(paceInput);
    } catch (ParserConfigurationException ex) {
        LOG.error("Failed to read empty Protocol data.", ex);
        return null;
    }
    AuthDataResponse paceInputMap = tmp.createResponse(paceInput);
    if (capturePin) {
        ExecutionResults executionResults = oldResults.get(getStepID());
        PasswordField canField = (PasswordField) executionResults.getResult(PINStep.CAN_FIELD);
        String canValue = new String(canField.getValue());
        if (canValue.length() != 6) {
            // let the user enter the can again, when input verification failed
            return null;
        } else {
            paceInputMap.addElement(PACEInputType.PIN, canValue);
        }
    }
    paceInputMap.addElement(PACEInputType.PIN_ID, PIN_ID_CAN);
    // perform PACE by EstablishChannelCommand
    EstablishChannel eChannel = createEstablishChannelStructure(paceInputMap);
    return (EstablishChannelResponse) dispatcher.safeDeliver(eChannel);
}
Also used : EstablishChannel(iso.std.iso_iec._24727.tech.schema.EstablishChannel) AuthDataMap(org.openecard.common.anytype.AuthDataMap) ExecutionResults(org.openecard.gui.executor.ExecutionResults) EstablishChannelResponse(iso.std.iso_iec._24727.tech.schema.EstablishChannelResponse) DIDAuthenticationDataType(iso.std.iso_iec._24727.tech.schema.DIDAuthenticationDataType) AuthDataResponse(org.openecard.common.anytype.AuthDataResponse) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) PasswordField(org.openecard.gui.definition.PasswordField)

Example 7 with AuthDataResponse

use of org.openecard.common.anytype.AuthDataResponse in project open-ecard by ecsec.

the class CANStepAction method perform.

@Override
public StepActionResult perform(Map<String, ExecutionResults> oldResults, StepResult result) {
    if (result.isBack()) {
        return new StepActionResult(StepActionResultStatus.BACK);
    }
    if (!state.equals(RecognizedState.PIN_suspended)) {
        return new StepActionResult(StepActionResultStatus.NEXT);
    }
    DIDAuthenticationDataType paceInput = new DIDAuthenticationDataType();
    paceInput.setProtocol(ECardConstants.Protocol.PACE);
    AuthDataMap tmp;
    try {
        tmp = new AuthDataMap(paceInput);
    } catch (ParserConfigurationException ex) {
        LOG.error("Failed to read empty Protocol data.", ex);
        return new StepActionResult(StepActionResultStatus.CANCEL);
    }
    AuthDataResponse paceInputMap = tmp.createResponse(paceInput);
    if (capturePin) {
        ExecutionResults executionResults = oldResults.get(getStepID());
        if (!verifyUserInput(executionResults)) {
            // let the user enter the can again, when input verification failed
            return new StepActionResult(StepActionResultStatus.REPEAT, createReplacementStep(false, true));
        } else {
            paceInputMap.addElement(PACEInputType.PIN, can);
        }
    }
    paceInputMap.addElement(PACEInputType.PIN_ID, PIN_ID_CAN);
    // perform PACE by EstablishChannelCommand
    EstablishChannel establishChannel = new EstablishChannel();
    establishChannel.setSlotHandle(conHandle.getSlotHandle());
    establishChannel.setAuthenticationProtocolData(paceInputMap.getResponse());
    establishChannel.getAuthenticationProtocolData().setProtocol(ECardConstants.Protocol.PACE);
    try {
        EstablishChannelResponse ecr = (EstablishChannelResponse) dispatcher.safeDeliver(establishChannel);
        WSHelper.checkResult(ecr);
        // pace was successfully performed, so get to the next step
        String title = lang.translationForKey(PINSTEP_TITLE);
        int retryCounter = 1;
        Step replacementStep = new ChangePINStep("pin-entry", title, capturePin, retryCounter, false, false);
        StepAction pinAction = new PINStepAction(capturePin, conHandle, dispatcher, replacementStep, retryCounter);
        replacementStep.setAction(pinAction);
        return new StepActionResult(StepActionResultStatus.NEXT, replacementStep);
    } catch (WSException ex) {
        LOG.info("Wrong CAN entered, trying again");
        return new StepActionResult(StepActionResultStatus.REPEAT, createReplacementStep(true, false));
    }
}
Also used : ExecutionResults(org.openecard.gui.executor.ExecutionResults) EstablishChannelResponse(iso.std.iso_iec._24727.tech.schema.EstablishChannelResponse) DIDAuthenticationDataType(iso.std.iso_iec._24727.tech.schema.DIDAuthenticationDataType) Step(org.openecard.gui.definition.Step) StepActionResult(org.openecard.gui.executor.StepActionResult) EstablishChannel(iso.std.iso_iec._24727.tech.schema.EstablishChannel) StepAction(org.openecard.gui.executor.StepAction) AuthDataMap(org.openecard.common.anytype.AuthDataMap) WSException(org.openecard.common.WSHelper.WSException) AuthDataResponse(org.openecard.common.anytype.AuthDataResponse) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException)

Example 8 with AuthDataResponse

use of org.openecard.common.anytype.AuthDataResponse in project open-ecard by ecsec.

the class GenericPINAction method performPACEWithPIN.

private EstablishChannelResponse performPACEWithPIN(Map<String, ExecutionResults> oldResults) throws ParserConfigurationException {
    DIDAuthenticationDataType paceInput = new DIDAuthenticationDataType();
    paceInput.setProtocol(ECardConstants.Protocol.PACE);
    AuthDataMap tmp = new AuthDataMap(paceInput);
    AuthDataResponse paceInputMap = tmp.createResponse(paceInput);
    if (capturePin) {
        ExecutionResults executionResults = oldResults.get(getStepID());
        PasswordField oldPINField = (PasswordField) executionResults.getResult(GenericPINStep.OLD_PIN_FIELD);
        char[] oldPINValue = oldPINField.getValue();
        if (oldPINValue.length > 6 && oldPINValue.length < 5) {
            // let the user enter the can again, when input verification failed
            return null;
        } else {
            paceInputMap.addElement(PACEInputType.PIN, new String(oldPINValue));
        }
    }
    paceInputMap.addElement(PACEInputType.PIN_ID, PIN_ID_PIN);
    // perform PACE by EstablishChannelCommand
    EstablishChannel eChannel = createEstablishChannelStructure(paceInputMap);
    return (EstablishChannelResponse) dispatcher.safeDeliver(eChannel);
}
Also used : EstablishChannel(iso.std.iso_iec._24727.tech.schema.EstablishChannel) AuthDataMap(org.openecard.common.anytype.AuthDataMap) ExecutionResults(org.openecard.gui.executor.ExecutionResults) EstablishChannelResponse(iso.std.iso_iec._24727.tech.schema.EstablishChannelResponse) DIDAuthenticationDataType(iso.std.iso_iec._24727.tech.schema.DIDAuthenticationDataType) AuthDataResponse(org.openecard.common.anytype.AuthDataResponse) PasswordField(org.openecard.gui.definition.PasswordField)

Example 9 with AuthDataResponse

use of org.openecard.common.anytype.AuthDataResponse in project open-ecard by ecsec.

the class PINStepAction method perform.

@Override
public StepActionResult perform(Map<String, ExecutionResults> oldResults, StepResult result) {
    if (result.isBack()) {
        return new StepActionResult(StepActionResultStatus.BACK);
    }
    DIDAuthenticationDataType paceInput = new DIDAuthenticationDataType();
    paceInput.setProtocol(ECardConstants.Protocol.PACE);
    AuthDataMap tmp;
    try {
        tmp = new AuthDataMap(paceInput);
    } catch (ParserConfigurationException ex) {
        LOG.error("Failed to read empty Protocol data.", ex);
        return new StepActionResult(StepActionResultStatus.CANCEL);
    }
    AuthDataResponse paceInputMap = tmp.createResponse(paceInput);
    if (capturePin) {
        ExecutionResults executionResults = oldResults.get(getStepID());
        if (!verifyUserInput(executionResults)) {
            // let the user enter the pin again, when input verification failed
            return new StepActionResult(StepActionResultStatus.REPEAT, createPINReplacementStep(false, true));
        } else {
            paceInputMap.addElement(PACEInputType.PIN, oldPIN);
        }
    }
    paceInputMap.addElement(PACEInputType.PIN_ID, PIN_ID_PIN);
    // perform PACE by EstablishChannel
    EstablishChannel establishChannel = new EstablishChannel();
    establishChannel.setSlotHandle(conHandle.getSlotHandle());
    establishChannel.setAuthenticationProtocolData(paceInputMap.getResponse());
    establishChannel.getAuthenticationProtocolData().setProtocol(ECardConstants.Protocol.PACE);
    try {
        EstablishChannelResponse establishChannelResponse = (EstablishChannelResponse) dispatcher.safeDeliver(establishChannel);
        WSHelper.checkResult(establishChannelResponse);
        // PACE completed successfully, we now modify the pin
        if (capturePin) {
            sendResetRetryCounter();
        } else {
            sendModifyPIN();
        }
        // PIN modified successfully, proceed with next step
        return new StepActionResult(StepActionResultStatus.NEXT);
    } catch (WSException ex) {
        if (capturePin) {
            retryCounter--;
            LOG.info("Wrong PIN entered, trying again (remaining tries {}).", retryCounter);
            if (retryCounter == 1) {
                Step replacementStep = createCANReplacementStep();
                return new StepActionResult(StepActionResultStatus.BACK, replacementStep);
            } else {
                Step replacementStep = createPINReplacementStep(true, false);
                return new StepActionResult(StepActionResultStatus.REPEAT, replacementStep);
            }
        } else {
            LOG.warn("PIN not entered successfully in terminal.");
            return new StepActionResult(StepActionResultStatus.CANCEL);
        }
    } catch (APDUException ex) {
        LOG.error("Failed to transmit Reset Retry Counter APDU.", ex);
        return new StepActionResult(StepActionResultStatus.CANCEL);
    } catch (IllegalArgumentException ex) {
        LOG.error("Failed to transmit Reset Retry Counter APDU.", ex);
        return new StepActionResult(StepActionResultStatus.CANCEL);
    } catch (IFDException ex) {
        LOG.error("Failed to transmit Reset Retry Counter APDU.", ex);
        return new StepActionResult(StepActionResultStatus.CANCEL);
    }
}
Also used : APDUException(org.openecard.common.apdu.exception.APDUException) ExecutionResults(org.openecard.gui.executor.ExecutionResults) EstablishChannelResponse(iso.std.iso_iec._24727.tech.schema.EstablishChannelResponse) DIDAuthenticationDataType(iso.std.iso_iec._24727.tech.schema.DIDAuthenticationDataType) Step(org.openecard.gui.definition.Step) StepActionResult(org.openecard.gui.executor.StepActionResult) EstablishChannel(iso.std.iso_iec._24727.tech.schema.EstablishChannel) AuthDataMap(org.openecard.common.anytype.AuthDataMap) WSException(org.openecard.common.WSHelper.WSException) AuthDataResponse(org.openecard.common.anytype.AuthDataResponse) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) IFDException(org.openecard.ifd.scio.IFDException)

Example 10 with AuthDataResponse

use of org.openecard.common.anytype.AuthDataResponse in project open-ecard by ecsec.

the class PUKStepAction method perform.

@Override
public StepActionResult perform(Map<String, ExecutionResults> oldResults, StepResult result) {
    if (result.isBack()) {
        return new StepActionResult(StepActionResultStatus.BACK);
    }
    DIDAuthenticationDataType paceInput = new DIDAuthenticationDataType();
    paceInput.setProtocol(ECardConstants.Protocol.PACE);
    AuthDataMap tmp;
    try {
        tmp = new AuthDataMap(paceInput);
    } catch (ParserConfigurationException ex) {
        LOG.error("Failed to read empty Protocol data.", ex);
        return new StepActionResult(StepActionResultStatus.CANCEL);
    }
    AuthDataResponse paceInputMap = tmp.createResponse(paceInput);
    if (capturePin) {
        ExecutionResults executionResults = oldResults.get(getStepID());
        if (!verifyUserInput(executionResults)) {
            // TODO inform user that something with his input is wrong
            return new StepActionResult(StepActionResultStatus.REPEAT);
        } else {
            paceInputMap.addElement(PACEInputType.PIN, puk);
        }
    }
    paceInputMap.addElement(PACEInputType.PIN_ID, PIN_ID_PUK);
    // perform PACE by sending an EstablishChannel
    EstablishChannel establishChannel = new EstablishChannel();
    establishChannel.setSlotHandle(slotHandle);
    establishChannel.setAuthenticationProtocolData(paceInputMap.getResponse());
    establishChannel.getAuthenticationProtocolData().setProtocol(ECardConstants.Protocol.PACE);
    try {
        EstablishChannelResponse establishChannelResponse = (EstablishChannelResponse) dispatcher.safeDeliver(establishChannel);
        WSHelper.checkResult(establishChannelResponse);
        // pace was successfully performed, so get to the next step
        return new StepActionResult(StepActionResultStatus.NEXT);
    } catch (WSException ex) {
        LOG.info("Wrong PUK entered, trying again");
        // TODO update the step to inform the user that he entered the puk wrong
        return new StepActionResult(StepActionResultStatus.REPEAT);
    } finally {
        DestroyChannel destroyChannel = new DestroyChannel();
        destroyChannel.setSlotHandle(slotHandle);
        dispatcher.safeDeliver(destroyChannel);
    }
}
Also used : EstablishChannel(iso.std.iso_iec._24727.tech.schema.EstablishChannel) DestroyChannel(iso.std.iso_iec._24727.tech.schema.DestroyChannel) AuthDataMap(org.openecard.common.anytype.AuthDataMap) ExecutionResults(org.openecard.gui.executor.ExecutionResults) EstablishChannelResponse(iso.std.iso_iec._24727.tech.schema.EstablishChannelResponse) DIDAuthenticationDataType(iso.std.iso_iec._24727.tech.schema.DIDAuthenticationDataType) WSException(org.openecard.common.WSHelper.WSException) AuthDataResponse(org.openecard.common.anytype.AuthDataResponse) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) StepActionResult(org.openecard.gui.executor.StepActionResult)

Aggregations

AuthDataResponse (org.openecard.common.anytype.AuthDataResponse)11 DIDAuthenticationDataType (iso.std.iso_iec._24727.tech.schema.DIDAuthenticationDataType)8 EstablishChannel (iso.std.iso_iec._24727.tech.schema.EstablishChannel)8 EstablishChannelResponse (iso.std.iso_iec._24727.tech.schema.EstablishChannelResponse)8 AuthDataMap (org.openecard.common.anytype.AuthDataMap)8 ExecutionResults (org.openecard.gui.executor.ExecutionResults)8 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)5 PasswordField (org.openecard.gui.definition.PasswordField)5 WSException (org.openecard.common.WSHelper.WSException)3 StepActionResult (org.openecard.gui.executor.StepActionResult)3 Step (org.openecard.gui.definition.Step)2 DestroyChannel (iso.std.iso_iec._24727.tech.schema.DestroyChannel)1 APDUException (org.openecard.common.apdu.exception.APDUException)1 StepAction (org.openecard.gui.executor.StepAction)1 IFDException (org.openecard.ifd.scio.IFDException)1