summaryrefslogtreecommitdiff
path: root/pdf-over-gui/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'pdf-over-gui/src/main/java')
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/LocalBKUState.java25
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/mobilebku/MobileBKUHandler.java37
2 files changed, 22 insertions, 40 deletions
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 908ed244..68dd60bb 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
@@ -20,14 +20,19 @@ import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpException;
import org.apache.commons.httpclient.HttpStatus;
import org.apache.commons.httpclient.methods.PostMethod;
+import org.apache.commons.httpclient.methods.multipart.FilePart;
+import org.apache.commons.httpclient.methods.multipart.MultipartRequestEntity;
+import org.apache.commons.httpclient.methods.multipart.Part;
+import org.apache.commons.httpclient.methods.multipart.StringPart;
import org.eclipse.swt.SWT;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import at.asit.pdfover.gui.MainWindow.Buttons;
import at.asit.pdfover.gui.MainWindowBehavior;
-import at.asit.pdfover.gui.controls.ErrorDialog;
import at.asit.pdfover.gui.controls.Dialog.BUTTONS;
+import at.asit.pdfover.gui.controls.ErrorDialog;
+import at.asit.pdfover.gui.utils.FileUploadSource;
import at.asit.pdfover.gui.utils.Messages;
import at.asit.pdfover.gui.workflow.StateMachine;
import at.asit.pdfover.gui.workflow.Status;
@@ -79,16 +84,28 @@ public class LocalBKUState extends State {
SLRequest request = this.state.signingState
.getSignatureRequest();
- String sl_request = request.getBase64Request();
+ //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$
- log.debug("SL REQUEST: " + sl_request); //$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$
- method.addParameter("XMLRequest", sl_request); //$NON-NLS-1$
+ //method.addParameter("XMLRequest", sl_request); //$NON-NLS-1$
int returnCode = client.executeMethod(method);
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/mobilebku/MobileBKUHandler.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/mobilebku/MobileBKUHandler.java
index 29f702e9..d82585db 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/mobilebku/MobileBKUHandler.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/mobilebku/MobileBKUHandler.java
@@ -17,7 +17,6 @@ package at.asit.pdfover.gui.workflow.states.mobilebku;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
-import java.io.InputStream;
import org.apache.commons.httpclient.Header;
import org.apache.commons.httpclient.HttpClient;
@@ -28,15 +27,14 @@ import org.apache.commons.httpclient.methods.PostMethod;
import org.apache.commons.httpclient.methods.multipart.FilePart;
import org.apache.commons.httpclient.methods.multipart.MultipartRequestEntity;
import org.apache.commons.httpclient.methods.multipart.Part;
-import org.apache.commons.httpclient.methods.multipart.PartSource;
import org.apache.commons.httpclient.methods.multipart.StringPart;
import org.apache.commons.httpclient.protocol.Protocol;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import at.asit.pdfover.gui.utils.FileUploadSource;
import at.asit.pdfover.gui.workflow.states.LocalBKUState;
import at.asit.pdfover.gui.workflow.states.MobileBKUState;
-import at.asit.pdfover.signator.DocumentSource;
import at.asit.pdfover.signator.SLRequest;
import at.asit.pdfover.signator.SigningState;
@@ -53,39 +51,6 @@ public abstract class MobileBKUHandler {
private MobileBKUState state;
/**
- * A FileUploadSource
- */
- private final class FileUploadSource implements PartSource {
-
- private DocumentSource source;
-
- /**
- * Constructor
- *
- * @param source
- * the source
- */
- public FileUploadSource(DocumentSource source) {
- this.source = source;
- }
-
- @Override
- public long getLength() {
- return this.source.getLength();
- }
-
- @Override
- public String getFileName() {
- return "sign.pdf"; //$NON-NLS-1$
- }
-
- @Override
- public InputStream createInputStream() throws IOException {
- return this.source.getInputStream();
- }
- }
-
- /**
* Constructor
* @param state the MobileBKUState
*/