summaryrefslogtreecommitdiff
path: root/pdf-over-signer/pdf-over-sigpdfas4
diff options
context:
space:
mode:
Diffstat (limited to 'pdf-over-signer/pdf-over-sigpdfas4')
-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);
}
}