aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/gv/egiz/pdfas/impl/api/PdfAsObject.java
diff options
context:
space:
mode:
authortknall <tknall@7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c>2008-03-05 12:29:57 +0000
committertknall <tknall@7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c>2008-03-05 12:29:57 +0000
commit3230d71393a3e48d95f5a8e0b659d471abbaf66e (patch)
tree8683e0dcd6872b234df0f08b2c53949e2cbd7a09 /src/main/java/at/gv/egiz/pdfas/impl/api/PdfAsObject.java
parenta75c0b5bbe5e5f1fc08750518dd67175346126fe (diff)
downloadpdf-as-3-3230d71393a3e48d95f5a8e0b659d471abbaf66e.tar.gz
pdf-as-3-3230d71393a3e48d95f5a8e0b659d471abbaf66e.tar.bz2
pdf-as-3-3230d71393a3e48d95f5a8e0b659d471abbaf66e.zip
SignatureProfile interface modified. Added method to retrieve signature block entries of the current profile relevant for the signature block search algorithm.
git-svn-id: https://joinup.ec.europa.eu/svn/pdf-as/trunk@253 7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c
Diffstat (limited to 'src/main/java/at/gv/egiz/pdfas/impl/api/PdfAsObject.java')
-rw-r--r--src/main/java/at/gv/egiz/pdfas/impl/api/PdfAsObject.java71
1 files changed, 61 insertions, 10 deletions
diff --git a/src/main/java/at/gv/egiz/pdfas/impl/api/PdfAsObject.java b/src/main/java/at/gv/egiz/pdfas/impl/api/PdfAsObject.java
index 39b4aff..f0c85d4 100644
--- a/src/main/java/at/gv/egiz/pdfas/impl/api/PdfAsObject.java
+++ b/src/main/java/at/gv/egiz/pdfas/impl/api/PdfAsObject.java
@@ -8,13 +8,18 @@ import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
+import java.util.Properties;
+import java.util.Vector;
+
+import org.apache.commons.lang.math.NumberUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import at.gv.egiz.pdfas.api.PdfAs;
import at.gv.egiz.pdfas.api.analyze.AnalyzeParameters;
import at.gv.egiz.pdfas.api.analyze.AnalyzeResult;
import at.gv.egiz.pdfas.api.commons.Constants;
import at.gv.egiz.pdfas.api.commons.SignatureInformation;
-import at.gv.egiz.pdfas.api.commons.SignatureProfile;
import at.gv.egiz.pdfas.api.exceptions.PdfAsException;
import at.gv.egiz.pdfas.api.sign.SignParameters;
import at.gv.egiz.pdfas.api.sign.SignResult;
@@ -65,6 +70,11 @@ public class PdfAsObject implements PdfAs
protected File workDirectory = null;
/**
+ * The log.
+ */
+ private static Log log = LogFactory.getLog(CheckHelper.class);
+
+ /**
* This constructor is for internal use only - use
* {@link at.gv.egiz.pdfas.PdfAsFactory} instead.
*
@@ -104,6 +114,7 @@ public class PdfAsObject implements PdfAs
*/
public List getProfileInformation() throws PdfAsException
{
+ log.debug("Collecting profile information.");
final String MOA_SIGN_KEY_IDENTIFIER_KEY = "moa.sign.KeyIdentifier";
SettingsReader settings = SettingsReader.getInstance();
@@ -120,6 +131,7 @@ public class PdfAsObject implements PdfAs
SignatureTypeDefinition profile = (SignatureTypeDefinition) it.next();
final String profileId = profile.getType();
+ log.debug("Processing profile \"" + profileId + "\".");
final String moaKeyIdentifier = settings.getSetting("sig_obj." + profileId + "." + MOA_SIGN_KEY_IDENTIFIER_KEY, defaultMoaKeyIdentifiert);
// modified by tknall
@@ -127,21 +139,60 @@ public class PdfAsObject implements PdfAs
// start - added by tknall
- // add key values
- final String parentProperty = "sig_obj." + profileId + ".key.";
- ArrayList keys = settings.getKeys(parentProperty);
- if (keys != null) {
- Iterator keyIt = keys.iterator();
+ // signature entries relevant to the search algorithm
+ Properties signatureEntries = new Properties();
+
+ // search for table entries
+ String parentPropertyKey = "sig_obj." + profileId + ".table";
+ log.debug("Looking for subkeys of \"" + parentPropertyKey + "\".");
+ Vector keysVector = settings.getSettingKeys(parentPropertyKey);
+ if (keysVector != null) {
+ Iterator keyIt = keysVector.iterator();
+ while (keyIt.hasNext()) {
+ String subKey = (String) keyIt.next();
+ if (subKey != null && subKey.length() > 0) {
+ String fullKey = parentPropertyKey + "." + subKey;
+ String value = settings.getValueFromKey(fullKey);
+ int lastIndex = fullKey.lastIndexOf(".");
+ if (lastIndex != -1) {
+ String endsWith = fullKey.substring(lastIndex + 1);
+ if (value != null && value.length() > 0) {
+ if (NumberUtils.isDigits(endsWith)) {
+ signatureEntries.setProperty(fullKey, value);
+ } else {
+ log.debug("Ignoring table entry \"" + fullKey + "\" because it does not end with a digit. Therefore it is not relevant for the seach algorithm.");
+ }
+ } else {
+ log.warn("Problem detected with key \"" + fullKey + "\". The value is empty.");
+ }
+ }
+ }
+ }
+ }
+
+ // search for table entries
+ parentPropertyKey = "sig_obj." + profileId + ".key";
+ log.debug("Looking for subkeys of \"" + parentPropertyKey + "\".");
+ keysVector = settings.getSettingKeys(parentPropertyKey);
+ if (keysVector != null) {
+ Iterator keyIt = keysVector.iterator();
while (keyIt.hasNext()) {
- String key = (String) keyIt.next();
- if (key != null && key.length() > 0) {
- String value = settings.getValueFromKey(parentProperty + key);
+ String subKey = (String) keyIt.next();
+ if (subKey != null && subKey.length() > 0) {
+ String fullKey = parentPropertyKey + "." + subKey;
+ String value = settings.getValueFromKey(fullKey);
if (value != null && value.length() > 0) {
- signatureProfile.setField(key, value);
+ signatureEntries.setProperty(fullKey, value);
+ } else {
+ log.warn("Problem detected with key \"" + fullKey + "\". The value is empty.");
}
}
}
}
+
+ // set properties
+ signatureProfile.setSignatureBlockEntries(signatureEntries);
+
// stop - added by tknall
profileInformation.add(signatureProfile);