aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Fitzek <andreas.fitzek@iaik.tugraz.at>2014-10-15 10:30:38 +0200
committerAndreas Fitzek <andreas.fitzek@iaik.tugraz.at>2014-10-15 10:30:38 +0200
commit9cfe09c62a519209e0193eaf2872872ca4f35a26 (patch)
treea2d65984e9212bb98b5f36a4301bf8c05b92f252
parent40e77eea8328ff9cef8d45b2ff3134349d7a65af (diff)
downloadpdf-as-4-9cfe09c62a519209e0193eaf2872872ca4f35a26.tar.gz
pdf-as-4-9cfe09c62a519209e0193eaf2872872ca4f35a26.tar.bz2
pdf-as-4-9cfe09c62a519209e0193eaf2872872ca4f35a26.zip
Removed log4 dependencies
-rw-r--r--pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/PdfAsFactory.java156
-rw-r--r--pdf-as-tests/src/test/java/at/gv/egiz/param_tests/ParameterizedSignatureTestSuite.java9
-rw-r--r--pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/filter/ExceptionCatchFilter.java2
3 files changed, 38 insertions, 129 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 1e28ad7a..f5f14626 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
@@ -28,8 +28,6 @@ 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;
@@ -38,8 +36,6 @@ import java.security.Security;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
-import org.apache.log4j.BasicConfigurator;
-import org.apache.log4j.PropertyConfigurator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -57,13 +53,6 @@ public class PdfAsFactory {
private static final String DEFAULT_CONFIG_RES = "config/config.zip";
- private static final String DEFAULT_LOG4J_ENV = "log4j.configuration";
-
- // private static final String MAN_ATTRIBUTE = "JARMANIFEST";
- // private static final String PDF_AS_LIB = "PDF-AS-LIB";
- // private static final String IMPL_VERSION = "Implementation-Version";
- // private static final String SCM_REVISION = "SCMREVISION";
-
protected static void registerProvider(Provider provider, int position) {
String name = provider.getName();
if (Security.getProvider(name) == null) {
@@ -94,111 +83,39 @@ public class PdfAsFactory {
}
}
- static {
- /*
- * PropertyConfigurator.configure(ClassLoader
- * .getSystemResourceAsStream("resources/log4j.properties"));
- */
- // IAIK.addAsProvider();
- // ECCelerate.addAsProvider();
- registerProvider(new IAIK(), 1);
- registerProvider(new ECCelerate(), -1);
-
- System.out
- .println("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
- System.out.println("+ PDF-AS: " + getVersion());
- System.out.println("+ PDF-AS SCM Revision: " + getSCMRevision());
- System.out.println("+ IAIK-JCE Version: " + IAIK.getVersionInfo());
- System.out.println("+ ECCelerate Version: "
- + ECCelerate.getInstance().getVersion());
- System.out
- .println("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
- }
-
- private static boolean log_configured = false;
- private static Object log_mutex = new Object();
-
- public static void dontConfigureLog4j() {
- synchronized (log_mutex) {
- log_configured = true;
- }
- }
+ private static boolean initialized = false;
+ private static Object init_mutex = new Object();
/**
* Configure log.
*
- * @param configuration the configuration
+ * @param configuration
+ * the configuration
*/
- private static void configureLog(File configuration) {
- if (!log_configured) {
-
- if (System.getProperty(DEFAULT_LOG4J_ENV) != null) {
- String file = System.getProperty(DEFAULT_LOG4J_ENV);
- File log4j = new File(file);
- System.out.println("Configuring logging with: "
- + log4j.getAbsolutePath());
- logger.info("Loading log4j configuration: "
- + log4j.getAbsolutePath());
- if (log4j.exists()) {
- try {
- //if (configuration != null) {
- // System.setProperty("pdf-as.work-dir",
- // configuration.getAbsolutePath());
- //}
- PropertyConfigurator.configure(new FileInputStream(
- log4j));
- logger.info("Configured Log4j with: "
- + log4j.getAbsolutePath());
- } catch (FileNotFoundException e) {
- e.printStackTrace();
- System.err
- .println("Failed to initialize logging System. Defaulting to basic configuration!");
- BasicConfigurator.configure();
- }
- } else {
- System.err
- .println("Log4j File: "
- + log4j.getAbsolutePath()
- + " does not exist! Defaulting to basic configuration!");
- BasicConfigurator.configure();
- }
- } else {
- if (configuration != null) {
- File log4j = new File(configuration.getAbsolutePath()
- + File.separator + "cfg" + File.separator
- + "log4j.properties");
- System.out.println("Configuring logging with: "
- + log4j.getAbsolutePath());
- logger.info("Loading log4j configuration: "
- + log4j.getAbsolutePath());
- if (log4j.exists()) {
- try {
- //System.setProperty("pdf-as.work-dir",
- // configuration.getAbsolutePath());
- PropertyConfigurator.configure(new FileInputStream(
- log4j));
- logger.info("Configured Log4j with: "
- + log4j.getAbsolutePath());
- } catch (FileNotFoundException e) {
- e.printStackTrace();
- System.err
- .println("Failed to initialize logging System. Defaulting to basic configuration!");
- BasicConfigurator.configure();
- }
- } else {
- System.err
- .println("Log4j File: "
- + log4j.getAbsolutePath()
- + " does not exist! Defaulting to basic configuration!");
- BasicConfigurator.configure();
- }
- } else {
- System.err.println("Failed to initialize logging System. Defaulting to basic configuration!");
- BasicConfigurator.configure();
+ private static void initialize(ISettings configuration) {
+ if (!initialized) {
+ synchronized (init_mutex) {
+ if (!initialized) {
+ initialized = true;
+
+ registerProvider(new IAIK(), 1);
+ registerProvider(new ECCelerate(), -1);
+
+ System.out
+ .println("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
+ System.out.println("+ PDF-AS: " + getVersion());
+ System.out.println("+ PDF-AS SCM Revision: "
+ + getSCMRevision());
+ System.out.println("+ IAIK-JCE Version: "
+ + IAIK.getVersionInfo());
+ System.out.println("+ ECCelerate Version: "
+ + ECCelerate.getInstance().getVersion());
+ System.out
+ .println("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
+
+ listRegisteredSecurityProviders();
}
}
- log_configured = true;
- listRegisteredSecurityProviders();
}
}
@@ -210,28 +127,31 @@ public class PdfAsFactory {
* @return
*/
public static PdfAs createPdfAs(File configuration) {
- if (!log_configured) {
- synchronized (log_mutex) {
- configureLog(configuration);
+ PdfAs pdfas = new PdfAsImpl(configuration);
+
+ if (!initialized) {
+ synchronized (init_mutex) {
+ initialize((ISettings) pdfas.getConfiguration());
}
}
- return new PdfAsImpl(configuration);
+ return pdfas;
}
/**
* Creates a new PdfAs object.
*
- * @param settings the settings
+ * @param settings
+ * the settings
* @return the pdf as
*/
public static PdfAs createPdfAs(ISettings settings) {
- if (!log_configured) {
- synchronized (log_mutex) {
- configureLog(null);
+ if (!initialized) {
+ synchronized (init_mutex) {
+ initialize(settings);
}
}
-
+
return new PdfAsImpl(settings);
}
diff --git a/pdf-as-tests/src/test/java/at/gv/egiz/param_tests/ParameterizedSignatureTestSuite.java b/pdf-as-tests/src/test/java/at/gv/egiz/param_tests/ParameterizedSignatureTestSuite.java
index a8e03b5e..7d065172 100644
--- a/pdf-as-tests/src/test/java/at/gv/egiz/param_tests/ParameterizedSignatureTestSuite.java
+++ b/pdf-as-tests/src/test/java/at/gv/egiz/param_tests/ParameterizedSignatureTestSuite.java
@@ -7,7 +7,6 @@ import java.io.PrintStream;
import java.net.URL;
import org.apache.commons.io.output.TeeOutputStream;
-import org.apache.log4j.PropertyConfigurator;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.runner.Description;
@@ -107,14 +106,6 @@ public class ParameterizedSignatureTestSuite {
TeeOutputStream teeStdErr = new TeeOutputStream(System.err, stderrLog);
stderrSave = System.err;
System.setErr(new PrintStream(teeStdErr));
- if (CONFIGURE_LOGGING && log4j != null) {
- try {
- PropertyConfigurator.configure(new FileInputStream(log4j
- .getFile()));
- } catch (FileNotFoundException e) {
- e.printStackTrace();
- }
- }
String testDir = System.getProperty("test.dir");
if (testDir == null)
diff --git a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/filter/ExceptionCatchFilter.java b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/filter/ExceptionCatchFilter.java
index c7bb19a0..4713e84f 100644
--- a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/filter/ExceptionCatchFilter.java
+++ b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/filter/ExceptionCatchFilter.java
@@ -34,7 +34,6 @@ import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
-import org.apache.log4j.BasicConfigurator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -93,7 +92,6 @@ public class ExceptionCatchFilter implements Filter {
* @see Filter#init(FilterConfig)
*/
public void init(FilterConfig fConfig) throws ServletException {
- BasicConfigurator.configure();
}
}