aboutsummaryrefslogtreecommitdiff
path: root/pdf-as-lib/src/main/java/at/gv/egiz
diff options
context:
space:
mode:
Diffstat (limited to 'pdf-as-lib/src/main/java/at/gv/egiz')
-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);
}