From 9a1263c3ccb75285fe7b8a08b39c5b8a9433d1cd Mon Sep 17 00:00:00 2001 From: Jakob Heher Date: Wed, 6 Jul 2022 11:31:01 +0200 Subject: YAGNI? YAGNI. --- .../asit/pdfover/gui/bku/MobileBKUConnector.java | 53 +++++++++++----------- 1 file changed, 26 insertions(+), 27 deletions(-) (limited to 'pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/MobileBKUConnector.java') 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 4ea96f04..c1b30add 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 @@ -71,7 +71,7 @@ public class MobileBKUConnector implements BkuSlConnector { handler.handleSLRequestResponse(responseData); } catch (Exception ex) { log.error("Error in PostSLRequestThread", ex); //$NON-NLS-1$ - this.state.setThreadException(ex); + this.state.threadException = ex; this.state.displayError(ex); throw new SignatureException(ex); } @@ -80,8 +80,8 @@ public class MobileBKUConnector implements BkuSlConnector { // Check if credentials are available, get them from user if not this.state.checkCredentials(); - if (this.state.status.getErrorMessage() != null && - this.state.status.getErrorMessage().equals("cancel")) //$NON-NLS-1$ + if (this.state.status.errorMessage != null && + this.state.status.errorMessage.equals("cancel")) //$NON-NLS-1$ throw new SignatureException(new IllegalStateException()); // Post credentials @@ -92,11 +92,11 @@ public class MobileBKUConnector implements BkuSlConnector { // handle polling this.state.showOpenAppMessageWithSMSandCancel(); - if (((ATrustStatus) this.state.status).isSmsTan()) { + if (((ATrustStatus) this.state.status).isSMSTan) { ATrustHandler aHandler = (ATrustHandler) handler; String response = aHandler.postSMSRequest(); aHandler.handleCredentialsResponse(response); - } else if (handleErrorMessage()) { + } else if (consumeCancelError()) { throw new SignatureException(new IllegalStateException()); } } else { @@ -108,10 +108,10 @@ public class MobileBKUConnector implements BkuSlConnector { } catch (Exception ex) { log.error("Error in PostCredentialsThread", ex); //$NON-NLS-1$ - this.state.setThreadException(new IllegalStateException()); + this.state.threadException = new IllegalStateException(); throw new SignatureException(new IllegalStateException()); } - } while(this.state.status.getErrorMessage() != null); + } while(this.state.status.errorMessage != null); // Check if response is already available if (signingState.hasSignatureResponse()) { @@ -127,19 +127,19 @@ public class MobileBKUConnector implements BkuSlConnector { if (status instanceof ATrustStatus) { ATrustStatus aStatus = (ATrustStatus) status; ATrustHandler aHandler = (ATrustHandler) handler; - if (aStatus.getQRCodeURL() != null) { + if (aStatus.qrCodeURL != null) { this.state.showQR(); - if (this.state.status.getErrorMessage() != null && - this.state.status.getErrorMessage().equals("cancel")) //$NON-NLS-1$ + if (this.state.status.errorMessage != null && + this.state.status.errorMessage.equals("cancel")) //$NON-NLS-1$ throw new SignatureException(new IllegalStateException()); - if (aStatus.getQRCodeURL() == null) { + if (aStatus.qrCodeURL == null) { try { String response = aHandler.postSMSRequest(); log.trace("Response from mobile BKU: " + response); //$NON-NLS-1$ handler.handleCredentialsResponse(response); } catch (Exception ex) { log.error("Error in PostCredentialsThread", ex); //$NON-NLS-1$ - this.state.setThreadException(new IllegalStateException()); + this.state.threadException = new IllegalStateException(); throw new SignatureException(new IllegalStateException()); } } else { @@ -150,12 +150,12 @@ public class MobileBKUConnector implements BkuSlConnector { try { this.state.showFingerPrintInformation(); - if (this.state.status.getErrorMessage() != null && - this.state.status.getErrorMessage().equals("cancel")) //$NON-NLS-1$ + if (this.state.status.errorMessage != null && + this.state.status.errorMessage.equals("cancel")) //$NON-NLS-1$ throw new SignatureException(new IllegalStateException()); } catch (Exception ex) { log.error("Error in PostCredentialsThread", ex); //$NON-NLS-1$ - this.state.setThreadException(new IllegalStateException()); + this.state.threadException = new IllegalStateException(); //this.state.displayError(ex); throw new SignatureException(new IllegalStateException()); } @@ -167,7 +167,7 @@ public class MobileBKUConnector implements BkuSlConnector { handler.handleCredentialsResponse(response); } catch (Exception e) { log.error("Error in PostCredentialsThread", e); //$NON-NLS-1$ - this.state.setThreadException(e); + this.state.threadException = e; this.state.displayError(e); throw new SignatureException(e); } @@ -183,8 +183,8 @@ public class MobileBKUConnector implements BkuSlConnector { this.state.checkTAN(); - if (this.state.status.getErrorMessage() != null && - this.state.status.getErrorMessage().equals("cancel")) //$NON-NLS-1$ + if (this.state.status.errorMessage != null && + this.state.status.errorMessage.equals("cancel")) //$NON-NLS-1$ throw new SignatureException(new IllegalStateException()); // Post TAN @@ -196,26 +196,25 @@ public class MobileBKUConnector implements BkuSlConnector { handler.handleTANResponse(responseData); } catch (Exception ex) { log.error("Error in PostTanThread", ex); //$NON-NLS-1$ - this.state.setThreadException(ex); + this.state.threadException = ex; this.state.displayError(ex); throw new SignatureException(ex); } } - } while (this.state.status.getErrorMessage() != null); - if (this.state.status.getTanTries() == -1) + } while (this.state.status.errorMessage != null); + if (this.state.status.tanTries == -1) throw new SignatureException(new IllegalStateException()); - } while (this.state.status.getTanTries() == -2); + } while (this.state.status.tanTries == -2); return signingState.getSignatureResponse(); } - private boolean handleErrorMessage() { + private boolean consumeCancelError() { if (this.state.status instanceof ATrustStatus) { - ATrustStatus aStatus = (ATrustStatus)this.state.status ; - if (aStatus.getErrorMessage() != null && - aStatus.getErrorMessage().equals("cancel")) { //$NON-NLS-1$ - ((ATrustStatus)this.state.status).setErrorMessage(null); + if (this.state.status.errorMessage != null && + this.state.status.errorMessage.equals("cancel")) { //$NON-NLS-1$ + this.state.status.errorMessage = null; return true; } } -- cgit v1.2.3