From f4a1952fa7ba68366c36d75d3d7233ce9af80259 Mon Sep 17 00:00:00 2001 From: rpiazzi Date: Thu, 3 Nov 2011 10:28:49 +0000 Subject: Added workaround for replacing special characters (Umlaute) that since July 2011 aren't rightly encoded by a-trust git-svn-id: https://joinup.ec.europa.eu/svn/pdf-as/trunk@880 7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c --- .../impl/signator/binary/BinarySignator_1_0_0.java | 60 +++++++++++++++++++--- 1 file changed, 53 insertions(+), 7 deletions(-) (limited to 'src/main/java/at') diff --git a/src/main/java/at/gv/egiz/pdfas/impl/signator/binary/BinarySignator_1_0_0.java b/src/main/java/at/gv/egiz/pdfas/impl/signator/binary/BinarySignator_1_0_0.java index 5766b89..46e46cb 100644 --- a/src/main/java/at/gv/egiz/pdfas/impl/signator/binary/BinarySignator_1_0_0.java +++ b/src/main/java/at/gv/egiz/pdfas/impl/signator/binary/BinarySignator_1_0_0.java @@ -301,12 +301,11 @@ public class BinarySignator_1_0_0 implements Signator { throw new SignatorException(e); } - + BinarySignature.replaceCertificate(iui); BinarySignature.replaceTimestamp(iui); BinarySignature.replacePlaceholders(iui); - -// dferbas: alternative sign attrib creation + // dferbas: alternative sign attrib creation // PdfReader reader = new PdfReader(iui.signed_pdf); // // OutputStream os = dataSink.createOutputStream(PdfAS.PDF_MIME_TYPE); @@ -358,14 +357,61 @@ public class BinarySignator_1_0_0 implements Signator ReplaceInfo ri = (ReplaceInfo) it.next(); String overrideVal = OverridePropertyHolder.getProperty(ri.sfd.field_name); if (overrideVal != null) { - ri.sfd.value = overrideVal; + ri.sfd.value = overrideVal; ri.value = overrideVal; } else if (ognl.containsExpression(ri.sfd.value)) { // dferbas // evaluate expression String res = ognl.compileMessage(ri.sfd.value); - - ri.value = this.normalizer.normalize(res, true); - + ri.value = this.normalizer.normalize(res, true); + //Workaround added by rpiazzi + //a-trust wrongly encodes since July 2011, therefore some special characters (e.g. Umlaute) have + //to replaced by their right character + if ((ri.value.contains("ü") || ri.value.contains("ä") || ri.value.contains("ö") || + ri.value.contains("á") || ri.value.contains("ß") || ri.value.contains("Ö") || + ri.value.contains("à") || ri.value.contains("é") || ri.value.contains("ú") || + ri.value.contains("ç")) && (ri.sfd.field_name.equals(SignatureTypes.SIG_SUBJECT))) { + if (ri.value.contains("ü")) { + ri.sfd.value = ri.sfd.value.replace("ü", "ü"); + ri.value = ri.value.replace("ü", "ü"); + } + if (ri.value.contains("ä")) { + ri.sfd.value = ri.sfd.value.replace("ä", "ä"); + ri.value = ri.value.replace("ä", "ä"); + } + if (ri.value.contains("ö")) { + ri.sfd.value = ri.sfd.value.replace("ö", "ö"); + ri.value = ri.value.replace("ö", "ö"); + } + if (ri.value.contains("á")) { + ri.sfd.value = ri.sfd.value.replace("á", "á"); + ri.value = ri.value.replace("á", "á"); + } + if (ri.value.contains("ß")) { + ri.sfd.value = ri.sfd.value.replace("ß", "ß"); + ri.value = ri.value.replace("ß", "ß"); + } + if (ri.value.contains("Ö")) { + ri.sfd.value = ri.sfd.value.replace("Ö", "Ö"); + ri.value = ri.value.replace("Ö", "Ö"); + } + if (ri.value.contains("à")) { + ri.sfd.value = ri.sfd.value.replace("à", "à"); + ri.value = ri.value.replace("à", "à"); + } + if (ri.value.contains("é")) { + ri.sfd.value = ri.sfd.value.replace("é", "é"); + ri.value = ri.value.replace("é", "é"); + } + if (ri.value.contains("ú")) { + ri.sfd.value = ri.sfd.value.replace("ú", "ú"); + ri.value = ri.value.replace("ú", "ú"); + } + if (ri.value.contains("ç")) { + ri.sfd.value = ri.sfd.value.replace("ç", "ç"); + ri.value = ri.value.replace("ç", "ç"); + } + } + //end added } else if (overrideVal == null) { //If SUBJECT is not overridden and and also isn't an expression //check whether a set value for subject exists. -- cgit v1.2.3