aboutsummaryrefslogtreecommitdiff
path: root/pdf-as-lib/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'pdf-as-lib/src/main/java')
-rw-r--r--pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/PdfAsParameter.java8
-rw-r--r--pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/PdfAsParameterImpl.java7
-rw-r--r--pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/CertificateAndRequestParameterResolver.java12
-rw-r--r--pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/RequestParameterResolver.java5
-rw-r--r--pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/TableFactory.java5
-rw-r--r--pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/ValueResolver.java39
-rw-r--r--pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/status/PDFObject.java5
7 files changed, 40 insertions, 41 deletions
diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/PdfAsParameter.java b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/PdfAsParameter.java
index c2368255..11a1941b 100644
--- a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/PdfAsParameter.java
+++ b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/PdfAsParameter.java
@@ -80,4 +80,12 @@ public interface PdfAsParameter {
* @param map the map
*/
public void setPreprocessorArguments(Map<String, String> map);
+
+ /**
+ * Sets the dynamic signatur block values.
+ *
+ * @param map the map
+ */
+ public void setDynamicSignatureBlockArguments(Map<String, String> map);
+
}
diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/PdfAsParameterImpl.java b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/PdfAsParameterImpl.java
index fb737c13..f3e1c301 100644
--- a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/PdfAsParameterImpl.java
+++ b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/PdfAsParameterImpl.java
@@ -36,7 +36,7 @@ protected Configuration configuration;
protected DataSource dataSource;
protected String transactionId;
protected Map<String, String> preProcessorProps;
-
+ protected Map<String, String> dynamicSignatureBlockArgumentsMap;
public PdfAsParameterImpl(Configuration configuration,
DataSource dataSource) {
this.configuration = configuration;
@@ -77,4 +77,9 @@ protected Configuration configuration;
public void setPreprocessorArguments(Map<String, String> map) {
this.preProcessorProps = map;
}
+
+ @Override
+ public void setDynamicSignatureBlockArguments(Map<String, String> map) {
+ this.dynamicSignatureBlockArgumentsMap = map;
+ }
}
diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/CertificateAndRequestParameterResolver.java b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/CertificateAndRequestParameterResolver.java
index d7d83b34..3fe8298b 100644
--- a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/CertificateAndRequestParameterResolver.java
+++ b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/CertificateAndRequestParameterResolver.java
@@ -23,6 +23,7 @@
******************************************************************************/
package at.gv.egiz.pdfas.lib.impl.stamping;
+import at.gv.egiz.pdfas.common.settings.IProfileConstants;
import at.gv.egiz.pdfas.common.settings.SignatureProfileSettings;
import at.gv.egiz.pdfas.common.utils.DNUtils;
import at.gv.egiz.pdfas.common.utils.OgnlUtils;
@@ -30,26 +31,24 @@ import at.gv.egiz.pdfas.lib.impl.status.OperationStatus;
import iaik.x509.X509Certificate;
import ognl.AbstractMemberAccess;
import ognl.MemberAccess;
-import ognl.Ognl;
import ognl.OgnlContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.naming.InvalidNameException;
-
import java.lang.reflect.Member;
import java.lang.reflect.Modifier;
import java.util.HashMap;
import java.util.Map;
-public class CertificateResolver implements IResolver {
+public class CertificateAndRequestParameterResolver implements IResolver {
- private static final Logger logger = LoggerFactory.getLogger(CertificateResolver.class);
+ private static final Logger logger = LoggerFactory.getLogger(CertificateAndRequestParameterResolver.class);
private OgnlContext ctx;
private X509Certificate certificate;
- public CertificateResolver(X509Certificate certificate, OperationStatus operationStatus) {
+ public CertificateAndRequestParameterResolver(X509Certificate certificate, OperationStatus operationStatus) {
this.certificate = certificate;
MemberAccess memberAccess = new AbstractMemberAccess() {
@@ -62,6 +61,9 @@ public class CertificateResolver implements IResolver {
this.ctx = new OgnlContext(null, null, memberAccess);
+ this.ctx = new OgnlContext(null, null, memberAccess);
+ this.ctx.put(IProfileConstants.DYNAMIC_REQUEST_PARAMETERS, operationStatus.getRequestParameters());
+
this.ctx.put("sn", this.certificate.getSerialNumber().toString());
try {
diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/RequestParameterResolver.java b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/RequestParameterResolver.java
index b8abb383..3f7a8ebe 100644
--- a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/RequestParameterResolver.java
+++ b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/RequestParameterResolver.java
@@ -18,7 +18,6 @@ public class RequestParameterResolver implements IResolver {
public RequestParameterResolver(Map<String, String> requestParameters) {
-// this.ctx = new OgnlContext(memberAccess, null, null, requestParameters);
MemberAccess memberAccess = new AbstractMemberAccess() {
@Override
public boolean isAccessible(Map context, Object target, Member member, String propertyName) {
@@ -29,10 +28,6 @@ public class RequestParameterResolver implements IResolver {
this.ctx = new OgnlContext(null, null, memberAccess);
this.ctx.put(IProfileConstants.DYNAMIC_REQUEST_PARAMETERS, requestParameters);
-// for(String key : requestParameters.keySet()) {
-// this.ctx.put(key, requestParameters.get(key));
-// }
-
}
@Override
diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/TableFactory.java b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/TableFactory.java
index 9f015594..2908cfcd 100644
--- a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/TableFactory.java
+++ b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/TableFactory.java
@@ -229,9 +229,8 @@ public class TableFactory implements IProfileConstants {
String value = profile.getValue(key);
//String caption = getSigCaption(key);
//String value = getSigValue(key);
- ValueResolver resolver = "req".equals(type)
- ? new ValueResolver(operationStatus)
- : new ValueResolver(certProvider, operationStatus);
+
+ ValueResolver resolver = new ValueResolver(certProvider, operationStatus);
if (value != null) {
Entry c_entry = new Entry(Entry.TYPE_CAPTION, caption, key);
diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/ValueResolver.java b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/ValueResolver.java
index 6e8d2a72..2481c77b 100644
--- a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/ValueResolver.java
+++ b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/ValueResolver.java
@@ -28,6 +28,7 @@ import at.gv.egiz.pdfas.common.settings.SignatureProfileSettings;
import at.gv.egiz.pdfas.lib.impl.status.ICertificateProvider;
import at.gv.egiz.pdfas.lib.impl.status.OperationStatus;
+import at.gv.egiz.pdfas.lib.impl.status.RequestedSignature;
import org.apache.commons.lang3.RandomStringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -60,29 +61,18 @@ public class ValueResolver implements IProfileConstants, IResolver {
private static final Charset UTF_8 = Charset.forName("UTF-8");
- private IResolver internalCertificateResolver;
- private IResolver internalRequestParameterResolver;
+ private IResolver internalResolver;
public ValueResolver(ICertificateProvider certProvider, OperationStatus operationStatus) {
- internalCertificateResolver = new CertificateResolver(
- certProvider.getCertificate(), operationStatus);
- Map<String, String> test = new HashMap<>();
- test.put("schoolNameRand", RandomStringUtils.randomAlphabetic(5));
- test.put("schoolName", "EGIZ testschule");
-
- test.put("subject","bbbbb");
- internalRequestParameterResolver = new RequestParameterResolver(test);
+// Map<String, String> test = new HashMap<>();
+// test.put("schoolNameRand", RandomStringUtils.randomAlphabetic(5));
+// test.put("schoolName", "EGIZ testschule");
+//
+// test.put("subject","bbBbb");
+// internalRequestParameterResolver = new RequestParameterResolver(test);
+ internalResolver = new CertificateAndRequestParameterResolver(certProvider.getCertificate(),
+ operationStatus);
}
-
- public ValueResolver(OperationStatus operationStatus) {
- Map<String, String> test = new HashMap<>();
- test.put("schoolNameRand", RandomStringUtils.randomAlphabetic(5));
- test.put("schoolName", "EGIZ testschule");
- test.put("subject","bbbbb");
- internalRequestParameterResolver = new RequestParameterResolver(test);
-
- }
-
public String resolve(String key, String value,
SignatureProfileSettings settings) {
@@ -126,13 +116,8 @@ public class ValueResolver implements IProfileConstants, IResolver {
result += tmp1;
curidx = idxe;
String tmpValue = matcher.group(1);
- if(!tmpValue.contains(DYNAMIC_REQUEST_PARAMETERS)) {
- String tmp = internalCertificateResolver.resolve(key, tmpValue, settings);
- result += tmp;
- }else {
- String tmp2 = internalRequestParameterResolver.resolve(key, tmpValue, settings);
- result += tmp2;
- }
+ String tmp2 = internalResolver.resolve(key, tmpValue, settings);
+ result += tmp2;
} while (matcher.find());
} else {
result = value;
diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/status/PDFObject.java b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/status/PDFObject.java
index de88f610..6722c69e 100644
--- a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/status/PDFObject.java
+++ b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/status/PDFObject.java
@@ -24,6 +24,7 @@
package at.gv.egiz.pdfas.lib.impl.status;
import java.io.IOException;
+import java.util.HashMap;
import javax.activation.DataSource;
@@ -69,4 +70,8 @@ public abstract class PDFObject {
}
public abstract String getPDFVersion();
+
+ public HashMap<String, String> getRequestParameters() {
+ return status.getRequestParameters();
+ }
}