summaryrefslogtreecommitdiff
path: root/pdf-over-gui/src/main/java/at
diff options
context:
space:
mode:
authorAndreas Abraham <andreas.abraham@egiz.gv.at>2021-01-27 10:22:29 +0100
committerAndreas Abraham <andreas.abraham@egiz.gv.at>2021-01-27 10:22:29 +0100
commite5538393176f31ecee44331bbf2761d82c48f334 (patch)
tree0a70666f3329c83ef9d7231a398a05e8e39e8561 /pdf-over-gui/src/main/java/at
parented17cf1ad4494c13dea26194ced9179311f29e7a (diff)
downloadpdf-over-e5538393176f31ecee44331bbf2761d82c48f334.tar.gz
pdf-over-e5538393176f31ecee44331bbf2761d82c48f334.tar.bz2
pdf-over-e5538393176f31ecee44331bbf2761d82c48f334.zip
Fixed Problem that timertask did not cancel
Diffstat (limited to 'pdf-over-gui/src/main/java/at')
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/ATrustHandler.java12
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/MobileBKUState.java86
2 files changed, 42 insertions, 56 deletions
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/ATrustHandler.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/ATrustHandler.java
index a1d33803..ef7cc81d 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/ATrustHandler.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/ATrustHandler.java
@@ -516,13 +516,9 @@ public class ATrustHandler extends MobileBKUHandler {
get.addRequestHeader("Accept", "application/json, text/javascript");
get.addRequestHeader("Connection", "keep-alive");
get.addRequestHeader("Referer", uri);
- System.out.println("URL" + uri);
- System.out.println("Cookies " + getStatus().getCookies());
int returnValue = client.executeMethod(get);
- System.out.println("retVal " + returnValue);
- //InputStream in = new BufferedInputStream(urlconnection.getInputStream());
InputStream in = new BufferedInputStream(get.getResponseBodyAsStream());
isReady = IOUtils.toString(in, "utf-8"); //$NON-NLS-1$
@@ -536,14 +532,6 @@ public class ATrustHandler extends MobileBKUHandler {
throw new ATrustConnectionException();
}
- /*if (serverStatus.isWait())
- waits++;
- if (waits > 4) {
- status.setErrorMessage(ERROR);
- log.error(ERROR);
- throw new ATrustConnectionException();
- }*/
-
} while (serverStatus.isWait());
if (serverStatus.isFin()) {
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/MobileBKUState.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/MobileBKUState.java
index 6485c270..36d29e49 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/MobileBKUState.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/MobileBKUState.java
@@ -368,7 +368,7 @@ public class MobileBKUState extends State {
final ATrustStatus status = (ATrustStatus) this.getStatus();
final ATrustHandler handler = (ATrustHandler) this.getHandler();
- final Timer checkDone = new Timer(true);
+ final Timer checkDone = new Timer();
checkDone.scheduleAtFixedRate(new TimerTask() {
@Override
@@ -382,6 +382,7 @@ public class MobileBKUState extends State {
Display display = getStateMachine().getGUIProvider().
getMainShell().getDisplay();
display.wake();
+ checkDone.cancel();
}
Display.getDefault().wake();
} catch (Exception e) {
@@ -389,51 +390,51 @@ public class MobileBKUState extends State {
}
}
}, 0, 5000);
- Display.getDefault().syncExec(new Runnable() {
- @Override
- public void run() {
- MobileBKUQRComposite qr = getMobileBKUQRComposite();
-
- qr.setRefVal(status.getRefVal());
- qr.setSignatureData(status.getSignatureDataURL());
- qr.setErrorMessage(status.getErrorMessage());
- InputStream qrcode = handler.getQRCode();
- if (qrcode == null) {
- MobileBKUState.this.threadException = new Exception(
- Messages.getString("error.FailedToLoadQRCode")); //$NON-NLS-1$
- }
- qr.setQR(qrcode);
- getStateMachine().getGUIProvider().display(qr);
- Display display = getStateMachine().getGUIProvider().getMainShell().getDisplay();
- while (!qr.isUserCancel() && !qr.isUserSMS() && !qr.isDone()) {
- if (!display.readAndDispatch()) {
- display.sleep();
- }
- }
- checkDone.cancel();
+ Display.getDefault().syncExec(() -> {
+ MobileBKUQRComposite qr = getMobileBKUQRComposite();
+
+ qr.setRefVal(status.getRefVal());
+ qr.setSignatureData(status.getSignatureDataURL());
+ qr.setErrorMessage(status.getErrorMessage());
+ InputStream qrcode = handler.getQRCode();
+ if (qrcode == null) {
+ MobileBKUState.this.threadException = new Exception(
+ Messages.getString("error.FailedToLoadQRCode")); //$NON-NLS-1$
+ }
+ qr.setQR(qrcode);
+ getStateMachine().getGUIProvider().display(qr);
- if (qr.isUserCancel()) {
- qr.setUserCancel(false);
- status.setErrorMessage("cancel"); //$NON-NLS-1$
- return;
+ Display display = getStateMachine().getGUIProvider().getMainShell().getDisplay();
+ while (!qr.isUserCancel() && !qr.isUserSMS() && !qr.isDone()) {
+ if (!display.readAndDispatch()) {
+ display.sleep();
}
+ }
- if (qr.isUserSMS()) {
- qr.setUserSMS(false);
- status.setQRCode(null);
- }
+ checkDone.cancel();
- if (qr.isDone())
- qr.setDone(false);
+ if (qr.isUserCancel()) {
+ qr.setUserCancel(false);
+ status.setErrorMessage("cancel"); //$NON-NLS-1$
+ return;
+ }
- // show waiting composite
- getStateMachine().getGUIProvider().display(
- MobileBKUState.this.getWaitingComposite());
+ if (qr.isUserSMS()) {
+ qr.setUserSMS(false);
+ status.setQRCode(null);
}
+
+ if (qr.isDone())
+ qr.setDone(false);
+
+ // show waiting composite
+ getStateMachine().getGUIProvider().display(
+ MobileBKUState.this.getWaitingComposite());
});
}
-
+
+
/**
* This composite notifies the user to open the signature-app
*/
@@ -498,12 +499,8 @@ public class MobileBKUState extends State {
if (handler.handlePolling()){
String response = handler.getSignaturePage();
handler.handleCredentialsResponse(response);
- Display.getDefault().syncExec(new Runnable() {
- @Override
- public void run() {
- getWaitingForAppComposite().setIsDone(true);
- }
- });
+ Display.getDefault().syncExec(() ->
+ getWaitingForAppComposite().setIsDone(true));
}
} catch (ATrustConnectionException e) {
log.error("Error when calling polling endpoint");
@@ -522,7 +519,7 @@ public class MobileBKUState extends State {
final ATrustStatus status = (ATrustStatus) this.getStatus();
final ATrustHandler handler = (ATrustHandler) this.getHandler();
- final Timer checkDone = new Timer(true);
+ Timer checkDone = new Timer();
checkDone.scheduleAtFixedRate(new TimerTask() {
@Override
@@ -535,6 +532,7 @@ public class MobileBKUState extends State {
getMobileBKUFingerprintComposite().setDone(true);
Display display = getStateMachine().getGUIProvider().getMainShell().getDisplay();
display.wake();
+ checkDone.cancel();
}
Display.getDefault().wake();
} catch (Exception e) {