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();
}
}
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;
}
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);
}
}
}
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);
}
}
}
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);
}
Aggregations