aboutsummaryrefslogtreecommitdiff
path: root/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl
diff options
context:
space:
mode:
authoremusic <emina.music@egiz.gv.at>2019-11-08 14:13:45 +0100
committeremusic <emina.music@egiz.gv.at>2019-11-08 14:13:45 +0100
commit79f8912b36d37a25867c52f86bcff13ff75e40a2 (patch)
tree40c2efdd0ded4750f0727b53f06a5f6eb01dd5b3 /pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl
parent867b8ec9c1ab329fa5f84d294d39c80a92d2b9d2 (diff)
downloadpdf-as-4-79f8912b36d37a25867c52f86bcff13ff75e40a2.tar.gz
pdf-as-4-79f8912b36d37a25867c52f86bcff13ff75e40a2.tar.bz2
pdf-as-4-79f8912b36d37a25867c52f86bcff13ff75e40a2.zip
Encoding of special characters
Diffstat (limited to 'pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl')
-rw-r--r--pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/CertificateResolver.java18
-rw-r--r--pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/ValueResolver.java26
2 files changed, 24 insertions, 20 deletions
diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/CertificateResolver.java b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/CertificateResolver.java
index bff573a4..edb87eb2 100644
--- a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/CertificateResolver.java
+++ b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/CertificateResolver.java
@@ -23,22 +23,18 @@
******************************************************************************/
package at.gv.egiz.pdfas.lib.impl.stamping;
+import at.gv.egiz.pdfas.common.settings.SignatureProfileSettings;
+import at.gv.egiz.pdfas.common.utils.DNUtils;
+import at.gv.egiz.pdfas.common.utils.OgnlUtils;
+import at.gv.egiz.pdfas.lib.impl.status.OperationStatus;
import iaik.x509.X509Certificate;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.naming.InvalidNameException;
-
import ognl.OgnlContext;
-
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import at.gv.egiz.pdfas.common.settings.SignatureProfileSettings;
-import at.gv.egiz.pdfas.common.utils.DNUtils;
-import at.gv.egiz.pdfas.common.utils.OgnlUtils;
-import at.gv.egiz.pdfas.lib.impl.status.OperationStatus;
+import javax.naming.InvalidNameException;
+import java.util.HashMap;
+import java.util.Map;
public class CertificateResolver implements IResolver {
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 c38756db..f7210036 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
@@ -23,20 +23,20 @@
******************************************************************************/
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.lib.impl.status.ICertificateProvider;
+import at.gv.egiz.pdfas.lib.impl.status.OperationStatus;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.nio.charset.Charset;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.TimeZone;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import at.gv.egiz.pdfas.common.settings.IProfileConstants;
-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;
-
/**
* Created with IntelliJ IDEA. User: afitzek Date: 9/11/13 Time: 11:11 AM To
* change this template use File | Settings | File Templates.
@@ -52,6 +52,9 @@ public class ValueResolver implements IProfileConstants, IResolver {
public static final String EXP_START = "${";
public static final String EXP_END = "}";
+ private static final Charset ISO = Charset.forName("ISO-8859-1");
+ private static final Charset UTF_8 = Charset.forName("UTF-8");
+
private CertificateResolver certificateResolver;
@@ -66,6 +69,11 @@ public class ValueResolver implements IProfileConstants, IResolver {
logger.debug("Resolving value for key: " + key);
logger.debug("Resolving value with value: " + value);
+ //this needs to be encoded because of special characters
+ if(settings.isLatin1Encoding()) {
+ value = new String(value.getBytes(ISO), UTF_8);
+ }
+
if (key.equals(SIG_DATE)) {
if (value == null) {
value = defaultDateFormat;
@@ -82,7 +90,7 @@ public class ValueResolver implements IProfileConstants, IResolver {
Calendar cal = Calendar.getInstance();
return fdf.format(cal.getTime());
}
-
+
if (value != null) {
Pattern pattern = Pattern.compile(PatternRegex);