Search in sources :

Example 1 with PINStep

use of org.openecard.sal.protocol.eac.gui.PINStep in project open-ecard by ecsec.

the class EacGuiImpl method getPinResult.

public List<OutputInfoUnit> getPinResult(Step step) throws InterruptedException {
    if (step instanceof PINStep) {
        PINStep pinStep = (PINStep) step;
        switch(pinStep.getStatus()) {
            case RC3:
                this.pinStatus.deliver(PinStatus.RC3);
                break;
            case RC2:
                this.pinStatus.deliver(PinStatus.RC2);
                break;
            case RC1:
                this.pinStatus.deliver(PinStatus.CAN);
                break;
        }
        // read values
        String pinValue = this.userPin.deref();
        String canValue = this.userCan.deref();
        ArrayList<OutputInfoUnit> result = new ArrayList<>();
        for (InputInfoUnit nextIn : pinStep.getInputInfoUnits()) {
            if (pinValue != null && nextIn instanceof PasswordField && nextIn.getID().equals("PACE_PIN_FIELD")) {
                PasswordField pw = new PasswordField(nextIn.getID());
                pw.copyContentFrom(nextIn);
                pw.setValue(pinValue.toCharArray());
                result.add(pw);
            } else if (canValue != null && nextIn instanceof PasswordField && nextIn.getID().equals("PACE_CAN_FIELD")) {
                PasswordField pw = new PasswordField(nextIn.getID());
                pw.copyContentFrom(nextIn);
                pw.setValue(canValue.toCharArray());
                result.add(pw);
            }
        }
        return result;
    } else {
        throw new InterruptedException("The given step is not a PinStep.");
    }
}
Also used : InputInfoUnit(org.openecard.gui.definition.InputInfoUnit) PINStep(org.openecard.sal.protocol.eac.gui.PINStep) ArrayList(java.util.ArrayList) OutputInfoUnit(org.openecard.gui.definition.OutputInfoUnit) PasswordField(org.openecard.gui.definition.PasswordField)

Example 2 with PINStep

use of org.openecard.sal.protocol.eac.gui.PINStep 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)

Aggregations

PINStep (org.openecard.sal.protocol.eac.gui.PINStep)2 ArrayList (java.util.ArrayList)1 StepResult (org.openecard.gui.StepResult)1 Checkbox (org.openecard.gui.definition.Checkbox)1 InputInfoUnit (org.openecard.gui.definition.InputInfoUnit)1 OutputInfoUnit (org.openecard.gui.definition.OutputInfoUnit)1 PasswordField (org.openecard.gui.definition.PasswordField)1 Step (org.openecard.gui.definition.Step)1 ToggleText (org.openecard.gui.definition.ToggleText)1 ExecutionResults (org.openecard.gui.executor.ExecutionResults)1 StepAction (org.openecard.gui.executor.StepAction)1 StepActionResult (org.openecard.gui.executor.StepActionResult)1