aboutsummaryrefslogtreecommitdiff
path: root/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib
diff options
context:
space:
mode:
authorAndreas Fitzek <andreas.fitzek@iaik.tugraz.at>2013-12-12 11:52:00 +0100
committerAndreas Fitzek <andreas.fitzek@iaik.tugraz.at>2013-12-12 11:52:00 +0100
commit4be6889e90dff021cc625649f013c428b2ef4a47 (patch)
tree81ed6c4190352cbb4c9a4508171b8ccf9192bf49 /pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib
parent22c56e9d4b8c8ba6bea4993d7bd3cc0a83a23d8b (diff)
downloadpdf-as-4-4be6889e90dff021cc625649f013c428b2ef4a47.tar.gz
pdf-as-4-4be6889e90dff021cc625649f013c428b2ef4a47.tar.bz2
pdf-as-4-4be6889e90dff021cc625649f013c428b2ef4a47.zip
Reading log4j configuration from pdf-as workdir
Diffstat (limited to 'pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib')
-rw-r--r--pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/PdfAsFactory.java41
1 files changed, 38 insertions, 3 deletions
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 963e4098..93fbbfea 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
@@ -5,6 +5,8 @@ import iaik.security.provider.IAIK;
import java.io.BufferedOutputStream;
import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
@@ -15,6 +17,8 @@ import org.apache.log4j.PropertyConfigurator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import com.sun.org.apache.bcel.internal.generic.NEW;
+
import at.gv.egiz.pdfas.lib.api.sign.SignParameter;
import at.gv.egiz.pdfas.lib.api.verify.VerifyParameter;
import at.gv.egiz.pdfas.lib.impl.PdfAsImpl;
@@ -33,14 +37,45 @@ public class PdfAsFactory {
.getSystemResourceAsStream("resources/log4j.properties"));
// BasicConfigurator.configure();
- //iaik.security.ecc.provider.ECCProvider.addAsProvider();
- IAIK.addAsProvider();;
- //ECCProvider.addAsProvider();
+ // iaik.security.ecc.provider.ECCProvider.addAsProvider();
+ IAIK.addAsProvider();
+ ;
+ // ECCProvider.addAsProvider();
// install security provider
ECCelerate.addAsProvider();
}
+ private static boolean log_configured = false;
+ private static Object log_mutex = new Object();
+
+ public static void dontConfigureLog4j() {
+ synchronized (log_mutex) {
+ log_configured = true;
+ }
+ }
+
public static PdfAs createPdfAs(File configuration) {
+ if (!log_configured) {
+ synchronized (log_mutex) {
+ if (!log_configured) {
+ File log4j = new File(configuration.getAbsolutePath()
+ + File.separator + "cfg" + File.separator
+ + "log4j.properties");
+ logger.info("Loading log4j configuration: " + log4j.getAbsolutePath());
+ if (log4j.exists()) {
+ try {
+ System.setProperty("pdf-as.work-dir", configuration.getAbsolutePath());
+ PropertyConfigurator.configure(new FileInputStream(
+ log4j));
+ } catch (FileNotFoundException e) {
+ e.printStackTrace();
+ }
+ }
+ log_configured = true;
+ }
+ }
+ }
+
return new PdfAsImpl(configuration);
}