aboutsummaryrefslogtreecommitdiff
path: root/id/server/moa-id-commons/src
diff options
context:
space:
mode:
authorThomas Lenz <tlenz@iaik.tugraz.at>2015-06-19 10:59:09 +0200
committerThomas Lenz <tlenz@iaik.tugraz.at>2015-06-19 11:10:50 +0200
commitc276e33e5ebdebc1c727dbd93ea1f876588a0dec (patch)
tree421ad087eefdea0848848012f4dce5efd7c93dce /id/server/moa-id-commons/src
parent8ec83e5be6888c9e5aeb8d21a35eb4d7ec040f67 (diff)
downloadmoa-id-spss-c276e33e5ebdebc1c727dbd93ea1f876588a0dec.tar.gz
moa-id-spss-c276e33e5ebdebc1c727dbd93ea1f876588a0dec.tar.bz2
moa-id-spss-c276e33e5ebdebc1c727dbd93ea1f876588a0dec.zip
refactor MOA-ID AuthConfiguration
Diffstat (limited to 'id/server/moa-id-commons/src')
-rw-r--r--id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/config/ConfigurationUtil.java1
-rw-r--r--id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/config/MOAIDConfigurationConstants.java246
-rw-r--r--id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/config/persistence/ConfigurationImpl.java161
-rw-r--r--id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/config/persistence/MOAIDConfiguration.java (renamed from id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/config/persistence/Configuration.java)50
-rw-r--r--id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/config/persistence/MOAIDConfigurationImpl.java136
-rw-r--r--id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/ConfigurationFromDBExtractor.java1
-rw-r--r--id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/MOAIDConfigurationConstants.java44
-rw-r--r--id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/NewConfigurationDBRead.java12
-rw-r--r--id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/NewConfigurationDBWrite.java11
-rw-r--r--id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/dao/config/ConfigPropertyDao.java58
-rw-r--r--id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/dao/config/ConfigPropertyDaoImpl.java169
-rw-r--r--id/server/moa-id-commons/src/test/java/at/gv/egovernment/moa/id/commons/db/ConfigurationDBReadTest.java13
12 files changed, 553 insertions, 349 deletions
diff --git a/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/config/ConfigurationUtil.java b/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/config/ConfigurationUtil.java
index d8fde7eee..e794951d7 100644
--- a/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/config/ConfigurationUtil.java
+++ b/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/config/ConfigurationUtil.java
@@ -18,7 +18,6 @@ import org.springframework.context.support.ClassPathXmlApplicationContext;
import at.gv.egovernment.moa.id.commons.config.persistence.Configuration;
import at.gv.egovernment.moa.id.commons.config.persistence.JsonMapper;
-import at.gv.egovernment.moa.id.commons.db.MOAIDConfigurationConstants;
import at.gv.egovernment.moa.id.commons.db.dao.config.MOAIDConfiguration;
import com.fasterxml.jackson.core.JsonProcessingException;
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
new file mode 100644
index 000000000..6217c6c68
--- /dev/null
+++ b/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/config/MOAIDConfigurationConstants.java
@@ -0,0 +1,246 @@
+package at.gv.egovernment.moa.id.commons.config;
+
+/**
+ *
+ *
+ */
+public final class MOAIDConfigurationConstants {
+
+ private MOAIDConfigurationConstants() {
+ // restrict instantiation
+ }
+
+ //Basic key namespaces
+ public static final String PREFIX_MOAID = "moa.id";
+ public static final String PREFIX_GENERAL = "general";
+ public static final String PREFIX_SERVICES = "services";
+ public static final String PREFIX_OA = "oa";
+ public static final String PREFIX_VIDP = "vidp";
+ public static final String PREFIX_IIDP = "iidp";
+ public static final String PREFIX_GATEWAY = "gateway";
+
+ public static final String PREFIX_MOAID_GENERAL = PREFIX_MOAID + "." + PREFIX_GENERAL;
+ public static final String PREFIX_MOAID_SERVICES = PREFIX_MOAID + "." + PREFIX_SERVICES;
+ public static final String PREFIX_MOAID_SERVICES_OA = PREFIX_MOAID_SERVICES + "." + PREFIX_OA;
+ public static final String PREFIX_MOAID_SERVICES_VIDP = PREFIX_MOAID_SERVICES + "." + PREFIX_VIDP;
+ public static final String PREFIX_MOAID_SERVICES_IIDP = PREFIX_MOAID_SERVICES + "." + PREFIX_IIDP;
+ public static final String PREFIX_MOAID_SERVICES_GATEWAY = PREFIX_MOAID_SERVICES + "." + PREFIX_GATEWAY;
+
+ //Namespaces for online applications
+ public static final String SERVICE_UNIQUEIDENTIFIER = "uniqueID"; //publicURLPrefix
+ public static final String SERVICE_FRIENDLYNAME = "friendlyName"; //friendlyName
+ public static final String SERVICE_TYPE = "type"; //type
+ public static final String SERVICE_ISACTIVE = "isActive"; //isActive
+
+ //service authentication keys
+ private static final String AUTH = "auth";
+ private static final String TARGET = "target";
+ private static final String BKU = "bku";
+ private static final String TESTCREDENTIALS = "testcredentials";
+ private static final String MANDATES = "mandates";
+ private static final String FOREIGNBPK = "foreignbPK";
+ private static final String SSO = "sso";
+ private static final String STORK = "stork";
+ private static final String TEMPLATES = "templates";
+ private static final String INTERFEDERATION = "interfederation";
+
+ private static final String PROTOCOLS = "protocols";
+ private static final String SAML1 = "saml1";
+ private static final String PVP2X = "pvp2x";
+ private static final String OPENID = "openID";
+
+ public static final String SERVICE_AUTH_TARGET = AUTH + "." + TARGET;
+ public static final String SERVICE_AUTH_TARGET_TYPE = SERVICE_AUTH_TARGET + ".type"; //targetFriendlyName or IdentificationType
+ public static final String SERVICE_AUTH_TARGET_VALUE = SERVICE_AUTH_TARGET + ".value"; //target or IdentificationValue
+
+ private static final String SERVICE_AUTH_BKU = AUTH + "." + BKU;
+ public static final String SERVICE_AUTH_BKU_ONLINE = SERVICE_AUTH_BKU + ".onlineBKU";
+ public static final String SERVICE_AUTH_BKU_LOCAL = SERVICE_AUTH_BKU + ".localBKU";
+ public static final String SERVICE_AUTH_BKU_HANDY = SERVICE_AUTH_BKU + ".handyBKU";
+ public static final String SERVICE_AUTH_BKU_KEYBOXIDENTIFIER = SERVICE_AUTH_BKU + ".keyBoxIdentifier";
+ public static final String SERVICE_AUTH_BKU_TEMPLATE_LIST = SERVICE_AUTH_BKU + ".template"; //SecurityLayer Templates
+ public static final String SERVICE_AUTH_BKU_TEMPLATE_LIST_VALUE = "url";
+ public static final String SERVICE_AUTH_BKU_AUTHBLOCKTEXT = SERVICE_AUTH_BKU + "authblock.additionaltext";
+ public static final String SERVICE_AUTH_BKU_AUTHBLOCK_REMOVEBPK = SERVICE_AUTH_BKU + "authblock.removebPK";
+
+ private static final String SERVICE_AUTH_TEMPLATES = AUTH + "." + TEMPLATES;
+ public static final String SERVICE_AUTH_TEMPLATES_BKUSELECTION = SERVICE_AUTH_TEMPLATES + ".bkuselection";
+ public static final String SERVICE_AUTH_TEMPLATES_SENDASSERTION = SERVICE_AUTH_TEMPLATES + ".sendAssertion";
+ private static final String SERVICE_AUTH_TEMPLATES_CUSTOMIZATION = SERVICE_AUTH_TEMPLATES + ".customize";
+ public static final String SERVICE_AUTH_TEMPLATES_CUSTOMIZATION_FONTTYPE = SERVICE_AUTH_TEMPLATES_CUSTOMIZATION + ".fonttype";
+ public static final String SERVICE_AUTH_TEMPLATES_CUSTOMIZATION_BACKGROUNDCOLOR = SERVICE_AUTH_TEMPLATES_CUSTOMIZATION + ".color.back";
+ public static final String SERVICE_AUTH_TEMPLATES_CUSTOMIZATION_FRONTCOLOR = SERVICE_AUTH_TEMPLATES_CUSTOMIZATION + ".color.front";
+ public static final String SERVICE_AUTH_TEMPLATES_CUSTOMIZATION_HEADERBACKGROUNDCOLOR = SERVICE_AUTH_TEMPLATES_CUSTOMIZATION + ".header.color.back";
+ public static final String SERVICE_AUTH_TEMPLATES_CUSTOMIZATION_HEADERFRONTCOLOR = SERVICE_AUTH_TEMPLATES_CUSTOMIZATION + ".header.color.front";
+ public static final String SERVICE_AUTH_TEMPLATES_CUSTOMIZATION_HEADERTEXT = SERVICE_AUTH_TEMPLATES_CUSTOMIZATION + ".header.text";
+ public static final String SERVICE_AUTH_TEMPLATES_CUSTOMIZATION_BUTTONBACKGROUNDCOLOR = SERVICE_AUTH_TEMPLATES_CUSTOMIZATION + ".button.color.back";
+ public static final String SERVICE_AUTH_TEMPLATES_CUSTOMIZATION_BUTTONBACLGROUNDCOLORFOCUS = SERVICE_AUTH_TEMPLATES_CUSTOMIZATION + ".button.color.back.focus";
+ public static final String SERVICE_AUTH_TEMPLATES_CUSTOMIZATION_BUTTONFRONTCOLOR = SERVICE_AUTH_TEMPLATES_CUSTOMIZATION + ".button.color.front";
+ public static final String SERVICE_AUTH_TEMPLATES_CUSTOMIZATION_APPLETREDIRECTTARGET = SERVICE_AUTH_TEMPLATES_CUSTOMIZATION + ".applet.redirecttarget";
+ public static final String SERVICE_AUTH_TEMPLATES_CUSTOMIZATION_APPLETHEIGHT = SERVICE_AUTH_TEMPLATES_CUSTOMIZATION + ".applet.hight";
+ public static final String SERVICE_AUTH_TEMPLATES_CUSTOMIZATION_APPLETWIDTH = SERVICE_AUTH_TEMPLATES_CUSTOMIZATION + ".applet.width";
+
+ private static final String SERVICE_AUTH_TESTCREDENTIALS = AUTH + "." + TESTCREDENTIALS;
+ public static final String SERVICE_AUTH_TESTCREDENTIALS_ENABLED = SERVICE_AUTH_TESTCREDENTIALS + ".enabled";
+ public static final String SERVICE_AUTH_TESTCREDENTIALS_OIDs = SERVICE_AUTH_TESTCREDENTIALS + ".oids";
+
+ private static final String SERVICE_AUTH_MANDATES = AUTH + "." + MANDATES;
+ public static final String SERVICE_AUTH_MANDATES_ONLY = SERVICE_AUTH_MANDATES + "only";
+ public static final String SERVICE_AUTH_MANDATES_PROFILES = SERVICE_AUTH_MANDATES + "profiles";
+
+ public static final String SERVICE_AUTH_FOREIGNBPK = AUTH + "." + FOREIGNBPK; //complex attribute
+
+ private static final String SERVICE_AUTH_SSO = AUTH + "." + SSO;
+ public static final String SERVICE_AUTH_SSO_ENABLED = SERVICE_AUTH_SSO + ".enabled";
+ public static final String SERVICE_AUTH_SSO_USERREQUEST = SERVICE_AUTH_SSO + ".userRequest";
+
+ private static final String SERVICE_AUTH_STORK = AUTH + "." + STORK;
+ public static final String SERVICE_AUTH_STORK_ENABLED = SERVICE_AUTH_STORK + ".enabled";
+ public static final String SERVICE_AUTH_STORK_COUNTRIES_LIST = SERVICE_AUTH_STORK + ".countries";
+ public static final String SERVICE_AUTH_STORK_COUNTRIES_LIST_ENABLED = "enabled";
+ public static final String SERVICE_AUTH_STORK_ATTRIBUTES_LIST = SERVICE_AUTH_STORK + ".attributes";
+ public static final String SERVICE_AUTH_STORK_ATTRIBUTES_LIST_NAME = "name";
+ public static final String SERVICE_AUTH_STORK_ATTRIBUTES_LIST_MANDATORY = "mandatory";
+ public static final String SERVICE_AUTH_STORK_REQUIRECONSENT = SERVICE_AUTH_STORK + ".requireConsent";
+ public static final String SERVICE_AUTH_STORK_ATTRIBUTPROVIDER_LIST = SERVICE_AUTH_STORK + ".attributeprovider";
+ public static final String SERVICE_AUTH_STORK_ATTRIBUTPROVIDER_LIST_NAME = "name";
+ public static final String SERVICE_AUTH_STORK_ATTRIBUTPROVIDER_LIST_URL = "url";
+ public static final String SERVICE_AUTH_STORK_ATTRIBUTPROVIDER_LIST_ATTRIBUTES = "attributes";
+
+ private static final String SERVICE_PROTOCOLS_SAML1 = PROTOCOLS + "." + SAML1;
+ public static final String SERVICE_PROTOCOLS_SAML1_ENABLED = SERVICE_PROTOCOLS_SAML1 + ".enabled";
+ public static final String SERVICE_PROTOCOLS_SAML1_IDL = SERVICE_PROTOCOLS_SAML1 + ".idl";
+ public static final String SERVICE_PROTOCOLS_SAML1_BASEID = SERVICE_PROTOCOLS_SAML1 + ".baseid";
+ public static final String SERVICE_PROTOCOLS_SAML1_AUTHBLOCK = SERVICE_PROTOCOLS_SAML1 + ".authblock";
+ public static final String SERVICE_PROTOCOLS_SAML1_CERTIFICATE = SERVICE_PROTOCOLS_SAML1 + ".certificate";
+ public static final String SERVICE_PROTOCOLS_SAML1_MANDATE = SERVICE_PROTOCOLS_SAML1 + ".mandate";
+ public static final String SERVICE_PROTOCOLS_SAML1_RETURNERROR = SERVICE_PROTOCOLS_SAML1 + ".returnError";
+
+ private static final String SERVICE_PROTOCOLS_PVP2X = PROTOCOLS + "." + PVP2X;
+ public static final String SERVICE_PROTOCOLS_PVP2X_RELOAD = SERVICE_PROTOCOLS_PVP2X + ".reload";
+ public static final String SERVICE_PROTOCOLS_PVP2X_URL = SERVICE_PROTOCOLS_PVP2X + ".URL";
+ public static final String SERVICE_PROTOCOLS_PVP2X_CERTIFICATE = SERVICE_PROTOCOLS_PVP2X + ".certificate";
+
+ private static final String SERVICE_PROTOCOLS_OPENID = PROTOCOLS + "." + OPENID;
+ public static final String SERVICE_PROTOCOLS_OPENID_CLIENTID = SERVICE_PROTOCOLS_OPENID + ".clientID";
+ public static final String SERVICE_PROTOCOLS_OPENID_CLIENTSECRET = SERVICE_PROTOCOLS_OPENID + ".secret";
+ public static final String SERVICE_PROTOCOLS_OPENID_REDIRECTURL = SERVICE_PROTOCOLS_OPENID + ".redirectURL";
+
+ public static final String SERVICE_INTERFEDERATION_SSO_INBOUND = INTERFEDERATION + ".SSO.inbound";
+ public static final String SERVICE_INTERFEDERATION_SSO_OUTBOUND = INTERFEDERATION + ".SSO.outbound";
+ public static final String SERVICE_INTERFEDERATION_SSO_STORE = INTERFEDERATION + ".SSO.store";
+ public static final String SERVICE_INTERFEDERATION_ATTRIBUTQUERY_URL = INTERFEDERATION + ".attributequery.url";
+
+ public static final String SERVICE_INTERFEDERATION_PASSIVEREQUEST = INTERFEDERATION + ".passiveReqeust";
+ public static final String SERVICE_INTERFEDERATION_LOCALAUTHONERROR = INTERFEDERATION + ".localAuthOnError";
+ public static final String SERVICE_INTERFEDERATION_FORWARD_IDPIDENTIFIER = INTERFEDERATION + ".forward.IDP";
+ public static final String SERVICE_INTERFEDERATION_FORWARD_PROTOCOL = INTERFEDERATION + ".forward.protocol";
+
+
+
+ //Namespaces for general MOA-ID config
+ public static final String GENERAL_PUBLICURLPREFIX = "publicURLPrefix";
+
+ private static final String GENERAL_DEFAULTS = "defaults";
+ private static final String GENERAL_DEFAULTS_BKU = GENERAL_DEFAULTS + "." + BKU;
+ public static final String GENERAL_DEFAULTS_BKU_ONLINE = GENERAL_DEFAULTS_BKU + ".onlineBKU";
+ public static final String GENERAL_DEFAULTS_BKU_HANDY = GENERAL_DEFAULTS_BKU + ".handyBKU";
+ public static final String GENERAL_DEFAULTS_BKU_LOCAL = GENERAL_DEFAULTS_BKU + ".localBKU";
+ private static final String GENERAL_DEFAULTS_TEMPLATES = GENERAL_DEFAULTS + "." + TEMPLATES;
+ public static final String GENERAL_DEFAULTS_TEMPLATES_LOCAL = GENERAL_DEFAULTS_TEMPLATES + ".localBKU";
+ public static final String GENERAL_DEFAULTS_TEMPLATES_HANDY = GENERAL_DEFAULTS_TEMPLATES + ".handyBKU";
+ public static final String GENERAL_DEFAULTS_TEMPLATES_ONLINE = GENERAL_DEFAULTS_TEMPLATES + ".onlineBKU";
+
+ private static final String GENERAL_AUTH = "auth";
+ public static final String GENERAL_AUTH_CERTSTORE_URL = GENERAL_AUTH + ".certstore.url";
+ public static final String GENERAL_AUTH_TRUSTSTORE_URL = GENERAL_AUTH + ".truststore.url";
+ public static final String GENERAL_AUTH_REVOCATIONCHECKING = GENERAL_AUTH + ".revocationchecking";
+
+ public static final String GENERAL_AUTH_TIMEOUTS_TRANSACTION = GENERAL_AUTH + ".timeouts.transaction"; //Anmeldedaten
+ public static final String GENERAL_AUTH_TIMEOUS_SSO_CREATE = GENERAL_AUTH + ".timeouts.sso.create";
+ public static final String GENERAL_AUTH_TIMEOUS_SSO_UPDATE = GENERAL_AUTH + ".timeouts.sso.update";
+
+ public static final String GENERAL_AUTH_MOASP_TRUSTPROFILE_IDL_PROD = GENERAL_AUTH + ".moasp.trustprofile.idl.prod";
+ public static final String GENERAL_AUTH_MOASP_TRUSTPROFILE_IDL_TEST = GENERAL_AUTH + ".moasp.trustprofile.idl.test";
+ public static final String GENERAL_AUTH_MOASP_TRUSTPROFILE_AUTHBLOCK_PROD = GENERAL_AUTH + ".moasp.trustprofile.authblock.prod";
+ public static final String GENERAL_AUTH_MOASP_TRUSTPROFILE_AUTHBLOCK_TEST = GENERAL_AUTH + ".moasp.trustprofile.authblock.test";
+ public static final String GENERAL_AUTH_MOASP_AUTHBLOCK_TRANSFORM = GENERAL_AUTH + ".moasp.authblock.transform";
+ public static final String GENERAL_AUTH_MOASP_URL = GENERAL_AUTH + ".moasp.url";
+
+ public static final String GENERAL_AUTH_SERVICES_OVS_URL = GENERAL_AUTH + ".services.ovs.url";
+ public static final String GENERAL_AUTH_SERVICES_SZRGW_URL = GENERAL_AUTH + ".services.szrgw.url";
+
+
+ public static final String GENERAL_AUTH_SSO_SERVICENAME = GENERAL_AUTH + "." + SSO + ".servicename";
+ public static final String GENERAL_AUTH_SSO_TARGET = GENERAL_AUTH + "." + SSO + ".target";
+ public static final String GENERAL_AUTH_SSO_AUTHBLOCK_TEXT = GENERAL_AUTH + "." + SSO + ".authblock.text";
+
+ private static final String GENERAL_PROTOCOLS = PROTOCOLS;
+ private static final String GENERAL_PROTOCOLS_SAML1 = GENERAL_PROTOCOLS + "." + SAML1;
+ private static final String GENERAL_PROTOCOLS_PVP2X = GENERAL_PROTOCOLS + "." + PVP2X;
+ private static final String GENERAL_PROTOCOLS_OPENID = GENERAL_PROTOCOLS + "." + OPENID;
+ public static final String GENERAL_PROTOCOLS_SAML1_ENABLED = GENERAL_PROTOCOLS_SAML1 + ".enabled";
+ public static final String GENERAL_PROTOCOLS_SAML1_LEGACY = GENERAL_PROTOCOLS_SAML1 + ".legacy";
+ public static final String GENERAL_PROTOCOLS_SAML1_SOURCEID = GENERAL_PROTOCOLS_SAML1 + ".sourceID";
+ public static final String GENERAL_PROTOCOLS_OPENID_ENABLED = GENERAL_PROTOCOLS_OPENID + ".enabled";
+ public static final String GENERAL_PROTOCOLS_OPENID_LEGACY = GENERAL_PROTOCOLS_OPENID + ".legacy";
+
+ public static final String GENERAL_PROTOCOLS_PVP2X_ENABLED = GENERAL_PROTOCOLS_PVP2X + ".enabled";
+ public static final String GENERAL_PROTOCOLS_PVP2X_LEGACY = GENERAL_PROTOCOLS_PVP2X + ".legacy";
+ public static final String GENERAL_PROTOCOLS_PVP2X_METADATA_SERVICENAMME = GENERAL_PROTOCOLS_PVP2X + ".metadata.servicename";
+ public static final String GENERAL_PROTOCOLS_PVP2X_METADATA_ORG_SHORTNAME = GENERAL_PROTOCOLS_PVP2X + ".metadata.org.name.short";
+ public static final String GENERAL_PROTOCOLS_PVP2X_METADATA_ORG_FULLNAME = GENERAL_PROTOCOLS_PVP2X + ".metadata.org.name.full";
+ public static final String GENERAL_PROTOCOLS_PVP2X_METADATA_ORG_URL = GENERAL_PROTOCOLS_PVP2X + ".metadata.org.url";
+
+ public static final String GENERAL_PROTOCOLS_PVP2X_METADATA_CONTACT_FAMLIYNAME = GENERAL_PROTOCOLS_PVP2X + ".metadata.contact.familyname";
+ public static final String GENERAL_PROTOCOLS_PVP2X_METADATA_CONTACT_GIVENNAME = GENERAL_PROTOCOLS_PVP2X + ".metadata.contact.givenname";
+ public static final String GENERAL_PROTOCOLS_PVP2X_METADATA_CONTACT_MAIL = GENERAL_PROTOCOLS_PVP2X + ".metadata.contact.mail";
+ public static final String GENERAL_PROTOCOLS_PVP2X_METADATA_CONTACT_PHONE = GENERAL_PROTOCOLS_PVP2X + ".metadata.contact.phone";
+ public static final String GENERAL_PROTOCOLS_PVP2X_METADATA_CONTACT_COMPANY = GENERAL_PROTOCOLS_PVP2X + ".metadata.contact.company";
+ public static final String GENERAL_PROTOCOLS_PVP2X_METADATA_CONTACT_TYPE = GENERAL_PROTOCOLS_PVP2X + ".metadata.contact.type";
+
+ public static final String GENERAL_AUTH_AUTHBLOCK_TRANSFORMATION_NAME = GENERAL_AUTH + ".authblock.transformation.name";
+ 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_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_NAME = "friendlyname";
+ public static final String GENERAL_AUTH_STORK_ATTRIBUTES_LIST_MANDATORY = "mandatory";
+
+// // old!!!!!!!!!!! //
+// // keys for the object in the key-value database
+// public static final String ONLINE_APPLICATIONS_KEY = "OnlineApplications";
+// public static final String AUTH_COMPONENT_GENERAL_KEY = "AuthComponentGeneral";
+// public static final String CHAINING_MODES_KEY = "ChainingModes";
+// public static final String TRUSTED_CERTIFICATES_KEY = "TruestedCertificates";
+// public static final String DEFAULT_BKUS_KEY = "DefaultBKUs";
+// public static final String SLREQUEST_TEMPLATES_KEY = "SLRequestTemplates";
+// public static final String TIMESTAMP_ITEM_KEY = "TimestampItem";
+// public static final String PVP2REFRESH_ITEM_KEY = "Pvp2RefreshItem";
+// public static final String GENERIC_CONFIGURATION_KEY = "GenericConfiguration";
+//
+// /**
+// * Returns all relevant (database-) keys that {@link MOAIDConfiguration} contains.
+// * @return the keys as {@code String[]}
+// */
+// public static final String[] getMOAIDConfigurationKeys() {
+// return new String[] { AUTH_COMPONENT_GENERAL_KEY, CHAINING_MODES_KEY, TRUSTED_CERTIFICATES_KEY,
+// DEFAULT_BKUS_KEY, SLREQUEST_TEMPLATES_KEY, TIMESTAMP_ITEM_KEY, PVP2REFRESH_ITEM_KEY };
+// }
+//
+// /**
+// * Returns all (database-) keys that {@link MOAIDConfiguration} contains.
+// * @return the keys as {@code String[]}
+// */
+// public static final String[] getAllMOAIDConfigurationKeys() {
+// return new String[] { ONLINE_APPLICATIONS_KEY, AUTH_COMPONENT_GENERAL_KEY, CHAINING_MODES_KEY,
+// TRUSTED_CERTIFICATES_KEY, DEFAULT_BKUS_KEY, SLREQUEST_TEMPLATES_KEY, TIMESTAMP_ITEM_KEY,
+// PVP2REFRESH_ITEM_KEY };
+// }
+}
diff --git a/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/config/persistence/ConfigurationImpl.java b/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/config/persistence/ConfigurationImpl.java
deleted file mode 100644
index c90b60440..000000000
--- a/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/config/persistence/ConfigurationImpl.java
+++ /dev/null
@@ -1,161 +0,0 @@
-package at.gv.egovernment.moa.id.commons.config.persistence;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.persistence.EntityExistsException;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Required;
-import org.springframework.stereotype.Component;
-
-import at.gv.egovernment.moa.id.commons.db.dao.config.ConfigProperty;
-import at.gv.egovernment.moa.id.commons.db.dao.config.ConfigPropertyDao;
-
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.JsonMappingException;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.type.CollectionType;
-import com.fasterxml.jackson.databind.type.TypeFactory;
-
-/**
- * The implementation of a key-value configuration implementing the {@link Configuration} interface.
- * It employs the {@link ConfigPropertyDao} to persist configuration data.
- */
-@Component
-public class ConfigurationImpl implements Configuration {
-
- private final Logger log = LoggerFactory.getLogger(getClass());
-
- ConfigPropertyDao configPropertyDao;
- private JsonMapper mapper = new JsonMapper();
-
- /**
- * Sets the {@link ConfigPropertyDao}.
- * @param configPropertyDao the ConfigPropertyDao
- */
- @Required
- public void setConfigPropertyDao(ConfigPropertyDao configPropertyDao) {
- this.configPropertyDao = configPropertyDao;
- }
-
- @Override
- public List<String> getAllKeys(){
- try {
- return this.configPropertyDao.getAllKeys();
- } catch (Exception e) {
- log.debug("Error while retrieving a list of all keys in the database.");
- return null;
- }
- }
-
- @Override
- public Object get(String key) {
- // return null if key does not exist
- try {
- ConfigProperty property = configPropertyDao.getProperty(key);
- if (property != null && property.getValue() != null) {
- return mapper.deserialize(property.getValue(), null);
- } else {
- return null;
- }
- } catch (IllegalArgumentException e) {
- log.debug("Error while searching for key '{}' in the database.", key);
- return null;
- } catch (Exception e) {
- log.debug("Error while deserializing value of key '{}' to object.", key);
- return null;
- }
- }
-
- @Override
- public <T> T get(String key, Class<T> clazz) {
- // return null if key does not exist
- try {
- ConfigProperty property = configPropertyDao.getProperty(key);
- if (property != null && property.getValue() != null) {
- return clazz.cast(mapper.deserialize(property.getValue(), clazz));
- } else {
- return null;
- }
- } catch (IllegalArgumentException e) {
- log.debug("Error while searching for key '{}' in the database.", key);
- return null;
- } catch (Exception e) {
- log.debug("Error while deserializing value of key '{}' to object of type {}.", key, clazz.getClass());
- return null;
- }
- }
-
- @Override
- public boolean set(String key, Object value) {
-
- try {
- if (value == null) {
- configPropertyDao.delete(key);
- return true;
- } else {
-
- ConfigProperty keyValue = new ConfigProperty();
- keyValue.setKey(key);
-
- keyValue.setValue(mapper.serialize(value));
- configPropertyDao.saveProperty(keyValue);
- return true;
- }
- } catch (JsonProcessingException e) {
- log.debug("Error while serializing object for key '{}'.", key);
- return false;
- } catch (EntityExistsException e) {
- log.debug("Property '{}' already exists!", key);
- return false;
- } catch (Exception e) {
- log.debug("Error while setting value for key '{}' in the database.", key);
- return false;
- }
- }
-
- @Override
- public <T> T get(String key, Class<T> clazz, Object defaultValue) {
-
- T value = get(key, clazz);
- if (value != null) {
- return value;
- } else {
- return clazz.cast(defaultValue);
- }
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public <T> List<T> getList(String key, Class<T> clazz) {
-
- CollectionType listType = TypeFactory.defaultInstance().constructCollectionType(List.class, clazz);
- try {
- if ((configPropertyDao.getProperty(key) == null)
- || (configPropertyDao.getProperty(key).getValue() == null)) {
- return new ArrayList<T>();
- }
- String json = configPropertyDao.getProperty(key).getValue();
- ObjectMapper mapper = new ObjectMapper();
-
- return (List<T>) mapper.readValue(json, listType);
- } catch (JsonMappingException e) {
- ArrayList<T> tmp = new ArrayList<T>();
- T value = get(key, clazz);
- if (value != null) {
- tmp.add(value);
- }
- return tmp;
- } catch (IOException e) {
- log.debug("Error while deserializing value for key '{}' to List<{}>.", key, clazz.getClass());
- return new ArrayList<T>();
- } catch (Exception e){
- log.debug("Error while searching key '{}' in the database.", key);
- return new ArrayList<T>();
- }
- }
-
-}
diff --git a/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/config/persistence/Configuration.java b/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/config/persistence/MOAIDConfiguration.java
index f357fc570..45f37ef97 100644
--- a/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/config/persistence/Configuration.java
+++ b/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/config/persistence/MOAIDConfiguration.java
@@ -2,10 +2,12 @@ package at.gv.egovernment.moa.id.commons.config.persistence;
import java.util.List;
+import at.gv.egiz.components.configuration.api.Configuration;
+
/**
* An interface for a key-value configuration.
*/
-public interface Configuration {
+public interface MOAIDConfiguration {
/**
* Gets all keys in the database. NOTE: may return an empty list or {@code null}.
@@ -16,9 +18,9 @@ public interface Configuration {
/**
* Get the value associated with the given key as {@link Object}.
* @param key the key
- * @return the object associated with the given key or {@code null} if the key does not exist or does not have a value.
+ * @return the String associated with the given key or {@code null} if the key does not exist or does not have a value.
*/
- Object get(String key);
+ String get(String key);
/**
* Get the object of type {@code T} associated with the given key.
@@ -33,28 +35,28 @@ public interface Configuration {
* Store an object associated with a key. If the given object is set to {@code null} then the entry associated with the key is deleted.
*
* @param key the key under which the value is stored, respectively key determining the entry to be deleted.
- * @param value the object to store. if value is set to {@code null} then the entry associated with key {@code key} is deleted.
+ * @param value the String to store. if value is set to {@code null} then the entry associated with key {@code key} is deleted.
* @return {@code true} if the operation was carried out successfully, {@code false} otherwise.
*/
- boolean set(String key, Object value);
-
- /**
- * Get the object of type {@code T} associated with the given key from the database. If the key does not exist or does not have a value, the given default
- * value is returned.
- *
- * @param key the key
- * @param clazz the type of the requested object
- * @param defaultValue the default value to return
- * @return the object associated with the given key or {@code defaultValue} if the key does not exist or does not have a value.
- */
- <T> T get(String key, Class<T> clazz, Object defaultValue);
-
- /**
- * Get a list of objects associated with the given key. The list may be empty or contain only a single object.
- * @param key the key
- * @param clazz the type of the requested object
- * @return a list containing objects of type {@code T} or an empty list if no objects are associated with the key.
- */
- <T> List<T> getList(String key, Class<T> clazz);
+ boolean set(String key, String value);
+//
+// /**
+// * Get the object of type {@code T} associated with the given key from the database. If the key does not exist or does not have a value, the given default
+// * value is returned.
+// *
+// * @param key the key
+// * @param clazz the type of the requested object
+// * @param defaultValue the default value to return
+// * @return the object associated with the given key or {@code defaultValue} if the key does not exist or does not have a value.
+// */
+// <T> T get(String key, Class<T> clazz, Object defaultValue);
+//
+// /**
+// * Get a list of objects associated with the given key. The list may be empty or contain only a single object.
+// * @param key the key
+// * @param clazz the type of the requested object
+// * @return a list containing objects of type {@code T} or an empty list if no objects are associated with the key.
+// */
+// <T> List<T> getList(String key, Class<T> clazz);
} \ No newline at end of file
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
new file mode 100644
index 000000000..10ed19f83
--- /dev/null
+++ b/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/config/persistence/MOAIDConfigurationImpl.java
@@ -0,0 +1,136 @@
+package at.gv.egovernment.moa.id.commons.config.persistence;
+
+import java.util.Arrays;
+import java.util.List;
+
+import javax.persistence.EntityExistsException;
+
+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;
+
+/**
+ * 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 implements MOAIDConfiguration {
+
+ private final Logger log = LoggerFactory.getLogger(getClass());
+
+ Configuration configPropertyDao;
+// private JsonMapper mapper = new JsonMapper();
+
+ /**
+ * Sets the {@link ConfigPropertyDao}.
+ * @param configPropertyDao the ConfigPropertyDao
+ */
+ @Required
+ public void setConfigPropertyDao(Configuration configPropertyDao) {
+ this.configPropertyDao = configPropertyDao;
+ }
+
+ @Override
+ public List<String> getAllKeys(){
+ try {
+ return Arrays.asList(this.configPropertyDao.getConfigurationIds());
+ } catch (Exception e) {
+ log.debug("Error while retrieving a list of all keys in the database.");
+ return null;
+ }
+ }
+
+ @Override
+ public String get(String key) {
+ // return null if key does not exist
+ try {
+ return configPropertyDao.getStringValue(key);
+
+ } catch (Exception e) {
+ log.debug("Error while searching value of key '{}' to object.", key);
+ return null;
+ }
+ }
+
+ @Override
+ public <T> T get(String key, Class<T> clazz) {
+ // return null if key does not exist
+ try {
+ T property = configPropertyDao.getObjectValue(key, clazz);
+ return property;
+
+ } catch (IllegalArgumentException e) {
+ log.debug("Error while searching for key '{}' in the database.", key);
+ return null;
+ } catch (Exception e) {
+ log.debug("Error while deserializing value of key '{}' to object of type {}.", key, clazz.getClass());
+ return null;
+ }
+ }
+
+ @Override
+ public boolean set(String key, String value) {
+
+ try {
+ //TODO: add delete
+ if (value == null) {
+ //configPropertyDao.delete(key);
+ return true;
+ } else {
+ configPropertyDao.setStringValue(key, value);
+ return true;
+ }
+ } catch (EntityExistsException e) {
+ log.debug("Property '{}' already exists!", key);
+ return false;
+ } catch (Exception e) {
+ log.debug("Error while setting value for key '{}' in the database.", key);
+ return false;
+ }
+ }
+
+// @Override
+// public <T> T get(String key, Class<T> clazz, Object defaultValue) {
+//
+// T value = get(key, clazz);
+// if (value != null) {
+// return value;
+// } else {
+// return clazz.cast(defaultValue);
+// }
+// }
+//
+// @SuppressWarnings("unchecked")
+// @Override
+// public <T> List<T> getList(String key, Class<T> clazz) {
+//
+// CollectionType listType = TypeFactory.defaultInstance().constructCollectionType(List.class, clazz);
+// try {
+// if ((configPropertyDao.getProperty(key) == null)
+// || (configPropertyDao.getProperty(key).getValue() == null)) {
+// return new ArrayList<T>();
+// }
+// String json = configPropertyDao.getProperty(key).getValue();
+// ObjectMapper mapper = new ObjectMapper();
+//
+// return (List<T>) mapper.readValue(json, listType);
+// } catch (JsonMappingException e) {
+// ArrayList<T> tmp = new ArrayList<T>();
+// T value = get(key, clazz);
+// if (value != null) {
+// tmp.add(value);
+// }
+// return tmp;
+// } catch (IOException e) {
+// log.debug("Error while deserializing value for key '{}' to List<{}>.", key, clazz.getClass());
+// return new ArrayList<T>();
+// } catch (Exception e){
+// log.debug("Error while searching key '{}' in the database.", key);
+// return new ArrayList<T>();
+// }
+// }
+
+}
diff --git a/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/ConfigurationFromDBExtractor.java b/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/ConfigurationFromDBExtractor.java
index 394c9cdeb..f6066d68f 100644
--- a/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/ConfigurationFromDBExtractor.java
+++ b/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/ConfigurationFromDBExtractor.java
@@ -7,6 +7,7 @@ import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.TypedQuery;
+import at.gv.egovernment.moa.id.commons.config.MOAIDConfigurationConstants;
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.DefaultBKUs;
diff --git a/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/MOAIDConfigurationConstants.java b/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/MOAIDConfigurationConstants.java
deleted file mode 100644
index 30897bc1d..000000000
--- a/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/MOAIDConfigurationConstants.java
+++ /dev/null
@@ -1,44 +0,0 @@
-package at.gv.egovernment.moa.id.commons.db;
-
-import at.gv.egovernment.moa.id.commons.db.dao.config.MOAIDConfiguration;
-
-/**
- *
- *
- */
-public final class MOAIDConfigurationConstants {
-
- private MOAIDConfigurationConstants() {
- // restrict instantiation
- }
-
- // keys for the object in the key-value database
- public static final String ONLINE_APPLICATIONS_KEY = "OnlineApplications";
- public static final String AUTH_COMPONENT_GENERAL_KEY = "AuthComponentGeneral";
- public static final String CHAINING_MODES_KEY = "ChainingModes";
- public static final String TRUSTED_CERTIFICATES_KEY = "TruestedCertificates";
- public static final String DEFAULT_BKUS_KEY = "DefaultBKUs";
- public static final String SLREQUEST_TEMPLATES_KEY = "SLRequestTemplates";
- public static final String TIMESTAMP_ITEM_KEY = "TimestampItem";
- public static final String PVP2REFRESH_ITEM_KEY = "Pvp2RefreshItem";
- public static final String GENERIC_CONFIGURATION_KEY = "GenericConfiguration";
-
- /**
- * Returns all relevant (database-) keys that {@link MOAIDConfiguration} contains.
- * @return the keys as {@code String[]}
- */
- public static final String[] getMOAIDConfigurationKeys() {
- return new String[] { AUTH_COMPONENT_GENERAL_KEY, CHAINING_MODES_KEY, TRUSTED_CERTIFICATES_KEY,
- DEFAULT_BKUS_KEY, SLREQUEST_TEMPLATES_KEY, TIMESTAMP_ITEM_KEY, PVP2REFRESH_ITEM_KEY };
- }
-
- /**
- * Returns all (database-) keys that {@link MOAIDConfiguration} contains.
- * @return the keys as {@code String[]}
- */
- public static final String[] getAllMOAIDConfigurationKeys() {
- return new String[] { ONLINE_APPLICATIONS_KEY, AUTH_COMPONENT_GENERAL_KEY, CHAINING_MODES_KEY,
- TRUSTED_CERTIFICATES_KEY, DEFAULT_BKUS_KEY, SLREQUEST_TEMPLATES_KEY, TIMESTAMP_ITEM_KEY,
- PVP2REFRESH_ITEM_KEY };
- }
-}
diff --git a/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/NewConfigurationDBRead.java b/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/NewConfigurationDBRead.java
index 28363a1eb..64d8e9d80 100644
--- a/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/NewConfigurationDBRead.java
+++ b/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/NewConfigurationDBRead.java
@@ -7,12 +7,12 @@ import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
-import at.gv.egovernment.moa.id.commons.config.persistence.Configuration;
+import at.gv.egovernment.moa.id.commons.config.MOAIDConfigurationConstants;
+import at.gv.egovernment.moa.id.commons.config.persistence.MOAIDConfiguration;
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.DefaultBKUs;
import at.gv.egovernment.moa.id.commons.db.dao.config.GenericConfiguration;
-import at.gv.egovernment.moa.id.commons.db.dao.config.MOAIDConfiguration;
import at.gv.egovernment.moa.id.commons.db.dao.config.OnlineApplication;
import at.gv.egovernment.moa.id.commons.db.dao.config.SLRequestTemplates;
import at.gv.egovernment.moa.id.commons.db.dao.config.UserDatabase;
@@ -24,10 +24,10 @@ import at.gv.egovernment.moa.logging.Logger;
*/
public class NewConfigurationDBRead {
- private static Configuration conf;
+ private static MOAIDConfiguration conf;
@Autowired(required = true)
- public void setConfiguration(Configuration conf) {
+ public void setConfiguration(MOAIDConfiguration conf) {
// https://jira.spring.io/browse/SPR-3845
NewConfigurationDBRead.conf = conf;
}
@@ -100,7 +100,7 @@ public class NewConfigurationDBRead {
*
* @return
*/
- public static MOAIDConfiguration getMOAIDConfiguration() {
+ public static at.gv.egovernment.moa.id.commons.db.dao.config.MOAIDConfiguration getMOAIDConfiguration() {
Logger.trace("Load MOAID Configuration from database.");
AuthComponentGeneral authComponent = (AuthComponentGeneral) conf.get(MOAIDConfigurationConstants.AUTH_COMPONENT_GENERAL_KEY,
@@ -126,7 +126,7 @@ public class NewConfigurationDBRead {
// }
// select moaidconfiguration from MOAIDConfiguration moaidconfiguration
- MOAIDConfiguration result = new MOAIDConfiguration();
+ at.gv.egovernment.moa.id.commons.db.dao.config.MOAIDConfiguration result = new at.gv.egovernment.moa.id.commons.db.dao.config.MOAIDConfiguration();
result.setAuthComponentGeneral(authComponent);
result.setChainingModes(chainingModes);
result.setGenericConfiguration(genericConfigurations);
diff --git a/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/NewConfigurationDBWrite.java b/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/NewConfigurationDBWrite.java
index de4a1789e..69e03db28 100644
--- a/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/NewConfigurationDBWrite.java
+++ b/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/NewConfigurationDBWrite.java
@@ -6,12 +6,12 @@ import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
-import at.gv.egovernment.moa.id.commons.config.persistence.Configuration;
+import at.gv.egovernment.moa.id.commons.config.MOAIDConfigurationConstants;
+import at.gv.egovernment.moa.id.commons.config.persistence.MOAIDConfiguration;
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.DefaultBKUs;
import at.gv.egovernment.moa.id.commons.db.dao.config.GenericConfiguration;
-import at.gv.egovernment.moa.id.commons.db.dao.config.MOAIDConfiguration;
import at.gv.egovernment.moa.id.commons.db.dao.config.OnlineApplication;
import at.gv.egovernment.moa.id.commons.db.dao.config.SLRequestTemplates;
import at.gv.egovernment.moa.id.commons.db.dao.config.UserDatabase;
@@ -22,10 +22,10 @@ import at.gv.egovernment.moa.id.commons.db.dao.config.UserDatabase;
@Component
public class NewConfigurationDBWrite {
- private static Configuration conf;
+ private static MOAIDConfiguration conf;
@Autowired(required = true)
- public void setConfiguration(Configuration conf) {
+ public void setConfiguration(MOAIDConfiguration conf) {
// https://jira.spring.io/browse/SPR-3845
NewConfigurationDBWrite.conf = conf;
}
@@ -106,7 +106,8 @@ public class NewConfigurationDBWrite {
} else if (dbo instanceof MOAIDConfiguration) {
- MOAIDConfiguration moaconfig = (MOAIDConfiguration) dbo;
+ at.gv.egovernment.moa.id.commons.db.dao.config.MOAIDConfiguration moaconfig =
+ (at.gv.egovernment.moa.id.commons.db.dao.config.MOAIDConfiguration) dbo;
result = true;
result &= saveAuthComponentGeneral(moaconfig.getAuthComponentGeneral());
diff --git a/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/dao/config/ConfigPropertyDao.java b/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/dao/config/ConfigPropertyDao.java
deleted file mode 100644
index db35ba1df..000000000
--- a/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/dao/config/ConfigPropertyDao.java
+++ /dev/null
@@ -1,58 +0,0 @@
-package at.gv.egovernment.moa.id.commons.db.dao.config;
-
-import java.util.List;
-import java.util.Set;
-
-/**
- * DAO interface providing means for accessing MOAID configuration properties.
- *
- */
-public interface ConfigPropertyDao {
-
- /**
- * Gets all keys in the database.
- * @return a List containing all keys in the database.
- */
- List<String> getAllKeys();
-
- /**
- * Returns the {@link ConfigProperty} associated with {@code key} or {@code null} if the entry does not exist.
- *
- * @param key The configuration key.
- * @return The configuration property value or {@code null}.
- */
- ConfigProperty getProperty(String key);
-
- /**
- * Persists a given {@link ConfigProperty}.
- * @param property The property to be persisted.
- */
- void saveProperty(ConfigProperty property);
-
- /**
- * Returns a {@link List} containing all stored {@linkplain ConfigProperty ConfigProperties}.
- * @return The list with the properties.
- */
- List<ConfigProperty> getProperties();
-
- /**
- * Returns the value for the configuration property associated with {@code key} or {@code null} if the entry does not exist or its value is {@code null}.
- *
- * @param key The configuration key.
- * @return The configuration property value or {@code null}.
- */
- String getPropertyValue(String key);
-
- /**
- * Persists a {@link List} of {@linkplain ConfigProperty ConfigProperties}.
- * @param properties The list containing all the properties to be persisted.
- */
- void saveProperties(Set<ConfigProperty> properties);
-
- /**
- * Deletes the object associated with the given key.
- * @param key the key
- */
- void delete(String key);
-
-}
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 6a76c1d17..24195b0cf 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
@@ -1,10 +1,8 @@
package at.gv.egovernment.moa.id.commons.db.dao.config;
import java.util.List;
-import java.util.Set;
import javax.persistence.EntityManager;
-import javax.persistence.NoResultException;
import javax.persistence.PersistenceContext;
import javax.persistence.TypedQuery;
@@ -12,20 +10,25 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.transaction.annotation.Transactional;
+import at.gv.egiz.components.configuration.api.AbstractConfigurationImpl;
+import at.gv.egiz.components.configuration.api.ConfigurationException;
+import at.gv.egovernment.moa.util.MiscUtil;
+
/**
* Database backed implementation of the DAO interface
*
*/
@Transactional("transactionManager")
-public class ConfigPropertyDaoImpl implements ConfigPropertyDao {
+public class ConfigPropertyDaoImpl extends AbstractConfigurationImpl {
private Logger log = LoggerFactory.getLogger(getClass());
@PersistenceContext(unitName = "moaidconf")
private EntityManager em;
+
@Override
- public List<String> getAllKeys() {
+ protected List<String> getAllKeys() {
if (null == em) {
log.error("No EntityManager set!");
return null;
@@ -35,70 +38,150 @@ public class ConfigPropertyDaoImpl implements ConfigPropertyDao {
return result;
}
+ /* (non-Javadoc)
+ * @see at.gv.egiz.components.configuration.api.AbstractConfigurationImpl#getValue(java.lang.String)
+ */
+ @Override
+ protected String getValue(String key) throws ConfigurationException {
+ ConfigProperty property = getProperty(key);
+ if (property == null)
+ return null;
+
+ else {
+ if (MiscUtil.isEmpty(property.getValue()))
+ return new String();
+ else
+ return property.getValue();
+
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see at.gv.egiz.components.configuration.api.AbstractConfigurationImpl#containsKey(java.lang.String)
+ */
+ @Override
+ protected boolean containsKey(String key) throws ConfigurationException {
+ ConfigProperty property = getProperty(key);
+ if (property == null)
+ return false;
+ else
+ return true;
+
+ }
+
+ /* (non-Javadoc)
+ * @see at.gv.egiz.components.configuration.api.AbstractConfigurationImpl#storeKey(java.lang.String, java.lang.String)
+ */
@Override
- public void saveProperty(ConfigProperty property) {
+ protected void storeKey(String key, String value) throws ConfigurationException {
if (null == em) {
log.error("No EntityManager set!");
return;
+
}
-
+ ConfigProperty property = new ConfigProperty();
+ property.setKey(key);
+ property.setValue(value);
log.debug("Storing '{}'.", property.toString());
em.persist(property);
+
}
- @Override
- public ConfigProperty getProperty(String key) {
- log.debug("Looking for configuration property for key '{}'.", key);
- ConfigProperty result = em.find(ConfigProperty.class, key);
- if (result != null) {
- log.debug("Found configuration property {}.", result);
- } else {
- log.debug("Unable to find configuration property for key '{}'.", key);
- }
- return result;
+ protected void deleteKey(String key) {
+ log.debug("Deleting entry with key '{}'.", key);
+ em.remove(em.find(ConfigProperty.class, key));
}
-
+
+ /* (non-Javadoc)
+ * @see at.gv.egiz.components.configuration.api.AbstractConfigurationImpl#findConfigurationId(java.lang.String)
+ */
@Override
- public String getPropertyValue(String key) {
- ConfigProperty property = getProperty(key);
- if (property == null) {
+ public String[] findConfigurationId(String searchString)
+ throws ConfigurationException {
+ if (null == em) {
+ log.error("No EntityManager set!");
return null;
}
- return property.getValue();
+
+ TypedQuery<String> query = em.createQuery("select * 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()]);
}
+ /* (non-Javadoc)
+ * @see at.gv.egiz.components.configuration.api.AbstractConfigurationImpl#findByValue(java.lang.String)
+ */
@Override
- public List<ConfigProperty> getProperties() {
-
+ public String[] findByValue(String searchString)
+ throws ConfigurationException {
if (null == em) {
log.error("No EntityManager set!");
return null;
}
-
- log.debug("Retrieving all properties from database.");
- TypedQuery<ConfigProperty> query = em.createQuery("select mc from ConfigProperty mc", ConfigProperty.class);
- try {
- List<ConfigProperty> propertiesList = query.getResultList();
- return propertiesList;
- } catch (NoResultException e) {
- log.debug("No property found in database.");
- return null;
- }
+
+ TypedQuery<String> query = em.createQuery("select * 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()]);
}
+ /* (non-Javadoc)
+ * @see at.gv.egiz.components.configuration.api.AbstractConfigurationImpl#synchronize()
+ */
@Override
- public void saveProperties(Set<ConfigProperty> properties) {
- log.debug("Storing {} properties to database.", properties.size());
- for (ConfigProperty cp : properties) {
- saveProperty(cp);
- }
- em.flush();
+ public void synchronize() throws ConfigurationException {
+ //INFO: no implementation required
+
}
+ /* (non-Javadoc)
+ * @see at.gv.egiz.components.configuration.api.AbstractConfigurationImpl#getName()
+ */
@Override
- public void delete(String key) {
- log.debug("Deleting entry with key '{}'.", key);
- em.remove(em.find(ConfigProperty.class, key));
+ public String getName() {
+ return "DatabaseConfiguration";
+ }
+
+
+ private ConfigProperty getProperty(String key) {
+ log.debug("Looking for configuration property for key '{}'.", key);
+ ConfigProperty result = em.find(ConfigProperty.class, key);
+ if (result != null) {
+ log.debug("Found configuration property {}.", result);
+ } else {
+ log.debug("Unable to find configuration property for key '{}'.", key);
+ }
+ return result;
}
-}
+
+// @Override
+// public String getPropertyValue(String key) {
+// ConfigProperty property = getProperty(key);
+// if (property == null) {
+// return null;
+// }
+// return property.getValue();
+// }
+//
+// @Override
+// public List<ConfigProperty> getProperties() {
+//
+// if (null == em) {
+// log.error("No EntityManager set!");
+// return null;
+// }
+//
+// log.debug("Retrieving all properties from database.");
+// TypedQuery<ConfigProperty> query = em.createQuery("select mc from ConfigProperty mc", ConfigProperty.class);
+// try {
+// List<ConfigProperty> propertiesList = query.getResultList();
+// return propertiesList;
+// } catch (NoResultException e) {
+// log.debug("No property found in database.");
+// return null;
+// }
+// }
+
+} \ No newline at end of file
diff --git a/id/server/moa-id-commons/src/test/java/at/gv/egovernment/moa/id/commons/db/ConfigurationDBReadTest.java b/id/server/moa-id-commons/src/test/java/at/gv/egovernment/moa/id/commons/db/ConfigurationDBReadTest.java
index 7b596fab8..c8a234565 100644
--- a/id/server/moa-id-commons/src/test/java/at/gv/egovernment/moa/id/commons/db/ConfigurationDBReadTest.java
+++ b/id/server/moa-id-commons/src/test/java/at/gv/egovernment/moa/id/commons/db/ConfigurationDBReadTest.java
@@ -20,9 +20,8 @@ import org.springframework.test.annotation.IfProfileValue;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-import at.gv.egovernment.moa.id.commons.config.persistence.Configuration;
+import at.gv.egovernment.moa.id.commons.config.persistence.MOAIDConfiguration;
import at.gv.egovernment.moa.id.commons.db.dao.config.AuthComponentGeneral;
-import at.gv.egovernment.moa.id.commons.db.dao.config.MOAIDConfiguration;
import at.gv.egovernment.moa.id.commons.db.ex.MOADatabaseException;
import com.fasterxml.jackson.annotation.JsonProperty;
@@ -33,7 +32,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
public class ConfigurationDBReadTest {
@Autowired
- Configuration configDataBase;
+ MOAIDConfiguration configDataBase;
private Properties getHibernateProperties() throws FileNotFoundException, IOException {
@@ -93,11 +92,11 @@ public class ConfigurationDBReadTest {
SecurityException {
// get the old moaid configuration
- MOAIDConfiguration oldConfig = ConfigurationDBRead.getMOAIDConfiguration();
+ at.gv.egovernment.moa.id.commons.db.dao.config.MOAIDConfiguration oldConfig = ConfigurationDBRead.getMOAIDConfiguration();
// get the a new moaid configuration from the data in the key value
// database
- MOAIDConfiguration newConfig = NewConfigurationDBRead.getMOAIDConfiguration();
+ at.gv.egovernment.moa.id.commons.db.dao.config.MOAIDConfiguration newConfig = NewConfigurationDBRead.getMOAIDConfiguration();
// check if both configurations yield a similar MOAIDConfiguration
// object
@@ -111,14 +110,14 @@ public class ConfigurationDBReadTest {
SecurityException {
// get the old moaid configuration
- MOAIDConfiguration oldConfig = ConfigurationDBRead.getMOAIDConfiguration();
+ at.gv.egovernment.moa.id.commons.db.dao.config.MOAIDConfiguration oldConfig = ConfigurationDBRead.getMOAIDConfiguration();
// delete part of the configuration
oldConfig.setAuthComponentGeneral(new AuthComponentGeneral());
// get the a new moaid configuration from the data in the key value
// database
- MOAIDConfiguration newConfig = NewConfigurationDBRead.getMOAIDConfiguration();
+ at.gv.egovernment.moa.id.commons.db.dao.config.MOAIDConfiguration newConfig = NewConfigurationDBRead.getMOAIDConfiguration();
// check if both configurations yield a similar MOAIDConfiguration
// object