From 529e08cd21115834dc9887305a8d199ea83638d2 Mon Sep 17 00:00:00 2001 From: Jakob Heher Date: Fri, 30 Sep 2022 13:51:08 +0200 Subject: get rid of unneeded fields in SLResponse --- .../at/asit/pdfover/gui/bku/LocalBKUConnector.java | 24 +--------------------- .../asit/pdfover/gui/bku/mobile/ATrustHandler.java | 8 ++++---- .../pdfover/gui/workflow/states/LocalBKUState.java | 24 ++++------------------ 3 files changed, 9 insertions(+), 47 deletions(-) (limited to 'pdf-over-gui') diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/LocalBKUConnector.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/LocalBKUConnector.java index 7967fe0e..f91924ad 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/LocalBKUConnector.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/LocalBKUConnector.java @@ -21,7 +21,6 @@ import java.io.IOException; import org.apache.commons.httpclient.HttpClient; import org.apache.commons.httpclient.HttpException; -import org.apache.commons.httpclient.HttpMethod; import org.apache.commons.httpclient.HttpStatus; import org.apache.commons.httpclient.methods.PostMethod; import org.apache.commons.httpclient.methods.multipart.FilePart; @@ -95,18 +94,9 @@ public class LocalBKUConnector implements BkuSlConnector { method.getResponseBodyAsString()); } - String server = getResponseHeader(method, BKU_RESPONSE_HEADER_SERVER); - if (server == null) - server = ""; - String userAgent = getResponseHeader(method, BKU_RESPONSE_HEADER_USERAGENT); - if (userAgent == null) - userAgent = ""; - String signatureLayout = getResponseHeader(method, BKU_RESPONSE_HEADER_SIGNATURE_LAYOUT); - String response = method.getResponseBodyAsString(); log.debug("SL Response: " + response); - SLResponse slResponse = new SLResponse(response, server, - userAgent, signatureLayout); + SLResponse slResponse = new SLResponse(response); return slResponse; } catch (HttpException e) { log.error("LocalBKUConnector: ", e); @@ -116,16 +106,4 @@ public class LocalBKUConnector implements BkuSlConnector { throw new SignatureException(e); } } - - /** - * Returns the value corresponding to the given header name - * @param method the HTTP method - * @param headerName the header name - * @return the header value (or null if not found) - */ - private static String getResponseHeader(HttpMethod method, String headerName) { - if (method.getResponseHeader(headerName) == null) - return null; - return method.getResponseHeader(headerName).getValue(); - } } 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 fb1a5c11..867bdfd6 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 @@ -512,12 +512,12 @@ public class ATrustHandler { // credentials ok! InfoboxReadResponse state.rememberCredentialsIfNecessary(); log.debug("Credentials accepted - Response given"); - getSigningState().signatureResponse = new SLResponse(responseData, getStatus().server, null, null); + getSigningState().signatureResponse = new SLResponse(responseData); return; } else if (responseData.contains("undecided.aspx?sid=")) { // skip intermediate page log.debug("Page Undecided"); - getSigningState().signatureResponse = new SLResponse(responseData, getStatus().server, null, null); + getSigningState().signatureResponse = new SLResponse(responseData); status.errorMessage = "waiting..."; return; }else { @@ -591,7 +591,7 @@ public class ATrustHandler { responseData.contains("sl:CreateCMSSignatureResponse xmlns:sl")) { // success !! - getSigningState().signatureResponse = new SLResponse(responseData, getStatus().server, null, null); + getSigningState().signatureResponse = new SLResponse(responseData); } else { try { String tries = MobileBKUHelper.extractSubstring( @@ -701,7 +701,7 @@ public class ATrustHandler { responseData.contains("sl:CreateCMSSignatureResponse xmlns:sl")) { // success !! - getSigningState().signatureResponse = new SLResponse(responseData, getStatus().server, null, null); + getSigningState().signatureResponse = new SLResponse(responseData); return true; } return false; diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/LocalBKUState.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/LocalBKUState.java index 6e3922dc..59274567 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/LocalBKUState.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/LocalBKUState.java @@ -112,32 +112,16 @@ public class LocalBKUState extends State { method.addParameter("XMLRequest", sl_request); int returnCode = client.executeMethod(method); - String userAgent = getResponseHeader(method, BKU_RESPONSE_HEADER_USERAGENT); - String server = getResponseHeader(method, BKU_RESPONSE_HEADER_SERVER); - if (returnCode != HttpStatus.SC_OK) { this.state.threadException = new HttpException( method.getResponseBodyAsString()); } else { - server = getResponseHeader(method, BKU_RESPONSE_HEADER_SERVER); - if (server == null) - server = ""; - else - if (server.contains("trustDeskbasic") || server.contains("asignSecurityLayer")) - LocalBKUState.this.useBase64Request = true; - - userAgent = getResponseHeader(method, BKU_RESPONSE_HEADER_USERAGENT); - if (userAgent == null) - userAgent = ""; - String signatureLayout = getResponseHeader(method, BKU_RESPONSE_HEADER_SIGNATURE_LAYOUT); - - log.debug("Server - UA: " + server + " - " + userAgent); + String server = getResponseHeader(method, BKU_RESPONSE_HEADER_SERVER); + if ((server != null) && (server.contains("trustDeskbasic") || server.contains("asignSecurityLayer"))) + LocalBKUState.this.useBase64Request = true; String response = method.getResponseBodyAsString(); - log.debug("SL Response: " + response); - SLResponse slResponse = new SLResponse(response, server, - userAgent, signatureLayout); - this.signingState.signatureResponse = slResponse; + this.signingState.signatureResponse = new SLResponse(response); this.signingState.useBase64Request = LocalBKUState.this.useBase64Request; } } catch (Exception e) { -- cgit v1.2.3