aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pdf-as-common/src/main/java/at/gv/egiz/pdfas/common/settings/IProfileConstants.java1
-rw-r--r--pdf-as-common/src/main/java/at/gv/egiz/pdfas/common/settings/SignatureProfileSettings.java10
-rw-r--r--pdf-as-common/src/main/java/at/gv/egiz/pdfas/common/utils/OgnlUtils.java3
-rw-r--r--pdf-as-common/src/main/java/at/gv/egiz/pdfas/common/utils/StringUtils.java8
-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
-rw-r--r--pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox2/PDFBoxFont.java2
7 files changed, 42 insertions, 26 deletions
diff --git a/pdf-as-common/src/main/java/at/gv/egiz/pdfas/common/settings/IProfileConstants.java b/pdf-as-common/src/main/java/at/gv/egiz/pdfas/common/settings/IProfileConstants.java
index df1f4682..e1fcb9d0 100644
--- a/pdf-as-common/src/main/java/at/gv/egiz/pdfas/common/settings/IProfileConstants.java
+++ b/pdf-as-common/src/main/java/at/gv/egiz/pdfas/common/settings/IProfileConstants.java
@@ -94,5 +94,6 @@ public interface IProfileConstants {
public final static String SIG_PDFA1B_VALID = "SIG_PDFA1B_VALID";
public final static String SIG_PDFA_VALID = "SIG_PDFA_VALID";
public final static String SIG_PDFUA_FORCE = "SIG_PDFUA_FORCE";
+ public final static String LATIN1_ENCODING = "latin1_encoding";
}
diff --git a/pdf-as-common/src/main/java/at/gv/egiz/pdfas/common/settings/SignatureProfileSettings.java b/pdf-as-common/src/main/java/at/gv/egiz/pdfas/common/settings/SignatureProfileSettings.java
index bb6cca83..a151f12e 100644
--- a/pdf-as-common/src/main/java/at/gv/egiz/pdfas/common/settings/SignatureProfileSettings.java
+++ b/pdf-as-common/src/main/java/at/gv/egiz/pdfas/common/settings/SignatureProfileSettings.java
@@ -238,6 +238,16 @@ public class SignatureProfileSettings implements IProfileConstants {
return false;
}
+
+ public boolean isLatin1Encoding() {
+ SignatureProfileEntry entry = profileInformations.get(LATIN1_ENCODING);
+ if (entry != null) {
+ String value = entry.getCaption();
+ return "true".equals(value);
+ }
+ return false;
+ }
+
public boolean isPDFA3() {
if(this.pdfAVersion != null) {
return "3".equals(this.pdfAVersion);
diff --git a/pdf-as-common/src/main/java/at/gv/egiz/pdfas/common/utils/OgnlUtils.java b/pdf-as-common/src/main/java/at/gv/egiz/pdfas/common/utils/OgnlUtils.java
index d5bae58e..50a34c57 100644
--- a/pdf-as-common/src/main/java/at/gv/egiz/pdfas/common/utils/OgnlUtils.java
+++ b/pdf-as-common/src/main/java/at/gv/egiz/pdfas/common/utils/OgnlUtils.java
@@ -30,6 +30,8 @@ import ognl.OgnlException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import java.nio.charset.Charset;
+
/**
* Created with IntelliJ IDEA.
* User: afitzek
@@ -52,6 +54,7 @@ public class OgnlUtils {
valueString = valueString.substring(0, valueString.length() - 1);
}
return valueString;
+
} catch (OgnlException e) {
logger.warn("OGNL resolver failed!", e);
}
diff --git a/pdf-as-common/src/main/java/at/gv/egiz/pdfas/common/utils/StringUtils.java b/pdf-as-common/src/main/java/at/gv/egiz/pdfas/common/utils/StringUtils.java
index dbea3c70..7156a97b 100644
--- a/pdf-as-common/src/main/java/at/gv/egiz/pdfas/common/utils/StringUtils.java
+++ b/pdf-as-common/src/main/java/at/gv/egiz/pdfas/common/utils/StringUtils.java
@@ -23,13 +23,13 @@
******************************************************************************/
package at.gv.egiz.pdfas.common.utils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.Formatter;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
/**
* Created with IntelliJ IDEA. User: afitzek Date: 8/28/13 Time: 12:42 PM To
* change this template use File | Settings | File Templates.
@@ -62,7 +62,7 @@ public class StringUtils {
public static String convertStringToPDFFormat(String value)
throws UnsupportedEncodingException {
-
+
if(value == null) {
logger.warn("Trying to convert null string!");
return value;
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);
diff --git a/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox2/PDFBoxFont.java b/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox2/PDFBoxFont.java
index 9c848ff9..415aa74a 100644
--- a/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox2/PDFBoxFont.java
+++ b/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox2/PDFBoxFont.java
@@ -202,7 +202,6 @@ public class PDFBoxFont {
return font;
-
}
private PDFont generateFont(String fonttype, String fontder,
@@ -242,7 +241,6 @@ public class PDFBoxFont {
this.font = defaultFont;
this.fontSize = defaultFontSize;
}
-
}
public PDFBoxFont(String fontDesc, ISettings settings,