summaryrefslogtreecommitdiff
path: root/smccSTAL
diff options
context:
space:
mode:
authorclemenso <clemenso@8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4>2008-11-11 12:16:00 +0000
committerclemenso <clemenso@8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4>2008-11-11 12:16:00 +0000
commite4a47aa9393d74647f4f0c66b54dc4519fed492f (patch)
treedcacbccfc7b4e777854ee6b9b1c74f84f7fc7915 /smccSTAL
parent82c59c9d862d3ee9ad43fdc1509d0b5a61cc107c (diff)
downloadmocca-e4a47aa9393d74647f4f0c66b54dc4519fed492f.tar.gz
mocca-e4a47aa9393d74647f4f0c66b54dc4519fed492f.tar.bz2
mocca-e4a47aa9393d74647f4f0c66b54dc4519fed492f.zip
Interrupt in waitForAction (applet closed)
git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@162 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4
Diffstat (limited to 'smccSTAL')
-rw-r--r--smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/AbstractRequestHandler.java9
-rw-r--r--smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/AbstractSMCCSTAL.java28
-rw-r--r--smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/InfoBoxReadRequestHandler.java4
-rw-r--r--smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/SMCCSTALRequestHandler.java2
-rw-r--r--smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/SignRequestHandler.java4
5 files changed, 31 insertions, 16 deletions
diff --git a/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/AbstractRequestHandler.java b/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/AbstractRequestHandler.java
index 995e2b77..98b21f79 100644
--- a/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/AbstractRequestHandler.java
+++ b/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/AbstractRequestHandler.java
@@ -39,8 +39,8 @@ public abstract class AbstractRequestHandler implements SMCCSTALRequestHandler,
protected boolean actionPerformed = false;
@Override
- public abstract STALResponse handleRequest(STALRequest request);
-
+ public abstract STALResponse handleRequest(STALRequest request) throws InterruptedException;
+
@Override
public void init(SignatureCard sc, BKUGUIFacade gui) {
if ((sc == null) || (gui == null)) {
@@ -60,13 +60,14 @@ public abstract class AbstractRequestHandler implements SMCCSTALRequestHandler,
}
}
- protected synchronized void waitForAction() {
+ protected synchronized void waitForAction() throws InterruptedException {
try {
while (!actionPerformed) {
wait();
}
} catch (InterruptedException e) {
- log.info(e);
+ log.error("interrupt in waitForAction");
+ throw e;
}
actionPerformed = false;
}
diff --git a/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/AbstractSMCCSTAL.java b/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/AbstractSMCCSTAL.java
index f310dd42..04d8d0dd 100644
--- a/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/AbstractSMCCSTAL.java
+++ b/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/AbstractSMCCSTAL.java
@@ -24,6 +24,8 @@ import java.util.Locale;
import java.util.Map;
import java.util.Set;
+import java.util.logging.Level;
+import java.util.logging.Logger;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -34,6 +36,7 @@ import at.gv.egiz.stal.InfoboxReadRequest;
import at.gv.egiz.stal.STAL;
import at.gv.egiz.stal.STALRequest;
import at.gv.egiz.stal.STALResponse;
+import java.util.Collections;
public abstract class AbstractSMCCSTAL implements STAL {
private static Log log = LogFactory.getLog(AbstractSMCCSTAL.class);
@@ -61,7 +64,7 @@ public abstract class AbstractSMCCSTAL implements STAL {
protected abstract BKUGUIFacade getGUI();
- private STALResponse getRespone(STALRequest request) {
+ private STALResponse getRespone(STALRequest request) throws InterruptedException {
log.info("Processing: " + request.getClass());
int retryCounter = 0;
while (retryCounter < maxRetries) {
@@ -99,6 +102,9 @@ public abstract class AbstractSMCCSTAL implements STAL {
log.info("Got null response from handler, assuming quit");
return null;
}
+ } catch (InterruptedException e) {
+ log.info("Interrupt in handleRequest, do not retry");
+ throw e;
} catch (Exception e) {
log.info("Error while handling STAL request:" + e);
if (++retryCounter < maxRetries) {
@@ -125,14 +131,22 @@ public abstract class AbstractSMCCSTAL implements STAL {
.size());
for (STALRequest request : requestList) {
log.info("Processing: " + request.getClass());
- STALResponse response = getRespone(request);
- if (response != null) {
- responseList.add(response);
- if (response instanceof ErrorResponse) {
- log.info("Got an error response, don't process remaining requests");
- break;
+ STALResponse response;
+ try {
+ response = getRespone(request);
+ if (response != null) {
+ responseList.add(response);
+ if (response instanceof ErrorResponse) {
+ log.info("Got an error response, don't process remaining requests");
+ break;
+ }
}
+ } catch (InterruptedException ex) {
+ log.error("got interrupted, return ErrorResponse 6001");
+ responseList = Collections.singletonList((STALResponse) new ErrorResponse(6001));
+ break;
}
+
}
return responseList;
}
diff --git a/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/InfoBoxReadRequestHandler.java b/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/InfoBoxReadRequestHandler.java
index cfc5c4bd..04f179e7 100644
--- a/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/InfoBoxReadRequestHandler.java
+++ b/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/InfoBoxReadRequestHandler.java
@@ -41,7 +41,7 @@ public class InfoBoxReadRequestHandler extends AbstractRequestHandler implements
private int retryCounter = 0;
@Override
- public STALResponse handleRequest(STALRequest request) {
+ public STALResponse handleRequest(STALRequest request) throws InterruptedException {
if (request instanceof InfoboxReadRequest) {
InfoboxReadRequest infoBox = (InfoboxReadRequest) request;
try {
@@ -134,7 +134,7 @@ public class InfoBoxReadRequestHandler extends AbstractRequestHandler implements
}
@Override
- public String providePIN(PINSpec spec, int retries) {
+ public String providePIN(PINSpec spec, int retries) throws InterruptedException {
if (retryCounter++ > 0) {
log.info("PIN wrong retrying ...");
gui.showCardPINRetryDialog(spec, retries, this, "ok", this, "cancel");
diff --git a/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/SMCCSTALRequestHandler.java b/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/SMCCSTALRequestHandler.java
index 94ab7a5b..f19b3ef3 100644
--- a/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/SMCCSTALRequestHandler.java
+++ b/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/SMCCSTALRequestHandler.java
@@ -26,7 +26,7 @@ public interface SMCCSTALRequestHandler {
public void init(SignatureCard sc, BKUGUIFacade gui);
- public STALResponse handleRequest(STALRequest request);
+ public STALResponse handleRequest(STALRequest request) throws InterruptedException;
public boolean requireCard();
diff --git a/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/SignRequestHandler.java b/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/SignRequestHandler.java
index dbc70bff..6c30a68a 100644
--- a/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/SignRequestHandler.java
+++ b/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/SignRequestHandler.java
@@ -67,7 +67,7 @@ public abstract class SignRequestHandler extends AbstractRequestHandler implemen
@SuppressWarnings("unchecked")
@Override
- public STALResponse handleRequest(STALRequest request) {
+ public STALResponse handleRequest(STALRequest request) throws InterruptedException {
if (request instanceof SignRequest) {
SignRequest signReq = (SignRequest) request;
newSTALMessage("Message.RequestCaption", "Message.SignRequest");
@@ -213,7 +213,7 @@ public abstract class SignRequestHandler extends AbstractRequestHandler implemen
}
@Override
- public String providePIN(PINSpec spec, int retries) {
+ public String providePIN(PINSpec spec, int retries) throws InterruptedException {
showSignaturePINDialog(spec, retries);