aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pdf-as-common/src/main/java/at/gv/egiz/pdfas/api/ws/PDFASSignRequest.java44
-rw-r--r--pdf-as-common/src/main/java/at/gv/egiz/pdfas/api/ws/PDFASSignResponse.java41
-rw-r--r--pdf-as-common/src/main/java/at/gv/egiz/pdfas/api/ws/PDFASSigning.java6
-rw-r--r--pdf-as-web-client/src/main/java/at/gv/egiz/pdfas/web/client/RemotePDFSigner.java10
-rw-r--r--pdf-as-web-client/src/test/java/at/gv/egiz/pdfas/web/client/test/SimpleTest.java72
-rw-r--r--pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/ws/PDFASSigningImpl.java39
6 files changed, 202 insertions, 10 deletions
diff --git a/pdf-as-common/src/main/java/at/gv/egiz/pdfas/api/ws/PDFASSignRequest.java b/pdf-as-common/src/main/java/at/gv/egiz/pdfas/api/ws/PDFASSignRequest.java
new file mode 100644
index 00000000..c875171d
--- /dev/null
+++ b/pdf-as-common/src/main/java/at/gv/egiz/pdfas/api/ws/PDFASSignRequest.java
@@ -0,0 +1,44 @@
+package at.gv.egiz.pdfas.api.ws;
+
+import java.io.Serializable;
+
+import javax.xml.bind.annotation.XmlElement;
+
+public class PDFASSignRequest implements Serializable {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -5572093903422676582L;
+
+ String requestID;
+ byte[] inputData;
+ PDFASSignParameters parameters;
+
+ @XmlElement(required = true, nillable = false)
+ public String getRequestID() {
+ return requestID;
+ }
+
+ public void setRequestID(String requestID) {
+ this.requestID = requestID;
+ }
+
+ @XmlElement(required = true, nillable = false)
+ public byte[] getInputData() {
+ return inputData;
+ }
+
+ public void setInputData(byte[] inputData) {
+ this.inputData = inputData;
+ }
+
+ @XmlElement(required = true, nillable = false)
+ public PDFASSignParameters getParameters() {
+ return parameters;
+ }
+
+ public void setParameters(PDFASSignParameters parameters) {
+ this.parameters = parameters;
+ }
+}
diff --git a/pdf-as-common/src/main/java/at/gv/egiz/pdfas/api/ws/PDFASSignResponse.java b/pdf-as-common/src/main/java/at/gv/egiz/pdfas/api/ws/PDFASSignResponse.java
new file mode 100644
index 00000000..a27d1afe
--- /dev/null
+++ b/pdf-as-common/src/main/java/at/gv/egiz/pdfas/api/ws/PDFASSignResponse.java
@@ -0,0 +1,41 @@
+package at.gv.egiz.pdfas.api.ws;
+
+import java.io.Serializable;
+
+import javax.xml.bind.annotation.XmlElement;
+
+public class PDFASSignResponse implements Serializable {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -6369697640117556071L;
+
+ String requestID;
+ String error;
+ byte[] signedPDF;
+
+ @XmlElement(required = true, nillable = false)
+ public String getRequestID() {
+ return requestID;
+ }
+ public void setRequestID(String requestID) {
+ this.requestID = requestID;
+ }
+
+ @XmlElement(required = false, nillable = false)
+ public byte[] getSignedPDF() {
+ return signedPDF;
+ }
+ public void setSignedPDF(byte[] signedPDF) {
+ this.signedPDF = signedPDF;
+ }
+
+ @XmlElement(required = false)
+ public String getError() {
+ return error;
+ }
+ public void setError(String error) {
+ this.error = error;
+ }
+}
diff --git a/pdf-as-common/src/main/java/at/gv/egiz/pdfas/api/ws/PDFASSigning.java b/pdf-as-common/src/main/java/at/gv/egiz/pdfas/api/ws/PDFASSigning.java
index aa37cf69..5d283cf7 100644
--- a/pdf-as-common/src/main/java/at/gv/egiz/pdfas/api/ws/PDFASSigning.java
+++ b/pdf-as-common/src/main/java/at/gv/egiz/pdfas/api/ws/PDFASSigning.java
@@ -11,4 +11,10 @@ import javax.jws.soap.SOAPBinding.Style;
public interface PDFASSigning {
@WebMethod(operationName = "sign")
public byte[] signPDFDokument(@WebParam(name = "pdfDocument")byte[] inputDocument, @WebParam(name = "parameters")PDFASSignParameters parameters);
+
+ @WebMethod(operationName = "signSingle")
+ public PDFASSignResponse signPDFDokument(@WebParam(name = "signRequest") PDFASSignRequest request);
+
+ @WebMethod(operationName = "signBulk")
+ public PDFASSignResponse[] signPDFDokument(@WebParam(name = "signRequests") PDFASSignRequest[] request);
}
diff --git a/pdf-as-web-client/src/main/java/at/gv/egiz/pdfas/web/client/RemotePDFSigner.java b/pdf-as-web-client/src/main/java/at/gv/egiz/pdfas/web/client/RemotePDFSigner.java
index 9e80faf5..0a019152 100644
--- a/pdf-as-web-client/src/main/java/at/gv/egiz/pdfas/web/client/RemotePDFSigner.java
+++ b/pdf-as-web-client/src/main/java/at/gv/egiz/pdfas/web/client/RemotePDFSigner.java
@@ -8,6 +8,8 @@ import javax.xml.ws.Service;
import javax.xml.ws.soap.SOAPBinding;
import at.gv.egiz.pdfas.api.ws.PDFASSignParameters;
+import at.gv.egiz.pdfas.api.ws.PDFASSignRequest;
+import at.gv.egiz.pdfas.api.ws.PDFASSignResponse;
import at.gv.egiz.pdfas.api.ws.PDFASSigning;
public class RemotePDFSigner implements PDFASSigning {
@@ -35,4 +37,12 @@ public class RemotePDFSigner implements PDFASSigning {
return proxy.signPDFDokument(inputDocument, parameters);
}
+ public PDFASSignResponse signPDFDokument(PDFASSignRequest request) {
+ return proxy.signPDFDokument(request);
+ }
+
+ public PDFASSignResponse[] signPDFDokument(PDFASSignRequest[] request) {
+ return proxy.signPDFDokument(request);
+ }
+
}
diff --git a/pdf-as-web-client/src/test/java/at/gv/egiz/pdfas/web/client/test/SimpleTest.java b/pdf-as-web-client/src/test/java/at/gv/egiz/pdfas/web/client/test/SimpleTest.java
index 954d0e2e..aa672701 100644
--- a/pdf-as-web-client/src/test/java/at/gv/egiz/pdfas/web/client/test/SimpleTest.java
+++ b/pdf-as-web-client/src/test/java/at/gv/egiz/pdfas/web/client/test/SimpleTest.java
@@ -6,6 +6,8 @@ import java.net.URL;
import at.gv.egiz.pdfas.api.ws.PDFASSignParameters;
import at.gv.egiz.pdfas.api.ws.PDFASSignParameters.Connector;
+import at.gv.egiz.pdfas.api.ws.PDFASSignRequest;
+import at.gv.egiz.pdfas.api.ws.PDFASSignResponse;
import at.gv.egiz.pdfas.web.client.RemotePDFSigner;
import sun.misc.IOUtils;
@@ -13,25 +15,75 @@ public class SimpleTest {
public static void main(String[] args) {
try {
- FileInputStream fis = new FileInputStream("/home/afitzek/simple.pdf");
+ FileInputStream fis = new FileInputStream(
+ "/home/afitzek/simple.pdf");
byte[] inputData = IOUtils.readFully(fis, -1, true);
-
+
PDFASSignParameters signParameters = new PDFASSignParameters();
signParameters.setConnector(Connector.JKS);
signParameters.setPosition(null);
signParameters.setProfile("SIGNATURBLOCK_DE");
-
- URL endpoint = new URL("http://localhost:8080/pdf-as-web/wssign?wsdl");
-
+
+ PDFASSignRequest request = new PDFASSignRequest();
+ request.setInputData(inputData);
+ request.setParameters(signParameters);
+ request.setRequestID("SOME TEST ID");
+
+ URL endpoint = new URL("http://demo.egiz.gv.at/demoportal-pdf_as/wssign?wsdl");
+ //URL endpoint = new URL(
+ // "http://localhost:8080/pdf-as-web/wssign?wsdl");
+
RemotePDFSigner signer = new RemotePDFSigner(endpoint, false);
-
- byte[] outputFile = signer.signPDFDokument(inputData, signParameters);
-
- FileOutputStream fos = new FileOutputStream("/home/afitzek/signed.pdf");
+
+ System.out.println("Simple Request:");
+ byte[] outputFile = signer.signPDFDokument(inputData,
+ signParameters);
+
+ FileOutputStream fos = new FileOutputStream(
+ "/home/afitzek/simple_request_signed.pdf");
fos.write(outputFile);
fos.close();
+
+ System.out.println("Simple Request Obj:");
+ PDFASSignResponse response = signer.signPDFDokument(request);
+
+ if (response.getSignedPDF() != null) {
+ FileOutputStream fos2 = new FileOutputStream(
+ "/home/afitzek/simple_request_obj_signed.pdf");
+ fos2.write(response.getSignedPDF());
+ fos2.close();
+ }
+
+ if(response.getError() != null) {
+ System.out.println("ERROR: " + response.getError());
+ }
+
+ PDFASSignRequest[] bulk = new PDFASSignRequest[20];
+ for(int i = 0; i < bulk.length; i++) {
+ bulk[i] = request;
+ }
+
+ System.out.println("Bulk Request:");
+ PDFASSignResponse[] responses = signer.signPDFDokument(bulk);
+
+ for(int i = 0; i < responses.length; i++) {
+ PDFASSignResponse bulkresponse = responses[i];
+ System.out.println("ID: " + bulkresponse.getRequestID());
+
+ if (bulkresponse.getSignedPDF() != null) {
+ FileOutputStream fos2 = new FileOutputStream(
+ "/home/afitzek/simple_request_obj_signed_"+ i +".pdf");
+ fos2.write(bulkresponse.getSignedPDF());
+ fos2.close();
+ }
+
+ if(bulkresponse.getError() != null) {
+ System.out.println("ERROR: " + bulkresponse.getError());
+ }
+ }
- } catch(Throwable e) {
+ System.out.println("Done!");
+ } catch (Throwable e) {
e.printStackTrace();
}
}
diff --git a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/ws/PDFASSigningImpl.java b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/ws/PDFASSigningImpl.java
index 96829b26..01f9205a 100644
--- a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/ws/PDFASSigningImpl.java
+++ b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/ws/PDFASSigningImpl.java
@@ -1,5 +1,8 @@
package at.gv.egiz.pdfas.web.ws;
+import java.util.ArrayList;
+import java.util.List;
+
import javax.jws.WebService;
import javax.xml.ws.WebServiceException;
import javax.xml.ws.soap.MTOM;
@@ -8,6 +11,8 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import at.gv.egiz.pdfas.api.ws.PDFASSignParameters;
+import at.gv.egiz.pdfas.api.ws.PDFASSignRequest;
+import at.gv.egiz.pdfas.api.ws.PDFASSignResponse;
import at.gv.egiz.pdfas.api.ws.PDFASSigning;
import at.gv.egiz.pdfas.web.config.WebConfiguration;
import at.gv.egiz.pdfas.web.helper.PdfAsHelper;
@@ -33,4 +38,38 @@ public class PDFASSigningImpl implements PDFASSigning {
}
}
+ public PDFASSignResponse signPDFDokument(PDFASSignRequest request) {
+ if(request == null) {
+ logger.warn("SOAP Sign Request is null!");
+ return null;
+ }
+ PDFASSignResponse response = new PDFASSignResponse();
+ try {
+ response.setSignedPDF(signPDFDokument(request.getInputData(), request.getParameters()));
+ } catch(Throwable e) {
+ if(e.getCause() != null) {
+ response.setError(e.getCause().getMessage());
+ } else {
+ response.setError(e.getMessage());
+ }
+ }
+ response.setRequestID(request.getRequestID());
+ return response;
+ }
+
+ public PDFASSignResponse[] signPDFDokument(PDFASSignRequest[] request) {
+ List<PDFASSignResponse> responses = new ArrayList<PDFASSignResponse>();
+ for(int i = 0; i < request.length; i++) {
+ PDFASSignResponse response = signPDFDokument(request[i]);
+ if(response != null) {
+ responses.add(response);
+ }
+ }
+ PDFASSignResponse[] array = new PDFASSignResponse[responses.size()];
+ for(int i = 0; i < responses.size(); i++) {
+ array[i] = responses.get(i);
+ }
+ return array;
+ }
+
}