diff options
Diffstat (limited to 'pdf-as-lib/src/main/java/at')
-rw-r--r-- | pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/verify/VerifierDispatcher.java | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/verify/VerifierDispatcher.java b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/verify/VerifierDispatcher.java index 9a830097..e0b57262 100644 --- a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/verify/VerifierDispatcher.java +++ b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/verify/VerifierDispatcher.java @@ -1,6 +1,5 @@ package at.gv.egiz.pdfas.lib.impl.verify; -import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.List; @@ -18,22 +17,39 @@ public class VerifierDispatcher { private static final Logger logger = LoggerFactory .getLogger(VerifierDispatcher.class); - public static final String[] currentClasses = new String[] { + public static final String[] defaultClasses = new String[] { "at.gv.egiz.pdfas.sigs.pkcs7detached.PKCS7DetachedVerifier", - // Uncomment to verify via MOA conncetor "at.gv.egiz.pdfas.sigs.pades.PAdESVerifier" }; + public static final String CONF_VERIFIER = "default.verifier"; + public Map<String, HashMap<String, IVerifyFilter>> filterMap = new HashMap<String, HashMap<String, IVerifyFilter>>(); public VerifierDispatcher(ISettings settings) { - // TODO: read config build verify filter + // TODO: add configuration parameter to set verifier + + Map<String, String> verifierClasses = settings + .getValuesPrefix(CONF_VERIFIER); + String[] currentClasses = null; + if (verifierClasses == null || verifierClasses.isEmpty()) { + logger.info("No verifier configured using default"); + currentClasses = defaultClasses; + } else { + currentClasses = new String[verifierClasses.values().size()]; + Iterator<String> classIt = verifierClasses.values().iterator(); + int j = 0; + while (classIt.hasNext()) { + currentClasses[j] = classIt.next(); + j++; + } + } try { for (int i = 0; i < currentClasses.length; i++) { String clsName = currentClasses[i]; Class<? extends IVerifyFilter> cls = (Class<? extends IVerifyFilter>) Class .forName(clsName); IVerifyFilter filter = cls.newInstance(); - filter.setConfiguration((Configuration)settings); + filter.setConfiguration((Configuration) settings); List<FilterEntry> entries = filter.getFiters(); Iterator<FilterEntry> it = entries.iterator(); while (it.hasNext()) { |