aboutsummaryrefslogtreecommitdiff
path: root/pdf-as-lib/src/main/java/at/gv/egiz/sl/util
diff options
context:
space:
mode:
authorAndreas Fitzek <andreas.fitzek@iaik.tugraz.at>2014-05-14 11:37:09 +0200
committerAndreas Fitzek <andreas.fitzek@iaik.tugraz.at>2014-05-14 11:37:09 +0200
commit9e4d7a91c3e6c7cece30bf9956e2360dbf4c312b (patch)
treec338c4e326c08c60db492484ba8ef9708367e78c /pdf-as-lib/src/main/java/at/gv/egiz/sl/util
parent87cd5e8be869b19e6b37dbb13056882efff976a0 (diff)
downloadpdf-as-4-9e4d7a91c3e6c7cece30bf9956e2360dbf4c312b.tar.gz
pdf-as-4-9e4d7a91c3e6c7cece30bf9956e2360dbf4c312b.tar.bz2
pdf-as-4-9e4d7a91c3e6c7cece30bf9956e2360dbf4c312b.zip
Log Levels changed
Diffstat (limited to 'pdf-as-lib/src/main/java/at/gv/egiz/sl/util')
-rw-r--r--pdf-as-lib/src/main/java/at/gv/egiz/sl/util/MOAConnector.java29
1 files changed, 26 insertions, 3 deletions
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);
}