From a50acb0863935747edbf1ebccf000d28822dc2db Mon Sep 17 00:00:00 2001 From: Andreas Abraham Date: Thu, 12 Nov 2020 09:54:44 +0100 Subject: settings --- .../java/at/asit/pdfover/signer/pdfas/PdfAs4SignatureParameter.java | 2 ++ .../src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4Signer.java | 2 ++ 2 files changed, 4 insertions(+) (limited to 'pdf-over-signer/pdf-over-sigpdfas4/src') diff --git a/pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4SignatureParameter.java b/pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4SignatureParameter.java index 679e1e0e..38a2bc8f 100644 --- a/pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4SignatureParameter.java +++ b/pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4SignatureParameter.java @@ -26,6 +26,7 @@ import java.util.Locale; import org.slf4j.Logger; import org.slf4j.LoggerFactory; + import at.asit.pdfover.signator.SignatureDimension; import at.asit.pdfover.signator.SignatureParameter; import at.asit.pdfover.signator.SignaturePosition; @@ -163,6 +164,7 @@ public class PdfAs4SignatureParameter extends SignatureParameter { String lang = getSignatureLanguage(); boolean useNote = (getProperty("SIG_NOTE") != null); boolean usePdfACompat = (getSignaturePdfACompat()); + String profile = getProperty("SIGNATURE_PROFILE"); //Add Signature Param here// String profileId; diff --git a/pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4Signer.java b/pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4Signer.java index c7dba85f..a729f65b 100644 --- a/pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4Signer.java +++ b/pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4Signer.java @@ -90,6 +90,8 @@ public class PdfAs4Signer implements Signer { param.getConfiguration().setValue(IConfigurationConstants.PLACEHOLDER_MODE, "3"); param.getConfiguration().setValue(IConfigurationConstants.PLACEHOLDER_SEARCH_ENABLED, IConfigurationConstants.TRUE); } + + state.setSignParameter(param); state.setOutput(output); -- cgit v1.2.3 From 1eddc2b51034df2ce3e814c297311e27dccacee1 Mon Sep 17 00:00:00 2001 From: Andreas Abraham Date: Thu, 12 Nov 2020 14:13:18 +0100 Subject: fixed problem handing over the selected profile to pdf-as4 signer --- .../pdfover/signer/pdfas/PdfAs4SignatureParameter.java | 16 +++++++++++++++- .../java/at/asit/pdfover/signer/pdfas/PdfAs4Signer.java | 2 +- 2 files changed, 16 insertions(+), 2 deletions(-) (limited to 'pdf-over-signer/pdf-over-sigpdfas4/src') diff --git a/pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4SignatureParameter.java b/pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4SignatureParameter.java index 38a2bc8f..aed66b9b 100644 --- a/pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4SignatureParameter.java +++ b/pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4SignatureParameter.java @@ -68,6 +68,7 @@ public class PdfAs4SignatureParameter extends SignatureParameter { **/ static final Logger log = LoggerFactory .getLogger(PdfAs4SignatureParameter.class); + private String profile; /* (non-Javadoc) * @see at.asit.pdfover.signator.SignatureParameter#getPlaceholderDimension() @@ -164,7 +165,7 @@ public class PdfAs4SignatureParameter extends SignatureParameter { String lang = getSignatureLanguage(); boolean useNote = (getProperty("SIG_NOTE") != null); boolean usePdfACompat = (getSignaturePdfACompat()); - String profile = getProperty("SIGNATURE_PROFILE"); + //Add Signature Param here// String profileId; @@ -191,4 +192,17 @@ public class PdfAs4SignatureParameter extends SignatureParameter { log.debug("Profile ID: " + profileId); return profileId; } + + @Override + public void setSignatureProfile(String profile) { + this.profile = profile; + } + + @Override + public String getSignatureProfile() { + return this.profile; + } } + + + diff --git a/pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4Signer.java b/pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4Signer.java index a729f65b..5c4782ba 100644 --- a/pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4Signer.java +++ b/pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4Signer.java @@ -91,7 +91,7 @@ public class PdfAs4Signer implements Signer { param.getConfiguration().setValue(IConfigurationConstants.PLACEHOLDER_SEARCH_ENABLED, IConfigurationConstants.TRUE); } - + state.setSignParameter(param); state.setOutput(output); -- cgit v1.2.3 From 400529060ae22fb9741ff7eb1c0ce81807b2d5f5 Mon Sep 17 00:00:00 2001 From: Andreas Abraham Date: Thu, 12 Nov 2020 14:50:02 +0100 Subject: Implemented invisbile sigantures visability --- .../pdfover/signer/pdfas/PdfAs4SignatureParameter.java | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'pdf-over-signer/pdf-over-sigpdfas4/src') diff --git a/pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4SignatureParameter.java b/pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4SignatureParameter.java index aed66b9b..57f36fbd 100644 --- a/pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4SignatureParameter.java +++ b/pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4SignatureParameter.java @@ -166,30 +166,28 @@ public class PdfAs4SignatureParameter extends SignatureParameter { boolean useNote = (getProperty("SIG_NOTE") != null); boolean usePdfACompat = (getSignaturePdfACompat()); - //Add Signature Param here// String profileId; - if (PROFILE_VISIBILITY) - { - profileId = PROFILE_ID_BASE; - profileId += (lang != null && lang.equals("en")) ? - PROFILE_ID_LANG_EN : PROFILE_ID_LANG_DE;} - - else + if (!PROFILE_VISIBILITY || this.profile.equals("Unsichtbar")) { profileId ="INVISIBLE"; + } else { + profileId = PROFILE_ID_BASE; + profileId += (lang != null && lang.equals("en")) ? + PROFILE_ID_LANG_EN : PROFILE_ID_LANG_DE; } + if (useNote) profileId += PROFILE_ID_NOTE; if (usePdfACompat) profileId += PROFILE_ID_PDFA; - log.debug("Profile ID: " + profileId); + log.debug("Profile ID: {0}", profileId); return profileId; } @@ -202,6 +200,7 @@ public class PdfAs4SignatureParameter extends SignatureParameter { public String getSignatureProfile() { return this.profile; } + } -- cgit v1.2.3 From a43f3b3f266a63a505ae866a2378f01e5b508cc9 Mon Sep 17 00:00:00 2001 From: Andreas Abraham Date: Fri, 13 Nov 2020 12:18:13 +0100 Subject: new module pdf-over-commons added --- .../signer/pdfas/PdfAs4SignatureParameter.java | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'pdf-over-signer/pdf-over-sigpdfas4/src') diff --git a/pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4SignatureParameter.java b/pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4SignatureParameter.java index 57f36fbd..5d286d44 100644 --- a/pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4SignatureParameter.java +++ b/pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4SignatureParameter.java @@ -34,6 +34,7 @@ import at.gv.egiz.pdfas.lib.api.Configuration; import at.gv.egiz.pdfas.lib.api.PdfAs; import at.gv.egiz.pdfas.lib.api.PdfAsFactory; import at.gv.egiz.pdfas.lib.api.sign.SignParameter; +import at.asit.pdfover.gui.Constants; /** * Implementation of SignatureParameter for PDF-AS 4 Library @@ -49,7 +50,7 @@ public class PdfAs4SignatureParameter extends SignatureParameter { private static final String PROFILE_ID_NOTE = "_NOTE"; /** The profile ID extension for PDF/A compatibility */ private static final String PROFILE_ID_PDFA = "_PDFA"; - + /** * Visibility of signature block */ @@ -58,7 +59,7 @@ public class PdfAs4SignatureParameter extends SignatureParameter { private HashMap genericProperties = new HashMap(); /** - * This parameters are defining the signature block size + * This parameters are defining the signature block size */ private int sig_w = 229; private int sig_h = 77; @@ -131,7 +132,7 @@ public class PdfAs4SignatureParameter extends SignatureParameter { /** * Gets the Signature Position String for PDF-AS - * + * * @return Signature Position String */ public String getPdfAsSignaturePosition() { @@ -168,14 +169,16 @@ public class PdfAs4SignatureParameter extends SignatureParameter { //Add Signature Param here// String profileId; - - - + + + if (!PROFILE_VISIBILITY || this.profile.equals("Unsichtbar")) { - profileId ="INVISIBLE"; + //TODO set base profile id using the this.profile + //TODO verifiy + profileId = "INVISIBLE"; } else { - profileId = PROFILE_ID_BASE; + profileId = Constants.PROFILE.getProfile(this.profile).name();//PROFILE_ID_BASE; profileId += (lang != null && lang.equals("en")) ? PROFILE_ID_LANG_EN : PROFILE_ID_LANG_DE; } @@ -187,7 +190,8 @@ public class PdfAs4SignatureParameter extends SignatureParameter { if (usePdfACompat) profileId += PROFILE_ID_PDFA; - log.debug("Profile ID: {0}", profileId); + log.debug("Profile ID: {}", profileId); + System.out.println(profileId); return profileId; } -- cgit v1.2.3 From d658f95290ea03bd0ecdc01110b48244b28e6f19 Mon Sep 17 00:00:00 2001 From: Andreas Abraham Date: Fri, 13 Nov 2020 13:49:59 +0100 Subject: refactored Profile --- .../at/asit/pdfover/signer/pdfas/PdfAs4SignatureParameter.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'pdf-over-signer/pdf-over-sigpdfas4/src') diff --git a/pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4SignatureParameter.java b/pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4SignatureParameter.java index 5d286d44..62533868 100644 --- a/pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4SignatureParameter.java +++ b/pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4SignatureParameter.java @@ -34,7 +34,7 @@ import at.gv.egiz.pdfas.lib.api.Configuration; import at.gv.egiz.pdfas.lib.api.PdfAs; import at.gv.egiz.pdfas.lib.api.PdfAsFactory; import at.gv.egiz.pdfas.lib.api.sign.SignParameter; -import at.asit.pdfover.gui.Constants; +import at.asit.pdfover.commons.Profile; /** * Implementation of SignatureParameter for PDF-AS 4 Library @@ -172,13 +172,11 @@ public class PdfAs4SignatureParameter extends SignatureParameter { - if (!PROFILE_VISIBILITY || this.profile.equals("Unsichtbar")) + if (!PROFILE_VISIBILITY || this.profile.equals("Unsichtbar") || Profile.getProfile(this.profile).equals(Profile.INVISIBLE)) { - //TODO set base profile id using the this.profile - //TODO verifiy profileId = "INVISIBLE"; } else { - profileId = Constants.PROFILE.getProfile(this.profile).name();//PROFILE_ID_BASE; + profileId = Profile.getProfile(this.profile).name(); profileId += (lang != null && lang.equals("en")) ? PROFILE_ID_LANG_EN : PROFILE_ID_LANG_DE; } -- cgit v1.2.3 From 92b4ef89ee39b6b337c8201f6d330f26d5558f54 Mon Sep 17 00:00:00 2001 From: Andreas Abraham Date: Fri, 13 Nov 2020 13:52:09 +0100 Subject: Improved code --- .../java/at/asit/pdfover/signer/pdfas/PdfAs4SignatureParameter.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'pdf-over-signer/pdf-over-sigpdfas4/src') diff --git a/pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4SignatureParameter.java b/pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4SignatureParameter.java index 62533868..68712db9 100644 --- a/pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4SignatureParameter.java +++ b/pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4SignatureParameter.java @@ -40,8 +40,6 @@ import at.asit.pdfover.commons.Profile; * Implementation of SignatureParameter for PDF-AS 4 Library */ public class PdfAs4SignatureParameter extends SignatureParameter { - /** The base profile ID */ - private static final String PROFILE_ID_BASE = "SIGNATURBLOCK_SMALL"; /** The profile ID extension for the German signature block */ private static final String PROFILE_ID_LANG_DE = "_DE"; /** The profile ID extension for the English signature block */ @@ -172,7 +170,7 @@ public class PdfAs4SignatureParameter extends SignatureParameter { - if (!PROFILE_VISIBILITY || this.profile.equals("Unsichtbar") || Profile.getProfile(this.profile).equals(Profile.INVISIBLE)) + if (!PROFILE_VISIBILITY || Profile.getProfile(this.profile).equals(Profile.INVISIBLE)) { profileId = "INVISIBLE"; } else { -- cgit v1.2.3 From df362d82d20d0301099ff3b43517034b4880bd9c Mon Sep 17 00:00:00 2001 From: Andreas Abraham Date: Thu, 19 Nov 2020 09:24:38 +0100 Subject: Fixed smaller bugs and typos --- .../signer/pdfas/PdfAs4SignatureParameter.java | 36 ++++++++++++++++------ .../at/asit/pdfover/signer/pdfas/PdfAs4Signer.java | 7 +++-- 2 files changed, 31 insertions(+), 12 deletions(-) (limited to 'pdf-over-signer/pdf-over-sigpdfas4/src') diff --git a/pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4SignatureParameter.java b/pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4SignatureParameter.java index 68712db9..08722617 100644 --- a/pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4SignatureParameter.java +++ b/pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4SignatureParameter.java @@ -49,6 +49,8 @@ public class PdfAs4SignatureParameter extends SignatureParameter { /** The profile ID extension for PDF/A compatibility */ private static final String PROFILE_ID_PDFA = "_PDFA"; + private static final String PROFILE_ID_RECOMMENDED = "_RECOMMENDED"; + /** * Visibility of signature block */ @@ -168,17 +170,25 @@ public class PdfAs4SignatureParameter extends SignatureParameter { //Add Signature Param here// String profileId; - - - if (!PROFILE_VISIBILITY || Profile.getProfile(this.profile).equals(Profile.INVISIBLE)) - { - profileId = "INVISIBLE"; - } else { - profileId = Profile.getProfile(this.profile).name(); - profileId += (lang != null && lang.equals("en")) ? - PROFILE_ID_LANG_EN : PROFILE_ID_LANG_DE; + if (!PROFILE_VISIBILITY){ + log.debug("Profile visibility was set to false"); + return Profile.INVISIBLE.name(); } + switch (Profile.getProfile(this.profile)){ + case BASE_LOGO: + case INVISIBLE: + return getProfileName(); + case AMTSSIGNATURBLOCK: + profileId = getProfileName(); + profileId += getLangProfilePart(lang); + profileId += PROFILE_ID_RECOMMENDED; + return profileId; + default: + profileId = getProfileName(); + profileId += getLangProfilePart(lang); + break; + } if (useNote) profileId += PROFILE_ID_NOTE; @@ -191,6 +201,14 @@ public class PdfAs4SignatureParameter extends SignatureParameter { return profileId; } + private String getProfileName(){ + return Profile.getProfile(this.profile).name(); + } + + private String getLangProfilePart(String lang){ + return (lang != null && lang.equals("en")) ? PROFILE_ID_LANG_EN : PROFILE_ID_LANG_DE; + } + @Override public void setSignatureProfile(String profile) { this.profile = profile; diff --git a/pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4Signer.java b/pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4Signer.java index 5c4782ba..67a8fe7f 100644 --- a/pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4Signer.java +++ b/pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4Signer.java @@ -5,6 +5,7 @@ import java.util.UUID; import javax.activation.DataSource; +import at.asit.pdfover.commons.Profile; import at.asit.pdfover.signator.ByteArrayDocumentSource; import at.asit.pdfover.signator.SignResult; import at.asit.pdfover.signator.SignResultImpl; @@ -144,6 +145,8 @@ public class PdfAs4Signer implements Signer { sp = new SignaturePosition(); else if (tp.isPauto()) sp = new SignaturePosition(tp.getPosX(), tp.getPosY()); + else if (param.getSignatureProfileId().contains(Profile.AMTSSIGNATURBLOCK.getName())) + sp = new SignaturePosition(); else sp = new SignaturePosition(tp.getPosX(), tp.getPosY(), tp.getPage()); result.setSignaturePosition(sp); @@ -151,9 +154,7 @@ public class PdfAs4Signer implements Signer { result.setSignedDocument(new ByteArrayDocumentSource(sstate.getOutput().toByteArray())); return result; - } catch (PdfAsException e) { - throw new SignatureException(e); - } catch (PDFASError e) { + } catch (PdfAsException | PDFASError e) { throw new SignatureException(e); } } -- cgit v1.2.3