From c4671f7b414547ab3f412eb46d35f6048d463307 Mon Sep 17 00:00:00 2001 From: Thomas Lenz Date: Wed, 11 Jun 2014 12:02:05 +0200 Subject: change initialization step in AuthenticationFilter --- .../config/ConfigurationProvider.java | 15 +++++--------- .../exception/ConfigurationException.java | 6 +++++- .../configuration/filter/AuthenticationFilter.java | 23 ++++++++++------------ 3 files changed, 20 insertions(+), 24 deletions(-) (limited to 'id/ConfigWebTool/src/main/java/at/gv/egovernment') diff --git a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/config/ConfigurationProvider.java b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/config/ConfigurationProvider.java index e176e5141..bea6220ff 100644 --- a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/config/ConfigurationProvider.java +++ b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/config/ConfigurationProvider.java @@ -85,19 +85,14 @@ public class ConfigurationProvider { public static ConfigurationProvider getInstance() throws ConfigurationException { if (instance == null) { - synchronized (ConfigurationProvider.class) { - instance = new ConfigurationProvider(); - } + instance = new ConfigurationProvider(); + instance.inizialize(); } return instance; } - - private ConfigurationProvider() throws ConfigurationException { - inizialize(); - } - + private void inizialize() throws ConfigurationException { configFileName = System.getProperty(SYSTEM_PROP_CONFIG); @@ -143,10 +138,10 @@ public class ConfigurationProvider { } catch (FileNotFoundException e) { - throw new ConfigurationException("config.01", e); + throw new ConfigurationException("config.01", new Object[]{configFileName}, e); } catch (IOException e) { - throw new ConfigurationException("config.02", e); + throw new ConfigurationException("config.02", new Object[]{configFileName}, e); } catch (MOADatabaseException e) { throw new ConfigurationException("config.03", e); diff --git a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/exception/ConfigurationException.java b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/exception/ConfigurationException.java index ebabd600d..3aa3910cc 100644 --- a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/exception/ConfigurationException.java +++ b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/exception/ConfigurationException.java @@ -35,7 +35,11 @@ public class ConfigurationException extends Exception { public ConfigurationException(String errorname, Throwable e) { super(LanguageHelper.getErrorString(errorname, null), e); } - + + public ConfigurationException(String errorname, Object[] params, Throwable e) { + super(LanguageHelper.getErrorString(errorname, params, null), e); + } + public ConfigurationException(Throwable e) { super(e); } diff --git a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/filter/AuthenticationFilter.java b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/filter/AuthenticationFilter.java index 9ca1d08cc..1f631afea 100644 --- a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/filter/AuthenticationFilter.java +++ b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/filter/AuthenticationFilter.java @@ -75,17 +75,6 @@ public class AuthenticationFilter implements Filter{ private static String[] excludedPages = null; private static Pattern excludedRegEx = null; - - - public AuthenticationFilter() throws ServletException { - try { - config = ConfigurationProvider.getInstance(); - - } catch (ConfigurationException e) { - throw new ServletException(AuthenticationFilter.class + ": Configuration can not be loaded!", e); - } - } - public static String getErrorPage() { return errorPage; } @@ -224,9 +213,17 @@ public class AuthenticationFilter implements Filter{ } } - public void init(FilterConfig filterConfig) throws ServletException { + public void init(FilterConfig filterConfig) throws ServletException { log.debug("Starting init of " + this.getClass().getName() + "."); - + + try { + config = ConfigurationProvider.getInstance(); + + } catch (ConfigurationException e) { + throw new ServletException(e.getMessage(), e); + + } + // login page loginPage = StringUtils.trim(filterConfig.getInitParameter(WEB_XML_INIT_PARAM_LOGIN_PAGE)); if (MiscUtil.isEmpty(loginPage)) { -- cgit v1.2.3