From 42e68c8f3e53b34663d2fe9c434b0b034ff9ddf0 Mon Sep 17 00:00:00 2001 From: Thomas <> Date: Wed, 11 Jan 2023 23:23:30 +0100 Subject: feat(web): add bulk-light functionality into PDF-AS-Web --- .../egiz/pdfas/api/processing/CoreSignParams.java | 32 +++++++++++ .../egiz/pdfas/api/processing/DocumentToSign.java | 22 ++++++++ .../pdfas/api/processing/PdfasSignRequest.java | 62 ++++++++++++++++++++++ .../pdfas/api/processing/PdfasSignResponse.java | 23 ++++++++ .../egiz/pdfas/api/processing/SignedDocument.java | 25 +++++++++ .../gv/egiz/pdfas/api/ws/PDFASSignParameters.java | 14 +++-- .../java/at/gv/egiz/pdfas/api/ws/PDFASSigning.java | 10 ++++ .../egiz/pdfas/api/ws/PdfasGetMultipleRequest.java | 24 +++++++++ .../at/gv/egiz/pdfas/api/ws/PdfasSignDocument.java | 37 +++++++++++++ .../pdfas/api/ws/PdfasSignMultipleRequest.java | 60 +++++++++++++++++++++ .../pdfas/api/ws/PdfasSignMultipleResponse.java | 35 ++++++++++++ .../gv/egiz/pdfas/api/ws/PdfasSignedDocument.java | 30 +++++++++++ 12 files changed, 370 insertions(+), 4 deletions(-) create mode 100644 pdf-as-common/src/main/java/at/gv/egiz/pdfas/api/processing/CoreSignParams.java create mode 100644 pdf-as-common/src/main/java/at/gv/egiz/pdfas/api/processing/DocumentToSign.java create mode 100644 pdf-as-common/src/main/java/at/gv/egiz/pdfas/api/processing/PdfasSignRequest.java create mode 100644 pdf-as-common/src/main/java/at/gv/egiz/pdfas/api/processing/PdfasSignResponse.java create mode 100644 pdf-as-common/src/main/java/at/gv/egiz/pdfas/api/processing/SignedDocument.java create mode 100644 pdf-as-common/src/main/java/at/gv/egiz/pdfas/api/ws/PdfasGetMultipleRequest.java create mode 100644 pdf-as-common/src/main/java/at/gv/egiz/pdfas/api/ws/PdfasSignDocument.java create mode 100644 pdf-as-common/src/main/java/at/gv/egiz/pdfas/api/ws/PdfasSignMultipleRequest.java create mode 100644 pdf-as-common/src/main/java/at/gv/egiz/pdfas/api/ws/PdfasSignMultipleResponse.java create mode 100644 pdf-as-common/src/main/java/at/gv/egiz/pdfas/api/ws/PdfasSignedDocument.java (limited to 'pdf-as-common/src') diff --git a/pdf-as-common/src/main/java/at/gv/egiz/pdfas/api/processing/CoreSignParams.java b/pdf-as-common/src/main/java/at/gv/egiz/pdfas/api/processing/CoreSignParams.java new file mode 100644 index 00000000..f86e93b6 --- /dev/null +++ b/pdf-as-common/src/main/java/at/gv/egiz/pdfas/api/processing/CoreSignParams.java @@ -0,0 +1,32 @@ +package at.gv.egiz.pdfas.api.processing; + +import java.io.Serializable; +import java.util.Map; + +import at.gv.egiz.pdfas.api.ws.PDFASSignParameters.Connector; +import lombok.Data; + +@Data +public class CoreSignParams implements Serializable { + + private static final long serialVersionUID = 947480605651880556L; + + String transactionId; + + Connector connector; + + String invokeUrl; + + String invokeTarget; + + String invokeErrorUrl; + + String keyIdentifier; + + Map preprocessor; + + Map overrides; + + Map signatureBlockParameters; + +} diff --git a/pdf-as-common/src/main/java/at/gv/egiz/pdfas/api/processing/DocumentToSign.java b/pdf-as-common/src/main/java/at/gv/egiz/pdfas/api/processing/DocumentToSign.java new file mode 100644 index 00000000..6cc3a933 --- /dev/null +++ b/pdf-as-common/src/main/java/at/gv/egiz/pdfas/api/processing/DocumentToSign.java @@ -0,0 +1,22 @@ +package at.gv.egiz.pdfas.api.processing; + +import java.io.Serializable; + +import lombok.Data; + +@Data +public class DocumentToSign implements Serializable { + + private static final long serialVersionUID = 551977730667465367L; + + byte[] inputData; + + String fileName; + + String position; + + String qrCodeContent; + + String profile; + +} diff --git a/pdf-as-common/src/main/java/at/gv/egiz/pdfas/api/processing/PdfasSignRequest.java b/pdf-as-common/src/main/java/at/gv/egiz/pdfas/api/processing/PdfasSignRequest.java new file mode 100644 index 00000000..b36b5a4c --- /dev/null +++ b/pdf-as-common/src/main/java/at/gv/egiz/pdfas/api/processing/PdfasSignRequest.java @@ -0,0 +1,62 @@ +package at.gv.egiz.pdfas.api.processing; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import at.gv.egiz.pdfas.api.ws.VerificationLevel; +import lombok.Getter; +import lombok.Setter; + +@Getter +public class PdfasSignRequest implements Serializable, Iterator { + + private static final long serialVersionUID = -7245405996920651806L; + + @Setter + String requestID; + + @Setter + CoreSignParams coreParams; + + @Setter + VerificationLevel verificationLevel; + + List input; + + /** + * Add single PDF for signing. + * + * @param pdf PDF to sign + */ + public void addDocumentToSign(DocumentToSign pdf) { + if (input == null) { + input = new ArrayList<>(); + + } + input.add(pdf); + + } + + + /** + * true if there is one or more {@link DocumentToSign}, otherwise false. + */ + @Override + public boolean hasNext() { + return input != null && !input.isEmpty(); + + } + + /** + * Get next {@link DocumentToSign}. + */ + @Override + public synchronized DocumentToSign next() { + return input.remove(0); + + } + + +} diff --git a/pdf-as-common/src/main/java/at/gv/egiz/pdfas/api/processing/PdfasSignResponse.java b/pdf-as-common/src/main/java/at/gv/egiz/pdfas/api/processing/PdfasSignResponse.java new file mode 100644 index 00000000..3618715f --- /dev/null +++ b/pdf-as-common/src/main/java/at/gv/egiz/pdfas/api/processing/PdfasSignResponse.java @@ -0,0 +1,23 @@ +package at.gv.egiz.pdfas.api.processing; + +import java.io.Serializable; +import java.util.List; + +import lombok.Builder; +import lombok.Data; +import lombok.Singular; + +@Data +@Builder(toBuilder = true) +public class PdfasSignResponse implements Serializable { + + private static final long serialVersionUID = -3235466827933651452L; + + String requestId; + + String transactionId; + + @Singular + List signedPdfs; + +} diff --git a/pdf-as-common/src/main/java/at/gv/egiz/pdfas/api/processing/SignedDocument.java b/pdf-as-common/src/main/java/at/gv/egiz/pdfas/api/processing/SignedDocument.java new file mode 100644 index 00000000..348746df --- /dev/null +++ b/pdf-as-common/src/main/java/at/gv/egiz/pdfas/api/processing/SignedDocument.java @@ -0,0 +1,25 @@ +package at.gv.egiz.pdfas.api.processing; + +import java.io.Serializable; + +import at.gv.egiz.pdfas.api.ws.PDFASVerificationResponse; +import lombok.Builder; +import lombok.Data; + +@Data +@Builder +public class SignedDocument implements Serializable { + + private static final long serialVersionUID = 5409915106152807937L; + + Long signingTimestamp; + + byte[] outputData; + + String fileName; + + String signerCertificate; + + PDFASVerificationResponse verificationResponse; + +} diff --git a/pdf-as-common/src/main/java/at/gv/egiz/pdfas/api/ws/PDFASSignParameters.java b/pdf-as-common/src/main/java/at/gv/egiz/pdfas/api/ws/PDFASSignParameters.java index 94906112..a70b8f56 100644 --- a/pdf-as-common/src/main/java/at/gv/egiz/pdfas/api/ws/PDFASSignParameters.java +++ b/pdf-as-common/src/main/java/at/gv/egiz/pdfas/api/ws/PDFASSignParameters.java @@ -23,11 +23,8 @@ ******************************************************************************/ package at.gv.egiz.pdfas.api.ws; -import at.gv.egiz.pdfas.common.settings.SignatureProfileSettings; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import java.io.Serializable; +import java.util.Arrays; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlEnumValue; @@ -71,6 +68,15 @@ public class PDFASSignParameters implements Serializable { public String toString(){ return name; } + + public static Connector fromString(String value) { + return Arrays.asList(Connector.values()).stream() + .filter(el -> el.toString().equalsIgnoreCase(value)) + .findFirst() + .get(); + + } + } 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 667080fa..beeff937 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 @@ -44,4 +44,14 @@ public interface PDFASSigning { @WebMethod(operationName = "signBulk") @WebResult(name="bulkResponse") public PDFASBulkSignResponse signPDFDokument(@WebParam(name = "signBulkRequest") PDFASBulkSignRequest request); + + @WebMethod(operationName = "signMultiple") + @WebResult(name="signMultipleResponse") + public PdfasSignMultipleResponse signPDFDokument(@WebParam(name = "signMultipleRequest") PdfasSignMultipleRequest request); + + @WebMethod(operationName = "getMultiple") + @WebResult(name="getMultipleResponse") + public PdfasSignMultipleResponse getSignedDokument(@WebParam(name = "getMultipleRequest") PdfasGetMultipleRequest request); + + } diff --git a/pdf-as-common/src/main/java/at/gv/egiz/pdfas/api/ws/PdfasGetMultipleRequest.java b/pdf-as-common/src/main/java/at/gv/egiz/pdfas/api/ws/PdfasGetMultipleRequest.java new file mode 100644 index 00000000..5f4f3a27 --- /dev/null +++ b/pdf-as-common/src/main/java/at/gv/egiz/pdfas/api/ws/PdfasGetMultipleRequest.java @@ -0,0 +1,24 @@ +package at.gv.egiz.pdfas.api.ws; + +import java.io.Serializable; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlType; + +import lombok.Getter; +import lombok.Setter; + +@Getter +@Setter +@XmlType(name="getMultipleRequest") +@XmlAccessorType(XmlAccessType.FIELD) +public class PdfasGetMultipleRequest implements Serializable { + + private static final long serialVersionUID = -7105371679206044280L; + + @XmlElement(required = true, nillable = false, name="token") + String token; + +} diff --git a/pdf-as-common/src/main/java/at/gv/egiz/pdfas/api/ws/PdfasSignDocument.java b/pdf-as-common/src/main/java/at/gv/egiz/pdfas/api/ws/PdfasSignDocument.java new file mode 100644 index 00000000..e065ef5e --- /dev/null +++ b/pdf-as-common/src/main/java/at/gv/egiz/pdfas/api/ws/PdfasSignDocument.java @@ -0,0 +1,37 @@ +package at.gv.egiz.pdfas.api.ws; + +import java.io.Serializable; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlType; + +import lombok.Getter; +import lombok.Setter; + +@Getter +@Setter +@XmlType(name="signMultipleFile") +@XmlAccessorType(XmlAccessType.FIELD) +public class PdfasSignDocument implements Serializable { + + private static final long serialVersionUID = -2422995343468207094L; + + @XmlElement(required = true, nillable = false, name="inputData") + byte[] inputData; + + @XmlElement(required = true, nillable = false, name="fileName") + String fileName; + + @XmlElement(required = false, nillable = true, name="position") + String position; + + @XmlElement(required = false, nillable = true, name="qrCodeContent") + String qrCodeContent; + + @XmlElement(required = false, nillable = true, name="profile") + String profile; + +} + diff --git a/pdf-as-common/src/main/java/at/gv/egiz/pdfas/api/ws/PdfasSignMultipleRequest.java b/pdf-as-common/src/main/java/at/gv/egiz/pdfas/api/ws/PdfasSignMultipleRequest.java new file mode 100644 index 00000000..8d172bfb --- /dev/null +++ b/pdf-as-common/src/main/java/at/gv/egiz/pdfas/api/ws/PdfasSignMultipleRequest.java @@ -0,0 +1,60 @@ +package at.gv.egiz.pdfas.api.ws; + +import java.io.Serializable; +import java.util.List; +import java.util.Map; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlType; + +import at.gv.egiz.pdfas.api.ws.PDFASSignParameters.Connector; +import lombok.Getter; +import lombok.Setter; + +@Getter +@Setter +@XmlType(name="signMultipleRequest") +@XmlAccessorType(XmlAccessType.FIELD) +public class PdfasSignMultipleRequest implements Serializable { + + private static final long serialVersionUID = 4338536417988335976L; + + @XmlElement(required = true, nillable = false, name="requestID") + String requestID; + + @XmlElement(required = false, nillable = true, name="transactionId") + String transactionId; + + @XmlElement(required = true, nillable = false, name="connector") + Connector connector; + + @XmlElement(required = false, nillable = true, name="invoke-url") + String invokeUrl; + + @XmlElement(required = false, nillable = true, name="invoke-target") + String invokeTarget; + + @XmlElement(required = false, nillable = true, name="invoke-error-url") + String invokeErrorUrl; + + @XmlElement(required = false, nillable = true, name="keyIdentifier") + String keyIdentifier; + + @XmlElement(required = false, nillable = true, name="preprocessorArguments") + PDFASPropertyMap preprocessor; + + @XmlElement(required = false, nillable = true, name="configurationOverrides") + PDFASPropertyMap overrides; + + @XmlElement(required = false, nillable = true, name="signatureBlockParameter") + Map signatureBlockParameters; + + @XmlElement(required = false, nillable = true, name="verificationLevel") + VerificationLevel verificationLevel; + + @XmlElement(required = true, nillable = false, name="documents") + List input; + +} diff --git a/pdf-as-common/src/main/java/at/gv/egiz/pdfas/api/ws/PdfasSignMultipleResponse.java b/pdf-as-common/src/main/java/at/gv/egiz/pdfas/api/ws/PdfasSignMultipleResponse.java new file mode 100644 index 00000000..a2391d11 --- /dev/null +++ b/pdf-as-common/src/main/java/at/gv/egiz/pdfas/api/ws/PdfasSignMultipleResponse.java @@ -0,0 +1,35 @@ +package at.gv.egiz.pdfas.api.ws; + +import java.io.Serializable; +import java.util.List; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlType; + +import lombok.Getter; +import lombok.Setter; + +@Getter +@Setter +@XmlType(name="signMultipleResponse") +@XmlAccessorType(XmlAccessType.FIELD) +public class PdfasSignMultipleResponse implements Serializable { + private static final long serialVersionUID = 2544165926674778203L; + + @XmlElement(required = true, nillable = false, name="requestID") + String requestID; + + @XmlElement(required = false, nillable = true, name="transactionId") + String transactionId; + + @XmlElement(required = false, name="error") + String error; + + @XmlElement(required = false, name="redirectUrl") + String redirectUrl; + + @XmlElement(required = true, nillable = false, name="documents") + List output; +} diff --git a/pdf-as-common/src/main/java/at/gv/egiz/pdfas/api/ws/PdfasSignedDocument.java b/pdf-as-common/src/main/java/at/gv/egiz/pdfas/api/ws/PdfasSignedDocument.java new file mode 100644 index 00000000..7ac13e1d --- /dev/null +++ b/pdf-as-common/src/main/java/at/gv/egiz/pdfas/api/ws/PdfasSignedDocument.java @@ -0,0 +1,30 @@ +package at.gv.egiz.pdfas.api.ws; + +import java.io.Serializable; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlType; + +import lombok.Getter; +import lombok.Setter; + +@Getter +@Setter +@XmlType(name="signedMultipleFile") +@XmlAccessorType(XmlAccessType.FIELD) +public class PdfasSignedDocument implements Serializable { + + private static final long serialVersionUID = -2621030544869357960L; + + @XmlElement(required = true, nillable = false, name="outputData") + byte[] outputData; + + @XmlElement(required = false, nillable = true, name="fileName") + String fileName; + + @XmlElement(required = false, nillable = false, name="verificationResponse") + PDFASVerificationResponse verificationResponse; + +} -- cgit v1.2.3