summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakob Heher <jakob.heher@iaik.tugraz.at>2022-08-04 13:53:14 +0200
committerJakob Heher <jakob.heher@iaik.tugraz.at>2022-08-04 13:53:14 +0200
commit671d24d8e638b073b3aa5da00526978af2ebd06b (patch)
tree252998ce7e44d6db1c862c4ed9b7083d6aea5213
parent03b80912dc888296647412b0276e7610315fef13 (diff)
downloadpdf-over-671d24d8e638b073b3aa5da00526978af2ebd06b.tar.gz
pdf-over-671d24d8e638b073b3aa5da00526978af2ebd06b.tar.bz2
pdf-over-671d24d8e638b073b3aa5da00526978af2ebd06b.zip
pass Profile instead of String around
(in a bunch of different places)
-rw-r--r--pdf-over-commons/src/main/java/at/asit/pdfover/commons/Profile.java4
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/configuration/AdvancedConfigurationComposite.java4
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/configuration/SimpleConfigurationComposite.java4
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigurationManager.java18
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PositioningState.java2
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareSigningState.java2
-rw-r--r--pdf-over-signer/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4SignatureParameter.java13
7 files changed, 23 insertions, 24 deletions
diff --git a/pdf-over-commons/src/main/java/at/asit/pdfover/commons/Profile.java b/pdf-over-commons/src/main/java/at/asit/pdfover/commons/Profile.java
index 4e766f8e..f06d489d 100644
--- a/pdf-over-commons/src/main/java/at/asit/pdfover/commons/Profile.java
+++ b/pdf-over-commons/src/main/java/at/asit/pdfover/commons/Profile.java
@@ -24,8 +24,8 @@ public enum Profile {
return null;
}
- public static String getDefaultProfile(){
- return SIGNATURBLOCK_SMALL.name();
+ public static Profile getDefaultProfile(){
+ return SIGNATURBLOCK_SMALL;
}
public String getDefaultSignatureBlockNote(Locale locale){
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/configuration/AdvancedConfigurationComposite.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/configuration/AdvancedConfigurationComposite.java
index e24aa9a8..7316b91e 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/configuration/AdvancedConfigurationComposite.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/configuration/AdvancedConfigurationComposite.java
@@ -663,7 +663,7 @@ public class AdvancedConfigurationComposite extends ConfigurationCompositeBase {
}
this.configurationContainer.proxyUser = provider.getProxyUserPersistent();
this.configurationContainer.proxyPass = provider.getProxyPassPersistent();
- this.configurationContainer.setSignatureProfile(Profile.getProfile(provider.getSignatureProfile()));
+ this.configurationContainer.setSignatureProfile(provider.getSignatureProfile());
}
/*
@@ -745,7 +745,7 @@ public class AdvancedConfigurationComposite extends ConfigurationCompositeBase {
store.setUpdateCheckPersistent(this.configurationContainer.updateCheck);
- store.setSignatureProfilePersistent(this.configurationContainer.getSignatureProfile().name());
+ store.setSignatureProfilePersistent(this.configurationContainer.getSignatureProfile());
String hostOld = store.getProxyHostPersistent();
String hostNew = this.configurationContainer.proxyHost;
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/configuration/SimpleConfigurationComposite.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/configuration/SimpleConfigurationComposite.java
index 52c78e9d..8f652603 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/configuration/SimpleConfigurationComposite.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/configuration/SimpleConfigurationComposite.java
@@ -348,7 +348,7 @@ public class SimpleConfigurationComposite extends ConfigurationCompositeBase {
try {
PdfAs4SignatureParameter param = new PdfAs4SignatureParameter();
- param.signatureProfileName = this.configurationContainer.getSignatureProfile().name();
+ param.signatureProfile = this.configurationContainer.getSignatureProfile();
if(this.configurationContainer.signatureNote != null && !this.configurationContainer.signatureNote.isEmpty()) {
param.setProperty("SIG_NOTE", this.configurationContainer.signatureNote);
}
@@ -612,7 +612,7 @@ public class SimpleConfigurationComposite extends ConfigurationCompositeBase {
store.setDefaultEmblemPersistent(this.configurationContainer.getEmblemPath());
store.setSignatureLocalePersistent(this.configurationContainer.signatureLocale);
store.setSignatureNotePersistent(this.configurationContainer.signatureNote);
- store.setSignatureProfilePersistent(this.configurationContainer.getSignatureProfile().name());
+ store.setSignatureProfilePersistent(this.configurationContainer.getSignatureProfile());
}
/*
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigurationManager.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigurationManager.java
index df059e68..25353ac4 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigurationManager.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigurationManager.java
@@ -127,12 +127,12 @@ public class ConfigurationManager {
String signatureProfileName = diskConfig.getProperty(Constants.SIGNATURE_PROFILE);
if (signatureProfileName != null)
- setSignatureProfilePersistent(signatureProfileName);
+ setSignatureProfilePersistent(Profile.getProfile(signatureProfileName));
if (diskConfig.containsKey(Constants.CFG_SIGNATURE_NOTE))
setSignatureNotePersistent(diskConfig.getProperty(Constants.CFG_SIGNATURE_NOTE));
else
- setSignatureNotePersistent(Profile.getProfile(getSignatureProfile()).getDefaultSignatureBlockNote(getSignatureLocale()));
+ setSignatureNotePersistent(getSignatureProfile().getDefaultSignatureBlockNote(getSignatureLocale()));
String compat = diskConfig.getProperty(Constants.CFG_SIGNATURE_PDFA_COMPAT);
if (compat != null)
@@ -373,7 +373,7 @@ public class ConfigurationManager {
if (!getUpdateCheck())
props.setProperty(Constants.CFG_UPDATE_CHECK, Constants.FALSE);
- props.setProperty(Constants.SIGNATURE_PROFILE, getSignatureProfile());
+ props.setProperty(Constants.SIGNATURE_PROFILE, getSignatureProfile().name());
FileOutputStream outputstream = new FileOutputStream(configFile, false);
@@ -955,10 +955,6 @@ public class ConfigurationManager {
if (useMarker) setUseSignatureFieldsPersistent(false);
}
- public void setSignatureProfilePersistent(String profile) {
- this.configuration.setSignatureProfile(Profile.getProfile(profile));
- }
-
public void setSaveFilePostFixPersistent(String postFix) {
this.configuration.saveFilePostFix = postFix;
}
@@ -967,8 +963,12 @@ public class ConfigurationManager {
return this.configuration.saveFilePostFix;
}
- public String getSignatureProfile() {
- return this.configuration.getSignatureProfile().name();
+ public Profile getSignatureProfile() {
+ return this.configuration.getSignatureProfile();
+ }
+
+ public void setSignatureProfilePersistent(Profile profile) {
+ this.configuration.setSignatureProfile(profile);
}
public void setEnablePlaceholderUsagePersistent(boolean bool) {
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PositioningState.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PositioningState.java
index 15a67876..29a37970 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PositioningState.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PositioningState.java
@@ -107,7 +107,7 @@ public class PositioningState extends State {
ConfigurationManager config = stateMachine.configProvider;
PdfAs4SignatureParameter param = new PdfAs4SignatureParameter();
- param.signatureProfileName = config.getSignatureProfile();
+ param.signatureProfile = config.getSignatureProfile();
Emblem emblem = new Emblem(config.getDefaultEmblemPath());
param.emblem = emblem;
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareSigningState.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareSigningState.java
index bb3190ef..b0cfa71e 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareSigningState.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareSigningState.java
@@ -150,7 +150,7 @@ public class PrepareSigningState extends State {
this.state.signatureParameter.enablePDFACompat = configuration.getSignaturePdfACompat();
- this.state.signatureParameter.signatureProfileName = configuration.getSignatureProfile();
+ this.state.signatureParameter.signatureProfile = configuration.getSignatureProfile();
this.state.signingState = PdfAs4Signer.prepare(this.state.signatureParameter);
diff --git a/pdf-over-signer/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4SignatureParameter.java b/pdf-over-signer/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4SignatureParameter.java
index 5898d2d1..c6613657 100644
--- a/pdf-over-signer/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4SignatureParameter.java
+++ b/pdf-over-signer/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4SignatureParameter.java
@@ -80,7 +80,7 @@ public class PdfAs4SignatureParameter {
private HashMap<String, String> genericProperties = new HashMap<String, String>();
- public String signatureProfileName = Profile.getDefaultProfile();
+ public Profile signatureProfile = Profile.getDefaultProfile();
public Image getPlaceholder() {
String sigProfile = getPdfAsSignatureProfileId();
@@ -104,7 +104,7 @@ public class PdfAs4SignatureParameter {
Image placeholder = pdfas.generateVisibleSignaturePreview(param, cert, 72 * 4);
// WORKAROUND for #110, manually paint a black border
- if (!this.signatureProfileName.equals(Profile.BASE_LOGO.name()))
+ if (!this.signatureProfile.equals(Profile.BASE_LOGO))
{
Graphics2D ctx = (Graphics2D)placeholder.getGraphics();
ctx.setColor(Color.BLACK);
@@ -165,18 +165,17 @@ public class PdfAs4SignatureParameter {
return Profile.INVISIBLE.name();
}
- Profile profile = Profile.getProfile(this.signatureProfileName);
- switch (profile) {
+ switch (this.signatureProfile) {
case BASE_LOGO:
case INVISIBLE:
- return this.signatureProfileName;
+ return this.signatureProfile.name();
case AMTSSIGNATURBLOCK:
- profileId = this.signatureProfileName;
+ profileId = this.signatureProfile.name();
profileId += getLangProfilePart(this.signatureLanguage);
profileId += "_RECOMMENDED";
return profileId;
default:
- profileId = this.signatureProfileName;
+ profileId = this.signatureProfile.name();
profileId += getLangProfilePart(this.signatureLanguage);
break;
}