diff options
3 files changed, 56 insertions, 74 deletions
diff --git a/common/pom.xml b/common/pom.xml index e702c5e66..72cf702bc 100644 --- a/common/pom.xml +++ b/common/pom.xml @@ -74,11 +74,6 @@ <artifactId>slf4j-api</artifactId> <version>1.7.10</version> </dependency> -<!-- <dependency> - <groupId>org.slf4j</groupId> - <artifactId>slf4j-simple</artifactId> - <version>1.7.6</version> - </dependency> --> <dependency> <groupId>org.slf4j</groupId> <artifactId>jcl-over-slf4j</artifactId> @@ -86,28 +81,18 @@ </dependency> <dependency> <groupId>org.slf4j</groupId> - <artifactId>slf4j-api</artifactId> + <artifactId>jul-to-slf4j</artifactId> <version>1.7.10</version> </dependency> -<!-- <dependency> - <groupId>org.slf4j</groupId> - <artifactId>log4j-over-slf4j</artifactId> - <version>1.7.6</version> - </dependency> --> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-log4j12</artifactId> + <version>1.7.10</version> + </dependency> <dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> </dependency> - <dependency> - <groupId>org.slf4j</groupId> - <artifactId>slf4j-log4j12</artifactId> - <version>1.7.10</version> - </dependency> - <dependency> - <groupId>org.slf4j</groupId> - <artifactId>jul-to-slf4j</artifactId> - <version>1.7.10</version> - </dependency> </dependencies> <build> diff --git a/common/src/main/java/at/gv/egovernment/moa/logging/Logger.java b/common/src/main/java/at/gv/egovernment/moa/logging/Logger.java index 184be20cb..6999656ab 100644 --- a/common/src/main/java/at/gv/egovernment/moa/logging/Logger.java +++ b/common/src/main/java/at/gv/egovernment/moa/logging/Logger.java @@ -50,22 +50,22 @@ public class Logger { /** The Constant instances. */ - private static final Map<String, org.apache.log4j.Logger> instances = new HashMap<String, org.apache.log4j.Logger>(); + private static final Map<String, org.slf4j.Logger> instances = new HashMap<String, org.slf4j.Logger>(); /** * Gets the logger. * * @return the logger */ - private static synchronized org.apache.log4j.Logger getLogger() { + private static synchronized org.slf4j.Logger getLogger() { String className = Thread.currentThread().getStackTrace()[3].getClassName(); - org.apache.log4j.Logger logger = instances.get(className); + org.slf4j.Logger logger = instances.get(className); if (logger != null) { return logger; } - logger = org.apache.log4j.Logger.getLogger(className); + logger = org.slf4j.LoggerFactory.getLogger(className); instances.put(className, logger); return logger; @@ -78,7 +78,7 @@ public class Logger { * <code>false</code> otherwise. */ public static boolean isTraceEnabled() { - org.apache.log4j.Logger logger = getLogger(); + org.slf4j.Logger logger = getLogger(); return logger.isTraceEnabled(); } @@ -90,7 +90,7 @@ public class Logger { * <code>false</code> otherwise. */ public static boolean isTraceEnabled(String hierarchy) { - org.apache.log4j.Logger logger = getLogger(); + org.slf4j.Logger logger = getLogger(); return logger.isTraceEnabled(); } @@ -100,8 +100,8 @@ public class Logger { * @param message The message to trace. */ public static void trace(Object message) { - org.apache.log4j.Logger logger = getLogger(); - logger.trace(message); + org.slf4j.Logger logger = getLogger(); + logger.trace(message.toString()); } /** @@ -111,7 +111,7 @@ public class Logger { * <code>false</code> otherwise. */ public static boolean isDebugEnabled() { - org.apache.log4j.Logger logger = getLogger(); + org.slf4j.Logger logger = getLogger(); return logger.isDebugEnabled(); } @@ -123,7 +123,7 @@ public class Logger { * <code>false</code> otherwise. */ public static boolean isDebugEnabled(String hierarchy) { - org.apache.log4j.Logger logger = getLogger(); + org.slf4j.Logger logger = getLogger(); return logger.isDebugEnabled(); } @@ -133,8 +133,8 @@ public class Logger { * @param message The message to log. */ public static void debug(Object message) { - org.apache.log4j.Logger logger = getLogger(); - logger.debug(message); + org.slf4j.Logger logger = getLogger(); + logger.debug(message.toString()); } /** @@ -143,8 +143,8 @@ public class Logger { * @param message The message to log. */ public static void info(Object message) { - org.apache.log4j.Logger logger = getLogger(); - logger.info(message); + org.slf4j.Logger logger = getLogger(); + logger.info(message.toString()); } /** @@ -153,8 +153,8 @@ public class Logger { * @param message The message to log. */ public static void warn(Object message) { - org.apache.log4j.Logger logger = getLogger(); - logger.warn(message); + org.slf4j.Logger logger = getLogger(); + logger.warn(message.toString()); } /** @@ -164,8 +164,8 @@ public class Logger { * @param t An exception that may be the cause of the warning. */ public static void warn(Object message, Throwable t) { - org.apache.log4j.Logger logger = getLogger(); - logger.warn(message, t); + org.slf4j.Logger logger = getLogger(); + logger.warn(message.toString(), t); } /** @@ -174,8 +174,8 @@ public class Logger { * @param message The message to log. */ public static void error(Object message) { - org.apache.log4j.Logger logger = getLogger(); - logger.error(message); + org.slf4j.Logger logger = getLogger(); + logger.error(message.toString()); } /** @@ -185,8 +185,8 @@ public class Logger { * @param t An exception that may be the cause of the error. */ public static void error(Object message, Throwable t) { - org.apache.log4j.Logger logger = getLogger(); - logger.error(message, t); + org.slf4j.Logger logger = getLogger(); + logger.error(message.toString(), t); } /** @@ -195,8 +195,7 @@ public class Logger { * @param message The message to log. */ public static void fatal(Object message) { - org.apache.log4j.Logger logger = getLogger(); - logger.fatal(message); + error(message); } /** @@ -206,7 +205,6 @@ public class Logger { * @param t An exception that may be the cause of the error. */ public static void fatal(Object message, Throwable t) { - org.apache.log4j.Logger logger = getLogger(); - logger.fatal(message, t); + error(message, t); } } diff --git a/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/validation/ValidationHelper.java b/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/validation/ValidationHelper.java index be6d7d01e..13d680b78 100644 --- a/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/validation/ValidationHelper.java +++ b/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/validation/ValidationHelper.java @@ -44,14 +44,13 @@ import javax.net.ssl.SSLSession; import javax.net.ssl.SSLSocket; import javax.net.ssl.SSLSocketFactory; -import org.apache.log4j.Logger; +import at.gv.egovernment.moa.logging.Logger; public class ValidationHelper { public static final String PUBLICSERVICE_URL_POSTFIX = ".gv.at"; - private static final Logger log = Logger.getLogger(ValidationHelper.class); private static final String TEMPLATE_DATEFORMAT = "dd.MM.yyyy"; @@ -68,7 +67,7 @@ public class ValidationHelper { host = host.substring(0, host.length()-1); if (url.getHost().endsWith(PUBLICSERVICE_URL_POSTFIX)) { - log.debug("PublicURLPrefix with .gv.at Domain found."); + Logger.debug("PublicURLPrefix with .gv.at Domain found."); return true; } else { @@ -95,7 +94,7 @@ public class ValidationHelper { return false; } else { - log.info("Found correct X509 Extension in server certificate. PublicService is allowed"); + Logger.info("Found correct X509 Extension in server certificate. PublicService is allowed"); return true; } } @@ -104,27 +103,27 @@ public class ValidationHelper { } } catch (MalformedURLException e) { - log.warn("PublicURLPrefix can not parsed to URL", e); + Logger.warn("PublicURLPrefix can not parsed to URL", e); return false; } catch (UnknownHostException e) { - log.warn("Can not connect to PublicURLPrefix Server", e); + Logger.warn("Can not connect to PublicURLPrefix Server", e); return false; } catch (IOException e) { - log.warn("Can not connect to PublicURLPrefix Server", e); + Logger.warn("Can not connect to PublicURLPrefix Server", e); return false; } catch (CertificateEncodingException e) { - log.warn("Can not parse X509 server certificate", e); + Logger.warn("Can not parse X509 server certificate", e); return false; } catch (CertificateException e) { - log.warn("Can not read X509 server certificate", e); + Logger.warn("Can not read X509 server certificate", e); return false; } catch (X509ExtensionInitException e) { - log.warn("Can not read X509 server certificate extension", e); + Logger.warn("Can not read X509 server certificate extension", e); return false; } @@ -133,7 +132,7 @@ public class ValidationHelper { try { socket.close(); } catch (IOException e) { - log.warn("SSL Socket can not be closed.", e); + Logger.warn("SSL Socket can not be closed.", e); } } } @@ -148,7 +147,7 @@ public class ValidationHelper { return true; } catch (Throwable t) { - log.warn("No valid DataBase OAID received! " + oaIDObj); + Logger.warn("No valid DataBase OAID received! " + oaIDObj); } } return false; @@ -156,7 +155,7 @@ public class ValidationHelper { public static boolean validateNumber(String value) { - log.debug("Validate Number " + value); + Logger.debug("Validate Number " + value); try { Float.valueOf(value); @@ -171,7 +170,7 @@ public class ValidationHelper { } public static boolean validatePhoneNumber(String value) { - log.debug ("Validate PhoneNumber " + value); + Logger.debug ("Validate PhoneNumber " + value); /* ************************************************************************************************ * Legende: @@ -187,11 +186,11 @@ public class ValidationHelper { Matcher matcher = pattern.matcher(value); boolean b = matcher.matches(); if (b) { - log.debug("Parameter PhoneNumber erfolgreich ueberprueft"); + Logger.debug("Parameter PhoneNumber erfolgreich ueberprueft"); return true; } else { - log.error("Fehler Ueberpruefung Parameter PhoneNumber. PhoneNumber entspricht nicht den Kriterien ^ [a-zA-Z .,;:/\\-]* [ ]* [(]{0,1}[ ]*[+]{0,1}[ ]*[0-9]{0,2}[ ]*[)]{0,1} [ ]* [0-9]*[ ]*[/\\-]{0,1} [ ]*[ ]* [0-9]* [ ]* [a-zA-Z .,;:\\/-]* $"); + Logger.error("Fehler Ueberpruefung Parameter PhoneNumber. PhoneNumber entspricht nicht den Kriterien ^ [a-zA-Z .,;:/\\-]* [ ]* [(]{0,1}[ ]*[+]{0,1}[ ]*[0-9]{0,2}[ ]*[)]{0,1} [ ]* [0-9]*[ ]*[/\\-]{0,1} [ ]*[ ]* [0-9]* [ ]* [a-zA-Z .,;:\\/-]* $"); return false; } @@ -200,7 +199,7 @@ public class ValidationHelper { public static boolean validateURL(String urlString) { - log.debug("Validate URL " + urlString); + Logger.debug("Validate URL " + urlString); if (urlString.startsWith("http") || urlString.startsWith("https")) { try { @@ -216,7 +215,7 @@ public class ValidationHelper { // public static boolean validateGeneralURL(String urlString) { // -// log.debug("Validate URL " + urlString); +// Logger.debug("Validate URL " + urlString); // // try { // new URL(urlString); @@ -231,17 +230,17 @@ public class ValidationHelper { public static boolean isValidAdminTarget(String target) { - log.debug("Ueberpruefe Parameter Target"); + Logger.debug("Ueberpruefe Parameter Target"); Pattern pattern = Pattern.compile("[a-zA-Z-]{1,5}"); Matcher matcher = pattern.matcher(target); boolean b = matcher.matches(); if (b) { - log.debug("Parameter SSO-Target erfolgreich ueberprueft. SSO Target is PublicService."); + Logger.debug("Parameter SSO-Target erfolgreich ueberprueft. SSO Target is PublicService."); return true; } else { - log.info("Parameter SSO-Target entspricht nicht den Kriterien " + + Logger.info("Parameter SSO-Target entspricht nicht den Kriterien " + "(nur Zeichen a-z, A-Z und -, sowie 1-5 Zeichen lang) fuer den oeffentlichen Bereich. " + "Valiere SSO-Target fuer privatwirtschaftliche Bereiche."); return false; @@ -250,14 +249,14 @@ public class ValidationHelper { public static boolean isValidTarget(String target) { - log.debug("Ueberpruefe Parameter Target"); + Logger.debug("Ueberpruefe Parameter Target"); if (TargetValidator.isValidTarget(target)) { - log.debug("Parameter Target erfolgreich ueberprueft"); + Logger.debug("Parameter Target erfolgreich ueberprueft"); return true; } else { - log.error("Fehler Ueberpruefung Parameter Target. Target entspricht nicht den Kriterien (nur Zeichen a-z, A-Z und -, sowie 1-5 Zeichen lang)"); + Logger.error("Fehler Ueberpruefung Parameter Target. Target entspricht nicht den Kriterien (nur Zeichen a-z, A-Z und -, sowie 1-5 Zeichen lang)"); return false; } @@ -265,17 +264,17 @@ public class ValidationHelper { public static boolean isValidSourceID(String sourceID) { - log.debug("Ueberpruefe Parameter sourceID"); + Logger.debug("Ueberpruefe Parameter sourceID"); Pattern pattern = Pattern.compile("[\\w-_]{1,20}"); Matcher matcher = pattern.matcher(sourceID); boolean b = matcher.matches(); if (b) { - log.debug("Parameter sourceID erfolgreich ueberprueft"); + Logger.debug("Parameter sourceID erfolgreich ueberprueft"); return true; } else { - log.error("Fehler Ueberpruefung Parameter sourceID. SourceID entspricht nicht den Kriterien (nur Zeichen a-z, A-Z, - und _, sowie 1-20 Zeichen lang)"); + Logger.error("Fehler Ueberpruefung Parameter sourceID. SourceID entspricht nicht den Kriterien (nur Zeichen a-z, A-Z, - und _, sowie 1-20 Zeichen lang)"); return false; } } |