From bc912e9c3c790f5c5c92c7732d0662dbecd251e2 Mon Sep 17 00:00:00 2001 From: tkellner Date: Wed, 10 Apr 2013 19:41:33 +0000 Subject: Make upload request type configurable git-svn-id: https://joinup.ec.europa.eu/svn/pdf-over/trunk@451 174cde9d-5d70-4d2a-aa98-46368bc2aaf7 --- .../pdfover/gui/workflow/states/LocalBKUState.java | 35 +++++++++++++--------- 1 file changed, 21 insertions(+), 14 deletions(-) (limited to 'pdf-over-gui/src/main') 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 54c24abc..31cf1e06 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 @@ -64,6 +64,11 @@ public class LocalBKUState extends State { */ public static final String PDF_OVER_USER_AGENT_STRING = "PDF-Over 4.0"; //$NON-NLS-1$ + /** + * Whether to use Base64 or FileUpload Request + */ + public static final boolean USE_BASE64_REQUEST = true; + /** * */ @@ -84,28 +89,30 @@ public class LocalBKUState extends State { SLRequest request = this.state.signingState .getSignatureRequest(); - String sl_request = request.getBase64Request(); - //String sl_request = request.getFileUploadRequest(); - HttpClient client = new HttpClient(); PostMethod method = new PostMethod( "http://127.0.0.1:3495/http-security-layer-request"); //$NON-NLS-1$ - StringPart xmlpart = new StringPart( - "XMLRequest", sl_request, "UTF-8"); //$NON-NLS-1$ //$NON-NLS-2$ + String sl_request = null; + if (USE_BASE64_REQUEST) + { + 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())); + 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$ + Part[] parts = { xmlpart, filepart }; - method.addParameter("XMLRequest", sl_request); //$NON-NLS-1$ + method.setRequestEntity(new MultipartRequestEntity(parts, method + .getParams())); + } + //log.debug("SL REQUEST: " + sl_request); //$NON-NLS-1$ int returnCode = client.executeMethod(method); -- cgit v1.2.3