diff options
author | Jakob Heher <jakob.heher@iaik.tugraz.at> | 2022-05-05 10:58:58 +0200 |
---|---|---|
committer | Jakob Heher <jakob.heher@iaik.tugraz.at> | 2022-05-05 10:58:58 +0200 |
commit | e00f1a6ed5766f80357661f47686c0822e1f7e0e (patch) | |
tree | 6665115c82327a10366cf7295965c54252c81f60 /pdf-over-gui/src | |
parent | 6c2bcd00407f6c6ab9b17de203e4ee37f9777481 (diff) | |
download | pdf-over-e00f1a6ed5766f80357661f47686c0822e1f7e0e.tar.gz pdf-over-e00f1a6ed5766f80357661f47686c0822e1f7e0e.tar.bz2 pdf-over-e00f1a6ed5766f80357661f47686c0822e1f7e0e.zip |
clean up timeout code a bit
Diffstat (limited to 'pdf-over-gui/src')
-rw-r--r-- | pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/MobileBKUConnector.java | 14 | ||||
-rw-r--r-- | pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/MobileBKUState.java | 15 |
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)
*
|