From 03b9af56efaec1adecfadc09327a14dc116a9c3a Mon Sep 17 00:00:00 2001 From: Andreas Abraham Date: Tue, 5 Nov 2019 16:20:44 +0100 Subject: support of all cases when pressing the sms tan button --- .../asit/pdfover/gui/bku/MobileBKUConnector.java | 29 ++++++++++------------ .../asit/pdfover/gui/bku/mobile/ATrustHandler.java | 20 +++++++-------- .../asit/pdfover/gui/bku/mobile/IAIKHandler.java | 3 ++- .../pdfover/gui/bku/mobile/MobileBKUHandler.java | 2 +- .../gui/workflow/states/MobileBKUState.java | 4 +-- 5 files changed, 28 insertions(+), 30 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 891ff9f4..09e8d17d 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 @@ -88,20 +88,17 @@ public class MobileBKUConnector implements BkuSlConnector { try { String responseData = handler.postCredentials(); - if (responseData.contains("undecided.aspx?sid=")) { //$NON-NLS-1$ - // handle polling + if (responseData.contains("undecided.aspx?sid=")) { //$NON-NLS-1$ + // 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()); - } else { - handler.handlePolling(responseData); - } - + 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: @@ -149,7 +146,7 @@ public class MobileBKUConnector implements BkuSlConnector { enterTAN = false; } } - if (enterTAN && !aStatus.getTanField() && !aStatus.isSmsTan()) { + if (enterTAN && !aStatus.getTanField()) { try { this.state.showFingerPrintInformation(); @@ -158,9 +155,9 @@ public class MobileBKUConnector implements BkuSlConnector { throw new SignatureException(new IllegalStateException()); } catch (Exception ex) { log.error("Error in PostCredentialsThread", ex); //$NON-NLS-1$ - this.state.setThreadException(ex); - this.state.displayError(ex); - throw new SignatureException(ex); + this.state.setThreadException(new IllegalStateException()); + //this.state.displayError(ex); + throw new SignatureException(new IllegalStateException()); } if (this.state.getSMSStatus()) { 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 2c6f0e55..7d3f986a 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 @@ -452,11 +452,10 @@ public class ATrustHandler extends MobileBKUHandler { public Boolean handleWaitforAppResponse(String responseData) { getStatus().setErrorMessage(null); - if (!responseData.contains("Bitte starten Sie Ihre")) { //$NON-NLS-1$ - //getSigningState().setSignatureResponse( - // new SLResponse(responseData, getStatus().getServer(), null, null)); + if (!responseData.toLowerCase().contains("Bitte starten Sie Ihre Handy-Signatur App!".toLowerCase())/* || //$NON-NLS-1$ + responseData.toLowerCase().contains("TAN (Handy-Signatur App)".toLowerCase())*/) { //$NON-NLS-1$ + return true; - } return false; } @@ -497,14 +496,15 @@ public class ATrustHandler extends MobileBKUHandler { * */ @Override - public void handlePolling(String responseData) throws ATrustConnectionException { - + public boolean handlePolling() throws ATrustConnectionException { + ATrustStatus status = getStatus(); URLConnection urlconnection = null; String isReady = null; Status serverStatus = null; int waits = 0; final String ERROR = "Error: Server is not responding"; //$NON-NLS-1$ + try { do { @@ -527,11 +527,11 @@ public class ATrustHandler extends MobileBKUHandler { if (serverStatus.isFin()) { String response = getSignaturePage(); handleCredentialsResponse(response); - } else { - status.setErrorMessage("Server reponded ERROR during polling"); //$NON-NLS-1$ - log.error("Server reponded ERROR during polling"); //$NON-NLS-1$ - throw new ATrustConnectionException(); + return true; } + status.setErrorMessage("Server reponded ERROR during polling"); //$NON-NLS-1$ + log.error("Server reponded ERROR during polling"); //$NON-NLS-1$ + throw new ATrustConnectionException(); } catch (Exception e) { log.error("handle polling failed" + e.getMessage()); //$NON-NLS-1$ diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/IAIKHandler.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/IAIKHandler.java index efb2b37d..2595de44 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/IAIKHandler.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/IAIKHandler.java @@ -362,7 +362,8 @@ public class IAIKHandler extends MobileBKUHandler { } @Override - public void handlePolling(String responseData) { + public boolean handlePolling() { //nothing todo + return true; } } diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/MobileBKUHandler.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/MobileBKUHandler.java index 3ab47941..4c09c02d 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/MobileBKUHandler.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/MobileBKUHandler.java @@ -356,5 +356,5 @@ public abstract class MobileBKUHandler { /** * @param responseData */ - public abstract void handlePolling(String responseData) throws ATrustConnectionException; + public abstract boolean handlePolling() throws ATrustConnectionException; } 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 3d98ab5e..116d5bb2 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 @@ -458,10 +458,10 @@ public class MobileBKUState extends State { @Override public void run() { - // ping signature page to see if code has been scanned + // ping signature page try { String resp = handler.getSignaturePage(); - if (handler.handleWaitforAppResponse(resp)) { + if (handler.handleWaitforAppResponse(resp) || handler.handlePolling()) { log.debug("Signature page response: " + resp); //$NON-NLS-1$ getWaitingForAppComposite().setIsDone(true); Display display = getStateMachine().getGUIProvider().getMainShell().getDisplay(); -- cgit v1.2.3