From 57297522a1e6d925e6c15b46045e94b2db3e1b25 Mon Sep 17 00:00:00 2001 From: Thomas Lenz Date: Wed, 7 Aug 2013 10:25:31 +0200 Subject: Bugfixes: - ConfigDB Thread Problem (JPA does not close session automatically. Close JPA session manually in every Servlet) - Change general MOAID config operations at AuthConfigurationProvider.java --- .../servlet/GenerateIFrameTemplateServlet.java | 5 +- .../id/auth/servlet/GetMISSessionIDServlet.java | 5 + .../servlet/VerifyAuthenticationBlockServlet.java | 5 + .../id/auth/servlet/VerifyCertificateServlet.java | 13 +- .../id/auth/servlet/VerifyIdentityLinkServlet.java | 7 +- .../id/config/auth/AuthConfigurationProvider.java | 482 +++++++++++---------- .../moa/id/config/stork/STORKConfig.java | 45 +- .../moa/id/entrypoints/DispatcherServlet.java | 6 +- .../protocols/pvp2x/config/PVPConfiguration.java | 7 +- 9 files changed, 320 insertions(+), 255 deletions(-) (limited to 'id/server/idserverlib/src/main/java') diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/servlet/GenerateIFrameTemplateServlet.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/servlet/GenerateIFrameTemplateServlet.java index 8d23f1a3b..f68e0361a 100644 --- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/servlet/GenerateIFrameTemplateServlet.java +++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/servlet/GenerateIFrameTemplateServlet.java @@ -23,6 +23,7 @@ import at.gv.egovernment.moa.id.auth.WrongParametersException; import at.gv.egovernment.moa.id.auth.builder.StartAuthenticationBuilder; import at.gv.egovernment.moa.id.auth.data.AuthenticationSession; import at.gv.egovernment.moa.id.auth.parser.StartAuthentificationParameterParser; +import at.gv.egovernment.moa.id.commons.db.ConfigurationDBUtils; import at.gv.egovernment.moa.id.commons.db.ex.MOADatabaseException; import at.gv.egovernment.moa.id.config.auth.AuthConfigurationProvider; import at.gv.egovernment.moa.id.config.auth.OAAuthParameter; @@ -141,6 +142,8 @@ public class GenerateIFrameTemplateServlet extends AuthServlet { handleError(null, ex, req, resp, pendingRequestID); } - + finally { + ConfigurationDBUtils.closeSession(); + } } } diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/servlet/GetMISSessionIDServlet.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/servlet/GetMISSessionIDServlet.java index 8e5fccfef..67932063a 100644 --- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/servlet/GetMISSessionIDServlet.java +++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/servlet/GetMISSessionIDServlet.java @@ -48,6 +48,7 @@ import at.gv.egovernment.moa.id.auth.WrongParametersException; import at.gv.egovernment.moa.id.auth.builder.BPKBuilder; import at.gv.egovernment.moa.id.auth.builder.DataURLBuilder; import at.gv.egovernment.moa.id.auth.data.AuthenticationSession; +import at.gv.egovernment.moa.id.commons.db.ConfigurationDBUtils; import at.gv.egovernment.moa.id.config.ConnectionParameter; import at.gv.egovernment.moa.id.config.auth.AuthConfigurationProvider; import at.gv.egovernment.moa.id.moduls.ModulUtils; @@ -267,6 +268,10 @@ public class GetMISSessionIDServlet extends AuthServlet { } catch (ParserConfigurationException e) { handleError(null, e, req, resp, pendingRequestID); } + + finally { + ConfigurationDBUtils.closeSession(); + } } } diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/servlet/VerifyAuthenticationBlockServlet.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/servlet/VerifyAuthenticationBlockServlet.java index 96914647e..09e4e957d 100644 --- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/servlet/VerifyAuthenticationBlockServlet.java +++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/servlet/VerifyAuthenticationBlockServlet.java @@ -48,6 +48,7 @@ import at.gv.egovernment.moa.id.auth.MOAIDAuthConstants; import at.gv.egovernment.moa.id.auth.WrongParametersException; import at.gv.egovernment.moa.id.auth.builder.DataURLBuilder; import at.gv.egovernment.moa.id.auth.data.AuthenticationSession; +import at.gv.egovernment.moa.id.commons.db.ConfigurationDBUtils; import at.gv.egovernment.moa.id.commons.db.ex.MOADatabaseException; import at.gv.egovernment.moa.id.config.ConnectionParameter; import at.gv.egovernment.moa.id.config.auth.AuthConfigurationProvider; @@ -284,6 +285,10 @@ public class VerifyAuthenticationBlockServlet extends AuthServlet { } catch (TransformerException e) { handleError(null, e, req, resp, pendingRequestID); } + + finally { + ConfigurationDBUtils.closeSession(); + } } diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/servlet/VerifyCertificateServlet.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/servlet/VerifyCertificateServlet.java index 896bd0864..9e7c8536d 100644 --- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/servlet/VerifyCertificateServlet.java +++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/servlet/VerifyCertificateServlet.java @@ -43,6 +43,7 @@ import at.gv.egovernment.moa.id.auth.MOAIDAuthConstants; import at.gv.egovernment.moa.id.auth.WrongParametersException; import at.gv.egovernment.moa.id.auth.builder.DataURLBuilder; import at.gv.egovernment.moa.id.auth.data.AuthenticationSession; +import at.gv.egovernment.moa.id.commons.db.ConfigurationDBUtils; import at.gv.egovernment.moa.id.commons.db.ex.MOADatabaseException; import at.gv.egovernment.moa.id.storage.AuthenticationSessionStoreage; import at.gv.egovernment.moa.id.util.ParamValidatorUtils; @@ -177,12 +178,16 @@ public class VerifyCertificateServlet extends AuthServlet { Logger.debug("Send CreateXMLSignatureRequest to BKU"); - } - + } } - catch (MOAIDException ex) { + catch (MOAIDException ex) { + handleError(null, ex, req, resp, pendingRequestID); - } + } + + finally { + ConfigurationDBUtils.closeSession(); + } } diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/servlet/VerifyIdentityLinkServlet.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/servlet/VerifyIdentityLinkServlet.java index c6310d8c0..ac7466c11 100644 --- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/servlet/VerifyIdentityLinkServlet.java +++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/servlet/VerifyIdentityLinkServlet.java @@ -43,6 +43,7 @@ import at.gv.egovernment.moa.id.auth.WrongParametersException; import at.gv.egovernment.moa.id.auth.builder.DataURLBuilder; import at.gv.egovernment.moa.id.auth.builder.InfoboxReadRequestBuilderCertificate; import at.gv.egovernment.moa.id.auth.data.AuthenticationSession; +import at.gv.egovernment.moa.id.commons.db.ConfigurationDBUtils; import at.gv.egovernment.moa.id.commons.db.ex.MOADatabaseException; import at.gv.egovernment.moa.id.config.auth.AuthConfigurationProvider; import at.gv.egovernment.moa.id.config.auth.OAAuthParameter; @@ -225,8 +226,6 @@ public class VerifyIdentityLinkServlet extends AuthServlet { ServletUtils.writeCreateXMLSignatureRequestOrRedirect(resp, session, createXMLSignatureRequestOrRedirect, AuthenticationServer.REQ_PROCESS_VALIDATOR_INPUT, "VerifyIdentityLink"); } - - // } try { @@ -244,6 +243,10 @@ public class VerifyIdentityLinkServlet extends AuthServlet { catch (MOAIDException ex) { handleError(null, ex, req, resp, pendingRequestID); } + + finally { + ConfigurationDBUtils.closeSession(); + } } } diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/config/auth/AuthConfigurationProvider.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/config/auth/AuthConfigurationProvider.java index ff8c562a7..192be5bbb 100644 --- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/config/auth/AuthConfigurationProvider.java +++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/config/auth/AuthConfigurationProvider.java @@ -37,6 +37,7 @@ import java.security.NoSuchProviderException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.Properties; import javax.crypto.Cipher; @@ -54,6 +55,7 @@ import at.gv.egovernment.moa.id.commons.db.ConfigurationDBUtils; import at.gv.egovernment.moa.id.commons.db.MOASessionDBUtils; import at.gv.egovernment.moa.id.commons.db.dao.config.AuthComponentGeneral; import at.gv.egovernment.moa.id.commons.db.dao.config.ChainingModes; +import at.gv.egovernment.moa.id.commons.db.dao.config.Contact; import at.gv.egovernment.moa.id.commons.db.dao.config.ForeignIdentities; import at.gv.egovernment.moa.id.commons.db.dao.config.IdentificationNumber; import at.gv.egovernment.moa.id.commons.db.dao.config.IdentityLinkSigners; @@ -62,6 +64,7 @@ import at.gv.egovernment.moa.id.commons.db.dao.config.MOAIDConfiguration; import at.gv.egovernment.moa.id.commons.db.dao.config.MOASP; import at.gv.egovernment.moa.id.commons.db.dao.config.OnlineApplication; import at.gv.egovernment.moa.id.commons.db.dao.config.OnlineMandates; +import at.gv.egovernment.moa.id.commons.db.dao.config.Organization; import at.gv.egovernment.moa.id.commons.db.dao.config.PVP2; import at.gv.egovernment.moa.id.commons.db.dao.config.Protocols; import at.gv.egovernment.moa.id.commons.db.dao.config.SLRequestTemplates; @@ -154,11 +157,34 @@ public class AuthConfigurationProvider extends ConfigurationProvider { // // configuration data // - private static MOAIDConfiguration moaidconfig; + private static MOAIDConfiguration moaidconfig = null; - private static Properties props; + private static Properties props = null; - private static STORKConfig storkconfig; + private static STORKConfig storkconfig = null; + + private static TimeOuts timeouts = null; + + private static PVP2 pvp2general = null; + + private static String alternativesourceid = null; + + private static List legacyallowedprotocols = new ArrayList(); + + private static VerifyAuthBlock verifyidl = null; + + private static ConnectionParameter MoaSpConnectionParameter = null; + private static ConnectionParameter ForeignIDConnectionParameter = null; + private static ConnectionParameter OnlineMandatesConnectionParameter = null; + + private static String MoaSpIdentityLinkTrustProfileID = null; + + private static List TransformsInfos = null; + private static List IdentityLinkX509SubjectNames = new ArrayList(); + + private static Map SLRequestTemplates = new HashMap(); + + private static SSO ssoconfig = null; /** * Return the single instance of configuration data. @@ -359,13 +385,13 @@ public class AuthConfigurationProvider extends ConfigurationProvider { } //build STORK Config - AuthComponentGeneral authgeneral = getAuthComponentGeneral(); - ForeignIdentities foreign = authgeneral.getForeignIdentities(); + AuthComponentGeneral auth = getAuthComponentGeneral(); + ForeignIdentities foreign = auth.getForeignIdentities(); if (foreign == null ) { Logger.warn("Error in MOA-ID Configuration. No STORK configuration found."); - throw new ConfigurationException("config.02", null); - } - storkconfig = new STORKConfig(foreign.getSTORK(), props, rootConfigFileDir); + + } else + storkconfig = new STORKConfig(foreign.getSTORK(), props, rootConfigFileDir); //load Chaining modes @@ -393,7 +419,173 @@ public class AuthConfigurationProvider extends ConfigurationProvider { //set TrustManagerRevocationChecking setTrustManagerRevocationChecking(); - + + //set TimeOuts + if (auth.getGeneralConfiguration() != null) { + if (auth.getGeneralConfiguration().getTimeOuts() != null) { + + timeouts = new TimeOuts(); + timeouts.setAssertion(auth.getGeneralConfiguration().getTimeOuts().getAssertion()); + timeouts.setMOASessionCreated(auth.getGeneralConfiguration().getTimeOuts().getMOASessionCreated()); + timeouts.setMOASessionUpdated(auth.getGeneralConfiguration().getTimeOuts().getMOASessionUpdated()); + } + } + else { + Logger.warn("Error in MOA-ID Configuration. No TimeOuts defined."); + throw new ConfigurationException("config.02", null); + } + + //set PVP2 general config + Protocols protocols = auth.getProtocols(); + if (protocols != null) { + if (protocols.getPVP2() != null) { + PVP2 el = protocols.getPVP2();; + pvp2general = new PVP2(); + pvp2general.setIssuerName(el.getIssuerName()); + pvp2general.setPublicURLPrefix(el.getPublicURLPrefix()); + + if (el.getOrganization() != null) { + Organization org = new Organization(); + pvp2general.setOrganization(org); + org.setDisplayName(el.getOrganization().getDisplayName()); + org.setName(el.getOrganization().getName()); + org.setURL(el.getOrganization().getURL()); + } + + if (el.getContact() != null) { + List cont = new ArrayList(); + pvp2general.setContact(cont); + for (Contact e : el.getContact()) { + Contact c = new Contact(); + c.setCompany(e.getCompany()); + c.setGivenName(e.getGivenName()); + c.setMail(e.getMail()); + c.setPhone(e.getPhone()); + c.setSurName(e.getSurName()); + c.setType(e.getType()); + } + } + } + } else { + Logger.warn("Error in MOA-ID Configuration. No general Protcol configuration found."); + } + + //set alternativeSourceID + if (auth.getGeneralConfiguration() != null) + alternativesourceid = auth.getGeneralConfiguration().getAlternativeSourceID(); + else { + Logger.warn("Error in MOA-ID Configuration. No GeneralConfig defined."); + throw new ConfigurationException("config.02", null); + } + + //set LegacyAllowedProtocols + try { + if (auth.getProtocols() != null) { + Protocols procols = auth.getProtocols(); + if (procols.getLegacyAllowed() != null) { + LegacyAllowed legacy = procols.getLegacyAllowed(); + legacyallowedprotocols = new ArrayList(legacy.getProtocolName()); + } + } + } catch (Exception e) { + Logger.info("No protocols found with legacy allowed flag!"); + } + + //set VerifyAuthBlockConfig + MOASP moasp = getMOASPConfig(auth); + + VerifyAuthBlock el = moasp.getVerifyAuthBlock(); + if (el != null) { + verifyidl = new VerifyAuthBlock(); + verifyidl.setTrustProfileID(el.getTrustProfileID()); + verifyidl.setVerifyTransformsInfoProfileID(new ArrayList(el.getVerifyTransformsInfoProfileID())); + } + else { + Logger.warn("Error in MOA-ID Configuration. No Trustprofile for AuthBlock validation."); + throw new ConfigurationException("config.02", null); + } + + //set MOASP connection parameters + if (moasp.getConnectionParameter() != null) + MoaSpConnectionParameter = new ConnectionParameterMOASP(moasp.getConnectionParameter(), props, this.rootConfigFileDir); + else + MoaSpConnectionParameter = null; + + //set ForeignIDConnectionParameters + if (foreign != null) { + ForeignIDConnectionParameter = new ConnectionParameterForeign(foreign.getConnectionParameter(), props, this.rootConfigFileDir); + } else { + Logger.warn("Error in MOA-ID Configuration. No Connectionconfiguration to SZRGW Service found"); + } + + //set OnlineMandateConnectionParameters + OnlineMandates ovs = auth.getOnlineMandates(); + if (ovs != null) { + OnlineMandatesConnectionParameter = new ConnectionParameterMandate(ovs.getConnectionParameter(), props, this.rootConfigFileDir); + + } else { + Logger.warn("Error in MOA-ID Configuration. No Connectionconfiguration to OVS Service found"); + } + + //set MOASP IdentityLink Trust-ProfileID + VerifyIdentityLink verifyidl = moasp.getVerifyIdentityLink(); + if (verifyidl != null) + MoaSpIdentityLinkTrustProfileID = verifyidl.getTrustProfileID(); + else { + Logger.warn("Error in MOA-ID Configuration. No Trustprofile for IdentityLink validation."); + throw new ConfigurationException("config.02", null); + } + + //set SL transformation infos + SecurityLayer seclayer = auth.getSecurityLayer(); + if (seclayer == null) { + Logger.warn("Error in MOA-ID Configuration. No generalAuthConfiguration->SecurityLayer found"); + throw new ConfigurationException("config.02", null); + } else { + TransformsInfos = ConfigurationUtils.getTransformInfos(seclayer.getTransformsInfo()); + } + + //set IdentityLinkSignerSubjectNames + IdentityLinkSigners idlsigners = auth.getIdentityLinkSigners(); + if (idlsigners != null) { + IdentityLinkX509SubjectNames = new ArrayList(idlsigners.getX509SubjectName()); + + } else { + Logger.warn("Warning in MOA-ID Configuration. No IdenitiyLink signer found."); + } + + //set SLRequestTemplates + SLRequestTemplates templ = moaidconfig.getSLRequestTemplates(); + if (templ == null) { + Logger.warn("Error in MOA-ID Configuration. No SLRequestTemplates found"); + throw new ConfigurationException("config.02", null); + } else { + SLRequestTemplates.put(OAAuthParameter.ONLINEBKU, templ.getOnlineBKU()); + SLRequestTemplates.put(OAAuthParameter.LOCALBKU, templ.getLocalBKU()); + SLRequestTemplates.put(OAAuthParameter.HANDYBKU, templ.getHandyBKU()); + } + + //set SSO Config + if (auth.getSSO()!= null) { + ssoconfig = new SSO(); + ssoconfig.setFriendlyName(auth.getSSO().getFriendlyName()); + ssoconfig.setPublicURL(auth.getSSO().getPublicURL()); + ssoconfig.setSpecialText(auth.getSSO().getSpecialText()); + ssoconfig.setTarget(auth.getSSO().getTarget()); + + if (auth.getSSO().getIdentificationNumber() != null) { + IdentificationNumber value = new IdentificationNumber(); + value.setType(auth.getSSO().getIdentificationNumber().getType()); + value.setValue(auth.getSSO().getIdentificationNumber().getValue()); + ssoconfig.setIdentificationNumber(value); + } + } else { + Logger.warn("Error in MOA-ID Configuration. No Single Sign-On Config found"); + } + + //close Database + ConfigurationDBUtils.closeSession(); + } catch (Throwable t) { throw new ConfigurationException("config.02", null, t); } @@ -414,56 +606,19 @@ public class AuthConfigurationProvider extends ConfigurationProvider { public PVP2 getGeneralPVP2DBConfig() { - - try { - AuthComponentGeneral auth = getAuthComponentGeneral(); - Protocols protocols = auth.getProtocols(); - if (protocols != null) { - return protocols.getPVP2(); - } - Logger.warn("Error in MOA-ID Configuration. No general Protcol configuration found."); - return null; - - } catch (ConfigurationException e) { - Logger.warn("Error in MOA-ID Configuration. No general AuthComponent configuration found."); - return null; - } + return pvp2general; } - public TimeOuts getTimeOuts() throws ConfigurationException { - AuthComponentGeneral auth = getAuthComponentGeneral(); - - if (auth.getGeneralConfiguration() != null) - return auth.getGeneralConfiguration().getTimeOuts(); - else { - Logger.warn("Error in MOA-ID Configuration. No TimeOuts defined."); - throw new ConfigurationException("config.02", null); - } + public TimeOuts getTimeOuts() throws ConfigurationException { + return timeouts; } - public String getAlternativeSourceID() throws ConfigurationException { - AuthComponentGeneral auth = getAuthComponentGeneral(); - - if (auth.getGeneralConfiguration() != null) - return auth.getGeneralConfiguration().getAlternativeSourceID(); - else { - Logger.warn("Error in MOA-ID Configuration. No AlternativeSourceID defined."); - throw new ConfigurationException("config.02", null); - } + public String getAlternativeSourceID() throws ConfigurationException { + return alternativesourceid; } public List getLegacyAllowedProtocols() { - try { - AuthComponentGeneral auth = getAuthComponentGeneral(); - Protocols procols = auth.getProtocols(); - LegacyAllowed legacy = procols.getLegacyAllowed(); - return legacy.getProtocolName(); - - } catch (Exception e) { - Logger.info("No protocols found with legacy allowed flag!"); - return new ArrayList(); - } - + return legacyallowedprotocols; } @@ -496,16 +651,7 @@ public class AuthConfigurationProvider extends ConfigurationProvider { * @throws ConfigurationException */ public String getMoaSpAuthBlockTrustProfileID() throws ConfigurationException { - AuthComponentGeneral auth = getAuthComponentGeneral(); - MOASP moasp = getMOASPConfig(auth); - VerifyAuthBlock verifyidl = moasp.getVerifyAuthBlock(); - - if (verifyidl != null) - return verifyidl.getTrustProfileID(); - - Logger.warn("Error in MOA-ID Configuration. No Trustprofile for AuthBlock validation."); - throw new ConfigurationException("config.02", null); - + return verifyidl.getTrustProfileID(); } /** @@ -516,16 +662,7 @@ public class AuthConfigurationProvider extends ConfigurationProvider { * @throws ConfigurationException */ public List getMoaSpAuthBlockVerifyTransformsInfoIDs() throws ConfigurationException { - - AuthComponentGeneral auth = getAuthComponentGeneral(); - MOASP moasp = getMOASPConfig(auth); - VerifyAuthBlock verifyidl = moasp.getVerifyAuthBlock(); - - if (verifyidl != null) - return verifyidl.getVerifyTransformsInfoProfileID(); - - Logger.warn("Error in MOA-ID Configuration. No Trustprofile for AuthBlock validation."); - throw new ConfigurationException("config.02", null); + return verifyidl.getVerifyTransformsInfoProfileID(); } /** @@ -534,15 +671,8 @@ public class AuthConfigurationProvider extends ConfigurationProvider { * @return ConnectionParameter of the authentication component moa-sp element * @throws ConfigurationException */ - public ConnectionParameter getMoaSpConnectionParameter() throws ConfigurationException { - - AuthComponentGeneral authgeneral = getAuthComponentGeneral(); - MOASP moasp = getMOASPConfig(authgeneral); - - if (moasp.getConnectionParameter() != null) - return new ConnectionParameterMOASP(moasp.getConnectionParameter(), props, this.rootConfigFileDir); - else - return null; + public ConnectionParameter getMoaSpConnectionParameter() throws ConfigurationException { + return MoaSpConnectionParameter; } /** @@ -552,15 +682,7 @@ public class AuthConfigurationProvider extends ConfigurationProvider { * @throws ConfigurationException */ public ConnectionParameter getForeignIDConnectionParameter() throws ConfigurationException { - - AuthComponentGeneral authgeneral = getAuthComponentGeneral(); - ForeignIdentities foreign = authgeneral.getForeignIdentities(); - - if (foreign != null) { - return new ConnectionParameterForeign(foreign.getConnectionParameter(), props, this.rootConfigFileDir); - } - Logger.warn("Error in MOA-ID Configuration. No Connectionconfiguration to SZRGW Service found"); - throw new ConfigurationException("config.02", null); + return ForeignIDConnectionParameter; } /** @@ -570,15 +692,7 @@ public class AuthConfigurationProvider extends ConfigurationProvider { * @throws ConfigurationException */ public ConnectionParameter getOnlineMandatesConnectionParameter() throws ConfigurationException { - - AuthComponentGeneral authgeneral = getAuthComponentGeneral(); - OnlineMandates ovs = authgeneral.getOnlineMandates(); - - if (ovs != null) { - return new ConnectionParameterMandate(ovs.getConnectionParameter(), props, this.rootConfigFileDir); - } - Logger.warn("Error in MOA-ID Configuration. No Connectionconfiguration to OVS Service found"); - throw new ConfigurationException("config.02", null); + return OnlineMandatesConnectionParameter; } /** @@ -588,15 +702,7 @@ public class AuthConfigurationProvider extends ConfigurationProvider { * @throws ConfigurationException */ public String getMoaSpIdentityLinkTrustProfileID() throws ConfigurationException { - AuthComponentGeneral auth = getAuthComponentGeneral(); - MOASP moasp = getMOASPConfig(auth); - VerifyIdentityLink verifyidl = moasp.getVerifyIdentityLink(); - - if (verifyidl != null) - return verifyidl.getTrustProfileID(); - - Logger.warn("Error in MOA-ID Configuration. No Trustprofile for IdentityLink validation."); - throw new ConfigurationException("config.02", null); + return MoaSpIdentityLinkTrustProfileID; } /** @@ -605,16 +711,7 @@ public class AuthConfigurationProvider extends ConfigurationProvider { * @throws ConfigurationException */ public List getTransformsInfos() throws ConfigurationException { - - AuthComponentGeneral authgeneral = getAuthComponentGeneral(); - - SecurityLayer seclayer = authgeneral.getSecurityLayer(); - if (seclayer == null) { - Logger.warn("Error in MOA-ID Configuration. No generalAuthConfiguration->SecurityLayer found"); - throw new ConfigurationException("config.02", null); - } - - return ConfigurationUtils.getTransformInfos(seclayer.getTransformsInfo()); + return TransformsInfos; } /** @@ -623,142 +720,79 @@ public class AuthConfigurationProvider extends ConfigurationProvider { * @throws ConfigurationException */ public List getIdentityLinkX509SubjectNames() throws ConfigurationException { - - AuthComponentGeneral auth = getAuthComponentGeneral(); - IdentityLinkSigners idlsigners = auth.getIdentityLinkSigners(); - - if (idlsigners != null) { - return idlsigners.getX509SubjectName(); - - } - - Logger.warn("Warning in MOA-ID Configuration. No IdenitiyLink signer found."); - return new ArrayList(); + return IdentityLinkX509SubjectNames; } public List getSLRequestTemplates() throws ConfigurationException { - SLRequestTemplates templ = moaidconfig.getSLRequestTemplates(); - List list = new ArrayList(); - - if (templ == null) { - Logger.warn("Error in MOA-ID Configuration. No SLRequestTemplates found"); - throw new ConfigurationException("config.02", null); - } - list.add(templ.getOnlineBKU()); - list.add(templ.getHandyBKU()); - list.add(templ.getLocalBKU()); - return list; + return new ArrayList(SLRequestTemplates.values()); } public String getSLRequestTemplates(String type) throws ConfigurationException { - SLRequestTemplates templ = moaidconfig.getSLRequestTemplates(); - if (templ != null) { - if (type.equals(OAAuthParameter.ONLINEBKU)) - return templ.getOnlineBKU(); - else if (type.equals(OAAuthParameter.HANDYBKU)) - return templ.getHandyBKU(); - else if (type.equals(OAAuthParameter.LOCALBKU)) - return templ.getLocalBKU(); - - } - Logger.warn("getSLRequestTemplates: BKU Type does not match: " - + OAAuthParameter.ONLINEBKU + " or " + OAAuthParameter.HANDYBKU + " or " + OAAuthParameter.LOCALBKU); - return null; + String el = SLRequestTemplates.get(type); + if (MiscUtil.isNotEmpty(el)) + return el; + else { + Logger.warn("getSLRequestTemplates: BKU Type does not match: " + + OAAuthParameter.ONLINEBKU + " or " + OAAuthParameter.HANDYBKU + " or " + OAAuthParameter.LOCALBKU); + return null; + } } public boolean isSSOBusinessService() throws ConfigurationException { - AuthComponentGeneral auth = getAuthComponentGeneral(); - - SSO sso = auth.getSSO(); - if (sso!= null) { - if (sso.getIdentificationNumber() != null) - return true; - } - return false; + if (ssoconfig != null && ssoconfig.getIdentificationNumber() != null) + return true; + else + return false; } public IdentificationNumber getSSOBusinessService() throws ConfigurationException { - AuthComponentGeneral auth = getAuthComponentGeneral(); - - SSO sso = auth.getSSO(); - - if (sso!= null) - return sso.getIdentificationNumber(); - - return null; + if (ssoconfig != null) + return ssoconfig.getIdentificationNumber(); + else + return null; } - public String getSSOTarget() throws ConfigurationException { - AuthComponentGeneral auth = getAuthComponentGeneral(); - - SSO sso = auth.getSSO(); - - if (sso!= null) - return sso.getTarget(); + public String getSSOTarget() throws ConfigurationException { + if (ssoconfig!= null) + return ssoconfig.getTarget(); return null; } - public String getSSOFriendlyName() { - AuthComponentGeneral auth; - try { - auth = getAuthComponentGeneral(); - - SSO sso = auth.getSSO(); - - if (sso!= null) - return sso.getFriendlyName(); - - } catch (ConfigurationException e) { - Logger.warn("No SSO FriendlyName found. Use default Name!!!"); - } - return "Default MOA-ID friendly name for SSO"; + public String getSSOFriendlyName() { + if (ssoconfig!= null) { + if (MiscUtil.isNotEmpty(ssoconfig.getFriendlyName())) + return ssoconfig.getFriendlyName(); + } + + return "Default MOA-ID friendly name for SSO"; } public String getSSOSpecialText() { - try { - AuthComponentGeneral auth = getAuthComponentGeneral(); - - SSO sso = auth.getSSO(); + if (ssoconfig!= null) { + String text = ssoconfig.getSpecialText(); + if (MiscUtil.isEmpty(text)) + text = new String(); - if (sso!= null) { - String text = sso.getSpecialText(); - if (MiscUtil.isEmpty(text)) - text = new String(); - return text; - } - - - } catch (ConfigurationException e) { - } - return new String(); + return text; + } + return new String(); } public String getSSOPublicUrl() { - try { - AuthComponentGeneral auth = getAuthComponentGeneral(); - - SSO sso = auth.getSSO(); - - if (sso!= null) { - String url = sso.getPublicURL(); - - if (MiscUtil.isEmpty(url)) - url = new String(); - - return url; - } - - } catch (ConfigurationException e) { - } - return new String(); + if (ssoconfig!= null) { + String url = ssoconfig.getPublicURL(); + if (MiscUtil.isEmpty(url)) + url = new String(); + return url; + } + return new String(); } public String getMOASessionEncryptionKey() { - String prop = props.getProperty("configuration.moasession.key"); - + String prop = props.getProperty("configuration.moasession.key"); if (MiscUtil.isEmpty(prop)) return null; else diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/config/stork/STORKConfig.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/config/stork/STORKConfig.java index 82c9a92da..39f5479ce 100644 --- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/config/stork/STORKConfig.java +++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/config/stork/STORKConfig.java @@ -40,13 +40,13 @@ import at.gv.egovernment.moa.util.StringUtils; public class STORKConfig { /** STORK SAML signature creation parameters */ - private STORK stork; - private Properties props; - private Map cpepsMap; - private String basedirectory; + private Properties props = null; + private Map cpepsMap = null; + private String basedirectory = null; + private SignatureVerificationParameter sigverifyparam = null; + public STORKConfig(STORK stork, Properties props, String basedirectory) { - this.stork = stork; this.basedirectory = basedirectory; this.props = props; @@ -90,30 +90,33 @@ public class STORKConfig { + cpep.getCountryCode() + " has an invalid Attribute and is ignored."); } } - } - - public SignatureCreationParameter getSignatureCreationParameter() { - - return new SignatureCreationParameter(props, basedirectory); - } - - public SignatureVerificationParameter getSignatureVerificationParameter() { SAMLSigningParameter samlsign = stork.getSAMLSigningParameter(); if (samlsign == null) { Log.warn("Error in MOA-ID Configuration. No STORK->SAMLSigningParameter configuration found."); - return null; - } - - SignatureVerificationParameterType sigverify = samlsign.getSignatureVerificationParameter(); + + } else { + SignatureVerificationParameterType sigverify = samlsign.getSignatureVerificationParameter(); - if (sigverify == null) { - Log.warn("Error in MOA-ID Configuration. No STORK->SignatureVerificationParameter configuration found."); - return null; + if (sigverify == null) { + Log.warn("Error in MOA-ID Configuration. No STORK->SignatureVerificationParameter configuration found."); + + } else { + sigverifyparam = new SignatureVerificationParameter(sigverify.getTrustProfileID()); + } } - return new SignatureVerificationParameter(sigverify.getTrustProfileID()); + } + + public SignatureCreationParameter getSignatureCreationParameter() { + + return new SignatureCreationParameter(props, basedirectory); + } + + public SignatureVerificationParameter getSignatureVerificationParameter() { + + return sigverifyparam; } public Map getCpepsMap() { diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/entrypoints/DispatcherServlet.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/entrypoints/DispatcherServlet.java index f70596949..83d12be87 100644 --- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/entrypoints/DispatcherServlet.java +++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/entrypoints/DispatcherServlet.java @@ -452,8 +452,6 @@ public class DispatcherServlet extends AuthServlet{ authmanager.logout(req, resp, moasessionID); } - ConfigurationDBUtils.closeSession(); - //authmanager.logout(req, resp); } catch (Throwable e) { @@ -471,6 +469,10 @@ public class DispatcherServlet extends AuthServlet{ e.printStackTrace(); resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); } + + finally { + ConfigurationDBUtils.closeSession(); + } } diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/config/PVPConfiguration.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/config/PVPConfiguration.java index 7682566f2..0786f896a 100644 --- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/config/PVPConfiguration.java +++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/config/PVPConfiguration.java @@ -162,8 +162,13 @@ public class PVPConfiguration { try { OAAuthParameter oaParam = AuthConfigurationProvider.getInstance().getOnlineApplicationParameter(sp); - return oaParam.getTarget(); + if (oaParam != null) + return oaParam.getTarget(); + + Logger.warn("OnlineApplication with ID "+ sp + " is not found."); + return null; + } catch (ConfigurationException e) { Logger.warn("OnlineApplication with ID "+ sp + " is not found."); return null; -- cgit v1.2.3