From 7b6860087f50b7576c31f7aa50714d3fa7a9b228 Mon Sep 17 00:00:00 2001 From: Tobias Kellner Date: Mon, 23 Feb 2015 15:29:35 +0100 Subject: BASE64 request handling --- .../java/at/asit/pdfover/signator/SLRequest.java | 59 ---------------------- .../at/asit/pdfover/signator/SigningState.java | 8 ++- 2 files changed, 7 insertions(+), 60 deletions(-) (limited to 'pdf-over-signator') diff --git a/pdf-over-signator/src/main/java/at/asit/pdfover/signator/SLRequest.java b/pdf-over-signator/src/main/java/at/asit/pdfover/signator/SLRequest.java index 9edd0a02..5fd9c756 100644 --- a/pdf-over-signator/src/main/java/at/asit/pdfover/signator/SLRequest.java +++ b/pdf-over-signator/src/main/java/at/asit/pdfover/signator/SLRequest.java @@ -15,18 +15,11 @@ */ package at.asit.pdfover.signator; -import org.apache.commons.codec.binary.Base64; - /** * Security Layer Request */ public class SLRequest { - /** - * The String constant to replace the SL DATAOBJECT - */ - public static final String DATAOBJECT_STRING = "##DATAOBJECT##"; - /** * The security layer request */ @@ -39,64 +32,12 @@ public class SLRequest { /** * Set the SL request - * The data object should contain the placeholder DATAOBJECT_STRING * @param request the request to set */ protected void setRequest(String request) { this.request = request; } - /** - * The SL request String with the document encoded in base64 - * - * This SL Request is always a detached signature request which contains a - * reference to the data object in base64 encoding. - * - * @return SL request String - */ - public String getBase64Request() { - String b64content = new String(Base64.encodeBase64(getSignatureData().getByteArray())); - - String b64request = this.request.replace( - DATAOBJECT_STRING, - "" + b64content //$NON-NLS-1$ - + ""); //$NON-NLS-1$ - - return b64request; - } - - /** - * The SL request String with the document defined as file upload - * @return SL request String - */ - public String getFileUploadRequest() { - String fileUploadRequest = this.request.replace( - DATAOBJECT_STRING, - "formdata:fileupload"); //$NON-NLS-1$ - - return fileUploadRequest; - } - - /** - * The SL request String with the document referenced as an URI - * - * This SL Request is always a detached signature request which contains a - * reference to the data object as an URI - * The URI has to be provided and should be a valid reference to - * the document provided by getSignatureData(). - * - * @param uri The URI pointing to the signature data - * @return SL request String - */ - public String getURIRequest(String uri) { - String urirequest = this.request.replace( - DATAOBJECT_STRING, - "" + uri //$NON-NLS-1$ - + ""); //$NON-NLS-1$ - - return urirequest; - } - /** * Set the signature data (document to be signed) * @param signatureData the signatureData to set diff --git a/pdf-over-signator/src/main/java/at/asit/pdfover/signator/SigningState.java b/pdf-over-signator/src/main/java/at/asit/pdfover/signator/SigningState.java index b86e356c..f624e5b4 100644 --- a/pdf-over-signator/src/main/java/at/asit/pdfover/signator/SigningState.java +++ b/pdf-over-signator/src/main/java/at/asit/pdfover/signator/SigningState.java @@ -26,12 +26,18 @@ public interface SigningState { */ public SLRequest getSignatureRequest(); + /** + * Sets whether to use base64 (or FileUpload) for request data + * @param useBase64Request whether to use base64 for request data + */ + public void setUseBase64Request(boolean useBase64Request); + /** * Sets the Security Layer Response to the Signature Request * @param value The Signature Response */ public void setSignatureResponse(SLResponse value); - + /** * Has the state a SignatureResponse set ? * @return true if a SLResponse is set -- cgit v1.2.3