diff options
Diffstat (limited to 'id/server/moa-id-commons/src/main/java/at/gv')
4 files changed, 71 insertions, 18 deletions
diff --git a/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/config/MOAIDConfigurationConstants.java b/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/config/MOAIDConfigurationConstants.java index 71c95c1e6..6799fcb13 100644 --- a/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/config/MOAIDConfigurationConstants.java +++ b/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/config/MOAIDConfigurationConstants.java @@ -206,13 +206,13 @@ public final class MOAIDConfigurationConstants { public static final String GENERAL_AUTH_AUTHBLOCK_TRANSFORMATION_BASE64 = GENERAL_AUTH + ".authblock.transformation.base64"; public static final String GENERAL_AUTH_STORK = GENERAL_AUTH + "." + STORK; - public static final String GENERAL_AUTH_STORK_QAA = GENERAL_AUTH + "." + STORK + ".qaa"; - public static final String GENERAL_AUTH_STORK_CPEPS_LIST = GENERAL_AUTH + "." + STORK + ".cpeps"; + public static final String GENERAL_AUTH_STORK_QAA = GENERAL_AUTH_STORK + ".qaa"; + public static final String GENERAL_AUTH_STORK_CPEPS_LIST = GENERAL_AUTH_STORK + ".cpeps"; public static final String GENERAL_AUTH_STORK_CPEPS_LIST_COUNTRY = "countrycode"; public static final String GENERAL_AUTH_STORK_CPEPS_LIST_URL = "url"; public static final String GENERAL_AUTH_STORK_CPEPS_LIST_SUPPORT_XMLDSIG = "support.xmldsig"; - public static final String GENERAL_AUTH_STORK_ATTRIBUTES_LIST = GENERAL_AUTH + "." + STORK + ".attributes"; + public static final String GENERAL_AUTH_STORK_ATTRIBUTES_LIST = GENERAL_AUTH_STORK + ".attributes"; public static final String GENERAL_AUTH_STORK_ATTRIBUTES_LIST_NAME = "friendlyname"; public static final String GENERAL_AUTH_STORK_ATTRIBUTES_LIST_MANDATORY = "mandatory"; diff --git a/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/config/persistence/MOAIDConfiguration.java b/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/config/persistence/MOAIDConfiguration.java index 026a907d7..159b587df 100644 --- a/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/config/persistence/MOAIDConfiguration.java +++ b/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/config/persistence/MOAIDConfiguration.java @@ -3,6 +3,7 @@ package at.gv.egovernment.moa.id.commons.config.persistence; import java.util.Properties; import at.gv.egiz.components.configuration.api.Configuration; +import at.gv.egiz.components.configuration.api.ConfigurationException; /** * An interface for a key-value configuration. @@ -15,8 +16,18 @@ public interface MOAIDConfiguration extends Configuration { * @param preFix A key prefix * @return All key/value pairs with this prefix. The prefix is removed from the key. * + **/ + public Properties getPropertySubset(String preFix) throws ConfigurationException; + + + /** + * Load an OnlineApplication configuration and remove the OA key prefix + * + * @param publicURLPrefix: Unique identifier of online application + * @return Properties of the online application or null if no OA is found + * @throws ConfigurationException in case of an configuration access error */ - Properties getPropertySubset(final String preFix); + public Properties getOnlineApplication(String publicURLPrefix) throws ConfigurationException; // /** diff --git a/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/config/persistence/MOAIDConfigurationImpl.java b/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/config/persistence/MOAIDConfigurationImpl.java index 442ff6247..2d652d748 100644 --- a/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/config/persistence/MOAIDConfigurationImpl.java +++ b/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/config/persistence/MOAIDConfigurationImpl.java @@ -1,28 +1,28 @@ package at.gv.egovernment.moa.id.commons.config.persistence; -import java.util.Arrays; import java.util.List; import java.util.Properties; -import javax.persistence.EntityExistsException; +import javax.persistence.EntityManager; +import javax.persistence.TypedQuery; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Required; import org.springframework.stereotype.Component; import at.gv.egiz.components.configuration.api.Configuration; +import at.gv.egiz.components.configuration.api.ConfigurationException; +import at.gv.egovernment.moa.id.commons.config.MOAIDConfigurationConstants; +import at.gv.egovernment.moa.id.commons.db.dao.config.ConfigProperty; import at.gv.egovernment.moa.id.commons.db.dao.config.ConfigPropertyDaoImpl; +import at.gv.egovernment.moa.logging.Logger; /** * The implementation of a key-value configuration implementing the {@link Configuration} interface. * It employs the {@link ConfigPropertyDao} to persist configuration data. */ @Component -public class MOAIDConfigurationImpl extends ConfigPropertyDaoImpl implements MOAIDConfiguration { - - private final Logger log = LoggerFactory.getLogger(getClass()); - +public class MOAIDConfigurationImpl extends ConfigPropertyDaoImpl implements MOAIDConfiguration { + Configuration configPropertyDao; // private JsonMapper mapper = new JsonMapper(); @@ -39,13 +39,47 @@ public class MOAIDConfigurationImpl extends ConfigPropertyDaoImpl implements MOA /* (non-Javadoc) * @see at.gv.egovernment.moa.id.commons.config.persistence.MOAIDConfiguration#getPropertySubset(java.lang.String) */ - @Override - public Properties getPropertySubset(String preFix) { + public Properties getPropertySubset(String preFix) throws ConfigurationException{ // TODO Auto-generated method stub return null; } - + @Override + public Properties getOnlineApplication(String publicURLPrefix) + throws ConfigurationException { + EntityManager em = this.getPersistenceContext(); + if (null == em) { + Logger.error("No EntityManager set!"); + throw new ConfigurationException("No EntityManager set!"); + + } + + String keyId = MOAIDConfigurationConstants.PREFIX_MOAID_SERVICES + + ".%." + + MOAIDConfigurationConstants.SERVICE_UNIQUEIDENTIFIER; + TypedQuery<ConfigProperty> query = em.createQuery("select * from ConfigProperty dbconfig where dbconfig.key like :key and dbconfig.value = SUBSTRING(:uniqueID, 1, LENGTH(dbconfig.value))", ConfigProperty.class); + query.setParameter("key", keyId); + query.setParameter("uniqueID", publicURLPrefix); + List<ConfigProperty> result = query.getResultList(); + + if (result.size() == 0) { + Logger.debug("No entries found."); + return null; + } + + if (result.size() > 1) { + Logger.warn("OAIdentifier match to more then one DB-entry!"); + return null; + } + + String oaKey = result.get(0).getKey(); + String oaValue = result.get(0).getValue(); + Logger.trace("Find online application with uniqueID: " + oaValue + " and keyID: " + oaKey); + + + + return null; + } /** * Small helper method. NOTE: may return empty properties, but never {@code null}. * @param propPrefix the prefix of the desired property. diff --git a/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/dao/config/ConfigPropertyDaoImpl.java b/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/dao/config/ConfigPropertyDaoImpl.java index 24195b0cf..eaeb4e7f7 100644 --- a/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/dao/config/ConfigPropertyDaoImpl.java +++ b/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/dao/config/ConfigPropertyDaoImpl.java @@ -26,7 +26,14 @@ public class ConfigPropertyDaoImpl extends AbstractConfigurationImpl { @PersistenceContext(unitName = "moaidconf") private EntityManager em; - + /** + * + * @return EntityManager for database access + */ + protected EntityManager getPersistenceContext() { + return em; + } + @Override protected List<String> getAllKeys() { if (null == em) { @@ -103,7 +110,7 @@ public class ConfigPropertyDaoImpl extends AbstractConfigurationImpl { return null; } - TypedQuery<String> query = em.createQuery("select * from ConfigProperty dbconfig where dbconfig.key like :key", String.class); + TypedQuery<String> query = em.createQuery("select key from ConfigProperty dbconfig where dbconfig.key like :key", String.class); query.setParameter("key", searchString.replace("*", "%")); List<String> result = query.getResultList(); return result.toArray(new String[result.size()]); @@ -120,7 +127,7 @@ public class ConfigPropertyDaoImpl extends AbstractConfigurationImpl { return null; } - TypedQuery<String> query = em.createQuery("select * from ConfigProperty dbconfig where dbconfig.value like :value", String.class); + TypedQuery<String> query = em.createQuery("select key from ConfigProperty dbconfig where dbconfig.value like :value", String.class); query.setParameter("value", searchString.replace("*", "%")); List<String> result = query.getResultList(); return result.toArray(new String[result.size()]); @@ -156,6 +163,7 @@ public class ConfigPropertyDaoImpl extends AbstractConfigurationImpl { } + // @Override // public String getPropertyValue(String key) { // ConfigProperty property = getProperty(key); |