diff options
Diffstat (limited to 'pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku')
4 files changed, 24 insertions, 51 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 f862455c..eb1b57d6 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 @@ -47,9 +47,6 @@ public class LocalBKUConnector implements BkuSlConnector { private static final Logger log = LoggerFactory
.getLogger(LocalBKUConnector.class);
- /** Whether to use Base64 or FileUpload Request */
- private boolean useBase64Request = false;
-
/**
* HTTP Response server HEADER
*/
@@ -65,12 +62,6 @@ public class LocalBKUConnector implements BkuSlConnector { */
public final static String BKU_RESPONSE_HEADER_SIGNATURE_LAYOUT = "SignatureLayout"; //$NON-NLS-1$
- /**
- * Null-Operation SL-Request
- */
- private final static String NULL_OPERATION_REQUEST = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + //$NON-NLS-1$
- "<sl:NullOperationRequest xmlns:sl=\"http://www.buergerkarte.at/namespaces/securitylayer/1.2#\"/>"; //$NON-NLS-1$
-
/* (non-Javadoc)
* @see at.asit.pdfover.signator.BkuSlConnector#handleSLRequest(java.lang.String)
*/
@@ -78,54 +69,36 @@ public class LocalBKUConnector implements BkuSlConnector { public SLResponse handleSLRequest(SLRequest request) throws SignatureException {
try {
HttpClient client = BKUHelper.getHttpClient();
-
PostMethod method = new PostMethod(Constants.LOCAL_BKU_URL);
- String sl_request = NULL_OPERATION_REQUEST;
- method.addParameter("XMLRequest", sl_request); //$NON-NLS-1$
- int returnCode = client.executeMethod(method);
-
- String userAgent = getResponseHeader(method, BKU_RESPONSE_HEADER_USERAGENT);
- String server = getResponseHeader(method, BKU_RESPONSE_HEADER_SERVER);
- if (server != null && server.contains("trustDeskbasic")) //$NON-NLS-1$
- this.useBase64Request = true; // TDB doesn't support MultiPart requests
-
- method = new PostMethod(Constants.LOCAL_BKU_URL);
-
- if (request.getSignatureData() != null) {
- if (this.useBase64Request)
- {
- sl_request = request.getBase64Request();
- method.addParameter("XMLRequest", sl_request); //$NON-NLS-1$
- } else {
- sl_request = request.getFileUploadRequest();
- StringPart xmlpart = new StringPart(
- "XMLRequest", sl_request, "UTF-8"); //$NON-NLS-1$ //$NON-NLS-2$
-
- FilePart filepart = new FilePart("fileupload", //$NON-NLS-1$
- new FileUploadSource(request.getSignatureData()));
-
- Part[] parts = { xmlpart, filepart };
-
- method.setRequestEntity(new MultipartRequestEntity(parts, method
- .getParams()));
- }
+ String sl_request = request.getRequest();
+ if (request.getSignatureData() == null) {
+ method.addParameter("XMLRequest", sl_request); //$NON-NLS-1$
} else {
- method.addParameter("XMLRequest", request.getRequest()); //$NON-NLS-1$
+ StringPart xmlpart = new StringPart(
+ "XMLRequest", sl_request, "UTF-8"); //$NON-NLS-1$ //$NON-NLS-2$
+
+ FilePart filepart = new FilePart("fileupload", //$NON-NLS-1$
+ new FileUploadSource(request.getSignatureData()));
+
+ Part[] parts = { xmlpart, filepart };
+
+ method.setRequestEntity(new MultipartRequestEntity(parts, method
+ .getParams()));
}
- log.debug("SL REQUEST: " + sl_request); //$NON-NLS-1$
+ log.trace("SL REQUEST: " + sl_request); //$NON-NLS-1$
- returnCode = client.executeMethod(method);
+ int returnCode = client.executeMethod(method);
if (returnCode != HttpStatus.SC_OK) {
throw new HttpException(
method.getResponseBodyAsString());
}
- server = getResponseHeader(method, BKU_RESPONSE_HEADER_SERVER);
+ String server = getResponseHeader(method, BKU_RESPONSE_HEADER_SERVER);
if (server == null)
server = ""; //$NON-NLS-1$
- userAgent = getResponseHeader(method, BKU_RESPONSE_HEADER_USERAGENT);
+ String userAgent = getResponseHeader(method, BKU_RESPONSE_HEADER_USERAGENT);
if (userAgent == null)
userAgent = ""; //$NON-NLS-1$
String signatureLayout = getResponseHeader(method, BKU_RESPONSE_HEADER_SIGNATURE_LAYOUT);
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 7112bd94..12eff95b 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 @@ -239,7 +239,7 @@ public class ATrustHandler extends MobileBKUHandler { * @see at.asit.pdfover.gui.bku.mobile.MobileBKUHandler#useBase64Request() */ @Override - protected boolean useBase64Request() { + public boolean useBase64Request() { return false; } } 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 04338f8b..0904f045 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 @@ -306,7 +306,7 @@ public class IAIKHandler extends MobileBKUHandler { * @see at.asit.pdfover.gui.bku.mobile.MobileBKUHandler#useBase64Request() */ @Override - protected boolean useBase64Request() { + public boolean useBase64Request() { return false; } } 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 4644002e..429000f1 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 @@ -75,17 +75,17 @@ public abstract class MobileBKUHandler { PostMethod post = new PostMethod(mobileBKUUrl); String sl_request; if (request.getSignatureData() != null) { + sl_request = request.getRequest(); if (useBase64Request()) { - sl_request = request.getBase64Request(); post.addParameter("XMLRequest", sl_request); //$NON-NLS-1$ } else { - sl_request = request.getFileUploadRequest(); StringPart xmlpart = new StringPart( "XMLRequest", sl_request, "UTF-8"); //$NON-NLS-1$ //$NON-NLS-2$ - FilePart filepart = new FilePart("fileupload", //$NON-NLS-1$ - new FileUploadSource(request.getSignatureData())); + FilePart filepart = new FilePart("fileupload", //$NON-NLS-1$ + new FileUploadSource(request.getSignatureData()), + "application/pdf", "UTF-8"); //$NON-NLS-1$ //$NON-NLS-2$ Part[] parts = { xmlpart, filepart }; @@ -168,7 +168,7 @@ public abstract class MobileBKUHandler { * Whether to use a Base64 request * @return true if base64 request shall be used */ - protected abstract boolean useBase64Request(); + public abstract boolean useBase64Request(); /** * Execute a post to the mobile BKU, following redirects |