From 79f8912b36d37a25867c52f86bcff13ff75e40a2 Mon Sep 17 00:00:00 2001 From: emusic Date: Fri, 8 Nov 2019 14:13:45 +0100 Subject: Encoding of special characters --- .../lib/impl/stamping/CertificateResolver.java | 18 ++++++--------- .../pdfas/lib/impl/stamping/ValueResolver.java | 26 ++++++++++++++-------- 2 files changed, 24 insertions(+), 20 deletions(-) (limited to 'pdf-as-lib/src/main/java/at/gv') 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); -- cgit v1.2.3