aboutsummaryrefslogtreecommitdiff
path: root/pdf-as-lib/src/main/java/at/gv/egiz
diff options
context:
space:
mode:
Diffstat (limited to 'pdf-as-lib/src/main/java/at/gv/egiz')
-rw-r--r--pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/RequestParameterResolver.java23
-rw-r--r--pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/ValueResolver.java34
-rw-r--r--pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/status/OperationStatus.java6
3 files changed, 45 insertions, 18 deletions
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 1d8d4638..4b2a8f10 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
@@ -16,15 +16,22 @@ public class RequestParameterResolver implements IResolver {
private OgnlContext ctx;
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) {
- int modifiers = member.getModifiers();
- return Modifier.isPublic(modifiers);
- }
- };
-
- this.ctx = new OgnlContext(memberAccess, null, null, requestParameters);
+ @Override
+ public boolean isAccessible(Map context, Object target, Member member, String propertyName) {
+ int modifiers = member.getModifiers();
+ return Modifier.isPublic(modifiers);
+ }
+ };
+
+ this.ctx = new OgnlContext(null, null, memberAccess);
+ this.ctx.put("dynamic", 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/ValueResolver.java b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/ValueResolver.java
index c6cddc9e..e5905c22 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
@@ -35,7 +35,6 @@ import org.slf4j.LoggerFactory;
import java.nio.charset.Charset;
import java.text.SimpleDateFormat;
import java.util.Calendar;
-import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.TimeZone;
@@ -61,19 +60,27 @@ public class ValueResolver implements IProfileConstants, IResolver {
private static final Charset UTF_8 = Charset.forName("UTF-8");
- private IResolver internalResolver;
-
+ private IResolver internalCertificateResolver;
+ private IResolver internalRequestParameterResolver;
public ValueResolver(ICertificateProvider certProvider, OperationStatus operationStatus) {
- internalResolver = new CertificateResolver(
+ 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);
}
public ValueResolver(OperationStatus operationStatus) {
Map<String, String> test = new HashMap<>();
test.put("schoolNameRand", RandomStringUtils.randomAlphabetic(5));
- test.put("schoolName", "EGIZ testschule");
- internalResolver = new RequestParameterResolver(test);
-
+ test.put("schoolName", "EGIZ testschule");
+
+ test.put("subject","bbbbb");
+ internalRequestParameterResolver = new RequestParameterResolver(test);
+
}
public String resolve(String key, String value,
@@ -115,10 +122,17 @@ public class ValueResolver implements IProfileConstants, IResolver {
do {
int idx = matcher.start(0);
int idxe = matcher.end(0);
- result += value.substring(curidx, idx);
+ String tmp1 = value.substring(curidx, idx);
+ result += tmp1;
curidx = idxe;
- result += internalResolver.resolve(key,
- matcher.group(1), settings);
+ String tmpValue = matcher.group(1);
+ if(!tmpValue.contains("dynamic")) {
+ String tmp = internalCertificateResolver.resolve(key, tmpValue, settings);
+ result += tmp;
+ }else {
+ String tmp2 = internalRequestParameterResolver.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/OperationStatus.java b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/status/OperationStatus.java
index ecdddfa1..08dcd249 100644
--- a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/status/OperationStatus.java
+++ b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/status/OperationStatus.java
@@ -56,6 +56,8 @@ public class OperationStatus implements Serializable {
private PDFASBackend backend;
private Map<String, String> metaInformations = new HashMap<String, String>();
+ private HashMap<String, String> requestParameters = new HashMap<String, String>();
+
public OperationStatus(ISettings configuration, SignParameter signParameter, PDFASBackend backend) {
this.configuration = configuration;
this.signParamter = signParameter;
@@ -174,4 +176,8 @@ public class OperationStatus implements Serializable {
public Map<String, String> getMetaInformations() {
return metaInformations;
}
+
+ public HashMap<String, String> getRequestParameters() {
+ return requestParameters;
+ }
}