use of org.openecard.gui.executor.StepActionResult 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);
}
use of org.openecard.gui.executor.StepActionResult in project open-ecard by ecsec.
the class CardMonitor method call.
@Override
public StepActionResult call() throws Exception {
try {
logger.debug("Waiting for card to be removed.");
cardRemoved.deref();
logger.debug("Card has been removed.");
String title = langPin.translationForKey(ERROR_TITLE);
String desc = langPin.translationForKey(ERROR_CARD_REMOVED);
ErrorStep replacement = new ErrorStep(title, desc);
DynamicContext dynCtx = DynamicContext.getInstance(TR03112Keys.INSTANCE_KEY);
dynCtx.put(EACProtocol.PACE_EXCEPTION, WSHelper.createException(WSHelper.makeResultError(ECardConstants.Minor.IFD.INVALID_SLOT_HANDLE, "Card has been removed.")));
return new StepActionResult(StepActionResultStatus.REPEAT, replacement);
} catch (InterruptedException ex) {
logger.debug("Card has not been removed.");
// terminate the current thread
throw ex;
}
}
use of org.openecard.gui.executor.StepActionResult in project open-ecard by ecsec.
the class BackgroundTaskTest method testWait.
@Test()
public void testWait() {
UserConsent uc = new SwingUserConsent(new SwingDialogWrapper());
UserConsentDescription ucd = new UserConsentDescription("Test background wait");
Step s = new Step("Wait Step");
s.getInputInfoUnits().add(new Text("Please wait for the background task to complete ..."));
s.setBackgroundTask(new BackgroundTask() {
@Override
public StepActionResult call() throws Exception {
// first wait
Thread.sleep(1000);
// then repeat ;-)
Step replacement = new Step("Replacement Step");
replacement.getInputInfoUnits().add(new Text("Super cool it works."));
replacement.setInstantReturn(true);
return new StepActionResult(StepActionResultStatus.REPEAT, replacement);
}
});
ucd.getSteps().add(s);
ExecutionEngine e = new ExecutionEngine(uc.obtainNavigator(ucd));
e.process();
}
use of org.openecard.gui.executor.StepActionResult 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));
}
}
use of org.openecard.gui.executor.StepActionResult in project open-ecard by ecsec.
the class GenericPINAction method performUnblockPIN.
private StepActionResult performUnblockPIN(Map<String, ExecutionResults> oldResults) {
try {
EstablishChannelResponse pukResponse = performPACEWithPUK(oldResults);
if (pukResponse == null) {
gPINStep.setWrongPUKFormat(true);
gPINStep.setFailedPUKVerify(false);
// to reset the text fields
gPINStep.updateState(state);
return new StepActionResult(StepActionResultStatus.REPEAT);
}
if (pukResponse.getResult().getResultMajor().equals(ECardConstants.Major.ERROR)) {
if (pukResponse.getResult().getResultMinor().equals(ECardConstants.Minor.IFD.AUTHENTICATION_FAILED)) {
// i think we should not display the counter
// gPINStep.decreasePUKCounter();
gPINStep.setWrongPUKFormat(false);
gPINStep.setFailedPUKVerify(true);
// to reset the text fields
gPINStep.updateState(state);
return new StepActionResult(StepActionResultStatus.REPEAT);
} else {
WSHelper.checkResult(pukResponse);
}
}
// Here no exception is thrown so sent the ResetRetryCounter command
ResetRetryCounter resetRetryCounter = new ResetRetryCounter((byte) 0x03);
List<byte[]> responses = new ArrayList<>();
responses.add(new byte[] { (byte) 0x90, (byte) 0x00 });
responses.add(new byte[] { (byte) 0x69, (byte) 0x84 });
CardResponseAPDU resetCounterResponse = resetRetryCounter.transmit(dispatcher, slotHandle, responses);
if (Arrays.equals(resetCounterResponse.getTrailer(), new byte[] { (byte) 0x69, (byte) 0x84 })) {
gPINStep.updateState(RecognizedState.PUK_blocked);
return new StepActionResult(StepActionResultStatus.REPEAT);
} else if (Arrays.equals(resetCounterResponse.getTrailer(), new byte[] { (byte) 0x90, (byte) 0x00 })) {
gPINStep.updateState(RecognizedState.PIN_activated_RC3);
return new StepActionResult(StepActionResultStatus.REPEAT, generateSuccessStep(lang.translationForKey(PUK_SUCCESS)));
} else {
gPINStep.updateState(RecognizedState.UNKNOWN);
return new StepActionResult(StepActionResultStatus.REPEAT);
}
} catch (APDUException | ParserConfigurationException ex) {
LOG.error("An internal error occurred while trying to unblock the PIN.", ex);
return new StepActionResult(StepActionResultStatus.REPEAT, generateErrorStep(lang.translationForKey(ERROR_INTERNAL)));
} catch (WSHelper.WSException ex) {
// This is for PIN Pad Readers in case the user pressed the cancel button on the reader.
if (ex.getResultMinor().equals(ECardConstants.Minor.IFD.CANCELLATION_BY_USER)) {
LOG.error("User canceled the authentication manually or removed the card.", ex);
return new StepActionResult(StepActionResultStatus.REPEAT, generateErrorStep(lang.translationForKey(ERROR_USER_CANCELLATION_OR_CARD_REMOVED)));
}
// for users which forgot to type in something
if (ex.getResultMinor().equals(ECardConstants.Minor.IFD.TIMEOUT_ERROR)) {
LOG.error("The terminal timed out no password was entered.", ex);
return new StepActionResult(StepActionResultStatus.REPEAT, generateErrorStep(lang.translationForKey(ERROR_TIMEOUT)));
}
// for people which think they have to remove the card in the process
if (ex.getResultMinor().equals(ECardConstants.Minor.IFD.INVALID_SLOT_HANDLE)) {
LOG.error("The SlotHandle was invalid so probably the user removed the card or an reset occurred.", ex);
return new StepActionResult(StepActionResultStatus.REPEAT, generateErrorStep(lang.translationForKey(ERROR_CARD_REMOVED)));
}
// We don't know what happend so just show an general error message
LOG.error("An unknown error occurred while trying to verify the PUK.", ex);
return new StepActionResult(StepActionResultStatus.REPEAT, generateErrorStep(lang.translationForKey(ERROR_UNKNOWN)));
} finally {
// destroy the pace channel
DestroyChannel destChannel = new DestroyChannel();
destChannel.setSlotHandle(slotHandle);
dispatcher.safeDeliver(destChannel);
// For readers which do not support DestroyChannel but have generic pace support
Disconnect disconnect = new Disconnect();
disconnect.setSlotHandle(slotHandle);
disconnect.setAction(ActionType.RESET);
dispatcher.safeDeliver(disconnect);
}
}
Aggregations