summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakob Heher <jakob.heher@iaik.tugraz.at>2022-05-05 10:58:58 +0200
committerJakob Heher <jakob.heher@iaik.tugraz.at>2022-05-05 10:58:58 +0200
commite00f1a6ed5766f80357661f47686c0822e1f7e0e (patch)
tree6665115c82327a10366cf7295965c54252c81f60
parent6c2bcd00407f6c6ab9b17de203e4ee37f9777481 (diff)
downloadpdf-over-e00f1a6ed5766f80357661f47686c0822e1f7e0e.tar.gz
pdf-over-e00f1a6ed5766f80357661f47686c0822e1f7e0e.tar.bz2
pdf-over-e00f1a6ed5766f80357661f47686c0822e1f7e0e.zip
clean up timeout code a bit
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/MobileBKUConnector.java14
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/MobileBKUState.java15
2 files changed, 10 insertions, 19 deletions
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/MobileBKUConnector.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/MobileBKUConnector.java
index b24761a9..a3b70d00 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/MobileBKUConnector.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/MobileBKUConnector.java
@@ -92,13 +92,13 @@ public class MobileBKUConnector implements BkuSlConnector {
// handle polling
this.state.showOpenAppMessageWithSMSandCancel();
- if (((ATrustStatus) this.state.getStatus()).isSmsTan()) {
- ATrustHandler aHandler = (ATrustHandler) handler;
- String response = aHandler.postSMSRequest();
- aHandler.handleCredentialsResponse(response);
- } else if (handleErrorMessage()) {
- throw new SignatureException(new IllegalStateException());
- }
+ if (((ATrustStatus) this.state.getStatus()).isSmsTan()) {
+ ATrustHandler aHandler = (ATrustHandler) handler;
+ String response = aHandler.postSMSRequest();
+ aHandler.handleCredentialsResponse(response);
+ } else if (handleErrorMessage()) {
+ throw new SignatureException(new IllegalStateException());
+ }
} else {
// Now we have received some data lets check it:
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 ebd434f7..2c5fbd48 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
@@ -461,10 +461,10 @@ public class MobileBKUState extends State {
Display display = getStateMachine().getGUIProvider().getMainShell().getDisplay();
undecidedPolling();
- long startTime = System.nanoTime();
+ long timeoutTime = System.nanoTime() + (300 * ((long)1e9));
while (!waitingForAppcomposite.getUserCancel() && !waitingForAppcomposite.getUserSMS()
- && !waitingForAppcomposite.getIsDone() && !isTimout(startTime)) {
+ && !waitingForAppcomposite.getIsDone() && (System.nanoTime() < timeoutTime)) {
if (!display.readAndDispatch()) {
display.sleep();
}
@@ -490,7 +490,7 @@ public class MobileBKUState extends State {
if (waitingForAppcomposite.getIsDone())
waitingForAppcomposite.setIsDone(false);
- if (isTimout(startTime)){
+ if (!(System.nanoTime() < timeoutTime)) {
log.warn("The undecided polling got a timeout");
status.setQRCode(null);
status.setErrorMessage("Polling Timeout");
@@ -593,15 +593,6 @@ public class MobileBKUState extends State {
return this.getMobileBKUFingerprintComposite().isUserSMS();
}
-
- private boolean isTimout(long startTime){
- long NANOSEC_PER_SEC = 1000l*1000*1000;
- if ((System.nanoTime()-startTime)< 5*60*NANOSEC_PER_SEC){
- return false;
- }
- return true;
- }
-
/*
* (non-Javadoc)
*