summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pdf-over-commons/pom.xml2
-rw-r--r--pdf-over-gui/pom.xml2
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/SimpleConfigurationComposite.java3
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigProviderImpl.java7
-rw-r--r--pdf-over-install-helper/pom.xml2
-rw-r--r--pdf-over-signator/pom.xml2
-rw-r--r--pdf-over-signer/pdf-over-sigpdfas4/pom.xml2
-rw-r--r--pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4SignatureParameter.java373
-rw-r--r--pdf-over-signer/pom.xml2
-rw-r--r--pom.xml2
10 files changed, 204 insertions, 193 deletions
diff --git a/pdf-over-commons/pom.xml b/pdf-over-commons/pom.xml
index 4c952611..0f39262e 100644
--- a/pdf-over-commons/pom.xml
+++ b/pdf-over-commons/pom.xml
@@ -3,7 +3,7 @@
<parent>
<artifactId>pdf-over</artifactId>
<groupId>at.a-sit</groupId>
- <version>4.3.0-SNAPSHOt</version>
+ <version>4.3.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
diff --git a/pdf-over-gui/pom.xml b/pdf-over-gui/pom.xml
index f1b36d28..a439c79a 100644
--- a/pdf-over-gui/pom.xml
+++ b/pdf-over-gui/pom.xml
@@ -3,7 +3,7 @@
<parent>
<artifactId>pdf-over</artifactId>
<groupId>at.a-sit</groupId>
- <version>4.3.0-SNAPSHOt</version>
+ <version>4.3.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>pdf-over-gui</artifactId>
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/SimpleConfigurationComposite.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/SimpleConfigurationComposite.java
index 10be1500..8fd94eb7 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/SimpleConfigurationComposite.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/SimpleConfigurationComposite.java
@@ -243,9 +243,6 @@ public class SimpleConfigurationComposite extends BaseConfigurationComposite {
@Override
public void widgetSelected(SelectionEvent e) {
Profile current = SimpleConfigurationComposite.this.configurationContainer.getSignatureProfile();
- //Profile selected = Profile.getProfileByIndex(SimpleConfigurationComposite.this.cmbSignatureProfiles
- // .getSelectionIndex());
- //TODO to test
int index = SimpleConfigurationComposite.this.cmbSignatureProfiles.getSelectionIndex();
Profile selected = Profile.values()[index];
if (!current.equals(selected)) {
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigProviderImpl.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigProviderImpl.java
index a7e6592c..036154ab 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigProviderImpl.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigProviderImpl.java
@@ -151,8 +151,11 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator,
String signatureProfile = config.getProperty(Constants.SIGNATURE_PROFILE);
if (signatureProfile != null) {
- this.configuration.setSignatureProfile(Profile.getProfile(signatureProfile));
- this.configurationOverlay.setSignatureProfile(Profile.getProfile(signatureProfile));
+ Profile profile = Profile.getProfile(signatureProfile);
+ if (profile != null) {
+ this.configuration.setSignatureProfile(profile);
+ this.configurationOverlay.setSignatureProfile(profile);
+ }
}
String compat = config.getProperty(Constants.CFG_SIGNATURE_PDFA_COMPAT);
diff --git a/pdf-over-install-helper/pom.xml b/pdf-over-install-helper/pom.xml
index ef7c6a11..68d9f924 100644
--- a/pdf-over-install-helper/pom.xml
+++ b/pdf-over-install-helper/pom.xml
@@ -3,7 +3,7 @@
<parent>
<groupId>at.a-sit</groupId>
<artifactId>pdf-over</artifactId>
- <version>4.3.0-SNAPSHOt</version>
+ <version>4.3.0-SNAPSHOT</version>
</parent>
<!-- <groupId>at.a-sit</groupId> -->
<artifactId>pdf-over-install-helper</artifactId>
diff --git a/pdf-over-signator/pom.xml b/pdf-over-signator/pom.xml
index c039df72..69b2d295 100644
--- a/pdf-over-signator/pom.xml
+++ b/pdf-over-signator/pom.xml
@@ -3,7 +3,7 @@
<parent>
<artifactId>pdf-over</artifactId>
<groupId>at.a-sit</groupId>
- <version>4.3.0-SNAPSHOt</version>
+ <version>4.3.0-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>
<artifactId>pdf-over-signator</artifactId>
diff --git a/pdf-over-signer/pdf-over-sigpdfas4/pom.xml b/pdf-over-signer/pdf-over-sigpdfas4/pom.xml
index 078844cb..38c03dca 100644
--- a/pdf-over-signer/pdf-over-sigpdfas4/pom.xml
+++ b/pdf-over-signer/pdf-over-sigpdfas4/pom.xml
@@ -3,7 +3,7 @@
<parent>
<artifactId>pdf-over-signer</artifactId>
<groupId>at.a-sit</groupId>
- <version>4.3.0-SNAPSHOt</version>
+ <version>4.3.0-SNAPSHOT</version>
<!-- <relativePath>..</relativePath> -->
</parent>
<artifactId>pdf-over-sigpdfas4</artifactId>
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 0117b8d3..fbe1edfb 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
@@ -16,6 +16,7 @@
package at.asit.pdfover.signer.pdfas;
//Imports
+
import iaik.x509.X509Certificate;
import java.awt.Image;
@@ -40,187 +41,197 @@ import at.asit.pdfover.commons.Profile;
* Implementation of SignatureParameter for PDF-AS 4 Library
*/
public class PdfAs4SignatureParameter extends SignatureParameter {
- /** 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 */
- private static final String PROFILE_ID_LANG_EN = "_EN";
- /** The profile ID extension for the signature note */
- private static final String PROFILE_ID_NOTE = "_NOTE";
- /** 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
- */
- public static boolean PROFILE_VISIBILITY=true;
-
- private HashMap<String, String> genericProperties = new HashMap<String, String>();
-
- /**
- * This parameters are defining the signature block size
- */
- private int sig_w = 229;
- private int sig_h = 77;
-
- /**
- * SLF4J Logger instance
- **/
- static final Logger log = LoggerFactory
- .getLogger(PdfAs4SignatureParameter.class);
- private String profile = null;
-
- /* (non-Javadoc)
- * @see at.asit.pdfover.signator.SignatureParameter#getPlaceholderDimension()
- */
- @Override
- public SignatureDimension getPlaceholderDimension() {
- return new SignatureDimension(this.sig_w, this.sig_h);
- }
-
- /* (non-Javadoc)
- * @see at.asit.pdfover.signator.SignatureParameter#getPlaceholder()
- */
- @Override
- public Image getPlaceholder() {
- String sigProfile = getPdfAsSignatureProfileId();
- String sigEmblem = (getEmblem() == null ? null : getEmblem().getFileName());
- String sigNote = getProperty("SIG_NOTE");
-
- try {
- X509Certificate cert = new X509Certificate(PdfAs4SignatureParameter.class.getResourceAsStream("/qualified.cer"));
- PdfAs pdfas = PdfAs4Helper.getPdfAs();
- Configuration conf = pdfas.getConfiguration();
- if (sigEmblem != null && !sigEmblem.trim().equals("")) {
- conf.setValue("sig_obj." + sigProfile + ".value.SIG_LABEL", sigEmblem);
- }
- if (sigNote != null) {
- conf.setValue("sig_obj." + sigProfile + ".value.SIG_NOTE", sigNote);
- }
- SignParameter param = PdfAsFactory
- .createSignParameter(conf, null, null);
- param.setSignatureProfileId(sigProfile);
- Image img = pdfas.generateVisibleSignaturePreview(param, cert, 72*4);
- this.sig_w = img.getWidth(null)/4;
- this.sig_h = img.getHeight(null)/4;
-
- return img;
- } catch (Exception e) {
- log.error("Failed to get signature placeholder", e);
- return new BufferedImage(getPlaceholderDimension().getWidth(),
- getPlaceholderDimension().getHeight(),
- BufferedImage.TYPE_INT_RGB);
- }
- }
-
- /* (non-Javadoc)
- * @see at.asit.pdfover.signator.SignatureParameter#setProperty(java.lang.String, java.lang.String)
- */
- @Override
- public void setProperty(String key, String value) {
- this.genericProperties.put(key, value);
- }
-
- /* (non-Javadoc)
- * @see at.asit.pdfover.signator.SignatureParameter#getProperty(java.lang.String)
- */
- @Override
- public String getProperty(String key) {
- return this.genericProperties.get(key);
- }
-
- /**
- * Gets the Signature Position String for PDF-AS
- *
- * @return Signature Position String
- */
- public String getPdfAsSignaturePosition() {
- SignaturePosition in_pos = getSignaturePosition();
- String out_pos;
-
- if (!in_pos.useAutoPositioning()) {
- if (in_pos.getPage() < 1) {
- out_pos = String.format(
- (Locale) null,
- "p:new;x:%f;y:%f", in_pos.getX(),
- in_pos.getY());
- } else {
- out_pos = String.format(
- (Locale) null,
- "p:%d;x:%f;y:%f", in_pos.getPage(), in_pos.getX(),
- in_pos.getY());
- }
- } else {
- out_pos = "p:auto;x:auto;y:auto";
- }
-
- return out_pos;
- }
-
- /**
- * Get the Signature Profile ID for this set of parameters
- * @return the Signature Profile ID
- */
- public String getPdfAsSignatureProfileId() {
- String lang = getSignatureLanguage();
- boolean useNote = (getProperty("SIG_NOTE") != null);
- boolean usePdfACompat = (getSignaturePdfACompat());
-
- //Add Signature Param here//
- String profileId;
-
- if (!PROFILE_VISIBILITY){
- log.debug("Profile visibility was set to false");
- return Profile.INVISIBLE.name();
- }
-
- switch (Profile.getProfile(getProfileName())){
- 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;
-
- if (usePdfACompat)
- profileId += PROFILE_ID_PDFA;
-
- log.debug("Profile ID: {}", profileId);
- System.out.println(profileId);
- return profileId;
- }
-
- private String getProfileName(){
- if (this.profile == null){
- this.profile = Profile.SIGNATURBLOCK_SMALL.name();
- }
- 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;
- }
-
- @Override
- public String getSignatureProfile() {
- return this.profile;
- }
+ /**
+ * 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
+ */
+ private static final String PROFILE_ID_LANG_EN = "_EN";
+ /**
+ * The profile ID extension for the signature note
+ */
+ private static final String PROFILE_ID_NOTE = "_NOTE";
+ /**
+ * 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
+ */
+ public static boolean PROFILE_VISIBILITY = true;
+
+ private HashMap<String, String> genericProperties = new HashMap<String, String>();
+
+ /**
+ * This parameters are defining the signature block size
+ */
+ private int sig_w = 229;
+ private int sig_h = 77;
+
+ /**
+ * SLF4J Logger instance
+ **/
+ static final Logger log = LoggerFactory
+ .getLogger(PdfAs4SignatureParameter.class);
+ private String profile = null;
+
+ /* (non-Javadoc)
+ * @see at.asit.pdfover.signator.SignatureParameter#getPlaceholderDimension()
+ */
+ @Override
+ public SignatureDimension getPlaceholderDimension() {
+ return new SignatureDimension(this.sig_w, this.sig_h);
+ }
+
+ /* (non-Javadoc)
+ * @see at.asit.pdfover.signator.SignatureParameter#getPlaceholder()
+ */
+ @Override
+ public Image getPlaceholder() {
+ String sigProfile = getPdfAsSignatureProfileId();
+ String sigEmblem = (getEmblem() == null ? null : getEmblem().getFileName());
+ String sigNote = getProperty("SIG_NOTE");
+
+ try {
+ X509Certificate cert = new X509Certificate(PdfAs4SignatureParameter.class.getResourceAsStream("/qualified.cer"));
+ PdfAs pdfas = PdfAs4Helper.getPdfAs();
+ Configuration conf = pdfas.getConfiguration();
+ if (sigEmblem != null && !sigEmblem.trim().equals("")) {
+ conf.setValue("sig_obj." + sigProfile + ".value.SIG_LABEL", sigEmblem);
+ }
+ if (sigNote != null) {
+ conf.setValue("sig_obj." + sigProfile + ".value.SIG_NOTE", sigNote);
+ }
+ SignParameter param = PdfAsFactory
+ .createSignParameter(conf, null, null);
+ param.setSignatureProfileId(sigProfile);
+ Image img = pdfas.generateVisibleSignaturePreview(param, cert, 72 * 4);
+ this.sig_w = img.getWidth(null) / 4;
+ this.sig_h = img.getHeight(null) / 4;
+
+ return img;
+ } catch (Exception e) {
+ log.error("Failed to get signature placeholder", e);
+ return new BufferedImage(getPlaceholderDimension().getWidth(),
+ getPlaceholderDimension().getHeight(),
+ BufferedImage.TYPE_INT_RGB);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see at.asit.pdfover.signator.SignatureParameter#setProperty(java.lang.String, java.lang.String)
+ */
+ @Override
+ public void setProperty(String key, String value) {
+ this.genericProperties.put(key, value);
+ }
+
+ /* (non-Javadoc)
+ * @see at.asit.pdfover.signator.SignatureParameter#getProperty(java.lang.String)
+ */
+ @Override
+ public String getProperty(String key) {
+ return this.genericProperties.get(key);
+ }
+
+ /**
+ * Gets the Signature Position String for PDF-AS
+ *
+ * @return Signature Position String
+ */
+ public String getPdfAsSignaturePosition() {
+ SignaturePosition in_pos = getSignaturePosition();
+ String out_pos;
+
+ if (!in_pos.useAutoPositioning()) {
+ if (in_pos.getPage() < 1) {
+ out_pos = String.format(
+ (Locale) null,
+ "p:new;x:%f;y:%f", in_pos.getX(),
+ in_pos.getY());
+ } else {
+ out_pos = String.format(
+ (Locale) null,
+ "p:%d;x:%f;y:%f", in_pos.getPage(), in_pos.getX(),
+ in_pos.getY());
+ }
+ } else {
+ out_pos = "p:auto;x:auto;y:auto";
+ }
+
+ return out_pos;
+ }
+
+ /**
+ * Get the Signature Profile ID for this set of parameters
+ *
+ * @return the Signature Profile ID
+ */
+ public String getPdfAsSignatureProfileId() {
+ String lang = getSignatureLanguage();
+ boolean useNote = (getProperty("SIG_NOTE") != null);
+ boolean usePdfACompat = (getSignaturePdfACompat());
+
+ //Add Signature Param here//
+ String profileId;
+
+ if (!PROFILE_VISIBILITY) {
+ log.debug("Profile visibility was set to false");
+ return Profile.INVISIBLE.name();
+ }
+
+ Profile profile = Profile.getProfile(this.profile);
+ switch (profile) {
+ case BASE_LOGO:
+ case INVISIBLE:
+ return this.profile;
+ case AMTSSIGNATURBLOCK:
+ profileId = this.profile;
+ profileId += getLangProfilePart(lang);
+ profileId += PROFILE_ID_RECOMMENDED;
+ return profileId;
+ default:
+ profileId = this.profile;
+ profileId += getLangProfilePart(lang);
+ break;
+ }
+
+ if (useNote)
+ profileId += PROFILE_ID_NOTE;
+
+ if (usePdfACompat)
+ profileId += PROFILE_ID_PDFA;
+
+ log.debug("Profile ID: {}", profileId);
+ System.out.println(profileId);
+ return profileId;
+ }
+
+ private String getProfileName() {
+ if (this.profile == null) {
+ this.profile = Profile.SIGNATURBLOCK_SMALL.name();
+ }
+ 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;
+ }
+
+ @Override
+ public String getSignatureProfile() {
+ return this.profile;
+ }
}
diff --git a/pdf-over-signer/pom.xml b/pdf-over-signer/pom.xml
index 960913e9..d3281c2f 100644
--- a/pdf-over-signer/pom.xml
+++ b/pdf-over-signer/pom.xml
@@ -3,7 +3,7 @@
<parent>
<artifactId>pdf-over</artifactId>
<groupId>at.a-sit</groupId>
- <version>4.3.0-SNAPSHOt</version>
+ <version>4.3.0-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>
<artifactId>pdf-over-signer</artifactId>
diff --git a/pom.xml b/pom.xml
index 5752b27f..16a4f925 100644
--- a/pom.xml
+++ b/pom.xml
@@ -4,7 +4,7 @@
<groupId>at.a-sit</groupId>
<artifactId>pdf-over</artifactId>
- <version>4.3.0-SNAPSHOt</version>
+ <version>4.3.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>PDF-Over</name>