summaryrefslogtreecommitdiff
path: root/pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover
diff options
context:
space:
mode:
authorAndreas Abraham <andreas.abraham@egiz.gv.at>2020-11-19 09:24:38 +0100
committerAndreas Abraham <andreas.abraham@egiz.gv.at>2020-11-19 09:24:38 +0100
commitdf362d82d20d0301099ff3b43517034b4880bd9c (patch)
tree327d508a2f6cf87f8ad247d0d22c1f1c0302bcaa /pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover
parentaf14459241ed7c653531f769216d4e97d3c9ef2f (diff)
downloadpdf-over-df362d82d20d0301099ff3b43517034b4880bd9c.tar.gz
pdf-over-df362d82d20d0301099ff3b43517034b4880bd9c.tar.bz2
pdf-over-df362d82d20d0301099ff3b43517034b4880bd9c.zip
Fixed smaller bugs and typos
Diffstat (limited to 'pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover')
-rw-r--r--pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4SignatureParameter.java36
-rw-r--r--pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4Signer.java7
2 files changed, 31 insertions, 12 deletions
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);
}
}