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 ++++++++++------------ .../resources/applicationResources_de.properties | 6 +++--- .../resources/applicationResources_en.properties | 4 ++-- 5 files changed, 25 insertions(+), 29 deletions(-) (limited to 'id') 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)) { diff --git a/id/ConfigWebTool/src/main/resources/applicationResources_de.properties b/id/ConfigWebTool/src/main/resources/applicationResources_de.properties index f379a7a34..a4e5a5d05 100644 --- a/id/ConfigWebTool/src/main/resources/applicationResources_de.properties +++ b/id/ConfigWebTool/src/main/resources/applicationResources_de.properties @@ -1,8 +1,8 @@ title=MOA-ID 2.x Configuration Tool -config.01=Configfile is not found. -config.02=Configfile is not readable. +config.01=Configfile is not found. ({0}) +config.02=Configfile is not readable. ({0}) config.03=Hibernate Database connector can not be initialized config.04=OpenSAML (PVP2 Login) can not be initialized config.05=Configuration file not defined @@ -38,7 +38,7 @@ error.oa.oauth.keystore=Keystore darf nicht leer sein und muss eine richtige URL mail.userrequest.subject=Accountanforderung MOA-ID 2.x Konfigurationstool -webpages.slo.error=Der Abmeldevorgang bei allen Online-Applikationen war nicht erfolgreich. Bitte schlie \u00dfen Sie aus Sicherheitsgr\u00FCnden ihren Browser. +webpages.slo.error=Der Abmeldevorgang bei allen Online-Applikationen war nicht erfolgreich. Bitte schlie \t\u00DFen Sie aus Sicherheitsgr\u00FCnden ihren Browser. webpages.slo.success=Sie wurden erfolgreich bei allen Online-Applikationen abgemeldet. webpages.error.header=Es ist ein Fehler aufgetreten diff --git a/id/ConfigWebTool/src/main/resources/applicationResources_en.properties b/id/ConfigWebTool/src/main/resources/applicationResources_en.properties index 398df94a5..c9f4e1eb2 100644 --- a/id/ConfigWebTool/src/main/resources/applicationResources_en.properties +++ b/id/ConfigWebTool/src/main/resources/applicationResources_en.properties @@ -1,8 +1,8 @@ title=MOA-ID 2.x Configuration Tool -config.01=Configfile is not found. -config.02=Configfile is not readable. +config.01=Configfile is not found. ({0}) +config.02=Configfile is not readable. ({0}) config.03=Hibernate Database connector can not be initialized config.04=OpenSAML (PVP2 Login) can not be initialized config.05=Configuration file is not defined -- cgit v1.2.3