summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakob Heher <jakob.heher@iaik.tugraz.at>2022-09-30 13:51:08 +0200
committerJakob Heher <jakob.heher@iaik.tugraz.at>2022-09-30 13:51:08 +0200
commit529e08cd21115834dc9887305a8d199ea83638d2 (patch)
tree28c2ad696a9bf49d194216a7df1e1c2ca7258b0f
parent5a8c5930033509d66010069bd7cdfc6458c30050 (diff)
downloadpdf-over-529e08cd21115834dc9887305a8d199ea83638d2.tar.gz
pdf-over-529e08cd21115834dc9887305a8d199ea83638d2.tar.bz2
pdf-over-529e08cd21115834dc9887305a8d199ea83638d2.zip
get rid of unneeded fields in SLResponse
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/LocalBKUConnector.java24
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/ATrustHandler.java8
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/LocalBKUState.java24
-rw-r--r--pdf-over-signator/src/main/java/at/asit/pdfover/signator/SLResponse.java33
-rw-r--r--pdf-over-signer/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4BKUSLConnector.java5
5 files changed, 15 insertions, 79 deletions
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) {
diff --git a/pdf-over-signator/src/main/java/at/asit/pdfover/signator/SLResponse.java b/pdf-over-signator/src/main/java/at/asit/pdfover/signator/SLResponse.java
index 78c140b5..83e479ad 100644
--- a/pdf-over-signator/src/main/java/at/asit/pdfover/signator/SLResponse.java
+++ b/pdf-over-signator/src/main/java/at/asit/pdfover/signator/SLResponse.java
@@ -31,34 +31,6 @@ public class SLResponse {
private static Logger log = LoggerFactory.getLogger(SLResponse.class);
private String response;
- private String server;
-
- /**
- * Gets the server string
- * @return the server
- */
- public String getServer() {
- return this.server;
- }
-
- /**
- * Gets the user Agent string
- * @return the user Agent
- */
- public String getUserAgent() {
- return this.userAgent;
- }
-
- /**
- * Gets the signature Layout value
- * @return the signature Layout
- */
- public String getSignaturLayout() {
- return this.signaturLayout;
- }
-
- private String userAgent;
- private String signaturLayout;
/**
* Create a new Security Layer response
@@ -67,11 +39,8 @@ public class SLResponse {
* @param userAgent the user Agent
* @param signaturLayout the signature Layout
*/
- public SLResponse(String response, String server, String userAgent, String signaturLayout) {
+ public SLResponse(String response) {
this.response = response;
- this.server = server;
- this.userAgent = userAgent;
- this.signaturLayout = signaturLayout;
}
/**
diff --git a/pdf-over-signer/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4BKUSLConnector.java b/pdf-over-signer/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4BKUSLConnector.java
index a78e33c6..df094718 100644
--- a/pdf-over-signer/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4BKUSLConnector.java
+++ b/pdf-over-signer/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4BKUSLConnector.java
@@ -79,6 +79,11 @@ public class PdfAs4BKUSLConnector extends BaseSLConnector {
} catch (PdfAs4SLRequestException e) {
throw new PDFIOException("error.pdf.io.03", e);
} catch (SignatureException e) {
+ Throwable e2 = e;
+ while (e2.getCause() != null)
+ e2 = e2.getCause();
+ /*if (e2 instanceof IllegalStateException) // user cancelled (TODO: this is a pretty big hack honestly)
+ return null;*/
throw new PDFIOException("error.pdf.io.03", e);
}