diff options
author | Jakob Heher <jakob.heher@iaik.tugraz.at> | 2022-07-06 10:35:23 +0200 |
---|---|---|
committer | Jakob Heher <jakob.heher@iaik.tugraz.at> | 2022-07-06 10:35:23 +0200 |
commit | c598f60380077e4e156f3ad4424eb42ec8aa0f28 (patch) | |
tree | e3b6026f20f150a3300030523b995171813c5217 /pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku | |
parent | 1d5af6e11631484dc582796d823239d2f46ce6b3 (diff) | |
download | pdf-over-c598f60380077e4e156f3ad4424eb42ec8aa0f28.tar.gz pdf-over-c598f60380077e4e156f3ad4424eb42ec8aa0f28.tar.bz2 pdf-over-c598f60380077e4e156f3ad4424eb42ec8aa0f28.zip |
YAGNI cleanup #1
Diffstat (limited to 'pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku')
5 files changed, 30 insertions, 38 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 a3b70d00..4ea96f04 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 @@ -58,7 +58,7 @@ public class MobileBKUConnector implements BkuSlConnector { PdfAs4SigningState signingState = (PdfAs4SigningState) this.state.getSigningState();
signingState.setSignatureRequest(request);
- MobileBKUHandler handler = this.state.getHandler();
+ MobileBKUHandler handler = this.state.handler;
do {
// Post SL Request
@@ -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.getStatus().getErrorMessage() != null &&
- this.state.getStatus().getErrorMessage().equals("cancel")) //$NON-NLS-1$
+ if (this.state.status.getErrorMessage() != null &&
+ this.state.status.getErrorMessage().equals("cancel")) //$NON-NLS-1$
throw new SignatureException(new IllegalStateException());
// Post credentials
@@ -92,7 +92,7 @@ public class MobileBKUConnector implements BkuSlConnector { // handle polling
this.state.showOpenAppMessageWithSMSandCancel();
- if (((ATrustStatus) this.state.getStatus()).isSmsTan()) {
+ if (((ATrustStatus) this.state.status).isSmsTan()) {
ATrustHandler aHandler = (ATrustHandler) handler;
String response = aHandler.postSMSRequest();
aHandler.handleCredentialsResponse(response);
@@ -111,7 +111,7 @@ public class MobileBKUConnector implements BkuSlConnector { this.state.setThreadException(new IllegalStateException());
throw new SignatureException(new IllegalStateException());
}
- } while(this.state.getStatus().getErrorMessage() != null);
+ } while(this.state.status.getErrorMessage() != null);
// Check if response is already available
if (signingState.hasSignatureResponse()) {
@@ -121,18 +121,18 @@ public class MobileBKUConnector implements BkuSlConnector { }
do {
- MobileBKUStatus status = this.state.getStatus();
+ MobileBKUStatus status = this.state.status;
boolean enterTAN = true;
String responseData = null;
if (status instanceof ATrustStatus) {
ATrustStatus aStatus = (ATrustStatus) status;
ATrustHandler aHandler = (ATrustHandler) handler;
- if (aStatus.getQRCode() != null) {
+ if (aStatus.getQRCodeURL() != null) {
this.state.showQR();
- if (this.state.getStatus().getErrorMessage() != null &&
- this.state.getStatus().getErrorMessage().equals("cancel")) //$NON-NLS-1$
+ if (this.state.status.getErrorMessage() != null &&
+ this.state.status.getErrorMessage().equals("cancel")) //$NON-NLS-1$
throw new SignatureException(new IllegalStateException());
- if (aStatus.getQRCode() == null) {
+ if (aStatus.getQRCodeURL() == null) {
try {
String response = aHandler.postSMSRequest();
log.trace("Response from mobile BKU: " + response); //$NON-NLS-1$
@@ -150,8 +150,8 @@ public class MobileBKUConnector implements BkuSlConnector { try {
this.state.showFingerPrintInformation();
- if (this.state.getStatus().getErrorMessage() != null &&
- this.state.getStatus().getErrorMessage().equals("cancel")) //$NON-NLS-1$
+ if (this.state.status.getErrorMessage() != null &&
+ this.state.status.getErrorMessage().equals("cancel")) //$NON-NLS-1$
throw new SignatureException(new IllegalStateException());
} catch (Exception ex) {
log.error("Error in PostCredentialsThread", ex); //$NON-NLS-1$
@@ -183,8 +183,8 @@ public class MobileBKUConnector implements BkuSlConnector { this.state.checkTAN();
- if (this.state.getStatus().getErrorMessage() != null &&
- this.state.getStatus().getErrorMessage().equals("cancel")) //$NON-NLS-1$
+ if (this.state.status.getErrorMessage() != null &&
+ this.state.status.getErrorMessage().equals("cancel")) //$NON-NLS-1$
throw new SignatureException(new IllegalStateException());
// Post TAN
@@ -201,21 +201,21 @@ public class MobileBKUConnector implements BkuSlConnector { throw new SignatureException(ex);
}
}
- } while (this.state.getStatus().getErrorMessage() != null);
- if (this.state.getStatus().getTanTries() == -1)
+ } while (this.state.status.getErrorMessage() != null);
+ if (this.state.status.getTanTries() == -1)
throw new SignatureException(new IllegalStateException());
- } while (this.state.getStatus().getTanTries() == -2);
+ } while (this.state.status.getTanTries() == -2);
return signingState.getSignatureResponse();
}
private boolean handleErrorMessage() {
- if (this.state.getStatus() instanceof ATrustStatus) {
- ATrustStatus aStatus = (ATrustStatus)this.state.getStatus() ;
+ 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.getStatus()).setErrorMessage(null);
+ ((ATrustStatus)this.state.status).setErrorMessage(null);
return true;
}
}
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 05168d61..d5353b3e 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 @@ -247,7 +247,7 @@ public class ATrustHandler extends MobileBKUHandler { try {
qrCode = MobileBKUHelper.extractValueFromTagWithParam(responseData, "img", "class", "qrcode", "src"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
log.debug("QR Code found: " + qrCode); //$NON-NLS-1$
- status.setQRCode(qrCode);
+ status.setQRCodeURL(qrCode);
} catch (Exception e) {
log.debug("No QR Code found"); //$NON-NLS-1$
}
@@ -406,7 +406,7 @@ public class ATrustHandler extends MobileBKUHandler { HttpClient client = MobileBKUHelper.getHttpClient(getStatus());
GetMethod get = new GetMethod(status.getBaseURL() + "/" + //$NON-NLS-1$
- status.getQRCode());
+ status.getQRCodeURL());
try {
log.debug("Getting " + get.getURI()); //$NON-NLS-1$
@@ -478,7 +478,7 @@ public class ATrustHandler extends MobileBKUHandler { @Override
public ATrustStatus getStatus() {
- return (ATrustStatus) getState().getStatus();
+ return (ATrustStatus) state.status;
}
/* (non-Javadoc)
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/ATrustStatus.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/ATrustStatus.java index fe91dfa9..9994d522 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/ATrustStatus.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/ATrustStatus.java @@ -112,7 +112,7 @@ public class ATrustStatus extends AbstractMobileBKUStatusImpl { /**
* @return the QR code
*/
- public String getQRCode() {
+ public String getQRCodeURL() {
return this.qrcode;
}
@@ -120,7 +120,7 @@ public class ATrustStatus extends AbstractMobileBKUStatusImpl { * @param qrcode
* the QR code to set
*/
- public void setQRCode(String qrcode) {
+ public void setQRCodeURL(String qrcode) {
this.qrcode = qrcode;
}
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 1d0ec579..ec1c7c66 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 @@ -336,7 +336,7 @@ public class IAIKHandler extends MobileBKUHandler { @Override
public IAIKStatus getStatus() {
- return (IAIKStatus) getState().getStatus();
+ return (IAIKStatus) state.status;
}
private String getRedirect(HttpClient client, String redirectURL) throws HttpException, IOException {
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 4c09c02d..1ada0337 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 @@ -51,7 +51,7 @@ public abstract class MobileBKUHandler { static final Logger log = LoggerFactory
.getLogger(MobileBKUHandler.class);
- private MobileBKUState state;
+ public final MobileBKUState state;
/**
* Constructor
@@ -99,7 +99,7 @@ public abstract class MobileBKUHandler { }
log.trace("SL Request: " + sl_request); //$NON-NLS-1$
- getState().getStatus().setBaseURL(
+ state.status.setBaseURL(
MobileBKUHelper.stripQueryString(mobileBKUUrl));
return executePost(client, post);
@@ -142,19 +142,11 @@ public abstract class MobileBKUHandler { public abstract void handleTANResponse(String responseData) throws Exception;
/**
- * Get the MobileBKUState
- * @return the MobileBKUState
- */
- protected MobileBKUState getState() {
- return this.state;
- }
-
- /**
* Get the MobileBKUStatus
* @return the MobileBKUStatus
*/
protected MobileBKUStatus getStatus() {
- return this.state.getStatus();
+ return this.state.status;
}
/**
@@ -162,7 +154,7 @@ public abstract class MobileBKUHandler { * @return the SigningState
*/
protected SigningState getSigningState() {
- return getState().getSigningState();
+ return state.getSigningState();
}
/**
|