From 863f99753af19b3f5ce354d4d1ff0a5e8a4f32dd Mon Sep 17 00:00:00 2001 From: Andreas Fitzek Date: Thu, 12 Dec 2013 13:25:11 +0100 Subject: added configuration for verifer classes --- .../pdfas/lib/impl/verify/VerifierDispatcher.java | 26 +++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) (limited to 'pdf-as-lib/src/main/java') 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> filterMap = new HashMap>(); public VerifierDispatcher(ISettings settings) { - // TODO: read config build verify filter + // TODO: add configuration parameter to set verifier + + Map 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 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 cls = (Class) Class .forName(clsName); IVerifyFilter filter = cls.newInstance(); - filter.setConfiguration((Configuration)settings); + filter.setConfiguration((Configuration) settings); List entries = filter.getFiters(); Iterator it = entries.iterator(); while (it.hasNext()) { -- cgit v1.2.3