Search in sources :

Example 6 with ExecutionResults

use of org.openecard.gui.executor.ExecutionResults in project open-ecard by ecsec.

the class PINStepAction method performPACEWithPIN.

private EstablishChannelResponse performPACEWithPIN(Map<String, ExecutionResults> oldResults) {
    DIDAuthenticationDataType protoData = eacData.didRequest.getAuthenticationProtocolData();
    AuthDataMap paceAuthMap;
    try {
        paceAuthMap = new AuthDataMap(protoData);
    } catch (ParserConfigurationException ex) {
        LOG.error("Failed to read EAC Protocol data.", ex);
        return null;
    }
    AuthDataResponse paceInputMap = paceAuthMap.createResponse(protoData);
    if (capturePin) {
        ExecutionResults executionResults = oldResults.get(getStepID());
        PasswordField p = (PasswordField) executionResults.getResult(PINStep.PIN_FIELD);
        char[] pinIn = p.getValue();
        // TODO: check pin length and possibly allowed charset with CardInfo file
        if (pinIn.length == 0) {
            return null;
        } else {
            // NOTE: saving pin as string prevents later removal of the value from memory !!!
            paceInputMap.addElement(PACEInputType.PIN, new String(pinIn));
        }
    }
    // perform PACE
    paceInputMap.addElement(PACEInputType.PIN_ID, PasswordID.parse(eacData.pinID).getByteAsString());
    paceInputMap.addElement(PACEInputType.CHAT, eacData.selectedCHAT.toString());
    String certDesc = ByteUtils.toHexString(eacData.rawCertificateDescription);
    paceInputMap.addElement(PACEInputType.CERTIFICATE_DESCRIPTION, certDesc);
    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 ExecutionResults

use of org.openecard.gui.executor.ExecutionResults in project open-ecard by ecsec.

the class EacGuiImplTest method createInitialSteps.

private List<Step> createInitialSteps() {
    Step step1 = new Step("PROTOCOL_EAC_GUI_STEP_CVC", "CVC");
    ToggleText sub = new ToggleText();
    sub.setID("SubjectName");
    sub.setText("Test Subject");
    step1.getInputInfoUnits().add(sub);
    final Step step2 = new Step("PROTOCOL_EAC_GUI_STEP_CHAT", "CHAT");
    Checkbox readBox = new Checkbox("ReadCHATCheckBoxes");
    readBox.getBoxItems().add(makeBoxItem("DG04", false, false));
    readBox.getBoxItems().add(makeBoxItem("RESTRICTED_IDENTIFICATION", true, true));
    step2.getInputInfoUnits().add(readBox);
    step1.setAction(new StepAction(step1) {

        @Override
        public StepActionResult perform(Map<String, ExecutionResults> oldResults, StepResult result) {
            return new StepActionResult(StepActionResultStatus.NEXT, step2);
        }
    });
    final Step step3 = new PINStep(eacData, true, paceMarker, EacPinStatus.RC3);
    step2.setAction(new StepAction(step2) {

        @Override
        public StepActionResult perform(Map<String, ExecutionResults> oldResults, StepResult result) {
            return new StepActionResult(StepActionResultStatus.NEXT, step3);
        }
    });
    final Step step4 = new Step("PROTOCOL_GUI_STEP_PROCESSING", "Finished");
    return Arrays.asList(step1, step2, step3, step4);
}
Also used : ToggleText(org.openecard.gui.definition.ToggleText) StepAction(org.openecard.gui.executor.StepAction) Checkbox(org.openecard.gui.definition.Checkbox) ExecutionResults(org.openecard.gui.executor.ExecutionResults) PINStep(org.openecard.sal.protocol.eac.gui.PINStep) PINStep(org.openecard.sal.protocol.eac.gui.PINStep) Step(org.openecard.gui.definition.Step) StepResult(org.openecard.gui.StepResult) StepActionResult(org.openecard.gui.executor.StepActionResult)

Example 8 with ExecutionResults

use of org.openecard.gui.executor.ExecutionResults 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 9 with ExecutionResults

use of org.openecard.gui.executor.ExecutionResults 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 10 with ExecutionResults

use of org.openecard.gui.executor.ExecutionResults 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)

Aggregations

ExecutionResults (org.openecard.gui.executor.ExecutionResults)13 EstablishChannelResponse (iso.std.iso_iec._24727.tech.schema.EstablishChannelResponse)9 DIDAuthenticationDataType (iso.std.iso_iec._24727.tech.schema.DIDAuthenticationDataType)8 EstablishChannel (iso.std.iso_iec._24727.tech.schema.EstablishChannel)8 AuthDataMap (org.openecard.common.anytype.AuthDataMap)8 AuthDataResponse (org.openecard.common.anytype.AuthDataResponse)8 PasswordField (org.openecard.gui.definition.PasswordField)7 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)6 StepActionResult (org.openecard.gui.executor.StepActionResult)6 WSException (org.openecard.common.WSHelper.WSException)3 Step (org.openecard.gui.definition.Step)3 DestroyChannel (iso.std.iso_iec._24727.tech.schema.DestroyChannel)2 APDUException (org.openecard.common.apdu.exception.APDUException)2 BoxItem (org.openecard.gui.definition.BoxItem)2 Checkbox (org.openecard.gui.definition.Checkbox)2 StepAction (org.openecard.gui.executor.StepAction)2 IFDException (org.openecard.ifd.scio.IFDException)2 CardApplicationDisconnect (iso.std.iso_iec._24727.tech.schema.CardApplicationDisconnect)1 ControlIFDResponse (iso.std.iso_iec._24727.tech.schema.ControlIFDResponse)1 Disconnect (iso.std.iso_iec._24727.tech.schema.Disconnect)1