Search in sources :

Example 6 with StepAction

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

the class UnblockPINDialog method createPUKStep.

/**
 * Create the step that asks the user to insert the PUK.
 *
 * @return Step for PUK entry
 */
private Step createPUKStep() {
    Step pukStep = new Step("insert-card", lang.translationForKey(PUKSTEP_TITLE));
    Text i1 = new Text();
    pukStep.getInputInfoUnits().add(i1);
    if (!capturePin) {
        pukStep.setInstantReturn(true);
        i1.setText(lang.translationForKey(PUKSTEP_NATIVE_DESCRIPTION));
    } else {
        i1.setText(lang.translationForKey(PUKSTEP_DESCRIPTION));
        PasswordField pukField = new PasswordField(PUK_FIELD);
        pukField.setDescription(lang.translationForKey(PUKSTEP_PUK));
        pukStep.getInputInfoUnits().add(pukField);
    }
    StepAction pinAction = new PUKStepAction(capturePin, conHandle.getSlotHandle(), dispatcher, pukStep);
    pukStep.setAction(pinAction);
    return pukStep;
}
Also used : StepAction(org.openecard.gui.executor.StepAction) Text(org.openecard.gui.definition.Text) Step(org.openecard.gui.definition.Step) PasswordField(org.openecard.gui.definition.PasswordField)

Example 7 with StepAction

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

the class CVCStepAction method perform.

@Override
public StepActionResult perform(Map<String, ExecutionResults> oldResults, StepResult result) {
    if (result.isBack()) {
        // no going back to the initialization step
        return new StepActionResult(StepActionResultStatus.REPEAT);
    }
    DynamicContext ctx = DynamicContext.getInstance(TR03112Keys.INSTANCE_KEY);
    EACData eacData = (EACData) ctx.get(EACProtocol.EAC_DATA);
    CHATStep chatStep = new CHATStep(eacData);
    chatStep.setBackgroundTask(bTask);
    StepAction chatAction = new CHATStepAction(eacData, chatStep);
    chatStep.setAction(chatAction);
    return new StepActionResult(StepActionResultStatus.NEXT, chatStep);
}
Also used : StepAction(org.openecard.gui.executor.StepAction) EACData(org.openecard.sal.protocol.eac.EACData) StepActionResult(org.openecard.gui.executor.StepActionResult) DynamicContext(org.openecard.common.DynamicContext)

Example 8 with StepAction

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

the class CHATStepAction method perform.

@Override
public StepActionResult perform(Map<String, ExecutionResults> oldResults, StepResult result) {
    if (result.isOK()) {
        processResult(oldResults);
        DynamicContext ctx = DynamicContext.getInstance(TR03112Keys.INSTANCE_KEY);
        boolean nativePace = (boolean) ctx.get(EACProtocol.IS_NATIVE_PACE);
        PACEMarkerType paceMarker = (PACEMarkerType) ctx.get(EACProtocol.PACE_MARKER);
        EacPinStatus status = (EacPinStatus) ctx.get(EACProtocol.PIN_STATUS);
        byte[] slotHandle = (byte[]) ctx.get(EACProtocol.SLOT_HANDLE);
        Dispatcher dispatcher = (Dispatcher) ctx.get(EACProtocol.DISPATCHER);
        Step pinStep;
        assert (status != null);
        switch(status) {
            case BLOCKED:
                ctx.put(EACProtocol.PIN_BLOCKED_STATUS, status);
                pinStep = new ErrorStep(LANG.translationForKey("step_error_title_blocked", PIN), LANG.translationForKey("step_error_pin_blocked", PIN, PIN, PUK, PIN), WSHelper.createException(WSHelper.makeResultError(ECardConstants.Minor.IFD.PASSWORD_BLOCKED, "Password blocked.")));
                break;
            case DEACTIVATED:
                ctx.put(EACProtocol.PIN_BLOCKED_STATUS, status);
                pinStep = new ErrorStep(LANG.translationForKey("step_error_title_deactivated"), LANG.translationForKey("step_error_pin_deactivated"), WSHelper.createException(WSHelper.makeResultError(ECardConstants.Minor.IFD.PASSWORD_SUSPENDED, "Card deactivated.")));
                break;
            default:
                pinStep = new PINStep(eacData, !nativePace, paceMarker, status);
                pinStep.setBackgroundTask(bTask);
                StepAction pinAction = new PINStepAction(eacData, !nativePace, slotHandle, dispatcher, (PINStep) pinStep, status);
                pinStep.setAction(pinAction);
        }
        return new StepActionResult(StepActionResultStatus.NEXT, pinStep);
    } else {
        // cancel can not happen, so only back is left to be handled
        return new StepActionResult(StepActionResultStatus.BACK);
    }
}
Also used : PACEMarkerType(org.openecard.sal.protocol.eac.anytype.PACEMarkerType) StepAction(org.openecard.gui.executor.StepAction) Step(org.openecard.gui.definition.Step) Dispatcher(org.openecard.common.interfaces.Dispatcher) StepActionResult(org.openecard.gui.executor.StepActionResult) DynamicContext(org.openecard.common.DynamicContext)

Example 9 with StepAction

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

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

Aggregations

StepAction (org.openecard.gui.executor.StepAction)10 Step (org.openecard.gui.definition.Step)6 StepActionResult (org.openecard.gui.executor.StepActionResult)4 DynamicContext (org.openecard.common.DynamicContext)2 ExecutionResults (org.openecard.gui.executor.ExecutionResults)2 DIDAuthenticationDataType (iso.std.iso_iec._24727.tech.schema.DIDAuthenticationDataType)1 EstablishChannel (iso.std.iso_iec._24727.tech.schema.EstablishChannel)1 EstablishChannelResponse (iso.std.iso_iec._24727.tech.schema.EstablishChannelResponse)1 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)1 WSException (org.openecard.common.WSHelper.WSException)1 AuthDataMap (org.openecard.common.anytype.AuthDataMap)1 AuthDataResponse (org.openecard.common.anytype.AuthDataResponse)1 Dispatcher (org.openecard.common.interfaces.Dispatcher)1 StepResult (org.openecard.gui.StepResult)1 Checkbox (org.openecard.gui.definition.Checkbox)1 PasswordField (org.openecard.gui.definition.PasswordField)1 Text (org.openecard.gui.definition.Text)1 ToggleText (org.openecard.gui.definition.ToggleText)1 RecognizedState (org.openecard.plugins.pinplugin.RecognizedState)1 EACData (org.openecard.sal.protocol.eac.EACData)1