From 5754642c1d607049c013bb6f37718559e9449172 Mon Sep 17 00:00:00 2001 From: tkellner Date: Wed, 10 Apr 2013 19:16:02 +0000 Subject: Enable signature block lang selection for PDF-AS git-svn-id: https://joinup.ec.europa.eu/svn/pdf-over/trunk@231 174cde9d-5d70-4d2a-aa98-46368bc2aaf7 --- .../at/asit/pdfover/signer/pdfas/PDFASSigner.java | 15 ++----------- .../signer/pdfas/PdfAsSignatureParameter.java | 25 +++++++++++++++++++++- 2 files changed, 26 insertions(+), 14 deletions(-) (limited to 'pdf-over-signer/pdf-over-sigpdfas') diff --git a/pdf-over-signer/pdf-over-sigpdfas/src/main/java/at/asit/pdfover/signer/pdfas/PDFASSigner.java b/pdf-over-signer/pdf-over-sigpdfas/src/main/java/at/asit/pdfover/signer/pdfas/PDFASSigner.java index d613232f..e05a8ad5 100644 --- a/pdf-over-signer/pdf-over-sigpdfas/src/main/java/at/asit/pdfover/signer/pdfas/PDFASSigner.java +++ b/pdf-over-signer/pdf-over-sigpdfas/src/main/java/at/asit/pdfover/signer/pdfas/PDFASSigner.java @@ -33,17 +33,6 @@ public class PDFASSigner implements Signer { **/ static final Logger log = LoggerFactory.getLogger(PDFASSigner.class); - /** - * The profile ID - */ - protected static final String PROFILE_ID = "SIGNATURBLOCK_SMALL_DE"; - - /** - * The profile ID - * if a signature note is set - */ - protected static final String PROFILE_NOTE_ID = "SIGNATURBLOCK_SMALL_DE_NOTE"; - /** * The template URL */ @@ -83,7 +72,8 @@ public class PDFASSigner implements Signer { // params.setSignatureDevice(Constants.SIGNATURE_DEVICE_MOBILETEST); } params.setSignatureType(Constants.SIGNATURE_TYPE_BINARY); - params.setSignatureProfileId(PROFILE_ID); + + params.setSignatureProfileId(sign_para.getSignatureProfileID()); params.setOutput(new ByteArrayDataSink()); if (parameter.getEmblem() != null) { @@ -93,7 +83,6 @@ public class PDFASSigner implements Signer { if(parameter.getProperty("SIG_NOTE") != null) { params.setProfileOverrideValue("SIG_NOTE", parameter.getProperty("SIG_NOTE")); - params.setSignatureProfileId(PROFILE_NOTE_ID); } // Prepare Output sink diff --git a/pdf-over-signer/pdf-over-sigpdfas/src/main/java/at/asit/pdfover/signer/pdfas/PdfAsSignatureParameter.java b/pdf-over-signer/pdf-over-sigpdfas/src/main/java/at/asit/pdfover/signer/pdfas/PdfAsSignatureParameter.java index 899fa890..43916d08 100644 --- a/pdf-over-signer/pdf-over-sigpdfas/src/main/java/at/asit/pdfover/signer/pdfas/PdfAsSignatureParameter.java +++ b/pdf-over-signer/pdf-over-sigpdfas/src/main/java/at/asit/pdfover/signer/pdfas/PdfAsSignatureParameter.java @@ -55,6 +55,15 @@ public class PdfAsSignatureParameter extends SignatureParameter { static final Logger log = LoggerFactory .getLogger(PdfAsSignatureParameter.class); + /** The profile ID for the german signature block */ + private static final String PROFILE_ID_DE = "SIGNATURBLOCK_SMALL_DE"; + /** The profile ID for the german signature block if a signature note is set */ + private static final String PROFILE_ID_DE_NOTE = "SIGNATURBLOCK_SMALL_DE_NOTE"; + /** The profile ID for the english signature block */ + private static final String PROFILE_ID_EN = "SIGNATURBLOCK_SMALL_EN"; + /** The profile ID for the english signature block if a signature note is set */ + private static final String PROFILE_ID_EN_NOTE = "SIGNATURBLOCK_SMALL_EN_NOTE"; + private static final int PLACEHOLDER_SCALE = 4; private HashMap genericProperties = new HashMap(); @@ -117,6 +126,20 @@ public class PdfAsSignatureParameter extends SignatureParameter { return new SignatureDimension(276, 95); } + /** + * Get the Signature Profile ID for this set of parameters + * @return the Signature Profile ID + */ + public String getSignatureProfileID() { + String lang = getSignatureLanguage(); + boolean useNote = (getProperty("SIG_NOTE") != null); + + if (lang != null && lang.equals("en")) + return useNote ? PROFILE_ID_EN_NOTE : PROFILE_ID_EN; + + return useNote ? PROFILE_ID_DE_NOTE : PROFILE_ID_DE; + } + /* * (non-Javadoc) * @@ -129,7 +152,7 @@ public class PdfAsSignatureParameter extends SignatureParameter { PDFASHelper.getPdfAs(); SignatureObject sign_obj = at.knowcenter.wag.egov.egiz.PdfAS - .createSignatureObjectFromType(PDFASSigner.PROFILE_ID); + .createSignatureObjectFromType(getSignatureProfileID()); sign_obj.fillValues(' ', true, false); sign_obj.setKZ(BinarySignator_1_1_0.MY_ID); -- cgit v1.2.3