From 9e4d7a91c3e6c7cece30bf9956e2360dbf4c312b Mon Sep 17 00:00:00 2001 From: Andreas Fitzek Date: Wed, 14 May 2014 11:37:09 +0200 Subject: Log Levels changed --- .../main/java/at/gv/egiz/sl/util/MOAConnector.java | 29 +++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) (limited to 'pdf-as-lib/src/main/java/at/gv/egiz/sl/util') diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/sl/util/MOAConnector.java b/pdf-as-lib/src/main/java/at/gv/egiz/sl/util/MOAConnector.java index 71e7181a..9c5c720a 100644 --- a/pdf-as-lib/src/main/java/at/gv/egiz/sl/util/MOAConnector.java +++ b/pdf-as-lib/src/main/java/at/gv/egiz/sl/util/MOAConnector.java @@ -55,6 +55,8 @@ import org.xml.sax.SAXException; import at.gv.egiz.pdfas.common.exceptions.PdfAsException; import at.gv.egiz.pdfas.common.exceptions.PdfAsMOAException; +import at.gv.egiz.pdfas.common.exceptions.PdfAsWrappedIOException; +import at.gv.egiz.pdfas.common.settings.ISettings; import at.gv.egiz.pdfas.lib.api.Configuration; public class MOAConnector implements ISignatureConnector { @@ -95,9 +97,30 @@ public class MOAConnector implements ISignatureConnector { public MOAConnector(Configuration config) throws CertificateException, FileNotFoundException, IOException { - logger.info("Loading certificate: " + config.getValue(MOA_SIGN_CERTIFICATE)); - this.certificate = new X509Certificate(new FileInputStream(new File( - config.getValue(MOA_SIGN_CERTIFICATE)))); + if(config.getValue(MOA_SIGN_CERTIFICATE) == null) { + logger.error(MOA_SIGN_CERTIFICATE + " not configured for MOA connector"); + throw new PdfAsWrappedIOException(new PdfAsException("Please configure: " + MOA_SIGN_CERTIFICATE + " to use MOA connector")); + } + + if(!(config instanceof ISettings)) { + logger.error("Configuration is no instance of ISettings"); + throw new PdfAsWrappedIOException(new PdfAsException("Configuration is no instance of ISettings")); + } + + ISettings settings = (ISettings)config; + + String certificateValue = config.getValue(MOA_SIGN_CERTIFICATE); + + File certFile = new File(certificateValue); + if(!certFile.isAbsolute()) { + certificateValue = settings.getWorkingDirectory() + "/" + + config.getValue(MOA_SIGN_CERTIFICATE); + certFile = new File(certificateValue); + } + + logger.info("Loading certificate: " + certificateValue); + + this.certificate = new X509Certificate(new FileInputStream(certFile)); this.moaEndpoint = config.getValue(MOA_SIGN_URL); this.keyIdentifier = config.getValue(MOA_SIGN_KEY_ID); } -- cgit v1.2.3