Search in sources :

Example 1 with StepActionResult

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

the class StepFrame method runBackgroundTask.

private void runBackgroundTask() {
    final BackgroundTask task = step.getBackgroundTask();
    if (task != null) {
        bgThread = new Thread(new Runnable() {

            @Override
            public void run() {
                try {
                    StepActionResult result = task.call();
                    LOG.debug("Background thread terminated before the GUI.");
                    forceResult(result);
                } catch (InterruptedException ex) {
                    LOG.debug("Background task has been terminated from the Swing GUI.", ex);
                } catch (Exception ex) {
                    LOG.error("Background task terminated with an exception.", ex);
                }
            }
        }, "Swing-GUI-BG-Task");
        bgThread.setDaemon(true);
        bgThread.start();
    }
}
Also used : StepActionResult(org.openecard.gui.executor.StepActionResult) BackgroundTask(org.openecard.gui.executor.BackgroundTask)

Example 2 with StepActionResult

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

the class WaitAction method perform.

@Override
public StepActionResult perform(Map<String, ExecutionResults> oldResults, StepResult result) {
    System.out.println("sleeping for " + sleepTime + " ms.");
    startTime = System.currentTimeMillis();
    try {
        Thread.sleep(sleepTime);
    } catch (InterruptedException e) {
    // ignore in test
    }
    StepActionResult actionResult = new StepActionResult(StepActionResultStatus.NEXT);
    return actionResult;
}
Also used : StepActionResult(org.openecard.gui.executor.StepActionResult)

Example 3 with StepActionResult

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

the class PinChangeStepAction method perform.

@Override
public StepActionResult perform(Map<String, ExecutionResults> oldResults, StepResult result) {
    try {
        if (pinStep.isCapturePuk()) {
            if (pinStep.isProtectedAuthPath()) {
                pinStep.getSession().loginExternal(UserType.Security_Officer);
                pinStep.getSession().initPinExternal();
            } else {
                char[] puk = getPuk();
                pinStep.getSession().login(UserType.Security_Officer, puk);
                char[] newPin = getNewPin();
                pinStep.getSession().initPin(newPin);
            }
        } else {
            if (pinStep.isProtectedAuthPath()) {
                // pinStep.getSession().loginExternal(UserType.User);
                pinStep.getSession().changePinExternal();
            } else {
                char[] oldPin = getOldPin();
                char[] newPin = getNewPin();
                pinStep.getSession().changePin(oldPin, newPin);
            }
        }
        pinStep.setPinChangeSuccessful();
        pinStep.updateState();
        return new StepActionResult(StepActionResultStatus.REPEAT);
    } catch (PinIncorrectException ex) {
        if (LOG.isDebugEnabled()) {
            LOG.debug("PIN incorrect.", ex);
        } else {
            LOG.info("PIN incorrect.");
        }
        pinStep.setLastTryFailed();
        try {
            pinStep.updateState();
            return new StepActionResult(StepActionResultStatus.REPEAT);
        } catch (CryptokiException ex1) {
            // I suspect user removed card
            return new StepActionResult(StepActionResultStatus.CANCEL);
        }
    } catch (PinsDoNotMatchException ex) {
        LOG.debug("Mismatching PINs entered.", ex);
        try {
            pinStep.setPinsDoNotMatch();
            pinStep.updateState();
            return new StepActionResult(StepActionResultStatus.REPEAT);
        } catch (CryptokiException ex2) {
            // I suspect user removed card
            return new StepActionResult(StepActionResultStatus.CANCEL);
        }
    } catch (PinBlockedException ex) {
        // let the UI take care of producing a blocked error
        try {
            pinStep.updateState();
            return new StepActionResult(StepActionResultStatus.REPEAT);
        } catch (CryptokiException ex2) {
            // I suspect user removed card
            return new StepActionResult(StepActionResultStatus.CANCEL);
        }
    } catch (AuthenticationException ex) {
        LOG.error("Authentication error while entering the PIN.", ex);
        try {
            pinStep.setUnkownError();
            pinStep.updateState();
            return new StepActionResult(StepActionResultStatus.REPEAT);
        } catch (CryptokiException ex2) {
            // I suspect user removed card
            return new StepActionResult(StepActionResultStatus.CANCEL);
        }
    } catch (CryptokiException ex) {
        LOG.error("Unknown error while entering the PIN.", ex);
        try {
            pinStep.setUnkownError();
            pinStep.updateState();
            return new StepActionResult(StepActionResultStatus.REPEAT);
        } catch (CryptokiException ex2) {
            // I suspect user removed card
            return new StepActionResult(StepActionResultStatus.CANCEL);
        }
    }
}
Also used : CryptokiException(org.openecard.mdlw.sal.exceptions.CryptokiException) AuthenticationException(org.openecard.mdlw.sal.exceptions.AuthenticationException) PinBlockedException(org.openecard.mdlw.sal.exceptions.PinBlockedException) PinIncorrectException(org.openecard.mdlw.sal.exceptions.PinIncorrectException) StepActionResult(org.openecard.gui.executor.StepActionResult)

Example 4 with StepActionResult

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

the class PinEntryStepAction method perform.

@Override
public StepActionResult perform(Map<String, ExecutionResults> oldResults, StepResult result) {
    try {
        if (pinStep.isProtectedAuthPath()) {
            pinStep.getSession().loginExternal(UserType.User);
        } else {
            char[] pPin = getPin();
            pinStep.getSession().login(UserType.User, pPin);
        }
        pinStep.setPinAuthenticated();
        return new StepActionResult(StepActionResultStatus.NEXT);
    } catch (PinIncorrectException ex) {
        if (LOG.isDebugEnabled()) {
            LOG.debug("PIN incorrect.", ex);
        } else {
            LOG.info("PIN incorrect.");
        }
        pinStep.setLastTryFailed();
        try {
            pinStep.updateState();
            return new StepActionResult(StepActionResultStatus.REPEAT);
        } catch (CryptokiException ex1) {
            // I suspect user removed card
            return new StepActionResult(StepActionResultStatus.CANCEL);
        }
    } catch (PinBlockedException ex) {
        // let the UI take care of producing a blocked error
        try {
            pinStep.setPinBlocked();
            pinStep.updateState();
            return new StepActionResult(StepActionResultStatus.REPEAT);
        } catch (CryptokiException ex2) {
            // I suspect user removed card
            return new StepActionResult(StepActionResultStatus.CANCEL);
        }
    } catch (AuthenticationException ex) {
        LOG.error("Authentication error while entering the PIN.", ex);
        pinStep.setLastTryFailed();
        pinStep.setUnkownError();
        try {
            pinStep.updateState();
            return new StepActionResult(StepActionResultStatus.REPEAT);
        } catch (CryptokiException ex1) {
            // I suspect user removed card
            return new StepActionResult(StepActionResultStatus.CANCEL);
        }
    } catch (CryptokiException ex) {
        LOG.error("Unkonw error while entering the PIN.", ex);
        pinStep.setLastTryFailed();
        pinStep.setUnkownError();
        try {
            pinStep.updateState();
            return new StepActionResult(StepActionResultStatus.REPEAT);
        } catch (CryptokiException ex1) {
            // I suspect user removed card
            return new StepActionResult(StepActionResultStatus.CANCEL);
        }
    }
}
Also used : CryptokiException(org.openecard.mdlw.sal.exceptions.CryptokiException) AuthenticationException(org.openecard.mdlw.sal.exceptions.AuthenticationException) PinBlockedException(org.openecard.mdlw.sal.exceptions.PinBlockedException) PinIncorrectException(org.openecard.mdlw.sal.exceptions.PinIncorrectException) StepActionResult(org.openecard.gui.executor.StepActionResult)

Example 5 with StepActionResult

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

the class InsertCardStepAction method perform.

@Override
public StepActionResult perform(Map<String, ExecutionResults> oldResults, StepResult result) {
    List<ConnectionHandleType> availableCards = new ArrayList<>();
    // create session for wait for change
    availableCards.addAll(checkAvailability());
    while (availableCards.isEmpty()) {
        try {
            availableCards.add(promise.deref());
        } catch (InterruptedException ex) {
            return new StepActionResult(StepActionResultStatus.CANCEL);
        }
        availableCards.addAll(checkAvailability());
    }
    response.addAll(availableCards);
    return new StepActionResult(StepActionResultStatus.NEXT);
}
Also used : ConnectionHandleType(iso.std.iso_iec._24727.tech.schema.ConnectionHandleType) ArrayList(java.util.ArrayList) StepActionResult(org.openecard.gui.executor.StepActionResult)

Aggregations

StepActionResult (org.openecard.gui.executor.StepActionResult)18 EstablishChannelResponse (iso.std.iso_iec._24727.tech.schema.EstablishChannelResponse)7 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)6 ExecutionResults (org.openecard.gui.executor.ExecutionResults)6 Step (org.openecard.gui.definition.Step)5 WSException (org.openecard.common.WSHelper.WSException)4 StepAction (org.openecard.gui.executor.StepAction)4 DIDAuthenticationDataType (iso.std.iso_iec._24727.tech.schema.DIDAuthenticationDataType)3 DestroyChannel (iso.std.iso_iec._24727.tech.schema.DestroyChannel)3 EstablishChannel (iso.std.iso_iec._24727.tech.schema.EstablishChannel)3 DynamicContext (org.openecard.common.DynamicContext)3 WSHelper (org.openecard.common.WSHelper)3 AuthDataMap (org.openecard.common.anytype.AuthDataMap)3 AuthDataResponse (org.openecard.common.anytype.AuthDataResponse)3 APDUException (org.openecard.common.apdu.exception.APDUException)3 CardApplicationDisconnect (iso.std.iso_iec._24727.tech.schema.CardApplicationDisconnect)2 Disconnect (iso.std.iso_iec._24727.tech.schema.Disconnect)2 ArrayList (java.util.ArrayList)2 BackgroundTask (org.openecard.gui.executor.BackgroundTask)2 IFDException (org.openecard.ifd.scio.IFDException)2