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/at/gv/egovernment/moa/id/config | |
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/at/gv/egovernment/moa/id/config')
3 files changed, 138 insertions, 95 deletions
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; } /** |