aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pdf-as-common/src/main/java/at/gv/egiz/pdfas/api/ws/PDFASPropertyEntry.java27
-rw-r--r--pdf-as-common/src/main/java/at/gv/egiz/pdfas/api/ws/PDFASPropertyMap.java54
-rw-r--r--pdf-as-common/src/main/java/at/gv/egiz/pdfas/api/ws/PDFASSignParameters.java13
-rw-r--r--pdf-as-common/src/main/java/at/gv/egiz/pdfas/api/ws/PDFASVerifyRequest.java12
-rw-r--r--pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/preprocessor/PreProcessor.java35
-rw-r--r--pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper/PdfAsHelper.java15
-rw-r--r--pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper/PdfAsParameterExtractor.java22
-rw-r--r--pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/ExternSignServlet.java2
-rw-r--r--pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/UIEntryPointServlet.java10
-rw-r--r--pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/VerifyServlet.java3
-rw-r--r--pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/ws/PDFASSigningImpl.java13
-rw-r--r--pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/ws/PDFASVerificationImpl.java8
12 files changed, 202 insertions, 12 deletions
diff --git a/pdf-as-common/src/main/java/at/gv/egiz/pdfas/api/ws/PDFASPropertyEntry.java b/pdf-as-common/src/main/java/at/gv/egiz/pdfas/api/ws/PDFASPropertyEntry.java
new file mode 100644
index 00000000..8e6025f3
--- /dev/null
+++ b/pdf-as-common/src/main/java/at/gv/egiz/pdfas/api/ws/PDFASPropertyEntry.java
@@ -0,0 +1,27 @@
+package at.gv.egiz.pdfas.api.ws;
+
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlType;
+
+@XmlType(name="PropertyEntry")
+public class PDFASPropertyEntry {
+ String key;
+ String value;
+
+ @XmlElement(required = true, nillable = false, name="key")
+ public String getKey() {
+ return key;
+ }
+
+ public void setKey(String key) {
+ this.key = key;
+ }
+
+ @XmlElement(required = true, nillable = false, name="value")
+ public String getValue() {
+ return value;
+ }
+ public void setvalue(String value) {
+ this.value = value;
+ }
+}
diff --git a/pdf-as-common/src/main/java/at/gv/egiz/pdfas/api/ws/PDFASPropertyMap.java b/pdf-as-common/src/main/java/at/gv/egiz/pdfas/api/ws/PDFASPropertyMap.java
new file mode 100644
index 00000000..b83daab9
--- /dev/null
+++ b/pdf-as-common/src/main/java/at/gv/egiz/pdfas/api/ws/PDFASPropertyMap.java
@@ -0,0 +1,54 @@
+package at.gv.egiz.pdfas.api.ws;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlTransient;
+import javax.xml.bind.annotation.XmlType;
+
+@XmlType(name="PropertyMap")
+public class PDFASPropertyMap {
+ List<PDFASPropertyEntry> propertyEntries;
+
+ @XmlElement(required = true, nillable = false, name="propertyEntries")
+ public List<PDFASPropertyEntry> getPropertyEntries() {
+ return propertyEntries;
+ }
+
+ public void setPropertyEntries(List<PDFASPropertyEntry> propertyEntries) {
+ this.propertyEntries = propertyEntries;
+ }
+
+ @XmlTransient
+ public Map<String, String> getMap() {
+ if(propertyEntries != null) {
+ Map<String, String> map = new HashMap<String, String>();
+ Iterator<PDFASPropertyEntry> propsIt = propertyEntries.iterator();
+ while(propsIt.hasNext()) {
+ PDFASPropertyEntry entry = propsIt.next();
+ map.put(entry.getKey(), entry.value);
+ }
+ return map;
+ }
+ return null;
+ }
+
+ public void setMap(Map<String, String> map) {
+
+ if(map != null) {
+ propertyEntries = new ArrayList<PDFASPropertyEntry>();
+ Iterator<String> keyIt = map.keySet().iterator();
+ while(keyIt.hasNext()) {
+ String key = keyIt.next();
+ PDFASPropertyEntry entry = new PDFASPropertyEntry();
+ entry.setKey(key);
+ entry.setvalue(map.get(key));
+ propertyEntries.add(entry);
+ }
+ }
+ }
+}
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 9b295ff5..c6f3993e 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
@@ -24,6 +24,8 @@
package at.gv.egiz.pdfas.api.ws;
import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Map;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlEnumValue;
@@ -76,6 +78,7 @@ public class PDFASSignParameters implements Serializable {
String invokeErrorUrl;
String transactionId;
String profile;
+ PDFASPropertyMap preprocessor;
@XmlElement(required = true, nillable = false, name="connector")
public Connector getConnector() {
@@ -133,5 +136,15 @@ public class PDFASSignParameters implements Serializable {
public void setTransactionId(String transactionId) {
this.transactionId = transactionId;
}
+
+ @XmlElement(required = false, nillable = true, name="preprocessorArguments")
+ public PDFASPropertyMap getPreprocessor() {
+ return preprocessor;
+ }
+
+ public void setPreprocessor(PDFASPropertyMap preprocessor) {
+ this.preprocessor = preprocessor;
+ }
+
}
diff --git a/pdf-as-common/src/main/java/at/gv/egiz/pdfas/api/ws/PDFASVerifyRequest.java b/pdf-as-common/src/main/java/at/gv/egiz/pdfas/api/ws/PDFASVerifyRequest.java
index 7167e921..2afa1f08 100644
--- a/pdf-as-common/src/main/java/at/gv/egiz/pdfas/api/ws/PDFASVerifyRequest.java
+++ b/pdf-as-common/src/main/java/at/gv/egiz/pdfas/api/ws/PDFASVerifyRequest.java
@@ -1,6 +1,8 @@
package at.gv.egiz.pdfas.api.ws;
import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Map;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;
@@ -17,6 +19,7 @@ public class PDFASVerifyRequest implements Serializable {
byte[] inputData;
VerificationLevel verificationLevel;
Integer sigIdx;
+ PDFASPropertyMap preprocessor;
@XmlElement(required = true, nillable = false, name="requestID")
public String getRequestID() {
@@ -53,4 +56,13 @@ public class PDFASVerifyRequest implements Serializable {
public void setSignatureIndex(Integer sigIdx) {
this.sigIdx = sigIdx;
}
+
+ @XmlElement(required = false, nillable = true, name="preprocessorArguments")
+ public PDFASPropertyMap getPreprocessor() {
+ return preprocessor;
+ }
+
+ public void setPreprocessor(PDFASPropertyMap preprocessor) {
+ this.preprocessor = preprocessor;
+ }
}
diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/preprocessor/PreProcessor.java b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/preprocessor/PreProcessor.java
new file mode 100644
index 00000000..a70d31d7
--- /dev/null
+++ b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/preprocessor/PreProcessor.java
@@ -0,0 +1,35 @@
+package at.gv.egiz.pdfas.lib.api.preprocessor;
+
+import at.gv.egiz.pdfas.common.exceptions.PDFASError;
+import at.gv.egiz.pdfas.lib.api.sign.SignParameter;
+import at.gv.egiz.pdfas.lib.api.verify.VerifyParameter;
+
+/**
+ * The Interface PreProcessor.
+ */
+public interface PreProcessor {
+
+ /**
+ * Sign.
+ *
+ * @param parameter the parameter
+ * @throws PDFASError the PDFAS error
+ */
+ public void sign(SignParameter parameter) throws PDFASError;
+
+ /**
+ * Verify.
+ *
+ * @param parameter the parameter
+ * @throws PDFASError the PDFAS error
+ */
+ public void verify(VerifyParameter parameter) throws PDFASError;
+
+
+ /**
+ * Registration position.
+ *
+ * @return the int
+ */
+ public int registrationPosition();
+}
diff --git a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper/PdfAsHelper.java b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper/PdfAsHelper.java
index 3323a252..fc499f94 100644
--- a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper/PdfAsHelper.java
+++ b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper/PdfAsHelper.java
@@ -35,6 +35,7 @@ import java.net.URLEncoder;
import java.security.cert.CertificateException;
import java.util.Iterator;
import java.util.List;
+import java.util.Map;
import javax.imageio.ImageIO;
import javax.servlet.RequestDispatcher;
@@ -298,7 +299,7 @@ public class PdfAsHelper {
}
public static List<VerifyResult> synchornousVerify(byte[] pdfData,
- int signIdx, SignatureVerificationLevel lvl) throws Exception {
+ int signIdx, SignatureVerificationLevel lvl, Map<String, String> preProcessor) throws Exception {
logger.debug("Verifing Signature index: " + signIdx);
Configuration config = pdfAs.getConfiguration();
@@ -308,6 +309,7 @@ public class PdfAsHelper {
VerifyParameter verifyParameter = PdfAsFactory.createVerifyParameter(
config, dataSource);
+ verifyParameter.setPreprocessorArguments(preProcessor);
verifyParameter.setSignatureVerificationLevel(lvl);
verifyParameter.setDataSource(dataSource);
verifyParameter.setConfiguration(config);
@@ -425,6 +427,11 @@ public class PdfAsHelper {
// set Signature Position
signParameter.setSignaturePosition(params.getPosition());
+ // Set Preprocessor
+ if(params.getPreprocessor() != null) {
+ signParameter.setPreprocessorArguments(params.getPreprocessor().getMap());
+ }
+
SignResult signResult = pdfAs.sign(signParameter);
PDFASSignResponse signResponse = new PDFASSignResponse();
@@ -444,7 +451,7 @@ public class PdfAsHelper {
public static void startSignature(HttpServletRequest request,
HttpServletResponse response, ServletContext context,
byte[] pdfData, String connector, String position,
- String transactionId, String profile) throws Exception {
+ String transactionId, String profile, Map<String, String> preProcessor) throws Exception {
// TODO: Protect session so that only one PDF can be signed during one
// session
@@ -483,7 +490,7 @@ public class PdfAsHelper {
throw new PdfAsWebException(
"Invalid connector (bku | onlinebku | mobilebku | moa | jks)");
}
-
+ signParameter.setPreprocessorArguments(preProcessor);
signParameter.setPlainSigner(signer);
session.setAttribute(PDF_SIGNER, signer);
session.setAttribute(PDF_SL_INTERACTIVE, connector);
@@ -677,7 +684,7 @@ public class PdfAsHelper {
PDFASVerificationResponse verResponse = new PDFASVerificationResponse();
List<VerifyResult> verResults = PdfAsHelper.synchornousVerify(
signedPdf, -2,
- PdfAsHelper.getVerificationLevel(request));
+ PdfAsHelper.getVerificationLevel(request), null);
if (verResults.size() != 1) {
throw new WebServiceException(
diff --git a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper/PdfAsParameterExtractor.java b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper/PdfAsParameterExtractor.java
index c8f35f3c..9c5f8cc6 100644
--- a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper/PdfAsParameterExtractor.java
+++ b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper/PdfAsParameterExtractor.java
@@ -23,6 +23,10 @@
******************************************************************************/
package at.gv.egiz.pdfas.web.helper;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Map;
+
import javax.servlet.http.HttpServletRequest;
import at.gv.egiz.pdfas.lib.api.verify.VerifyParameter.SignatureVerificationLevel;
@@ -63,6 +67,8 @@ public class PdfAsParameterExtractor {
public static final String PARAM_SIG_IDX = "sig-idx";
public static final String PARAM_FILENAME = "filename";
+ public static final String PARAM_PREPROCESSOR_PREFIX = "pp:";
+
public static String getConnector(HttpServletRequest request) {
String connector = (String)request.getAttribute(PARAM_CONNECTOR);
if(connector != null) {
@@ -85,6 +91,22 @@ public class PdfAsParameterExtractor {
return (String)request.getAttribute(PARAM_INVOKE_URL);
}
+ public static Map<String, String> getPreProcessorMap(HttpServletRequest request) {
+ Map<String, String> map = new HashMap<String, String>();
+
+ Enumeration<String> parameterNames = request.getAttributeNames();
+ while(parameterNames.hasMoreElements()) {
+ String parameterName = parameterNames.nextElement();
+ if(parameterName.startsWith(PARAM_PREPROCESSOR_PREFIX)) {
+ String key = parameterName.substring(PARAM_PREPROCESSOR_PREFIX.length());
+ String value = (String)request.getAttribute(parameterName);
+ map.put(key, value);
+ }
+ }
+
+ return map;
+ }
+
public static SignatureVerificationLevel getVerificationLevel(HttpServletRequest request) {
String value = (String)request.getAttribute(PARAM_VERIFY_LEVEL);
if(value != null) {
diff --git a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/ExternSignServlet.java b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/ExternSignServlet.java
index ce19f803..7900dfde 100644
--- a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/ExternSignServlet.java
+++ b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/ExternSignServlet.java
@@ -302,7 +302,7 @@ public class ExternSignServlet extends HttpServlet {
PdfAsHelper.startSignature(request, response, getServletContext(), pdfData, connector,
PdfAsHelper.buildPosString(request, response), transactionId, PdfAsParameterExtractor
- .getSigType(request));
+ .getSigType(request), PdfAsParameterExtractor.getPreProcessorMap(request));
return;
} else if (connector.equals("jks") || connector.equals("moa")) {
// start synchronous siganture creation
diff --git a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/UIEntryPointServlet.java b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/UIEntryPointServlet.java
index 544f6c83..e602a8e0 100644
--- a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/UIEntryPointServlet.java
+++ b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/UIEntryPointServlet.java
@@ -24,6 +24,7 @@
package at.gv.egiz.pdfas.web.servlets;
import java.io.IOException;
+import java.util.Map;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
@@ -147,12 +148,17 @@ public class UIEntryPointServlet extends HttpServlet {
"Invalid connector mobilebku is not supported");
}
}
-
+ Map<String, String> map = null;
+ if(pdfAsRequest.getParameters().getPreprocessor() != null) {
+ map = pdfAsRequest.getParameters().getPreprocessor().getMap();
+ }
+
PdfAsHelper.startSignature(req, resp, getServletContext(),
pdfAsRequest.getInputData(), connector.toString(),
pdfAsRequest.getParameters().getPosition(),
pdfAsRequest.getParameters().getTransactionId(),
- pdfAsRequest.getParameters().getProfile());
+ pdfAsRequest.getParameters().getProfile(),
+ map);
} else {
throw new PdfAsWebException("Invalid connector ("
+ Connector.BKU + " | " + Connector.ONLINEBKU + " | "
diff --git a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/VerifyServlet.java b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/VerifyServlet.java
index 09af4357..aaa6afbb 100644
--- a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/VerifyServlet.java
+++ b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/VerifyServlet.java
@@ -254,7 +254,8 @@ public class VerifyServlet extends HttpServlet {
logger.debug("Format: " + format);
- List<VerifyResult> results = PdfAsHelper.synchornousVerify(pdfData, -1, lvl);
+ List<VerifyResult> results = PdfAsHelper.synchornousVerify(pdfData, -1, lvl,
+ PdfAsParameterExtractor.getPreProcessorMap(request));
PdfAsHelper.setVerificationResult(request, results);
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 6df63a3b..d15492b4 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
@@ -25,6 +25,7 @@ package at.gv.egiz.pdfas.web.ws;
import java.util.ArrayList;
import java.util.List;
+import java.util.Map;
import javax.jws.WebService;
import javax.xml.ws.WebServiceException;
@@ -39,7 +40,6 @@ 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.api.ws.PDFASSigning;
-import at.gv.egiz.pdfas.api.ws.PDFASVerificationResponse;
import at.gv.egiz.pdfas.api.ws.VerificationLevel;
import at.gv.egiz.pdfas.lib.api.verify.VerifyParameter.SignatureVerificationLevel;
import at.gv.egiz.pdfas.lib.api.verify.VerifyResult;
@@ -79,6 +79,11 @@ public class PDFASSigningImpl implements PDFASSigning {
"Invalid connector value!");
}
+ Map<String, String> preProcessor = null;
+ if(request.getParameters().getPreprocessor() != null) {
+ preProcessor = request.getParameters().getPreprocessor().getMap();
+ }
+
if (request.getParameters().getConnector().equals(Connector.MOA)
|| request.getParameters().getConnector()
.equals(Connector.JKS)) {
@@ -94,7 +99,8 @@ public class PDFASSigningImpl implements PDFASSigning {
.synchornousVerify(
response.getSignedPDF(),
-1,
- SignatureVerificationLevel.FULL_VERIFICATION);
+ SignatureVerificationLevel.FULL_VERIFICATION,
+ preProcessor);
if (verResults.size() != 1) {
throw new WebServiceException(
@@ -106,7 +112,8 @@ public class PDFASSigningImpl implements PDFASSigning {
.synchornousVerify(
response.getSignedPDF(),
-1,
- SignatureVerificationLevel.INTEGRITY_ONLY_VERIFICATION);
+ SignatureVerificationLevel.INTEGRITY_ONLY_VERIFICATION,
+ preProcessor);
if (verResults.size() != 1) {
throw new WebServiceException(
diff --git a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/ws/PDFASVerificationImpl.java b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/ws/PDFASVerificationImpl.java
index c6fb8cd7..0257f835 100644
--- a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/ws/PDFASVerificationImpl.java
+++ b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/ws/PDFASVerificationImpl.java
@@ -4,6 +4,7 @@ import iaik.x509.X509Certificate;
import java.util.ArrayList;
import java.util.List;
+import java.util.Map;
import javax.jws.WebService;
import javax.xml.ws.WebServiceException;
@@ -44,6 +45,11 @@ public class PDFASVerificationImpl implements PDFASVerification {
sigIdx = request.getSignatureIndex().intValue();
}
+ Map<String, String> preProcessor = null;
+ if(request.getPreprocessor() != null) {
+ preProcessor = request.getPreprocessor().getMap();
+ }
+
SignatureVerificationLevel lvl = SignatureVerificationLevel.INTEGRITY_ONLY_VERIFICATION;
if (request.getVerificationLevel().equals(
@@ -55,7 +61,7 @@ public class PDFASVerificationImpl implements PDFASVerification {
}
List<VerifyResult> results = PdfAsHelper.synchornousVerify(
- request.getInputData(), sigIdx, lvl);
+ request.getInputData(), sigIdx, lvl, preProcessor);
for(int i = 0; i < results.size(); i++) {
VerifyResult result = results.get(i);