From da64c825de6ad061f5c734630faf0d6e9606dc12 Mon Sep 17 00:00:00 2001 From: Christian Maierhofer Date: Thu, 23 Jun 2016 10:06:40 +0200 Subject: Added Profile configuration validation --- .../at/gv/egiz/pdfas/lib/api/PdfAsFactory.java | 25 +++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api') diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/PdfAsFactory.java b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/PdfAsFactory.java index cd0a4699..72d182ed 100644 --- a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/PdfAsFactory.java +++ b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/PdfAsFactory.java @@ -37,9 +37,10 @@ import java.io.OutputStream; import java.lang.management.ManagementFactory; import java.lang.management.OperatingSystemMXBean; import java.lang.management.RuntimeMXBean; -import java.lang.reflect.Field; import java.security.Provider; import java.security.Security; +import java.util.Map; +import java.util.Map.Entry; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; @@ -49,12 +50,16 @@ import javax.crypto.Cipher; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import at.gv.egiz.pdfas.common.exceptions.PdfAsSettingsException; +import at.gv.egiz.pdfas.common.exceptions.PdfAsSettingsValidationException; import at.gv.egiz.pdfas.common.settings.ISettings; import at.gv.egiz.pdfas.lib.api.sign.SignParameter; import at.gv.egiz.pdfas.lib.api.verify.VerifyParameter; +import at.gv.egiz.pdfas.lib.configuration.ConfigurationValidator; import at.gv.egiz.pdfas.lib.impl.PdfAsImpl; import at.gv.egiz.pdfas.lib.impl.SignParameterImpl; import at.gv.egiz.pdfas.lib.impl.VerifyParameterImpl; +import at.gv.egiz.pdfas.lib.impl.configuration.ConfigValidatorLoader; public class PdfAsFactory implements IConfigurationConstants { @@ -359,4 +364,22 @@ public class PdfAsFactory implements IConfigurationConstants { Package pack = PdfAsFactory.class.getPackage(); return pack.getImplementationVersion(); } + + /** + * Execute all loaded Configuration Validators + * + * @throws PdfAsSettingsValidationException + */ + public static void validateConfiguration(ISettings configuration) throws PdfAsSettingsValidationException{ + Map availableValidators = ConfigValidatorLoader.getAvailableValidators(); + if(availableValidators.isEmpty()){ + logger.info("No configuration validators available"); + } + for(Entry validatorEntry : availableValidators.entrySet()){ + logger.info("Running configuration validator: "+validatorEntry.getKey()); + validatorEntry.getValue().validate(configuration); + } + logger.info("All configuration validators succeded."); + + } } -- cgit v1.2.3