aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Fitzek <andreas.fitzek@iaik.tugraz.at>2016-07-01 10:20:24 +0200
committerAndreas Fitzek <andreas.fitzek@iaik.tugraz.at>2016-07-01 10:20:24 +0200
commit2df24d283591f0a7037b658bb637577613e0439a (patch)
treef2d6c943450b070307b025437e19eda1f8f96a19
parentdc834260d57e5d94e11d4c617f005369ccde2ce7 (diff)
downloadpdf-as-4-2df24d283591f0a7037b658bb637577613e0439a.tar.gz
pdf-as-4-2df24d283591f0a7037b658bb637577613e0439a.tar.bz2
pdf-as-4-2df24d283591f0a7037b658bb637577613e0439a.zip
added augmentating signature profiles
-rw-r--r--pdf-as-common/src/main/java/at/gv/egiz/pdfas/common/settings/Profiles.java22
-rw-r--r--pdf-as-common/src/main/java/at/gv/egiz/pdfas/common/settings/Settings.java668
-rw-r--r--pdf-as-common/src/main/java/at/gv/egiz/pdfas/common/utils/ImageUtils.java11
-rw-r--r--pdf-as-lib/src/configuration/cfg/profiles/AMTSSIGNATURBLOCK_BASE.properties49
-rw-r--r--pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/configuration/ConfigurationImpl.java3
5 files changed, 473 insertions, 280 deletions
diff --git a/pdf-as-common/src/main/java/at/gv/egiz/pdfas/common/settings/Profiles.java b/pdf-as-common/src/main/java/at/gv/egiz/pdfas/common/settings/Profiles.java
index 9969fdf0..2b5c5b6f 100644
--- a/pdf-as-common/src/main/java/at/gv/egiz/pdfas/common/settings/Profiles.java
+++ b/pdf-as-common/src/main/java/at/gv/egiz/pdfas/common/settings/Profiles.java
@@ -1,20 +1,23 @@
package at.gv.egiz.pdfas.common.settings;
-import java.util.Map;
-import java.util.Properties;
+import java.util.*;
public class Profiles {
private String name;
private Profiles parent;
+ private List<Profiles> augments;
private boolean initialized;
private static final String PARENT_CONFIG = ".parent";
+
+ private static final String AUGMENTS_CONFIG = ".augments";
public Profiles(String name) {
this.name = name;
this.initialized = false;
this.parent = null;
+ this.augments = new ArrayList<Profiles>();
}
public String getName() {
@@ -26,12 +29,27 @@ public class Profiles {
if(parentString != null) {
this.parent = profiles.get(parentString);
}
+
+ String augmentKeyPrefix = "sig_obj." + this.name + AUGMENTS_CONFIG;
+
+ Enumeration enumeration = props.propertyNames();
+ while(enumeration.hasMoreElements()) {
+ String key = (String)enumeration.nextElement();
+ if(key.startsWith(augmentKeyPrefix)) {
+ String augmentProfile = props.getProperty(key);
+ this.augments.add(profiles.get(augmentProfile));
+ }
+ }
}
public Profiles getParent() {
return this.parent;
}
+ public List<Profiles> getAugments() {
+ return this.augments;
+ }
+
public boolean isInitialized() {
return initialized;
}
diff --git a/pdf-as-common/src/main/java/at/gv/egiz/pdfas/common/settings/Settings.java b/pdf-as-common/src/main/java/at/gv/egiz/pdfas/common/settings/Settings.java
index f37ae452..0dc36fd2 100644
--- a/pdf-as-common/src/main/java/at/gv/egiz/pdfas/common/settings/Settings.java
+++ b/pdf-as-common/src/main/java/at/gv/egiz/pdfas/common/settings/Settings.java
@@ -3,19 +3,19 @@
* PDF-AS has been contracted by the E-Government Innovation Center EGIZ, a
* joint initiative of the Federal Chancellery Austria and Graz University of
* Technology.
- *
+ * <p>
* Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
* the European Commission - subsequent versions of the EUPL (the "Licence");
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at:
* http://www.osor.eu/eupl/
- *
+ * <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the Licence is distributed on an "AS IS" basis,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Licence for the specific language governing permissions and
* limitations under the Licence.
- *
+ * <p>
* This product combines work with different licenses. See the "NOTICE" text
* file for details on the various modules and licenses.
* The "NOTICE" text file is part of the distribution. Any derivative works
@@ -46,192 +46,306 @@ import at.gv.egiz.pdfas.common.exceptions.PdfAsSettingsException;
public class Settings implements ISettings, IProfileConstants {
- private static final Logger logger = LoggerFactory
- .getLogger(Settings.class);
-
- protected Properties properties = new Properties();
-
- protected File workDirectory;
-
- public Settings(File workDirectory) {
- try {
- this.workDirectory = workDirectory;
- loadSettings(workDirectory);
- } catch (PdfAsSettingsException e) {
- logger.error(e.getMessage(), e);
- }
- }
-
- private void loadSettingsRecursive(File workDirectory, File file)
- throws PdfAsSettingsException {
- try {
- String configDir = workDirectory.getAbsolutePath() + File.separator
- + CFG_DIR;
- Properties tmpProps = new Properties();
- logger.debug("Loading: " + file.getName());
- tmpProps.load(new FileInputStream(file));
-
- properties.putAll(tmpProps);
-
- Map<String, String> includes = this.getValuesPrefix(INCLUDE,
- tmpProps);
- File contextFolder = new File(configDir);
- if (includes != null) {
- Iterator<String> includeIterator = includes.values().iterator();
- while (includeIterator.hasNext()) {
- contextFolder = new File(configDir);
- String includeFileName = includeIterator.next();
-
- File includeInstruction = new File(contextFolder,
- includeFileName);
- contextFolder = includeInstruction.getParentFile();
- String includeName = includeInstruction.getName();
-
- WildcardFileFilter fileFilter = new WildcardFileFilter(
- includeName, IOCase.SENSITIVE);
- Collection<File> includeFiles = null;
-
- if (contextFolder != null && contextFolder.exists()
- && contextFolder.isDirectory()) {
- includeFiles = FileUtils.listFiles(contextFolder,
- fileFilter, null);
- }
- if (includeFiles != null && !includeFiles.isEmpty()) {
- logger.debug("Including '" + includeFileName + "'.");
- for (File includeFile : includeFiles) {
- loadSettingsRecursive(workDirectory, includeFile);
- }
- }
- }
- }
-
- } catch (IOException e) {
- throw new PdfAsSettingsException("Failed to read settings!", e);
- }
- }
-
- private void buildProfiles() {
- Map<String, Profiles> profiles = new HashMap<String, Profiles>();
-
- Iterator<String> itKeys = this.getFirstLevelKeys("sig_obj.types.")
- .iterator();
- while (itKeys.hasNext()) {
- String key = itKeys.next();
- String profile = key.substring("sig_obj.types.".length());
- //System.out.println("[" + profile + "]: " + this.getValue(key));
- if (this.getValue(key).equals("on")) {
- Profiles prof = new Profiles(profile);
- profiles.put(profile, prof);
- }
- }
-
- // Initialize Parent Structure ...
- Iterator<Entry<String, Profiles>> profileIterator = profiles.entrySet()
- .iterator();
- while (profileIterator.hasNext()) {
- Entry<String, Profiles> entry = profileIterator.next();
- entry.getValue().findParent(properties, profiles);
- }
-
- // Debug Output
- Iterator<Entry<String, Profiles>> profileIteratorDbg = profiles.entrySet()
- .iterator();
- while (profileIteratorDbg.hasNext()) {
- Entry<String, Profiles> entry = profileIteratorDbg.next();
- if(entry.getValue().getParent() == null) {
- logger.debug("Got Profile: [{}] : {}", entry.getKey(), entry.getValue().getName());
- } else {
- logger.debug("Got Profile: [{}] : {} (Parent {})", entry.getKey(),
- entry.getValue().getName(), entry.getValue().getParent().getName());
- }
- }
-
- logger.debug("Configured Settings: {}",
- properties.size());
-
- // Resolve Parent Structures ...
- while (!profiles.isEmpty()) {
- List<String> removes = new ArrayList<String>();
- Iterator<Entry<String, Profiles>> profileIt = profiles.entrySet()
- .iterator();
- while (profileIt.hasNext()) {
- Entry<String, Profiles> entry = profileIt.next();
-
- // Remove all base Profiles ...
- if (entry.getValue().getParent() == null) {
- entry.getValue().setInitialized(true);
- removes.add(entry.getKey());
- } else {
- Profiles parent = entry.getValue().getParent();
- if (parent.isInitialized()) {
- // If Parent is initialized Copy Properties from Parent
- // to this profile
- String parentBase = "sig_obj." + parent.getName();
- String childBase = "sig_obj."
- + entry.getValue().getName();
-
- Iterator<String> parentKeyIt = this.getKeys(
- parentBase+".").iterator();
- while (parentKeyIt.hasNext()) {
- String key = parentKeyIt.next();
- String keyToCopy = key.substring(parentBase
- .length());
- //logger.debug("Profile: {} => {}",
- // key, childBase+keyToCopy);
- String sourceKey = parentBase+keyToCopy;
- String targetKey = childBase+keyToCopy;
-
- if(!this.hasValue(targetKey)) {
- properties.setProperty(targetKey,
- this.getValue(sourceKey));
- //logger.debug("Replaced: {} with Value from {}",
- // childBase+keyToCopy, parentBase+keyToCopy);
- } else {
- //logger.debug("NOT Replaced: {} with Value from {}",
- // childBase+keyToCopy, parentBase+keyToCopy);
- }
- }
-
- // Copy done
- entry.getValue().setInitialized(true);
- removes.add(entry.getKey());
- }
- }
- }
-
- // Remove all Profiles from Remove List
-
- if(removes.isEmpty() && !profiles.isEmpty()) {
- logger.error("Failed to build inheritant Profiles, running in infinite loop! (aborting ...)");
- logger.error("Profiles that cannot be resolved completly:");
- Iterator<Entry<String, Profiles>> failedProfiles = profiles.entrySet().iterator();
- while (failedProfiles.hasNext()) {
- Entry<String, Profiles> entry = failedProfiles.next();
- logger.error("Problem Profile: [{}] : {}", entry.getKey(), entry.getValue().getName());
- }
- return;
- }
-
- Iterator<String> removeIt = removes.iterator();
- while(removeIt.hasNext()) {
- profiles.remove(removeIt.next());
- }
- }
-
- logger.debug("Derived Settings: {}",
- properties.size());
-
- }
-
- public void loadSettings(File workDirectory) throws PdfAsSettingsException {
- // try {
- String configDir = workDirectory.getAbsolutePath() + File.separator
- + CFG_DIR;
- String configFile = configDir + File.separator + CFG_FILE;
- loadSettingsRecursive(workDirectory, new File(configFile));
- buildProfiles();
- /*
- * logger.debug("Loading cfg file: " + configFile);
+ private static final Logger logger = LoggerFactory
+ .getLogger(Settings.class);
+
+ protected Properties properties = new Properties();
+
+ protected File workDirectory;
+
+ public Settings(File workDirectory) {
+ try {
+ this.workDirectory = workDirectory;
+ loadSettings(workDirectory);
+ } catch (PdfAsSettingsException e) {
+ logger.error(e.getMessage(), e);
+ }
+ }
+
+ private void loadSettingsRecursive(File workDirectory, File file)
+ throws PdfAsSettingsException {
+ try {
+ String configDir = workDirectory.getAbsolutePath() + File.separator
+ + CFG_DIR;
+ Properties tmpProps = new Properties();
+ logger.debug("Loading: " + file.getName());
+ tmpProps.load(new FileInputStream(file));
+
+ properties.putAll(tmpProps);
+
+ Map<String, String> includes = this.getValuesPrefix(INCLUDE,
+ tmpProps);
+ File contextFolder = new File(configDir);
+ if (includes != null) {
+ Iterator<String> includeIterator = includes.values().iterator();
+ while (includeIterator.hasNext()) {
+ contextFolder = new File(configDir);
+ String includeFileName = includeIterator.next();
+
+ File includeInstruction = new File(contextFolder,
+ includeFileName);
+ contextFolder = includeInstruction.getParentFile();
+ String includeName = includeInstruction.getName();
+
+ WildcardFileFilter fileFilter = new WildcardFileFilter(
+ includeName, IOCase.SENSITIVE);
+ Collection<File> includeFiles = null;
+
+ if (contextFolder != null && contextFolder.exists()
+ && contextFolder.isDirectory()) {
+ includeFiles = FileUtils.listFiles(contextFolder,
+ fileFilter, null);
+ }
+ if (includeFiles != null && !includeFiles.isEmpty()) {
+ logger.debug("Including '" + includeFileName + "'.");
+ for (File includeFile : includeFiles) {
+ loadSettingsRecursive(workDirectory, includeFile);
+ }
+ }
+ }
+ }
+
+ } catch (IOException e) {
+ throw new PdfAsSettingsException("Failed to read settings!", e);
+ }
+ }
+
+ private void showAugments(Profiles profiles) {
+ if (!profiles.getAugments().isEmpty()) {
+ logger.debug("\tAugments for {}", profiles.getName());
+ for (int i = 0; i < profiles.getAugments().size(); i++) {
+ logger.debug("\t\t{}", profiles.getAugments().get(i).getName());
+ }
+ }
+ }
+
+ private boolean isAugmentsReady(Profiles profiles) {
+ Iterator<Profiles> augmentingProfiles = profiles.getAugments().iterator();
+ boolean allInitialized = true;
+ while (augmentingProfiles.hasNext()) {
+ if (!augmentingProfiles.next().isInitialized()) {
+ allInitialized = false;
+ }
+ }
+ return allInitialized;
+ }
+
+ private boolean isParentReady(Profiles profiles) {
+ if (profiles.getParent() != null) {
+ return profiles.getParent().isInitialized();
+ } else {
+ return false;
+ }
+ }
+
+ private void performAugmentConfiguration(Profiles profiles) {
+ Iterator<Profiles> augmentingProfiles = profiles.getAugments().iterator();
+
+ String childBase = "sig_obj."
+ + profiles.getName();
+
+ while (augmentingProfiles.hasNext()) {
+ Profiles augmentingProfile = augmentingProfiles.next();
+ String augmentingBase = "sig_obj." + augmentingProfile.getName();
+
+ Iterator<String> augmentingKeyIt = this.getKeys(
+ augmentingBase + ".").iterator();
+
+ while (augmentingKeyIt.hasNext()) {
+ String key = augmentingKeyIt.next();
+ String keyToCopy = key.substring(augmentingBase
+ .length());
+ //logger.debug("Profile: {} => {}",
+ // key, childBase+keyToCopy);
+ String sourceKey = augmentingBase + keyToCopy;
+ String targetKey = childBase + keyToCopy;
+
+ if (!this.hasValue(targetKey)) {
+ properties.setProperty(targetKey,
+ this.getValue(sourceKey));
+ //logger.debug("Replaced: {} with Value from {}",
+ // childBase+keyToCopy, parentBase+keyToCopy);
+ } else {
+ //logger.debug("NOT Replaced: {} with Value from {}",
+ // childBase+keyToCopy, parentBase+keyToCopy);
+ }
+ }
+ }
+ }
+
+ private void performParentConfiguration(Profiles profiles) {
+ if (profiles.getParent() != null) {
+ // If Parent is initialized Copy Properties from Parent
+ // to this profile
+ String parentBase = "sig_obj." + profiles.getParent().getName();
+ String childBase = "sig_obj."
+ + profiles.getName();
+
+ Iterator<String> parentKeyIt = this.getKeys(
+ parentBase + ".").iterator();
+ while (parentKeyIt.hasNext()) {
+ String key = parentKeyIt.next();
+ String keyToCopy = key.substring(parentBase
+ .length());
+ //logger.debug("Profile: {} => {}",
+ // key, childBase+keyToCopy);
+ String sourceKey = parentBase + keyToCopy;
+ String targetKey = childBase + keyToCopy;
+
+ if (!this.hasValue(targetKey)) {
+ properties.setProperty(targetKey,
+ this.getValue(sourceKey));
+ //logger.debug("Replaced: {} with Value from {}",
+ // childBase+keyToCopy, parentBase+keyToCopy);
+ } else {
+ //logger.debug("NOT Replaced: {} with Value from {}",
+ // childBase+keyToCopy, parentBase+keyToCopy);
+ }
+ }
+ }
+ }
+
+ private void buildProfiles() {
+ Map<String, Profiles> profiles = new HashMap<String, Profiles>();
+
+ Iterator<String> itKeys = this.getFirstLevelKeys("sig_obj.types.")
+ .iterator();
+ while (itKeys.hasNext()) {
+ String key = itKeys.next();
+ String profile = key.substring("sig_obj.types.".length());
+ //System.out.println("[" + profile + "]: " + this.getValue(key));
+ if (this.getValue(key).equals("on")) {
+ Profiles prof = new Profiles(profile);
+ profiles.put(profile, prof);
+ }
+ }
+
+ // Initialize Parent Structure ...
+ Iterator<Entry<String, Profiles>> profileIterator = profiles.entrySet()
+ .iterator();
+ while (profileIterator.hasNext()) {
+ Entry<String, Profiles> entry = profileIterator.next();
+ entry.getValue().findParent(properties, profiles);
+ }
+
+ // Debug Output
+ Iterator<Entry<String, Profiles>> profileIteratorDbg = profiles.entrySet()
+ .iterator();
+ while (profileIteratorDbg.hasNext()) {
+ Entry<String, Profiles> entry = profileIteratorDbg.next();
+ if (entry.getValue().getParent() == null) {
+ logger.debug("Got Profile: [{}] : {}", entry.getKey(), entry.getValue().getName());
+ showAugments(entry.getValue());
+ } else {
+ logger.debug("Got Profile: [{}] : {} (Parent {})", entry.getKey(),
+ entry.getValue().getName(), entry.getValue().getParent().getName());
+ showAugments(entry.getValue());
+ }
+ }
+
+ logger.debug("Configured Settings: {}",
+ properties.size());
+
+ // Resolve Parent Structures ...
+ while (!profiles.isEmpty()) {
+ List<String> removes = new ArrayList<String>();
+ Iterator<Entry<String, Profiles>> profileIt = profiles.entrySet()
+ .iterator();
+ while (profileIt.hasNext()) {
+ Entry<String, Profiles> entry = profileIt.next();
+
+ // Remove all base Profiles ...
+ if (entry.getValue().getParent() == null && entry.getValue().getAugments().isEmpty()) {
+ // Has neither parent or augmenting profiles
+
+ entry.getValue().setInitialized(true);
+ removes.add(entry.getKey());
+ } else if (entry.getValue().getParent() == null) {
+ // Has augmenting profiles but no parent
+
+ // check if all augmenting profiles are initialized if so
+ // add them
+
+ Profiles profile = entry.getValue();
+ if (this.isAugmentsReady(profile)) {
+ this.performAugmentConfiguration(profile);
+ // Copy done
+ entry.getValue().setInitialized(true);
+ removes.add(entry.getKey());
+ } else {
+ logger.debug("Not all augmenting profiles are ready yet for {}", entry.getValue().getName());
+ }
+ } else if (entry.getValue().getAugments().isEmpty()) {
+
+ // Has parent but no augmenting profiles
+ Profiles profile = entry.getValue();
+
+ if (this.isParentReady(profile)) {
+ this.performParentConfiguration(profile);
+ // Copy done
+ entry.getValue().setInitialized(true);
+ removes.add(entry.getKey());
+ }
+ } else {
+
+ // Has parent and augmenting profiles
+
+ Profiles profile = entry.getValue();
+ if (this.isAugmentsReady(profile) && this.isParentReady(profile)) {
+ // order is curcial, augments preceed over parent configuration
+ this.performAugmentConfiguration(profile);
+ this.performParentConfiguration(profile);
+
+ // Copy done
+ entry.getValue().setInitialized(true);
+ removes.add(entry.getKey());
+ }
+ }
+ }
+
+ // Remove all Profiles from Remove List
+
+ if (removes.isEmpty() && !profiles.isEmpty()) {
+ logger.error("Failed to build inheritant Profiles, running in infinite loop! (aborting ...)");
+ logger.error("Profiles that cannot be resolved completly:");
+ Iterator<Entry<String, Profiles>> failedProfiles = profiles.entrySet().iterator();
+ while (failedProfiles.hasNext()) {
+ Entry<String, Profiles> entry = failedProfiles.next();
+ logger.error("Problem Profile: [{}] : {}", entry.getKey(), entry.getValue().getName());
+ }
+ return;
+ }
+
+ Iterator<String> removeIt = removes.iterator();
+ while (removeIt.hasNext()) {
+ profiles.remove(removeIt.next());
+ }
+ }
+
+ logger.debug("Derived Settings: {}",
+ properties.size());
+
+ }
+
+ public void debugDumpProfileSettings(String profileName) {
+ Iterator<String> keysIterator = this.getKeys("sig_obj." + profileName + ".").iterator();
+
+ logger.debug("Configuration for {}", profileName);
+ while(keysIterator.hasNext()) {
+ String key = keysIterator.next();
+ logger.debug(" {}: {}", key, this.getValue(key));
+ }
+ }
+
+ public void loadSettings(File workDirectory) throws PdfAsSettingsException {
+ // try {
+ String configDir = workDirectory.getAbsolutePath() + File.separator
+ + CFG_DIR;
+ String configFile = configDir + File.separator + CFG_FILE;
+ loadSettingsRecursive(workDirectory, new File(configFile));
+ buildProfiles();
+ /*
+ * logger.debug("Loading cfg file: " + configFile);
*
*
* properties.load(new FileInputStream(configFile));
@@ -258,97 +372,97 @@ public class Settings implements ISettings, IProfileConstants {
* e) { logger.error("Failed to load cfg file " + includeFile, e); } } }
* }
*/
- // logger.debug("Configured Properties:");
+ // logger.debug("Configured Properties:");
/*
* if(logger.isDebugEnabled()) { properties.list(System.out); }
*/
- // } catch (IOException e) {
- // throw new PdfAsSettingsException("Failed to read settings!", e);
- // }
- }
-
- public String getValue(String key) {
- return properties.getProperty(key);
- }
-
- public boolean hasValue(String key) {
- return properties.containsKey(key);
- }
-
- private Map<String, String> getValuesPrefix(String prefix, Properties props) {
- Iterator<Object> keyIterator = props.keySet().iterator();
- Map<String, String> valueMap = new HashMap<String, String>();
- while (keyIterator.hasNext()) {
- String key = keyIterator.next().toString();
-
- if (key.startsWith(prefix)) {
- valueMap.put(key, props.getProperty(key));
- }
- }
-
- if (valueMap.isEmpty()) {
- return null;
- }
-
- return valueMap;
- }
-
- public Map<String, String> getValuesPrefix(String prefix) {
- return getValuesPrefix(prefix, properties);
- }
-
- public Vector<String> getKeys(String prefix) {
- Iterator<Object> keyIterator = properties.keySet().iterator();
- Vector<String> valueMap = new Vector<String>();
- while (keyIterator.hasNext()) {
- String key = keyIterator.next().toString();
-
- if (key.startsWith(prefix)) {
- valueMap.add(key);
- }
- }
- return valueMap;
- }
-
- public Vector<String> getFirstLevelKeys(String prefix) {
- String mPrefix = prefix.endsWith(".") ? prefix : prefix + ".";
- Iterator<Object> keyIterator = properties.keySet().iterator();
- Vector<String> valueMap = new Vector<String>();
- while (keyIterator.hasNext()) {
- String key = keyIterator.next().toString();
-
- if (key.startsWith(prefix)) {
- int keyIdx = key.indexOf('.', mPrefix.length()) > 0 ? key
- .indexOf('.', mPrefix.length()) : key.length();
- String firstLevels = key.substring(0, keyIdx);
- if (!valueMap.contains(firstLevels)) {
- valueMap.add(firstLevels);
- }
- }
- }
-
- if (valueMap.isEmpty()) {
- return null;
- }
-
- return valueMap;
- }
-
- public boolean hasPrefix(String prefix) {
- Iterator<Object> keyIterator = properties.keySet().iterator();
- while (keyIterator.hasNext()) {
- String key = keyIterator.next().toString();
-
- if (key.startsWith(prefix)) {
- return true;
- }
- }
- return false;
- }
-
- public String getWorkingDirectory() {
- return this.workDirectory.getAbsolutePath();
- }
+ // } catch (IOException e) {
+ // throw new PdfAsSettingsException("Failed to read settings!", e);
+ // }
+ }
+
+ public String getValue(String key) {
+ return properties.getProperty(key);
+ }
+
+ public boolean hasValue(String key) {
+ return properties.containsKey(key);
+ }
+
+ private Map<String, String> getValuesPrefix(String prefix, Properties props) {
+ Iterator<Object> keyIterator = props.keySet().iterator();
+ Map<String, String> valueMap = new HashMap<String, String>();
+ while (keyIterator.hasNext()) {
+ String key = keyIterator.next().toString();
+
+ if (key.startsWith(prefix)) {
+ valueMap.put(key, props.getProperty(key));
+ }
+ }
+
+ if (valueMap.isEmpty()) {
+ return null;
+ }
+
+ return valueMap;
+ }
+
+ public Map<String, String> getValuesPrefix(String prefix) {
+ return getValuesPrefix(prefix, properties);
+ }
+
+ public Vector<String> getKeys(String prefix) {
+ Iterator<Object> keyIterator = properties.keySet().iterator();
+ Vector<String> valueMap = new Vector<String>();
+ while (keyIterator.hasNext()) {
+ String key = keyIterator.next().toString();
+
+ if (key.startsWith(prefix)) {
+ valueMap.add(key);
+ }
+ }
+ return valueMap;
+ }
+
+ public Vector<String> getFirstLevelKeys(String prefix) {
+ String mPrefix = prefix.endsWith(".") ? prefix : prefix + ".";
+ Iterator<Object> keyIterator = properties.keySet().iterator();
+ Vector<String> valueMap = new Vector<String>();
+ while (keyIterator.hasNext()) {
+ String key = keyIterator.next().toString();
+
+ if (key.startsWith(prefix)) {
+ int keyIdx = key.indexOf('.', mPrefix.length()) > 0 ? key
+ .indexOf('.', mPrefix.length()) : key.length();
+ String firstLevels = key.substring(0, keyIdx);
+ if (!valueMap.contains(firstLevels)) {
+ valueMap.add(firstLevels);
+ }
+ }
+ }
+
+ if (valueMap.isEmpty()) {
+ return null;
+ }
+
+ return valueMap;
+ }
+
+ public boolean hasPrefix(String prefix) {
+ Iterator<Object> keyIterator = properties.keySet().iterator();
+ while (keyIterator.hasNext()) {
+ String key = keyIterator.next().toString();
+
+ if (key.startsWith(prefix)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public String getWorkingDirectory() {
+ return this.workDirectory.getAbsolutePath();
+ }
}
diff --git a/pdf-as-common/src/main/java/at/gv/egiz/pdfas/common/utils/ImageUtils.java b/pdf-as-common/src/main/java/at/gv/egiz/pdfas/common/utils/ImageUtils.java
index 39ebd3e0..96efa315 100644
--- a/pdf-as-common/src/main/java/at/gv/egiz/pdfas/common/utils/ImageUtils.java
+++ b/pdf-as-common/src/main/java/at/gv/egiz/pdfas/common/utils/ImageUtils.java
@@ -179,7 +179,16 @@ public class ImageUtils {
}
is = new FileInputStream(img_file);
- } catch (PdfAsException | IOException e) {
+ } catch (PdfAsException e) {
+ try {
+ is = new ByteArrayInputStream(Base64.decodeBase64(imageValue));
+ } catch (Throwable e1) {
+ // Ignore value is not base 64!
+ logger.debug("Value is not base64: ", e1);
+ // rethrow e
+ throw e;
+ }
+ } catch (IOException e) {
try {
is = new ByteArrayInputStream(Base64.decodeBase64(imageValue));
} catch (Throwable e1) {
diff --git a/pdf-as-lib/src/configuration/cfg/profiles/AMTSSIGNATURBLOCK_BASE.properties b/pdf-as-lib/src/configuration/cfg/profiles/AMTSSIGNATURBLOCK_BASE.properties
new file mode 100644
index 00000000..11786c7e
--- /dev/null
+++ b/pdf-as-lib/src/configuration/cfg/profiles/AMTSSIGNATURBLOCK_BASE.properties
@@ -0,0 +1,49 @@
+###################################################################################################
+# PROFIL: Vollständiger Amtssignaturblock (Deutsch)
+
+sig_obj.AMTSSIGNATURBLOCK_BASE.description=Basis Profile fuer Amtssignaturblock (Deutsch)
+
+sig_obj.types.AMTSSIGNATURBLOCK_BASE=on
+
+sig_obj.AMTSSIGNATURBLOCK_BASE.key.SIG_SUBJECT=Unterzeichner/\nSiegelersteller
+sig_obj.AMTSSIGNATURBLOCK_BASE.key.SIG_ISSUER=Aussteller-Zertifikat
+sig_obj.AMTSSIGNATURBLOCK_BASE.key.SIG_NUMBER=Serien-Nr.
+sig_obj.AMTSSIGNATURBLOCK_BASE.key.SIG_META=Pr\u00fcfinformation
+sig_obj.AMTSSIGNATURBLOCK_BASE.key.SIG_NOTE=Hinweis
+sig_obj.AMTSSIGNATURBLOCK_BASE.key.SIG_DATE=Datum/Zeit-UTC
+
+sig_obj.AMTSSIGNATURBLOCK_BASE.value.SIG_META=Informationen zur Pr\u00FCfung des elektronischen Siegels bzw. der elektronischen Signatur finden Sie unter: https://www.signaturpruefung.gv.at\n\nInformationen zur Pr\u00FCfung des Ausdrucks finden Sie unter: https://www.behoerde.gv.at/el_signatur/
+sig_obj.AMTSSIGNATURBLOCK_BASE.value.SIG_LABEL=./images/amtsignatur-logo_demo.png
+sig_obj.AMTSSIGNATURBLOCK_BASE.value.SIG_NOTE=Dieses Dokument wurde amtssigniert. Auch ein Ausdruck dieses Dokuments hat gem\u00e4\u00df \u00A7 20 E-Government-Gesetz die Beweiskraft einer \u00f6ffentlichen Urkunde.
+sig_obj.AMTSSIGNATURBLOCK_BASE.value.SIG_SUBJECT=${subject.T != null ? (subject.T + " ") : ""}${subject.CN}
+sig_obj.AMTSSIGNATURBLOCK_BASE.value.SIG_ISSUER=${issuer.T != null ? (issuer.T + " ") : ""}${issuer.CN}
+sig_obj.AMTSSIGNATURBLOCK_BASE.value.SIG_NUMBER=${sn}
+
+sig_obj.AMTSSIGNATURBLOCK_BASE.pos=f:80
+sig_obj.AMTSSIGNATURBLOCK_BASE.adobeSignFieldValue=PDF-AS Signatur
+sig_obj.AMTSSIGNATURBLOCK_BASE.adobeSignReasonValue=Signaturpruefung unter http://www.signaturpruefung.gv.at
+sig_obj.AMTSSIGNATURBLOCK_BASE.verifyURL=http://www.signaturpruefung.gv.at
+sig_obj.AMTSSIGNATURBLOCK_BASE.sigLogoAltText=Abgebildet ist eine Standard-Signaturbildmarke.
+
+#---------------------- MAIN TABLE -------------------------
+sig_obj.AMTSSIGNATURBLOCK_BASE.table.main.1=SIG_LABEL-i|TABLE-info
+sig_obj.AMTSSIGNATURBLOCK_BASE.table.main.2=SIG_NOTE-cv
+
+sig_obj.AMTSSIGNATURBLOCK_BASE.table.main.ColsWidth=1 6
+sig_obj.AMTSSIGNATURBLOCK_BASE.table.main.Style.bgcolor=255 255 255
+sig_obj.AMTSSIGNATURBLOCK_BASE.table.main.Style.padding=4
+sig_obj.AMTSSIGNATURBLOCK_BASE.table.main.Style.border=0.1
+sig_obj.AMTSSIGNATURBLOCK_BASE.table.main.Style.halign=center
+sig_obj.AMTSSIGNATURBLOCK_BASE.table.main.Style.valuehalign=left
+sig_obj.AMTSSIGNATURBLOCK_BASE.table.main.Style.valign=top
+sig_obj.AMTSSIGNATURBLOCK_BASE.table.main.Style.imagevalign=middle
+sig_obj.AMTSSIGNATURBLOCK_BASE.table.main.Style.font=HELVETICA,8,BOLD
+sig_obj.AMTSSIGNATURBLOCK_BASE.table.main.Style.valuefont=COURIER,8,NORMAL
+
+#---------------------- INFO TABLE -------------------------
+sig_obj.AMTSSIGNATURBLOCK_BASE.table.info.ColsWidth=1 4
+sig_obj.AMTSSIGNATURBLOCK_BASE.table.info.1=SIG_SUBJECT-cv
+sig_obj.AMTSSIGNATURBLOCK_BASE.table.info.2=SIG_DATE-cv
+sig_obj.AMTSSIGNATURBLOCK_BASE.table.info.3=SIG_ISSUER-cv
+sig_obj.AMTSSIGNATURBLOCK_BASE.table.info.4=SIG_NUMBER-cv
+sig_obj.AMTSSIGNATURBLOCK_BASE.table.info.5=SIG_META-cv \ No newline at end of file
diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/configuration/ConfigurationImpl.java b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/configuration/ConfigurationImpl.java
index 60c5683a..369d97d1 100644
--- a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/configuration/ConfigurationImpl.java
+++ b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/configuration/ConfigurationImpl.java
@@ -162,5 +162,8 @@ public class ConfigurationImpl implements ISettings, Configuration {
}
}
+ public void debugDumpProfileSettings(String profileName) {
+ ((Settings)settings).debugDumpProfileSettings(profileName);
+ }
}