diff options
author | Thomas Lenz <tlenz@iaik.tugraz.at> | 2015-06-19 13:34:42 +0200 |
---|---|---|
committer | Thomas Lenz <tlenz@iaik.tugraz.at> | 2015-06-19 13:34:42 +0200 |
commit | e0c190004d654a2fa4f91f33133f6d55444e3798 (patch) | |
tree | f550ebfb176cf923a7749894e4b45c18159cc648 /id/server/idserverlib/src/main/java | |
parent | 0ac1586549bf1bb391c48a4151a5f32a0863a5f4 (diff) | |
download | moa-id-spss-e0c190004d654a2fa4f91f33133f6d55444e3798.tar.gz moa-id-spss-e0c190004d654a2fa4f91f33133f6d55444e3798.tar.bz2 moa-id-spss-e0c190004d654a2fa4f91f33133f6d55444e3798.zip |
refactoring for properties based configuration
Diffstat (limited to 'id/server/idserverlib/src/main/java')
6 files changed, 250 insertions, 260 deletions
diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/builder/AuthenticationDataBuilder.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/builder/AuthenticationDataBuilder.java index f646f200d..ffadc2631 100644 --- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/builder/AuthenticationDataBuilder.java +++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/builder/AuthenticationDataBuilder.java @@ -930,7 +930,7 @@ public class AuthenticationDataBuilder implements MOAIDAuthConstants { //set max. SSO session time if (authData.isSsoSession()) { - long maxSSOSessionTime = AuthConfigurationProviderFactory.getInstance().getTimeOuts().getMOASessionCreated().longValue() * 1000; + long maxSSOSessionTime = AuthConfigurationProviderFactory.getInstance().getSSOCreatedTimeOut() * 1000; Date ssoSessionValidTo = new Date(session.getSessionCreated().getTime() + maxSSOSessionTime); authData.setSsoSessionValidTo(ssoSessionValidTo); diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/config/auth/AuthConfiguration.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/config/auth/AuthConfiguration.java index 7228e6129..b93312f78 100644 --- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/config/auth/AuthConfiguration.java +++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/config/auth/AuthConfiguration.java @@ -19,11 +19,21 @@ public interface AuthConfiguration extends ConfigurationProvider{ public Properties getGeneralOAuth20ProperiesConfig(); public ProtocolAllowed getAllowedProtocols(); - + + @Deprecated public PVP2 getGeneralPVP2DBConfig(); + public Properties getConfigurationWithPrefix(final String Prefix); + + public String getConfigurationWithKey(final String key); + + @Deprecated public TimeOuts getTimeOuts() throws ConfigurationException; + public int getTransactionTimeOut(); + public int getSSOCreatedTimeOut(); + public int getSSOUpdatedTimeOut(); + public String getAlternativeSourceID() throws ConfigurationException; public List<String> getLegacyAllowedProtocols(); 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 dfb2a4dfd..7ebde05df 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 @@ -1199,5 +1199,23 @@ private void setCertStoreDirectory() throws ConfigurationException { } return moasp; } + +/* (non-Javadoc) + * @see at.gv.egovernment.moa.id.config.auth.AuthConfiguration#getConfigurationWithPrefix(java.lang.String) + */ +@Override +public Properties getConfigurationWithPrefix(String Prefix) { + // TODO Auto-generated method stub + return null; +} + +/* (non-Javadoc) + * @see at.gv.egovernment.moa.id.config.auth.AuthConfiguration#getConfigurationWithKey(java.lang.String) + */ +@Override +public String getConfigurationWithKey(String key) { + // TODO Auto-generated method stub + return null; +} } diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/config/auth/PropertyBasedAuthConfigurationProvider.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/config/auth/PropertyBasedAuthConfigurationProvider.java index 94fbe46c4..378dafa23 100644 --- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/config/auth/PropertyBasedAuthConfigurationProvider.java +++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/config/auth/PropertyBasedAuthConfigurationProvider.java @@ -140,6 +140,27 @@ public class PropertyBasedAuthConfigurationProvider extends ConfigurationProvide } } + /* (non-Javadoc) + * @see at.gv.egovernment.moa.id.config.auth.AuthConfiguration#getPropertiesWithPrefix(java.lang.String) + */ + @Override + public Properties getConfigurationWithPrefix(String Prefix) { + return configuration.getPropertySubset(Prefix); + } + + /* (non-Javadoc) + * @see at.gv.egovernment.moa.id.config.auth.AuthConfiguration#getPropertyWithKey(java.lang.String) + */ + @Override + public String getConfigurationWithKey(String key) { + try { + return configuration.getStringValue(key); + + } catch (at.gv.egiz.components.configuration.api.ConfigurationException e) { + return null; + } + } + /** * Returns the general pvp2 properties config. NOTE: may be empty but never {@code null}. * @return the general pvp2 properties config. @@ -162,91 +183,92 @@ public class PropertyBasedAuthConfigurationProvider extends ConfigurationProvide * @return the allowed protocols or {@code null}. */ public ProtocolAllowed getAllowedProtocols() { - - AuthComponentGeneral authComponentGeneral; try { - authComponentGeneral = getAuthComponentGeneral(); - } catch (ConfigurationException e) { - return null; - } - Protocols protocols = authComponentGeneral.getProtocols(); - if (protocols != null) { ProtocolAllowed allowedProtcols = new ProtocolAllowed(); - if (protocols.getSAML1() != null) { - allowedProtcols.setSAML1Active(protocols.getSAML1().isIsActive()); - } - - if (protocols.getOAuth() != null) { - allowedProtcols.setOAUTHActive(protocols.getOAuth().isIsActive()); - } - - if (protocols.getPVP2() != null) { - allowedProtcols.setPVP21Active(protocols.getPVP2().isIsActive()); - } + + allowedProtcols.setOAUTHActive( + configuration.getBooleanValue(MOAIDConfigurationConstants.GENERAL_PROTOCOLS_OPENID_ENABLED, true)); + allowedProtcols.setSAML1Active( + configuration.getBooleanValue(MOAIDConfigurationConstants.GENERAL_PROTOCOLS_SAML1_ENABLED, false)); + allowedProtcols.setPVP21Active( + configuration.getBooleanValue(MOAIDConfigurationConstants.GENERAL_PROTOCOLS_PVP2X_ENABLED, true)); + return allowedProtcols; - } else { - Logger.warn("Error in MOA-ID Configuration. No general Protcol configuration found."); + + } catch (at.gv.egiz.components.configuration.api.ConfigurationException e) { + Logger.error("Can not load protocol enabled information from configuration.", e); return null; } + + } + /** * Returns the general PVP2 configuration. NOTE: may return {@code null}. * * @return the general PVP2 configuration or {@code null}. + * + * @deprecated */ public PVP2 getGeneralPVP2DBConfig() { + return null; + } - AuthComponentGeneral authComponentGeneral; + + /* (non-Javadoc) + * @see at.gv.egovernment.moa.id.config.auth.AuthConfiguration#getTransactionTimeOut() + */ + @Override + public int getTransactionTimeOut() { try { - authComponentGeneral = getAuthComponentGeneral(); - } catch (ConfigurationException e) { - return null; + return configuration.getIntegerValue( + MOAIDConfigurationConstants.GENERAL_AUTH_TIMEOUTS_TRANSACTION, 300); + + } catch (at.gv.egiz.components.configuration.api.ConfigurationException e) { + Logger.warn("No transaction timeout defined. Use default values", e); + return 300; } - Protocols protocols = authComponentGeneral.getProtocols(); - PVP2 result = null; - if (protocols != null) { - PVP2 pvp2 = protocols.getPVP2(); - if (pvp2 != null) { - result = new PVP2(); - result.setIssuerName(pvp2.getIssuerName()); - result.setPublicURLPrefix(pvp2.getPublicURLPrefix()); - - if (pvp2.getOrganization() != null) { - Organization org = new Organization(); - result.setOrganization(org); - org.setDisplayName(pvp2.getOrganization().getDisplayName()); - org.setName(pvp2.getOrganization().getName()); - org.setURL(pvp2.getOrganization().getURL()); - } - - if (pvp2.getContact() != null) { - List<Contact> cont = new ArrayList<Contact>(); - result.setContact(cont); - for (Contact e : pvp2.getContact()) { - Contact c = new Contact(); - c.setCompany(e.getCompany()); - c.setGivenName(e.getGivenName()); - c.getMail().addAll(e.getMail()); - c.getPhone().addAll(e.getPhone()); - c.setSurName(e.getSurName()); - c.setType(e.getType()); - cont.add(c); - } - } - } + } - } else { - Logger.warn("Error in MOA-ID Configuration. No general Protcol configuration found."); + /* (non-Javadoc) + * @see at.gv.egovernment.moa.id.config.auth.AuthConfiguration#getSSOCreatedTimeOut() + */ + @Override + public int getSSOCreatedTimeOut() { + try { + return configuration.getIntegerValue( + MOAIDConfigurationConstants.GENERAL_AUTH_TIMEOUS_SSO_CREATE, 2700); + + } catch (at.gv.egiz.components.configuration.api.ConfigurationException e) { + Logger.warn("No SSO created timeout defined. Use default values", e); + return 2700; } - return result; } + /* (non-Javadoc) + * @see at.gv.egovernment.moa.id.config.auth.AuthConfiguration#getSSOUpdatedTimeOut() + */ + @Override + public int getSSOUpdatedTimeOut() { + try { + return configuration.getIntegerValue( + MOAIDConfigurationConstants.GENERAL_AUTH_TIMEOUS_SSO_UPDATE, 1200); + + } catch (at.gv.egiz.components.configuration.api.ConfigurationException e) { + Logger.warn("No SSO updated timeout defined. Use default values", e); + return 1200; + } + } + + /** * Returns the configured timeouts, or a default timeout. * * @return the configured timeout, or the default (never {@code null}). * @throws ConfigurationException is thrown in case of missing {@link AuthComponentGeneral}. + * + * @deprecated */ public TimeOuts getTimeOuts() throws ConfigurationException { @@ -257,27 +279,27 @@ public class PropertyBasedAuthConfigurationProvider extends ConfigurationProvide timeouts.setMOASessionCreated(new BigInteger("2700")); timeouts.setMOASessionUpdated(new BigInteger("1200")); - AuthComponentGeneral authComponentGeneral = getAuthComponentGeneral(); - // search timeouts in config - GeneralConfiguration generalConfiguration = authComponentGeneral.getGeneralConfiguration(); - if (generalConfiguration != null) { - if (generalConfiguration.getTimeOuts() != null) { - if (generalConfiguration.getTimeOuts().getAssertion() != null) { - timeouts.setAssertion(generalConfiguration.getTimeOuts().getAssertion()); - } - - if (generalConfiguration.getTimeOuts().getMOASessionCreated() != null) { - timeouts.setMOASessionCreated(generalConfiguration.getTimeOuts().getMOASessionCreated()); - } - - if (generalConfiguration.getTimeOuts().getMOASessionUpdated() != null) { - timeouts.setMOASessionUpdated(generalConfiguration.getTimeOuts().getMOASessionUpdated()); - } - - } else { - Logger.info("No TimeOuts defined. Use default values"); - } - } +// AuthComponentGeneral authComponentGeneral = getAuthComponentGeneral(); +// // search timeouts in config +// GeneralConfiguration generalConfiguration = authComponentGeneral.getGeneralConfiguration(); +// if (generalConfiguration != null) { +// if (generalConfiguration.getTimeOuts() != null) { +// if (generalConfiguration.getTimeOuts().getAssertion() != null) { +// timeouts.setAssertion(generalConfiguration.getTimeOuts().getAssertion()); +// } +// +// if (generalConfiguration.getTimeOuts().getMOASessionCreated() != null) { +// timeouts.setMOASessionCreated(generalConfiguration.getTimeOuts().getMOASessionCreated()); +// } +// +// if (generalConfiguration.getTimeOuts().getMOASessionUpdated() != null) { +// timeouts.setMOASessionUpdated(generalConfiguration.getTimeOuts().getMOASessionUpdated()); +// } +// +// } else { +// Logger.info("No TimeOuts defined. Use default values"); +// } +// } return timeouts; } @@ -288,20 +310,13 @@ public class PropertyBasedAuthConfigurationProvider extends ConfigurationProvide * @throws ConfigurationException is thrown in case of missing {@link AuthComponentGeneral} */ public String getAlternativeSourceID() throws ConfigurationException { - AuthComponentGeneral authComponentGeneral = getAuthComponentGeneral(); - String alternativeSourceId = null; - Protocols protocols = authComponentGeneral.getProtocols(); - if (protocols != null) { - SAML1 saml1 = protocols.getSAML1(); - if (saml1 != null && MiscUtil.isNotEmpty(saml1.getSourceID())) { - alternativeSourceId = saml1.getSourceID(); - } - } - GeneralConfiguration generalConfiguration = authComponentGeneral.getGeneralConfiguration(); - if (generalConfiguration != null && MiscUtil.isEmpty(alternativeSourceId)) { - alternativeSourceId = generalConfiguration.getAlternativeSourceID(); + try { + return configuration.getStringValue(MOAIDConfigurationConstants.GENERAL_PROTOCOLS_SAML1_SOURCEID); + + } catch (at.gv.egiz.components.configuration.api.ConfigurationException e) { + Logger.warn("SAML1 SourceID can not be read from configuration.", e); + return null; } - return alternativeSourceId; } /** diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/moduls/SSOManager.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/moduls/SSOManager.java index 621426ff1..5fc1f3c4d 100644 --- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/moduls/SSOManager.java +++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/moduls/SSOManager.java @@ -25,10 +25,8 @@ package at.gv.egovernment.moa.id.moduls; import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; -import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; -import java.io.Reader; import java.io.StringWriter; import java.net.URI; import java.util.Date; @@ -38,15 +36,12 @@ import javax.servlet.http.Cookie; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import org.apache.velocity.Template; import org.apache.velocity.VelocityContext; -import org.apache.velocity.app.Velocity; import org.apache.velocity.app.VelocityEngine; import org.hibernate.Query; import org.hibernate.Session; import at.gv.egovernment.moa.id.auth.MOAIDAuthConstants; -import at.gv.egovernment.moa.id.auth.data.AuthenticationSession; import at.gv.egovernment.moa.id.auth.exception.MOAIDException; import at.gv.egovernment.moa.id.commons.db.MOASessionDBUtils; import at.gv.egovernment.moa.id.commons.db.dao.session.AuthenticatedSessionStore; @@ -54,7 +49,6 @@ import at.gv.egovernment.moa.id.commons.db.dao.session.InterfederationSessionSto import at.gv.egovernment.moa.id.commons.db.dao.session.OldSSOSessionIDStore; import at.gv.egovernment.moa.id.config.ConfigurationException; import at.gv.egovernment.moa.id.config.auth.AuthConfigurationProviderFactory; -import at.gv.egovernment.moa.id.config.auth.OAAuthParameter; import at.gv.egovernment.moa.id.storage.AuthenticationSessionStoreage; import at.gv.egovernment.moa.id.util.Random; import at.gv.egovernment.moa.id.util.VelocityProvider; @@ -74,21 +68,11 @@ public class SSOManager { private static final int INTERFEDERATIONCOOKIEMAXAGE = 5 * 60;// sec private static SSOManager instance = null; - private static int sso_timeout; public static SSOManager getInstance() { if (instance == null) { instance = new SSOManager(); - - try { - sso_timeout = (int) AuthConfigurationProviderFactory.getInstance().getTimeOuts().getMOASessionUpdated().longValue(); - - } - catch (ConfigurationException e) { - Logger.info("SSO Timeout can not be loaded from MOA-ID configuration. Use default Timeout with " + DEFAULTSSOTIMEOUT); - sso_timeout = DEFAULTSSOTIMEOUT; - } - + } return instance; @@ -151,7 +135,7 @@ public class SSOManager { //check if session is out of lifetime Date now = new Date(); - long maxSSOSessionTime = AuthConfigurationProviderFactory.getInstance().getTimeOuts().getMOASessionCreated().longValue() * 1000; + long maxSSOSessionTime = AuthConfigurationProviderFactory.getInstance().getSSOCreatedTimeOut() * 1000; Date ssoSessionValidTo = new Date(storedSession.getCreated().getTime() + maxSSOSessionTime); if (now.after(ssoSessionValidTo)) { Logger.info("Found outdated SSO session information. Start reauthentication process ... "); @@ -249,7 +233,15 @@ public class SSOManager { } public void setSSOSessionID(HttpServletRequest httpReq, HttpServletResponse httpResp, String ssoId) { - setCookie(httpReq, httpResp, SSOCOOKIE, ssoId, sso_timeout); + int ssoTimeOut; + try { + ssoTimeOut = (int) AuthConfigurationProviderFactory.getInstance().getSSOCreatedTimeOut(); + + } catch (ConfigurationException e) { + Logger.info("SSO Timeout can not be loaded from MOA-ID configuration. Use default Timeout with " + DEFAULTSSOTIMEOUT); + ssoTimeOut = DEFAULTSSOTIMEOUT; + } + setCookie(httpReq, httpResp, SSOCOOKIE, ssoId, ssoTimeOut); } 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 d6f6308fd..5c473f32d 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 @@ -24,7 +24,6 @@ package at.gv.egovernment.moa.id.protocols.pvp2x.config; import iaik.x509.X509Certificate; -import java.io.File; import java.net.URL; import java.security.cert.CertificateException; import java.util.ArrayList; @@ -46,7 +45,7 @@ import org.opensaml.saml2.metadata.OrganizationURL; import org.opensaml.saml2.metadata.SurName; import org.opensaml.saml2.metadata.TelephoneNumber; -import at.gv.egovernment.moa.id.commons.db.dao.config.Contact; +import at.gv.egovernment.moa.id.commons.config.MOAIDConfigurationConstants; import at.gv.egovernment.moa.id.commons.db.dao.config.OAPVP2; import at.gv.egovernment.moa.id.config.ConfigurationException; import at.gv.egovernment.moa.id.config.auth.AuthConfigurationProviderFactory; @@ -92,31 +91,19 @@ public class PVPConfiguration { public static final String IDP_KEYALIASENCRYTPION = "sp.ks.assertion.encryption.alias"; public static final String IDP_KEY_PASSENCRYTPION = "sp.ks.assertion.encryption.keypassword"; - public static final String IDP_ISSUER_NAME = "idp.issuer.name"; - - public static final String METADATA_FILE = "md.dir"; - public static final String METADATA_EXTENSION = "md.ext"; - - public static final String IDP_ENTITY = "idp.entityid"; - public static final String IDP_ORG_NAME = "idp.org.name"; - public static final String IDP_ORG_DISPNAME = "idp.org.dispname"; - public static final String IDP_ORG_URL = "idp.org.url"; - - public static final String IDP_PUBLIC_URL = "idp.public.url"; - - public static final String IDP_TRUST_STORE = "idp.truststore"; - public static final String SP_TARGET_PREFIX = "sp.target."; - - public static final String IDP_CONTACT_PREFIX = "idp.contact"; - public static final String IDP_CONTACT_LIST = "idp.contact_list"; - - public static final String IDP_CONTACT_SURNAME = "surname"; - public static final String IDP_CONTACT_GIVENNAME = "givenname"; - public static final String IDP_CONTACT_MAIL = "mail"; - public static final String IDP_CONTACT_TYPE = "type"; - public static final String IDP_CONTACT_COMPANY = "company"; - public static final String IDP_CONTACT_PHONE = "phone"; - + public static final String IDP_ISSUER_NAME = "servicename"; + + public static final String IDP_ORG_NAME = "org.name.short"; + public static final String IDP_ORG_DISPNAME = "org.name.full"; + public static final String IDP_ORG_URL = "org.url"; + + public static final String IDP_CONTACT_SURNAME = "contact.familyname"; + public static final String IDP_CONTACT_GIVENNAME = "contact.givenname"; + public static final String IDP_CONTACT_MAIL = "contact.mail"; + public static final String IDP_CONTACT_TYPE = "contact.type"; + public static final String IDP_CONTACT_COMPANY = "contact.company"; + public static final String IDP_CONTACT_PHONE = "contact.phone"; + private static String moaIDVersion = null; //PVP2 generalpvpconfigdb; @@ -211,28 +198,8 @@ public class PVPConfiguration { moaIDVersion = parseMOAIDVersionFromManifest(); } - return AuthConfigurationProviderFactory.getInstance().getGeneralPVP2DBConfig().getIssuerName() + moaIDVersion; - } - - public List<String> getMetadataFiles() { - String filter = props.getProperty(METADATA_EXTENSION); - - if (filter == null) { - filter = ".mdxml"; - } - - List<String> files = new ArrayList<String>(); - - File[] faFiles = new File(props.getProperty(METADATA_FILE)).listFiles(); - for (File file : faFiles) { - if (!file.isDirectory()) { - if (file.getName().endsWith(filter)) { - files.add(file.getAbsolutePath()); - } - } - } - - return files; + return AuthConfigurationProviderFactory.getInstance().getConfigurationWithKey( + MOAIDConfigurationConstants.GENERAL_PROTOCOLS_PVP2X_METADATA_SERVICENAMME) + moaIDVersion; } //TODO: @@ -287,112 +254,100 @@ public class PVPConfiguration { public List<ContactPerson> getIDPContacts() throws ConfigurationException { List<ContactPerson> list = new ArrayList<ContactPerson>(); - List<Contact> contacts = AuthConfigurationProviderFactory.getInstance().getGeneralPVP2DBConfig().getContact(); + Properties contacts = AuthConfigurationProviderFactory.getInstance().getConfigurationWithPrefix( + MOAIDConfigurationConstants.GENERAL_PROTOCOLS_PVP2X_METADATA_CONTACT + "."); - if (contacts != null) { + ContactPerson person = SAML2Utils + .createSAMLObject(ContactPerson.class); + + String type = contacts.getProperty(IDP_CONTACT_TYPE); + + if (type == null) { + Logger.error("IDP Contact with SurName " + contacts.getProperty(IDP_CONTACT_SURNAME) + + " has no type defined!"); + } + + ContactPersonTypeEnumeration enumType = null; + + if (type.equals(ContactPersonTypeEnumeration.ADMINISTRATIVE + .toString())) { + enumType = ContactPersonTypeEnumeration.ADMINISTRATIVE; + } else if (type.equals(ContactPersonTypeEnumeration.BILLING + .toString())) { + enumType = ContactPersonTypeEnumeration.BILLING; + } else if (type.equals(ContactPersonTypeEnumeration.OTHER + .toString())) { + enumType = ContactPersonTypeEnumeration.OTHER; + } else if (type.equals(ContactPersonTypeEnumeration.SUPPORT + .toString())) { + enumType = ContactPersonTypeEnumeration.SUPPORT; + } else if (type.equals(ContactPersonTypeEnumeration.TECHNICAL + .toString())) { + enumType = ContactPersonTypeEnumeration.TECHNICAL; + } + + if (enumType == null) { + Logger.error("IDP Contact with SurName " + contacts.getProperty(IDP_CONTACT_SURNAME) + + " has invalid type defined: " + type); + } + + person.setType(enumType); + + String givenName = contacts.getProperty(IDP_CONTACT_GIVENNAME); + + if (givenName != null) { + GivenName name = SAML2Utils + .createSAMLObject(GivenName.class); + name.setName(givenName); + person.setGivenName(name); + } + + String company = contacts.getProperty(IDP_CONTACT_COMPANY); + + if (company != null) { + Company comp = SAML2Utils.createSAMLObject(Company.class); + comp.setName(company); + person.setCompany(comp); + } + + String surname = contacts.getProperty(IDP_CONTACT_SURNAME); + + if (surname != null) { + SurName name = SAML2Utils.createSAMLObject(SurName.class); + name.setName(surname); + person.setSurName(name); + } + + String phone = contacts.getProperty(IDP_CONTACT_PHONE); + if (phone != null) { + TelephoneNumber telePhone = SAML2Utils + .createSAMLObject(TelephoneNumber.class); + telePhone.setNumber(phone); + person.getTelephoneNumbers().add(telePhone); + } - for (Contact contact : contacts) { - - ContactPerson person = SAML2Utils - .createSAMLObject(ContactPerson.class); - - String type = contact.getType(); - - if (type == null) { - Logger.error("IDP Contact with SurName " + contact.getSurName() - + " has no type defined!"); - break; - } - - ContactPersonTypeEnumeration enumType = null; - - if (type.equals(ContactPersonTypeEnumeration.ADMINISTRATIVE - .toString())) { - enumType = ContactPersonTypeEnumeration.ADMINISTRATIVE; - } else if (type.equals(ContactPersonTypeEnumeration.BILLING - .toString())) { - enumType = ContactPersonTypeEnumeration.BILLING; - } else if (type.equals(ContactPersonTypeEnumeration.OTHER - .toString())) { - enumType = ContactPersonTypeEnumeration.OTHER; - } else if (type.equals(ContactPersonTypeEnumeration.SUPPORT - .toString())) { - enumType = ContactPersonTypeEnumeration.SUPPORT; - } else if (type.equals(ContactPersonTypeEnumeration.TECHNICAL - .toString())) { - enumType = ContactPersonTypeEnumeration.TECHNICAL; - } - - if (enumType == null) { - Logger.error("IDP Contact with SurName " + contact.getSurName() - + " has invalid type defined: " + type); - break; - } - - person.setType(enumType); - - String givenName = contact.getGivenName(); - - if (givenName != null) { - GivenName name = SAML2Utils - .createSAMLObject(GivenName.class); - name.setName(givenName); - person.setGivenName(name); - } - - String company = contact.getCompany(); - - if (company != null) { - Company comp = SAML2Utils.createSAMLObject(Company.class); - comp.setName(company); - person.setCompany(comp); - } - - String surname = contact.getSurName(); - - if (surname != null) { - SurName name = SAML2Utils.createSAMLObject(SurName.class); - name.setName(surname); - person.setSurName(name); - } - - List<String> phones = contact.getPhone(); - for (String phone : phones) { - TelephoneNumber telePhone = SAML2Utils - .createSAMLObject(TelephoneNumber.class); - telePhone.setNumber(phone); - person.getTelephoneNumbers().add(telePhone); - } - - List<String> mails = contact.getMail(); - for (String mail : mails) { - EmailAddress mailAddress = SAML2Utils - .createSAMLObject(EmailAddress.class); - mailAddress.setAddress(mail); - person.getEmailAddresses().add(mailAddress); - } - - list.add(person); - } + String mail = contacts.getProperty(IDP_CONTACT_MAIL); + if (mail != null) { + EmailAddress mailAddress = SAML2Utils + .createSAMLObject(EmailAddress.class); + mailAddress.setAddress(mail); + person.getEmailAddresses().add(mailAddress); } + + list.add(person); return list; } public Organization getIDPOrganisation() throws ConfigurationException { Organization org = SAML2Utils.createSAMLObject(Organization.class); - at.gv.egovernment.moa.id.commons.db.dao.config.Organization organisation = AuthConfigurationProviderFactory.getInstance().getGeneralPVP2DBConfig().getOrganization(); - - String org_name = null; - String org_dispname = null; - String org_url = null; - - if (organisation != null) { - org_name = organisation.getName(); - org_dispname = organisation.getDisplayName(); - org_url = organisation.getURL(); - } + Properties organisation = AuthConfigurationProviderFactory.getInstance().getConfigurationWithPrefix( + MOAIDConfigurationConstants.GENERAL_PROTOCOLS_PVP2X_METADATA_ORG + "."); + String org_name = organisation.getProperty(IDP_ORG_NAME); + String org_dispname = organisation.getProperty(IDP_ORG_DISPNAME); + String org_url = organisation.getProperty(IDP_ORG_URL); + if (org_name == null || org_dispname == null || org_url == null) { return null; } |