aboutsummaryrefslogtreecommitdiff
path: root/id/server/moa-id-commons/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'id/server/moa-id-commons/src/main')
-rw-r--r--id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/config/ConfigurationUtil.java479
-rw-r--r--id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/config/MOAIDConfigurationConstants.java86
-rw-r--r--id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/config/MigrateConfiguration.java206
-rw-r--r--id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/config/persistence/MOAIDConfiguration.java84
-rw-r--r--id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/config/persistence/MOAIDConfigurationImpl.java273
-rw-r--r--id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/ConfigurationDBRead.java658
-rw-r--r--id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/ConfigurationDBUtils.java310
-rw-r--r--id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/ConfigurationFromDBExtractor.java182
-rw-r--r--id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/dao/config/DatabaseConfigPropertyImpl.java (renamed from id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/dao/config/ConfigPropertyDaoImpl.java)24
-rw-r--r--id/server/moa-id-commons/src/main/resources/META-INF/persistence.xml2
-rw-r--r--id/server/moa-id-commons/src/main/resources/configuration.beans.xml_old (renamed from id/server/moa-id-commons/src/main/resources/configuration.beans.xml)9
-rw-r--r--id/server/moa-id-commons/src/main/resources/persistence_template.xml2
12 files changed, 1096 insertions, 1219 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 468e4a536..bac2d0011 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
@@ -1,226 +1,253 @@
-//package at.gv.egovernment.moa.id.commons.config;
-//
-//import java.io.File;
-//import java.io.FileInputStream;
-//import java.io.FileNotFoundException;
-//import java.io.FileOutputStream;
-//import java.io.IOException;
-//import java.util.Enumeration;
-//import java.util.List;
-//import java.util.Properties;
-//
-//import javax.xml.bind.JAXBContext;
-//import javax.xml.bind.JAXBException;
-//import javax.xml.bind.Unmarshaller;
-//
-//import org.springframework.context.ApplicationContext;
-//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.dao.config.MOAIDConfiguration;
-//
-//import com.fasterxml.jackson.core.JsonProcessingException;
-//
-//public class ConfigurationUtil {
-//
-// final boolean isOverwriteData;
-//
-// public ConfigurationUtil(boolean isOverwriteData){
-// this.isOverwriteData = isOverwriteData;
-// }
-//
-// /**
-// * Read an input MOAID 2 XML file, transfer it to properties and write the
-// * properties to a MOAID 3 property file.
-// *
-// * @param inStream
-// * the input stream to read from.
-// * @param outFile
-// * the output file to write to.
-// * @throws JAXBException
-// */
-// public void readFromXMLFileConvertToPropertyFile(FileInputStream inStream, File outFile) throws JAXBException {
-//
-// try (FileOutputStream outStream = new FileOutputStream(outFile);) {
-//
-// // get config from xml file
-// JAXBContext jc = JAXBContext.newInstance("at.gv.egovernment.moa.id.commons.db.dao.config");
-// Unmarshaller m = jc.createUnmarshaller();
-// MOAIDConfiguration config = (MOAIDConfiguration) m.unmarshal(inStream);
-//
-// // serialize config to JSON properties
-// Properties result = moaIdConfigToJsonProperties(config);
-//
-// // write to output stream
-// result.store(outStream, null);
-//
-// } catch (FileNotFoundException e) {
-// System.out.println("Could not find the output file.");
-// System.exit(1);
-// } catch (IOException e) {
-// System.out.println("Could not write to the output file.");
-// System.exit(1);
-// }
-// }
-//
-// /**
-// * Helper method to serialize a {@link MOAIDConfiguration} to Properties
-// * with JSON encoded values.
-// *
-// * @param config
-// * the MOAIDConfiguration to serialize
-// * @return {@link Properties} containing the database key and the serialized
-// * values
-// * @throws JsonProcessingException
-// * is thrown if problem occurred while serializing one of the
-// * database values
-// */
-// private Properties moaIdConfigToJsonProperties(MOAIDConfiguration config) throws JsonProcessingException {
-//
-// Properties result = new Properties();
-// boolean prettyPrint = true;
-// JsonMapper mapper = new JsonMapper(prettyPrint);
-//
-// // serialize config to JSON
-// String oaJson = mapper.serialize(config.getOnlineApplication());
-// String authCompGeneralJson = mapper.serialize(config.getAuthComponentGeneral());
-// String chainingModeJson = mapper.serialize(config.getChainingModes());
-// String defaultBKUJson = mapper.serialize(config.getDefaultBKUs());
-// String genericConfigJson = mapper.serialize(config.getGenericConfiguration());
-// String pvp2RefreshJson = mapper.serialize(config.getPvp2RefreshItem());
-// String slRequestTemplatesJson = mapper.serialize(config.getSLRequestTemplates());
-// String timestampJson = mapper.serialize(config.getTimestampItem());
-// String trustedCaCertJson = mapper.serialize(config.getTrustedCACertificates());
-//
-// // add to properties
-// result.put(MOAIDConfigurationConstants.ONLINE_APPLICATIONS_KEY, oaJson);
-// result.put(MOAIDConfigurationConstants.AUTH_COMPONENT_GENERAL_KEY, authCompGeneralJson);
-// result.put(MOAIDConfigurationConstants.CHAINING_MODES_KEY, chainingModeJson);
-// result.put(MOAIDConfigurationConstants.DEFAULT_BKUS_KEY, defaultBKUJson);
-// result.put(MOAIDConfigurationConstants.GENERIC_CONFIGURATION_KEY, genericConfigJson);
-// result.put(MOAIDConfigurationConstants.PVP2REFRESH_ITEM_KEY, pvp2RefreshJson);
-// result.put(MOAIDConfigurationConstants.SLREQUEST_TEMPLATES_KEY, slRequestTemplatesJson);
-// result.put(MOAIDConfigurationConstants.TIMESTAMP_ITEM_KEY, timestampJson);
-// result.put(MOAIDConfigurationConstants.TRUSTED_CERTIFICATES_KEY, trustedCaCertJson);
-//
-// return result;
-// }
-//
-// /**
-// * Exports a key-value database to a property file, where keys are the same
-// * as in the database, and the values are serialized JSON objects.
-// *
-// * @param inputDBConfigFilePath
-// * the path to the database properties, for the db the data is
-// * read from.
-// * @param outFile
-// * the destination file for the exported data.
-// */
-// public void readFromDBWriteToFile(String inputDBConfigFilePath, File outFile) {
-//
-// try (FileOutputStream outStream = new FileOutputStream(outFile);) {
-//
-// Properties result = new Properties();
-//
-// System.getProperties().setProperty("location", "file:" + inputDBConfigFilePath);
-// ApplicationContext context = new ClassPathXmlApplicationContext("configuration.beans.xml");
-// Configuration dbConfiguration = (Configuration) context.getBean("config");
-// boolean prettyPrint = true;
-// at.gv.egovernment.moa.id.commons.config.persistence.JsonMapper mapper = new JsonMapper(prettyPrint);
-//
-// for (String key : MOAIDConfigurationConstants.getAllMOAIDConfigurationKeys()) {
-//
-// // extract database value
-// Object value = dbConfiguration.get(key);
-//
-// // serialize value to JSON
-// String json = mapper.serialize(value);
-//
-// // add to properties
-// result.setProperty(key, json);
-// }
-//
-// // write to output stream
-// result.store(outStream, null);
-//
-// System.out.println("Property configuration written to:");
-// System.out.println(outFile.getAbsolutePath());
-//
-// } catch (FileNotFoundException e) {
-// System.out.println("Could not find the output file.");
-// System.exit(1);
-// } catch (IOException e) {
-// System.out.println("Could not write to the output file.");
-// System.exit(1);
-// }
-// }
-//
-// /**
-// * Read an input property file, deserialize it's values and write them to
-// * the given database.
-// *
-// * @param inStream
-// * the FileInputStream to read from.
-// * @param outputDBConfigFilePath
-// * the path to the database properties, for the db which is
-// * written.
-// * @throws IOException
-// * is thrown in case the properties could not be loaded from the
-// * stream
-// */
-// public void readFromFileWriteToDB(FileInputStream inStream, String outputDBConfigFilePath) throws IOException {
-//
-// Properties inProperties = new Properties();
-// inProperties.load(inStream);
-//
-// System.getProperties().setProperty("location", "file:" + outputDBConfigFilePath);
-// ApplicationContext context = new ClassPathXmlApplicationContext("configuration.beans.xml");
-// Configuration dbConfiguration = (Configuration) context.getBean("config");
-// boolean prettyPrint = true;
-// JsonMapper mapper = new JsonMapper(prettyPrint);
-//
-// List<String> keys = dbConfiguration.getAllKeys();
-//
-// if (keys == null) {
-// System.out.println("Database can not be read.");
-// System.exit(1);
-// }
-//
-// if (!keys.isEmpty() && !isOverwriteData) {
-// System.out.println("The database already contains configuration data.");
-// System.out.println("Use force switch if you want to override data)");
-// System.exit(1);
-// }
-//
-// if (isOverwriteData) {
-// // remove existing entries
-// for (String key : keys) {
-// dbConfiguration.set(key, null);
-// }
-// }
-//
-// Enumeration<?> propertyNames = inProperties.propertyNames();
-//
-// while (propertyNames.hasMoreElements()) {
-// String key = (String) propertyNames.nextElement();
-// // extract database value
-// String json = inProperties.getProperty(key);
-//
-// // deserialize value to object
-// Object value = mapper.deserialize(json, null);
-//
-// // add to database
-// boolean result = dbConfiguration.set(key, value);
-// if (!result) {
-// System.out.println("Could NOT persist the configuration file's information in the database.");
-// }
-// }
-// System.out.println("Data has been successfully written to the database.");
-// }
-//
-// private static void readFromDBWriteToDB(String inputDBConfigFilePath, String outputDBConfigFilePath) {
-// //TODO: implement
-// }
-//
-//}
+package at.gv.egovernment.moa.id.commons.config;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.Enumeration;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Unmarshaller;
+
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+import org.springframework.transaction.annotation.Transactional;
+
+import at.gv.egiz.components.configuration.api.Configuration;
+import at.gv.egiz.components.configuration.api.ConfigurationException;
+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.logging.Logger;
+import at.gv.egovernment.moa.util.MiscUtil;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+
+public class ConfigurationUtil {
+
+ final boolean isOverwriteData;
+
+ public ConfigurationUtil(boolean isOverwriteData){
+ this.isOverwriteData = isOverwriteData;
+ }
+
+ /**
+ * Read an input MOAID 2 XML file, transfer it to properties and write the
+ * properties to a MOAID 3 property file.
+ *
+ * @param inStream
+ * the input stream to read from.
+ * @param outFile
+ * the output file to write to.
+ * @throws JAXBException
+ */
+ public void readFromXMLFileConvertToPropertyFile(FileInputStream inStream, File outFile) throws JAXBException {
+
+ try (FileOutputStream outStream = new FileOutputStream(outFile);) {
+
+ // get config from xml file
+ JAXBContext jc = JAXBContext.newInstance("at.gv.egovernment.moa.id.commons.db.dao.config");
+ Unmarshaller m = jc.createUnmarshaller();
+ MOAIDConfiguration config = (MOAIDConfiguration) m.unmarshal(inStream);
+
+ // serialize config to JSON properties
+ Properties result = moaIdConfigToJsonProperties(config);
+
+ // write to output stream
+ result.store(outStream, null);
+
+ } catch (FileNotFoundException e) {
+ System.out.println("Could not find the output file.");
+ System.exit(1);
+ } catch (IOException e) {
+ System.out.println("Could not write to the output file.");
+ System.exit(1);
+ }
+ }
+
+ /**
+ * Helper method to serialize a {@link MOAIDConfiguration} to Properties
+ * with JSON encoded values.
+ *
+ * @param config
+ * the MOAIDConfiguration to serialize
+ * @return {@link Properties} containing the database key and the serialized
+ * values
+ * @throws JsonProcessingException
+ * is thrown if problem occurred while serializing one of the
+ * database values
+ */
+ private Properties moaIdConfigToJsonProperties(MOAIDConfiguration config) throws JsonProcessingException {
+
+ Properties result = new Properties();
+
+ //convert all online applications
+ List<OnlineApplication> oaList = config.getOnlineApplication();
+ for (int i=0; i<oaList.size(); i++) {
+ OnlineApplication oa = oaList.get(i);
+ Map<String, String> keyValueOA = ConfigurationMigrationUtils.convertHyberJaxBOnlineApplicationToKeyValue(oa);
+
+ String serviceIdentifier = keyValueOA.get(MOAIDConfigurationConstants.PREFIX_SERVICES);
+ if (MiscUtil.isEmpty(serviceIdentifier)) {
+ Logger.info("Use default ServiceIdentifier.");
+ serviceIdentifier = MOAIDConfigurationConstants.PREFIX_OA;
+ }
+
+ //write all OA key/value pairs to configuration
+ for (String key : keyValueOA.keySet()) {
+ if (MiscUtil.isNotEmpty(keyValueOA.get(key)))
+ result.put(MOAIDConfigurationConstants.PREFIX_MOAID_SERVICES
+ + "." + serviceIdentifier + "." + String.valueOf(i) + "."
+ + key,
+ keyValueOA.get(key));
+
+ }
+ }
+
+ Map<String, String> keyValueGeneral = ConfigurationMigrationUtils.convertHyberJaxBMOAIDConfigToKeyValue(config);
+ //write all OA key/value pairs to configuration
+ for (String key : keyValueGeneral.keySet()) {
+ if (MiscUtil.isNotEmpty(keyValueGeneral.get(key)))
+ result.put(key, keyValueGeneral.get(key));
+
+ }
+
+ return result;
+ }
+
+ /**
+ * Exports a key-value database to a property file, where keys are the same
+ * as in the database, and the values are serialized JSON objects.
+ *
+ * @param inputDBConfigFilePath
+ * the path to the database properties, for the db the data is
+ * read from.
+ * @param outFile
+ * the destination file for the exported data.
+ */
+ public void readFromDBWriteToFile(String inputDBConfigFilePath, File outFile) {
+
+ try (FileOutputStream outStream = new FileOutputStream(outFile);) {
+
+ Properties result = new Properties();
+
+ System.getProperties().setProperty("location", "file:" + inputDBConfigFilePath);
+ ApplicationContext context = new ClassPathXmlApplicationContext("configuration.beans.xml");
+ Configuration dbConfiguration = (Configuration) context.getBean("config");
+ String[] allKeys = dbConfiguration.getConfigurationIds();
+
+ for (String key : allKeys) {
+
+ // extract database value
+ String value = dbConfiguration.getStringValue(key);
+
+ // add to properties
+ result.setProperty(key, value);
+ }
+
+ // write to output stream
+ result.store(outStream, null);
+
+ System.out.println("Property configuration written to:");
+ System.out.println(outFile.getAbsolutePath());
+
+ } catch (FileNotFoundException e) {
+ System.out.println("Could not find the output file.");
+ System.exit(1);
+ } catch (IOException e) {
+ System.out.println("Could not write to the output file.");
+ System.exit(1);
+
+ } catch (ConfigurationException e) {
+ System.out.println("Could not read from database.");
+ System.exit(1);
+
+ }
+ }
+
+ /**
+ * Read an input property file, deserialize it's values and write them to
+ * the given database.
+ *
+ * @param inStream
+ * the FileInputStream to read from.
+ * @param outputDBConfigFilePath
+ * the path to the database properties, for the db which is
+ * written.
+ * @throws IOException
+ * is thrown in case the properties could not be loaded from the
+ * stream
+ */
+ @Transactional
+ public void readFromFileWriteToDB(FileInputStream inStream, String outputDBConfigFilePath) throws IOException {
+
+ Properties inProperties = new Properties();
+ inProperties.load(inStream);
+
+ System.getProperties().setProperty("location", "file:" + outputDBConfigFilePath);
+ ApplicationContext context = new ClassPathXmlApplicationContext("configuration.beans.xml");
+ Configuration dbConfiguration = (Configuration) context.getBean("moaidconfig");
+
+ List<String> keys = null;
+ try {
+ keys = Arrays.asList(dbConfiguration.getConfigurationIds());
+
+ } catch (ConfigurationException e1) {
+ System.out.println("Database can not be read.");
+ System.exit(1);
+ }
+
+ if (keys == null) {
+ System.out.println("Database can not be read.");
+ System.exit(1);
+ }
+
+ if (!keys.isEmpty() && !isOverwriteData) {
+ System.out.println("The database already contains configuration data.");
+ System.out.println("Use force switch if you want to override data)");
+ System.exit(1);
+ }
+
+ if (isOverwriteData) {
+ // remove existing entries
+ for (String key : keys) {
+ try {
+ dbConfiguration.setStringValue(key, null);
+ } catch (ConfigurationException e) {
+ System.out.println("Could NOT persist the configuration file's information in the database.");
+
+ }
+ }
+ }
+
+ Enumeration<?> propertyNames = inProperties.propertyNames();
+
+ while (propertyNames.hasMoreElements()) {
+ String key = (String) propertyNames.nextElement();
+ String json = inProperties.getProperty(key);
+
+ // add to database
+ try {
+ dbConfiguration.setStringValue(key, json);
+
+ } catch (ConfigurationException e) {
+ System.out.println("Could NOT persist the configuration file's information in the database.");
+
+ }
+
+
+
+ }
+ System.out.println("Data has been successfully written to the database.");
+ }
+
+ private static void readFromDBWriteToDB(String inputDBConfigFilePath, String outputDBConfigFilePath) {
+ //TODO: implement
+ }
+
+}
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 6799fcb13..884587d36 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
@@ -1,5 +1,9 @@
package at.gv.egovernment.moa.id.commons.config;
+import java.util.Collections;
+import java.util.Hashtable;
+import java.util.Map;
+
/**
*
*
@@ -10,6 +14,29 @@ public final class MOAIDConfigurationConstants {
// restrict instantiation
}
+ //general configuration constants
+
+ public static final String PREFIX_WPBK = "urn:publicid:gv.at:wbpk+";
+ public static final String PREFIX_STORK = "urn:publicid:gv.at:storkid+";
+
+ public static final String IDENIFICATIONTYPE_FN = "FN";
+ public static final String IDENIFICATIONTYPE_ERSB = "ERSB";
+ public static final String IDENIFICATIONTYPE_ZVR = "ZVR";
+ public static final String IDENIFICATIONTYPE_STORK = "STORK";
+
+ public static final Map<String, String> BUSINESSSERVICENAMES;
+
+ static {
+ Hashtable<String, String> tmp = new Hashtable<String, String>();
+ tmp.put(IDENIFICATIONTYPE_FN, "Firmenbuchnummer");
+ tmp.put(IDENIFICATIONTYPE_ZVR, "Vereinsnummer");
+ tmp.put(IDENIFICATIONTYPE_ERSB, "ERsB Kennzahl");
+ tmp.put(IDENIFICATIONTYPE_STORK, "STORK");
+
+ BUSINESSSERVICENAMES = Collections.unmodifiableMap(tmp);
+ }
+
+
//Basic key namespaces
public static final String PREFIX_MOAID = "moa.id";
public static final String PREFIX_GENERAL = "general";
@@ -27,10 +54,10 @@ public final class MOAIDConfigurationConstants {
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
+ public static final String SERVICE_UNIQUEIDENTIFIER = "uniqueID"; //publicURLPrefix
+ public static final String SERVICE_FRIENDLYNAME = "friendlyName"; //friendlyName
+ public static final String SERVICE_BUSINESSSERVICE = "businessservice"; //type
+ public static final String SERVICE_ISACTIVE = "isActive"; //isActive
//service authentication keys
private static final String AUTH = "auth";
@@ -49,23 +76,37 @@ public final class MOAIDConfigurationConstants {
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_TARGET = AUTH + "." + TARGET;
+ private static final String SERVICE_AUTH_TARGET_PUBLIC = SERVICE_AUTH_TARGET + ".public";
+ private static final String SERVICE_AUTH_TARGET_BUSINESS = SERVICE_AUTH_TARGET + ".business";
+ public static final String SERVICE_AUTH_TARGET_BUSINESS_TYPE = SERVICE_AUTH_TARGET_BUSINESS + ".type";
+ public static final String SERVICE_AUTH_TARGET_BUSINESS_VALUE = SERVICE_AUTH_TARGET_BUSINESS + ".value";
+
+ public static final String SERVICE_AUTH_TARGET_PUBLIC_TARGET = SERVICE_AUTH_TARGET_PUBLIC + ".target";
+ public static final String SERVICE_AUTH_TARGET_PUBLIC_TARGET_SUB = SERVICE_AUTH_TARGET_PUBLIC + ".target.sub";
+ public static final String SERVICE_AUTH_TARGET_PUBLIC_USE_SUB = SERVICE_AUTH_TARGET_PUBLIC + ".use.sub";
+ public static final String SERVICE_AUTH_TARGET_PUBLIC_USE_OWN = SERVICE_AUTH_TARGET_PUBLIC + ".use.own";
+ public static final String SERVICE_AUTH_TARGET_PUBLIC_OWN_TARGET = SERVICE_AUTH_TARGET_PUBLIC + ".own.target";
+ public static final String SERVICE_AUTH_TARGET_PUBLIC_OWN_NAME = SERVICE_AUTH_TARGET_PUBLIC + ".own.name";
+
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_TEMPLATE = SERVICE_AUTH_BKU + ".template"; //SecurityLayer Templates
+ public static final String SERVICE_AUTH_BKU_TEMPLATE_LEGACY = SERVICE_AUTH_BKU_TEMPLATE + ".legacy";
+ public static final String SERVICE_AUTH_BKU_TEMPLATE_FIRST_VALUE = SERVICE_AUTH_BKU_TEMPLATE + ".first.url";
+ public static final String SERVICE_AUTH_BKU_TEMPLATE_SECOND_VALUE = SERVICE_AUTH_BKU_TEMPLATE + ".second.url";
+ public static final String SERVICE_AUTH_BKU_TEMPLATE_THIRD_VALUE = SERVICE_AUTH_BKU_TEMPLATE + ".third.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_BKUSELECTION_FILENAME = SERVICE_AUTH_TEMPLATES + ".bkuselection.filename";
public static final String SERVICE_AUTH_TEMPLATES_SENDASSERTION = SERVICE_AUTH_TEMPLATES + ".sendAssertion";
+ public static final String SERVICE_AUTH_TEMPLATES_SENDASSERTION_FILENAME = SERVICE_AUTH_TEMPLATES + ".sendAssertion.filename";
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";
@@ -85,10 +126,19 @@ public final class MOAIDConfigurationConstants {
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_USE = SERVICE_AUTH_MANDATES + "use";
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
+ public static final String SERVICE_AUTH_FOREIGNBPK = AUTH + "." + FOREIGNBPK;
+ public static final String SERVICE_AUTH_FOREIGNBPK_DECRYPT = SERVICE_AUTH_FOREIGNBPK + ".decrypt";
+ public static final String SERVICE_AUTH_FOREIGNBPK_DECRYPT_IV = SERVICE_AUTH_FOREIGNBPK_DECRYPT + ".iv";
+ public static final String SERVICE_AUTH_FOREIGNBPK_DECRYPT_BLOB = SERVICE_AUTH_FOREIGNBPK_DECRYPT + ".blob";
+ public static final String SERVICE_AUTH_FOREIGNBPK_DECRYPT_FILENAME= SERVICE_AUTH_FOREIGNBPK_DECRYPT + ".filename";
+ public static final String SERVICE_AUTH_FOREIGNBPK_DECRYPT_KEYSTORE = SERVICE_AUTH_FOREIGNBPK_DECRYPT + ".keystore";
+ public static final String SERVICE_AUTH_FOREIGNBPK_DECRYPT_KEYSTOREPASSWORD = SERVICE_AUTH_FOREIGNBPK_DECRYPT + ".keystore.password";
+ public static final String SERVICE_AUTH_FOREIGNBPK_DECRYPT_KEYALIAS = SERVICE_AUTH_FOREIGNBPK_DECRYPT + ".key.alias";
+ public static final String SERVICE_AUTH_FOREIGNBPK_DECRYPT_KEYPASSWORD = SERVICE_AUTH_FOREIGNBPK_DECRYPT + ".key.password";
private static final String SERVICE_AUTH_SSO = AUTH + "." + SSO;
public static final String SERVICE_AUTH_SSO_ENABLED = SERVICE_AUTH_SSO + ".enabled";
@@ -96,11 +146,14 @@ public final class MOAIDConfigurationConstants {
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_MINQAALEVEL = SERVICE_AUTH_STORK + ".minqaalevel";
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_COUNTRIES_LIST_COUNTRYCODE = "countrycode";
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_ATTRIBUTES_LIST_MANDATORY = "mandatory";
+ public static final String SERVICE_AUTH_STORK_ATTRIBUTES_LIST_REQUESTED = "requested";
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";
@@ -120,6 +173,7 @@ public final class MOAIDConfigurationConstants {
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";
+ public static final String SERVICE_PROTOCOLS_PVP2X_CERTIFICATE_SUBJECT = SERVICE_PROTOCOLS_PVP2X + ".certificate.subject";
private static final String SERVICE_PROTOCOLS_OPENID = PROTOCOLS + "." + OPENID;
public static final String SERVICE_PROTOCOLS_OPENID_CLIENTID = SERVICE_PROTOCOLS_OPENID + ".clientID";
@@ -139,9 +193,9 @@ public final class MOAIDConfigurationConstants {
//Namespaces for general MOA-ID config
- public static final String GENERAL_PUBLICURLPREFIX = "publicURLPrefix";
+ public static final String GENERAL_PUBLICURLPREFIX = PREFIX_MOAID_GENERAL + ".publicURLPrefix";
- private static final String GENERAL_DEFAULTS = "defaults";
+ private static final String GENERAL_DEFAULTS = PREFIX_MOAID_GENERAL + ".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";
@@ -151,7 +205,7 @@ public final class MOAIDConfigurationConstants {
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";
+ private static final String GENERAL_AUTH = PREFIX_MOAID_GENERAL + ".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";
@@ -175,7 +229,7 @@ public final class MOAIDConfigurationConstants {
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";
- public static final String GENERAL_PROTOCOLS = PROTOCOLS;
+ public static final String GENERAL_PROTOCOLS = PREFIX_MOAID_GENERAL + "." + PROTOCOLS;
public static final String GENERAL_PROTOCOLS_SAML1 = GENERAL_PROTOCOLS + "." + SAML1;
public static final String GENERAL_PROTOCOLS_PVP2X = GENERAL_PROTOCOLS + "." + PVP2X;
public static final String GENERAL_PROTOCOLS_OPENID = GENERAL_PROTOCOLS + "." + OPENID;
diff --git a/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/config/MigrateConfiguration.java b/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/config/MigrateConfiguration.java
index 32dd97148..4e8c7dffd 100644
--- a/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/config/MigrateConfiguration.java
+++ b/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/config/MigrateConfiguration.java
@@ -1,103 +1,103 @@
-//package at.gv.egovernment.moa.id.commons.config;
-//
-//import java.io.File;
-//import java.io.FileInputStream;
-//import java.io.FileNotFoundException;
-//import java.io.IOException;
-//
-//import javax.xml.bind.JAXBException;
-//
-//import at.gv.egovernment.moa.id.commons.config.cli.MOAIDConfCLI;
-//import at.gv.egovernment.moa.id.commons.config.cli.MigrateConfigurationParams;
-//
-///**
-// * CLI tool which is able to perform the following tasks:
-// * <ul>
-// * <li>transform a MoaID 2 XML configuration XML file to a MoaID 3 property file
-// * </li>
-// * <li>read a property file and transfer it's content to a database</li>
-// * <li>write the content of a database to a property file</li>
-// * </ul>
-// */
-//public class MigrateConfiguration {
-//
-// public static void main(String[] args) {
-//
-// MOAIDConfCLI cli = new MOAIDConfCLI();
-// MigrateConfigurationParams parsedParameters = cli.parse(args);
-//
-// // consider settings of force switch
-// boolean isOverwriteData = parsedParameters.isOverwriteData();
-// ConfigurationUtil configUtil = new ConfigurationUtil(isOverwriteData);
-//
-// if (!parsedParameters.isInputDB() && (parsedParameters.getInputTarget() != null)) {
-// // read input from file
-// workWithInputFromFile(parsedParameters.getInputTarget(), parsedParameters, configUtil);
-//
-// } else if (parsedParameters.getInputDBConfig() != null) {
-// // read input from database
-// workWithImputFromDB(parsedParameters, configUtil);
-//
-// } else {
-// System.exit(1);
-// }
-// }
-//
-// /**
-// * Handle the case where input from a file is read.
-// *
-// * @param inputFileUrl
-// * the url of the input file.
-// * @param parsedParameters
-// * the command line parameters.
-// * @param configUtil
-// * the class for working with the configuration.
-// */
-// private static void workWithInputFromFile(String inputFileUrl, MigrateConfigurationParams parsedParameters,
-// ConfigurationUtil configUtil) {
-// File inFile = new File(inputFileUrl);
-// try (FileInputStream inStream = new FileInputStream(inFile);) {
-//
-// if (!parsedParameters.isOutputDB() && (parsedParameters.getOutputFile() != null)) {
-// // input from file and output to a file is desired
-// File outFile = new File(parsedParameters.getOutputFile());
-// configUtil.readFromXMLFileConvertToPropertyFile(inStream, outFile);
-//
-// } else if (parsedParameters.getOutputDBConfig() != null) {
-// // input from file and output to a database is desired
-// configUtil.readFromFileWriteToDB(inStream, parsedParameters.getOutputDBConfig());
-// }
-// } catch (JAXBException e) {
-// System.out.println("MOA-ID XML configuration can not be loaded from given file.");
-// System.exit(1);
-// } catch (FileNotFoundException e) {
-// System.out.println("Could not find the input file.");
-// System.exit(1);
-// } catch (IOException e) {
-// System.out.println("Could not read from the input file.");
-// System.exit(1);
-// }
-// }
-//
-// /**
-// * Handle the case where input is read from a database.
-// *
-// * @param parsedParameters
-// * the command line parameters.
-// * @param configUtil
-// * the class for working with the configuration.
-// */
-// private static void workWithImputFromDB(MigrateConfigurationParams parsedParameters, ConfigurationUtil configUtil) {
-// if (!parsedParameters.isOutputDB() && (parsedParameters.getOutputFile() != null)) {
-// // input from database and output to a file is desired
-// File outFile = new File(parsedParameters.getOutputFile());
-// String inputDBConfigFilePath = parsedParameters.getInputDBConfig();
-// configUtil.readFromDBWriteToFile(inputDBConfigFilePath, outFile);
-//
-// } else if (parsedParameters.getOutputDBConfig() != null) {
-// // input from database and output to a database is desired
-// // configUtil.readFromDBWriteToDB(inDBConfigFilePath,
-// // outDBConfigFilePath);
-// }
-// }
-//} \ No newline at end of file
+package at.gv.egovernment.moa.id.commons.config;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+
+import javax.xml.bind.JAXBException;
+
+import at.gv.egovernment.moa.id.commons.config.cli.MOAIDConfCLI;
+import at.gv.egovernment.moa.id.commons.config.cli.MigrateConfigurationParams;
+
+/**
+ * CLI tool which is able to perform the following tasks:
+ * <ul>
+ * <li>transform a MoaID 2 XML configuration XML file to a MoaID 3 property file
+ * </li>
+ * <li>read a property file and transfer it's content to a database</li>
+ * <li>write the content of a database to a property file</li>
+ * </ul>
+ */
+public class MigrateConfiguration {
+
+ public static void main(String[] args) {
+
+ MOAIDConfCLI cli = new MOAIDConfCLI();
+ MigrateConfigurationParams parsedParameters = cli.parse(args);
+
+ // consider settings of force switch
+ boolean isOverwriteData = parsedParameters.isOverwriteData();
+ ConfigurationUtil configUtil = new ConfigurationUtil(isOverwriteData);
+
+ if (!parsedParameters.isInputDB() && (parsedParameters.getInputTarget() != null)) {
+ // read input from file
+ workWithInputFromFile(parsedParameters.getInputTarget(), parsedParameters, configUtil);
+
+ } else if (parsedParameters.getInputDBConfig() != null) {
+ // read input from database
+ workWithImputFromDB(parsedParameters, configUtil);
+
+ } else {
+ System.exit(1);
+ }
+ }
+
+ /**
+ * Handle the case where input from a file is read.
+ *
+ * @param inputFileUrl
+ * the url of the input file.
+ * @param parsedParameters
+ * the command line parameters.
+ * @param configUtil
+ * the class for working with the configuration.
+ */
+ private static void workWithInputFromFile(String inputFileUrl, MigrateConfigurationParams parsedParameters,
+ ConfigurationUtil configUtil) {
+ File inFile = new File(inputFileUrl);
+ try (FileInputStream inStream = new FileInputStream(inFile);) {
+
+ if (!parsedParameters.isOutputDB() && (parsedParameters.getOutputFile() != null)) {
+ // input from file and output to a file is desired
+ File outFile = new File(parsedParameters.getOutputFile());
+ configUtil.readFromXMLFileConvertToPropertyFile(inStream, outFile);
+
+ } else if (parsedParameters.getOutputDBConfig() != null) {
+ // input from file and output to a database is desired
+ configUtil.readFromFileWriteToDB(inStream, parsedParameters.getOutputDBConfig());
+ }
+ } catch (JAXBException e) {
+ System.out.println("MOA-ID XML configuration can not be loaded from given file.");
+ System.exit(1);
+ } catch (FileNotFoundException e) {
+ System.out.println("Could not find the input file.");
+ System.exit(1);
+ } catch (IOException e) {
+ System.out.println("Could not read from the input file.");
+ System.exit(1);
+ }
+ }
+
+ /**
+ * Handle the case where input is read from a database.
+ *
+ * @param parsedParameters
+ * the command line parameters.
+ * @param configUtil
+ * the class for working with the configuration.
+ */
+ private static void workWithImputFromDB(MigrateConfigurationParams parsedParameters, ConfigurationUtil configUtil) {
+ if (!parsedParameters.isOutputDB() && (parsedParameters.getOutputFile() != null)) {
+ // input from database and output to a file is desired
+ File outFile = new File(parsedParameters.getOutputFile());
+ String inputDBConfigFilePath = parsedParameters.getInputDBConfig();
+ configUtil.readFromDBWriteToFile(inputDBConfigFilePath, outFile);
+
+ } else if (parsedParameters.getOutputDBConfig() != null) {
+ // input from database and output to a database is desired
+ // configUtil.readFromDBWriteToDB(inDBConfigFilePath,
+ // outDBConfigFilePath);
+ }
+ }
+} \ 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/MOAIDConfiguration.java b/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/config/persistence/MOAIDConfiguration.java
index 159b587df..fbb1597f3 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
@@ -1,5 +1,6 @@
package at.gv.egovernment.moa.id.commons.config.persistence;
+import java.util.Map;
import java.util.Properties;
import at.gv.egiz.components.configuration.api.Configuration;
@@ -13,71 +14,42 @@ public interface MOAIDConfiguration extends Configuration {
/**
* Get all key/value pairs with a prefix
*
- * @param preFix A key prefix
- * @return All key/value pairs with this prefix. The prefix is removed from the key.
+ * @param preFix: A key prefix
+ * @param removePrefix: Indicates, if the prefix should be removed from the result key
+ * @return All key/value pairs with this prefix or null if no key is found. The prefix is removed from the key.
*
**/
- public Properties getPropertySubset(String preFix) throws ConfigurationException;
+ public Map<String, String> getPropertySubset(String preFix) throws ConfigurationException;
/**
+ * Searches the configuration use '*' or '%' for wildcards.
+ *
+ * Example:
+ *
+ * db.server1.url=...
+ * db.server1.user=...
+ * db.server1.password=...
+ * db.server1.driver=...
+ * db.server2.url=...
+ * db.server2.user=...
+ * db.server2.password=...
+ * db.server2.driver=...
+ *
+ * searchString: "db.server1.*" returns
+ * ["db.server1.url", "db.server1.user", "db.server1.password", "db.server1.driver"]
+ * @param searchkey The search string
+ * @return All key/value pairs with this prefix or null if no key is found. The prefix is not removed from the key.
+ * @throws ConfigurationException if something went wrong
+ */
+ public Map<String, String> searchPropertiesWithWildcard(String searchkey) 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
*/
- public Properties getOnlineApplication(String publicURLPrefix) throws ConfigurationException;
-
-
-// /**
-// * Gets all keys in the database. NOTE: may return an empty list or {@code null}.
-// * @return a List containing all keys in the database or {@code null}.
-// */
-// List<String> getAllKeys();
-//
-// /**
-// * Get the value associated with the given key as {@link Object}.
-// * @param key the key
-// * @return the String associated with the given key or {@code null} if the key does not exist or does not have a value.
-// */
-// String get(String key);
-//
-// /**
-// * Get the object of type {@code T} associated with the given key.
-// *
-// * @param key the key
-// * @param clazz the type of the requested object
-// * @return the object associated with the given key or {@code null} if the key does not exist or does not have a value.
-// */
-// <T> T get(String key, Class<T> clazz);
-//
-// /**
-// * 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 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, 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);
-
+ public Map<String, String> getOnlineApplication(String publicURLPrefix) throws ConfigurationException;
} \ 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
index 2d652d748..06e174942 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,51 +1,108 @@
package at.gv.egovernment.moa.id.commons.config.persistence;
+import java.util.HashMap;
+import java.util.Iterator;
import java.util.List;
-import java.util.Properties;
+import java.util.Map;
import javax.persistence.EntityManager;
import javax.persistence.TypedQuery;
-import org.springframework.beans.factory.annotation.Required;
import org.springframework.stereotype.Component;
+import org.springframework.stereotype.Repository;
+import org.springframework.transaction.annotation.EnableTransactionManagement;
+import org.springframework.transaction.annotation.Transactional;
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.id.commons.db.dao.config.DatabaseConfigPropertyImpl;
+import at.gv.egovernment.moa.id.commons.utils.KeyValueUtils;
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 {
-
- Configuration configPropertyDao;
-// private JsonMapper mapper = new JsonMapper();
+@Repository
+@EnableTransactionManagement
+@Transactional("transactionManager")
+public class MOAIDConfigurationImpl extends DatabaseConfigPropertyImpl implements MOAIDConfiguration {
- /**
- * Sets the {@link ConfigPropertyDao}.
- * @param configPropertyDao the ConfigPropertyDao
+// Configuration configPropertyDao;
+//
+// /**
+// * Sets the {@link ConfigPropertyDao}.
+// * @param configPropertyDao the ConfigPropertyDao
+// */
+// @Required
+// public void setConfigPropertyDao(Configuration configPropertyDao) {
+// this.configPropertyDao = configPropertyDao;
+// }
+
+ /* (non-Javadoc)
+ * @see at.gv.egovernment.moa.id.commons.config.persistence.MOAIDConfiguration#getPropertySubset(java.lang.String)
*/
- @Required
- public void setConfigPropertyDao(Configuration configPropertyDao) {
- this.configPropertyDao = configPropertyDao;
- }
+ public Map<String, String> getPropertySubset(String preFix) throws ConfigurationException{
+ EntityManager em = this.getPersistenceContext();
+ if (null == em) {
+ Logger.error("No EntityManager set!");
+ throw new ConfigurationException("No EntityManager set!");
+
+ }
+
+ TypedQuery<ConfigProperty> configQuery = em.createQuery("select * from ConfigProperty dbconfig where dbconfig.key like :key", ConfigProperty.class);
+ configQuery.setParameter("key", preFix + ".%");
+ List<ConfigProperty> configResult = configQuery.getResultList();
+ if (configResult == null || configResult.isEmpty()) {
+ Logger.warn("Found no configuration keys with prefix: " + preFix + ".%");
+ return null;
+
+ }
+ Logger.trace("Find " + configResult.size() + " key/value pairs with prefix: " + preFix + ".%");
+
+ //build key/value configuration map from database entries
+ Map<String, String> result = getKeyValueFromDatabaseDAO(
+ configResult.iterator(), preFix, true);
+ return result;
+
+ }
/* (non-Javadoc)
- * @see at.gv.egovernment.moa.id.commons.config.persistence.MOAIDConfiguration#getPropertySubset(java.lang.String)
+ * @see at.gv.egovernment.moa.id.commons.config.persistence.MOAIDConfiguration#searchPropertiesWithWildcard(java.lang.String)
*/
- public Properties getPropertySubset(String preFix) throws ConfigurationException{
- // TODO Auto-generated method stub
- return null;
+ @Override
+ public Map<String, String> searchPropertiesWithWildcard(String searchKey)
+ throws ConfigurationException {
+ EntityManager em = this.getPersistenceContext();
+ if (null == em) {
+ Logger.error("No EntityManager set!");
+ throw new ConfigurationException("No EntityManager set!");
+
+ }
+
+ TypedQuery<ConfigProperty> configQuery = em.createQuery("select * from ConfigProperty dbconfig where dbconfig.key like :key", ConfigProperty.class);
+ configQuery.setParameter("key", searchKey.replace("*", "%"));
+ List<ConfigProperty> configResult = configQuery.getResultList();
+
+ if (configResult == null || configResult.isEmpty()) {
+ Logger.warn("Found no configuration keys with searchKey: " + searchKey);
+ return null;
+
+ }
+ Logger.trace("Find " + configResult.size() + " key/value pairs with searchKey: " + searchKey);
+
+ //build key/value configuration map from database entries
+ Map<String, String> result = getKeyValueFromDatabaseDAO(
+ configResult.iterator(), null, false);
+ return result;
+
}
@Override
- public Properties getOnlineApplication(String publicURLPrefix)
+ public Map<String, String> getOnlineApplication(String publicURLPrefix)
throws ConfigurationException {
EntityManager em = this.getPersistenceContext();
if (null == em) {
@@ -54,148 +111,74 @@ public class MOAIDConfigurationImpl extends ConfigPropertyDaoImpl implements MOA
}
+ //search key prefix for online application with this publicURLPrefix
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();
+
+ TypedQuery<ConfigProperty> oaSearchQuery = em.createQuery("select dbconfig from ConfigProperty dbconfig where dbconfig.key like :key and dbconfig.value = SUBSTRING(:uniqueID, 1, LENGTH(dbconfig.value))", ConfigProperty.class);
+ oaSearchQuery.setParameter("key", keyId);
+ oaSearchQuery.setParameter("uniqueID", publicURLPrefix);
+ List<ConfigProperty> oaSearchResult = oaSearchQuery.getResultList();
- if (result.size() == 0) {
+ if (oaSearchResult.size() == 0) {
Logger.debug("No entries found.");
- return null;
- }
+ return null; }
- if (result.size() > 1) {
+ if (oaSearchResult.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);
+ String oaIdKey = oaSearchResult.get(0).getKey();
+ String oaIdValue = oaSearchResult.get(0).getValue();
+ Logger.trace("Find online application with uniqueID: " + oaIdValue + " and keyID: " + oaIdKey);
+ //load all online application key/value pairs from database
+ String oaType = KeyValueUtils.getFirstChildAfterPrefix(oaIdKey, MOAIDConfigurationConstants.PREFIX_MOAID_SERVICES);
+ String oaKey = KeyValueUtils.getPrefixFromKey(oaIdKey, MOAIDConfigurationConstants.SERVICE_UNIQUEIDENTIFIER);
-
- return null;
+ TypedQuery<ConfigProperty> oaConfigQuery = em.createQuery("select dbconfig from ConfigProperty dbconfig where dbconfig.key like :key", ConfigProperty.class);
+ oaConfigQuery.setParameter("key", oaKey + ".%");
+ List<ConfigProperty> oaConfigResult = oaConfigQuery.getResultList();
+
+ if (oaConfigResult == null) {
+ Logger.warn("Found no configuration keys with prefix: " + oaKey + ".%");
+ return null;
+ }
+ Logger.trace("Find " + oaConfigResult.size() + " key/value pairs with prefix: " + oaKey + ".%");
+
+ //build key/value configuration map from database entries
+ Map<String, String> result = getKeyValueFromDatabaseDAO(
+ oaConfigResult.iterator(), oaKey, true);
+ result.put(MOAIDConfigurationConstants.PREFIX_MOAID_SERVICES, oaType);
+
+ return result;
}
+
/**
- * Small helper method. NOTE: may return empty properties, but never {@code null}.
- * @param propPrefix the prefix of the desired property.
- * @return the {@link Properties}
+ * Small helper method. NOTE: may return empty configuration properties, but never {@code null}.
+ *
+ * @param propPrefix: the prefix of the desired property.
+ * @param input: List of database objects with key/value information.
+ * @param removePrefix: Indicates if the prefix should be removed from the result key
+ * @return the {@link Map} of configuration properties
*/
- private Properties getGeneralProperiesConfig(Properties input, final String propPrefix) {
-
- Properties configProp = new Properties();
- for (Object key : input.keySet()) {
- if (key.toString().startsWith(propPrefix)) {
- String propertyName = key.toString().substring(propPrefix.length());
- configProp.put(propertyName, input.get(key.toString()));
- }
+ private Map<String, String> getKeyValueFromDatabaseDAO(Iterator<ConfigProperty> input, final String prefix, boolean removePrefix) {
+ Map<String, String> configProp = new HashMap<String, String>();
+ while (input.hasNext()) {
+ ConfigProperty el = input.next();
+ if (removePrefix) {
+ if (el.getKey().startsWith(prefix)) {
+ String propertyName = KeyValueUtils.removePrefixFromKey(el.getKey(), prefix);
+ configProp.put(propertyName, el.getValue());
+
+ }
+ } else
+ configProp.put(el.getKey(), el.getValue());
+
}
return configProp;
}
-
-
-// @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/ConfigurationDBRead.java b/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/ConfigurationDBRead.java
index 22a7bf76b..5c14df671 100644
--- a/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/ConfigurationDBRead.java
+++ b/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/ConfigurationDBRead.java
@@ -71,333 +71,333 @@ public class ConfigurationDBRead {
QUERIES.put("searchOnlineApplicationsWithID", "select onlineapplication from OnlineApplication onlineapplication where onlineapplication.friendlyName like :id");
}
- public static OnlineApplication getActiveOnlineApplication(String id) {
- MiscUtil.assertNotNull(id, "OnlineApplictionID");
- Logger.trace("Getting OnlineApplication with ID " + id + " from database.");
-
- List result;
- EntityManager session = ConfigurationDBUtils.getCurrentSession();
-
- javax.persistence.Query query = session.createQuery(QUERIES.get("getActiveOnlineApplicationWithID"));
- //query.setParameter("id", id+"%");
- query.setParameter("id", StringEscapeUtils.escapeHtml4(id));
- result = query.getResultList();
-
- Logger.trace("Found entries: " + result.size());
-
- 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;
- }
-
- return (OnlineApplication) result.get(0);
- }
-
- public static OnlineApplication getOnlineApplication(String id) {
- MiscUtil.assertNotNull(id, "OnlineApplictionID");
- Logger.trace("Getting OnlineApplication with ID " + id + " from database.");
-
- List result;
- EntityManager session = ConfigurationDBUtils.getCurrentSession();
-
- javax.persistence.Query query = session.createQuery(QUERIES.get("getOnlineApplicationWithID"));
- //query.setParameter("id", id+"%");
- query.setParameter("id", id);
- result = query.getResultList();
-
- Logger.trace("Found entries: " + result.size());
-
- if (result.size() == 0) {
- Logger.trace("No entries found.");
- return null;
- }
-
- if (result.size() > 1) {
- Logger.warn("OAIdentifier match to more then one DB-entry!");
- return null;
- }
-
- return (OnlineApplication) result.get(0);
- }
-
- public static OnlineApplication getOnlineApplication(long dbid) {
- MiscUtil.assertNotNull(dbid, "OnlineApplictionID");
- Logger.trace("Getting OnlineApplication with DBID " + dbid + " from database.");
-
- List result;
- EntityManager session = ConfigurationDBUtils.getCurrentSession();
-
- javax.persistence.Query query = session.createQuery(QUERIES.get("getOnlineApplicationWithDBID"));
- //query.setParameter("id", id+"%");
- query.setParameter("id", dbid);
- result = query.getResultList();
-
- Logger.trace("Found entries: " + result.size());
-
- if (result.size() == 0) {
- Logger.trace("No entries found.");
- return null;
- }
-
- return (OnlineApplication) result.get(0);
- }
-
- @JsonProperty("getMOAIDConfiguration")
- public static MOAIDConfiguration getMOAIDConfiguration() {
- Logger.trace("Load MOAID Configuration from database.");
-
- List<MOAIDConfiguration> result;
- EntityManager session = ConfigurationDBUtils.getCurrentSession();
-
- javax.persistence.Query query = session.createQuery(QUERIES.get("getMOAIDConfiguration"));
- result = query.getResultList();
-
- Logger.trace("Found entries: " + result.size());
-
- if (result.size() == 0) {
- Logger.trace("No entries found. Create fresh instance.");
- return null;
- }
-
- return (MOAIDConfiguration) result.get(0);
- }
-
- @JsonProperty("getAllOnlineApplications")
- public static List<OnlineApplication> getAllOnlineApplications() {
- Logger.trace("Get All OnlineApplications from database.");
-
- List<OnlineApplication> result = null;
- EntityManager session = ConfigurationDBUtils.getCurrentSession();
-
- javax.persistence.Query query = session.createQuery(QUERIES.get("getAllOnlineApplications"));
- result = query.getResultList();
-
- Logger.trace("Found entries: " + result.size());
-
- if (result.size() == 0) {
- Logger.trace("No entries found.");
- return null;
- }
- return result;
- }
-
- public static List<OnlineApplication> getAllNewOnlineApplications() {
- Logger.trace("Get All OnlineApplications from database.");
-
- List<OnlineApplication> result;
- EntityManager session = ConfigurationDBUtils.getCurrentSession();
-
- javax.persistence.Query query = session.createQuery(QUERIES.get("getAllNewOnlineApplications"));
- result = query.getResultList();
-
- Logger.trace("Found entries: " + result.size());
-
- if (result.size() == 0) {
- Logger.trace("No entries found.");
- return null;
- }
- return result;
- }
-
- @JsonProperty("getAllUsers")
- public static List<UserDatabase> getAllUsers() {
- Logger.trace("Get All OnlineApplications from database.");
-
- List<UserDatabase> result;
- EntityManager session = ConfigurationDBUtils.getCurrentSession();
-
- javax.persistence.Query query = session.createQuery(QUERIES.get("getAllUsers"));
- result = query.getResultList();
-
- Logger.trace("Found entries: " + result.size());
-
- if (result.size() == 0) {
- Logger.trace("No entries found.");
- return null;
- }
- return result;
- }
-
- public static List<OnlineApplication> getAllActiveOnlineApplications() {
- Logger.trace("Get All active OnlineApplications from database.");
-
- List<OnlineApplication> result;
- EntityManager session = ConfigurationDBUtils.getCurrentSession();
-
- javax.persistence.Query query = session.createQuery(QUERIES.get("getAllActiveOnlineApplications"));
- result = query.getResultList();
-
- Logger.trace("Found entries: " + result.size());
-
- if (result.size() == 0) {
- Logger.trace("No entries found.");
- result = new ArrayList<OnlineApplication>();
-
- }
- return result;
- }
-
- @SuppressWarnings("rawtypes")
- public static List<OnlineApplication> searchOnlineApplications(String id) {
- MiscUtil.assertNotNull(id, "OnlineApplictionID");
- Logger.trace("Getting OnlineApplication with ID " + id + " from database.");
-
- List<OnlineApplication> result;
- EntityManager session = ConfigurationDBUtils.getCurrentSession();
-
- javax.persistence.Query query = session.createQuery(QUERIES.get("searchOnlineApplicationsWithID"));
- query.setParameter("id", "%" + id + "%");
-
- result = query.getResultList();
-
- Logger.trace("Found entries: " + result.size());
-
- if (result.size() == 0) {
- Logger.trace("No entries found.");
- return null;
- }
-
- return result;
- }
-
- public static UserDatabase getUserWithID(long id) {
- MiscUtil.assertNotNull(id, "UserID");
- Logger.trace("Getting Userinformation with ID " + id + " from database.");
-
- List<UserDatabase> result;
- EntityManager session = ConfigurationDBUtils.getCurrentSession();
-
- javax.persistence.Query query = session.createQuery(QUERIES.get("getUserWithUserID"));
- query.setParameter("id", id);
- result = query.getResultList();
-
- Logger.trace("Found entries: " + result.size());
-
- if (result.size() == 0) {
- Logger.trace("No entries found.");
- return null;
- }
- return (UserDatabase) result.get(0);
- }
-
- public static UserDatabase getUsersWithOADBID(long id) {
- MiscUtil.assertNotNull(id, "OADBID");
- Logger.trace("Getting Userinformation with OADBID " + id + " from database.");
-
- List<UserDatabase> result;
- EntityManager session = ConfigurationDBUtils.getCurrentSession();
-
- javax.persistence.Query query = session.createQuery(QUERIES.get("getUsersWithOADBID"));
- query.setParameter("id", id);
- result = query.getResultList();
-
- Logger.trace("Found entries: " + result.size());
-
- if (result.size() == 0) {
- Logger.trace("No entries found.");
- return null;
- }
- return (UserDatabase) result.get(0);
- }
-
- public static UserDatabase getUserWithUserName(String username) {
- MiscUtil.assertNotNull(username, "UserName");
- Logger.trace("Getting Userinformation with ID " + username + " from database.");
-
- List<UserDatabase> result;
- EntityManager session = ConfigurationDBUtils.getCurrentSession();
-
- javax.persistence.Query query = session.createQuery(QUERIES.get("getUserWithUserUsername"));
- query.setParameter("username", username);
- result = query.getResultList();
-
- Logger.trace("Found entries: " + result.size());
-
- if (result.size() == 0) {
- Logger.trace("No entries found.");
- return null;
- }
- return (UserDatabase) result.get(0);
- }
-
- public static UserDatabase getUserWithUserBPKWBPK(String bpkwbpk) {
- MiscUtil.assertNotNull(bpkwbpk, "bpk/wbpk");
- Logger.trace("Getting Userinformation with ID " + bpkwbpk + " from database.");
-
- List<UserDatabase> result;
- EntityManager session = ConfigurationDBUtils.getCurrentSession();
-
- javax.persistence.Query query = session.createQuery(QUERIES.get("getUserWithUserBPKWBPK"));
- query.setParameter("bpk", bpkwbpk);
- result = query.getResultList();
-
- Logger.trace("Found entries: " + result.size());
-
- if (result.size() == 0) {
- Logger.trace("No entries found.");
- return null;
- }
- return (UserDatabase) result.get(0);
- }
-
- public static UserDatabase getNewUserWithTokken(String tokken) {
- MiscUtil.assertNotNull(tokken, "bpk/wbpk");
- Logger.trace("Getting Userinformation with Tokken " + tokken + " from database.");
-
- List<UserDatabase> result;
- EntityManager session = ConfigurationDBUtils.getCurrentSession();
-
- javax.persistence.Query query = session.createQuery(QUERIES.get("getNewUserWithUserTokken"));
- query.setParameter("tokken", tokken);
- result = query.getResultList();
-
- Logger.trace("Found entries: " + result.size());
-
- if (result.size() == 0) {
- Logger.trace("No entries found.");
- return null;
- }
- return (UserDatabase) result.get(0);
- }
-
- public static List<UserDatabase> getAllNewUsers() {
- Logger.trace("Get all new Users from Database");
-
- List<UserDatabase> result;
- EntityManager session = ConfigurationDBUtils.getCurrentSession();
-
- javax.persistence.Query query = session.createQuery(QUERIES.get("getAllNewUsers"));
- result = query.getResultList();
-
- Logger.trace("Found entries: " + result.size());
-
- if (result.size() == 0) {
- Logger.trace("No entries found.");
- return null;
- }
- return result;
- }
-
- public static List<UserDatabase> getAllOpenUsersRequests() {
- Logger.trace("Get all new Users from Database");
-
- List<UserDatabase> result;
- EntityManager session = ConfigurationDBUtils.getCurrentSession();
-
- javax.persistence.Query query = session.createQuery(QUERIES.get("getAllOpenUsersRequests"));
- result = query.getResultList();
-
- Logger.trace("Found entries: " + result.size());
-
- if (result.size() == 0) {
- Logger.trace("No entries found.");
- return null;
- }
- return result;
- }
+// public static OnlineApplication getActiveOnlineApplication(String id) {
+// MiscUtil.assertNotNull(id, "OnlineApplictionID");
+// Logger.trace("Getting OnlineApplication with ID " + id + " from database.");
+//
+// List result;
+// EntityManager session = ConfigurationDBUtils.getCurrentSession();
+//
+// javax.persistence.Query query = session.createQuery(QUERIES.get("getActiveOnlineApplicationWithID"));
+// //query.setParameter("id", id+"%");
+// query.setParameter("id", StringEscapeUtils.escapeHtml4(id));
+// result = query.getResultList();
+//
+// Logger.trace("Found entries: " + result.size());
+//
+// 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;
+// }
+//
+// return (OnlineApplication) result.get(0);
+// }
+//
+// public static OnlineApplication getOnlineApplication(String id) {
+// MiscUtil.assertNotNull(id, "OnlineApplictionID");
+// Logger.trace("Getting OnlineApplication with ID " + id + " from database.");
+//
+// List result;
+// EntityManager session = ConfigurationDBUtils.getCurrentSession();
+//
+// javax.persistence.Query query = session.createQuery(QUERIES.get("getOnlineApplicationWithID"));
+// //query.setParameter("id", id+"%");
+// query.setParameter("id", id);
+// result = query.getResultList();
+//
+// Logger.trace("Found entries: " + result.size());
+//
+// if (result.size() == 0) {
+// Logger.trace("No entries found.");
+// return null;
+// }
+//
+// if (result.size() > 1) {
+// Logger.warn("OAIdentifier match to more then one DB-entry!");
+// return null;
+// }
+//
+// return (OnlineApplication) result.get(0);
+// }
+//
+// public static OnlineApplication getOnlineApplication(long dbid) {
+// MiscUtil.assertNotNull(dbid, "OnlineApplictionID");
+// Logger.trace("Getting OnlineApplication with DBID " + dbid + " from database.");
+//
+// List result;
+// EntityManager session = ConfigurationDBUtils.getCurrentSession();
+//
+// javax.persistence.Query query = session.createQuery(QUERIES.get("getOnlineApplicationWithDBID"));
+// //query.setParameter("id", id+"%");
+// query.setParameter("id", dbid);
+// result = query.getResultList();
+//
+// Logger.trace("Found entries: " + result.size());
+//
+// if (result.size() == 0) {
+// Logger.trace("No entries found.");
+// return null;
+// }
+//
+// return (OnlineApplication) result.get(0);
+// }
+//
+// @JsonProperty("getMOAIDConfiguration")
+// public static MOAIDConfiguration getMOAIDConfiguration() {
+// Logger.trace("Load MOAID Configuration from database.");
+//
+// List<MOAIDConfiguration> result;
+// EntityManager session = ConfigurationDBUtils.getCurrentSession();
+//
+// javax.persistence.Query query = session.createQuery(QUERIES.get("getMOAIDConfiguration"));
+// result = query.getResultList();
+//
+// Logger.trace("Found entries: " + result.size());
+//
+// if (result.size() == 0) {
+// Logger.trace("No entries found. Create fresh instance.");
+// return null;
+// }
+//
+// return (MOAIDConfiguration) result.get(0);
+// }
+//
+// @JsonProperty("getAllOnlineApplications")
+// public static List<OnlineApplication> getAllOnlineApplications() {
+// Logger.trace("Get All OnlineApplications from database.");
+//
+// List<OnlineApplication> result = null;
+// EntityManager session = ConfigurationDBUtils.getCurrentSession();
+//
+// javax.persistence.Query query = session.createQuery(QUERIES.get("getAllOnlineApplications"));
+// result = query.getResultList();
+//
+// Logger.trace("Found entries: " + result.size());
+//
+// if (result.size() == 0) {
+// Logger.trace("No entries found.");
+// return null;
+// }
+// return result;
+// }
+//
+// public static List<OnlineApplication> getAllNewOnlineApplications() {
+// Logger.trace("Get All OnlineApplications from database.");
+//
+// List<OnlineApplication> result;
+// EntityManager session = ConfigurationDBUtils.getCurrentSession();
+//
+// javax.persistence.Query query = session.createQuery(QUERIES.get("getAllNewOnlineApplications"));
+// result = query.getResultList();
+//
+// Logger.trace("Found entries: " + result.size());
+//
+// if (result.size() == 0) {
+// Logger.trace("No entries found.");
+// return null;
+// }
+// return result;
+// }
+//
+// @JsonProperty("getAllUsers")
+// public static List<UserDatabase> getAllUsers() {
+// Logger.trace("Get All OnlineApplications from database.");
+//
+// List<UserDatabase> result;
+// EntityManager session = ConfigurationDBUtils.getCurrentSession();
+//
+// javax.persistence.Query query = session.createQuery(QUERIES.get("getAllUsers"));
+// result = query.getResultList();
+//
+// Logger.trace("Found entries: " + result.size());
+//
+// if (result.size() == 0) {
+// Logger.trace("No entries found.");
+// return null;
+// }
+// return result;
+// }
+//
+// public static List<OnlineApplication> getAllActiveOnlineApplications() {
+// Logger.trace("Get All active OnlineApplications from database.");
+//
+// List<OnlineApplication> result;
+// EntityManager session = ConfigurationDBUtils.getCurrentSession();
+//
+// javax.persistence.Query query = session.createQuery(QUERIES.get("getAllActiveOnlineApplications"));
+// result = query.getResultList();
+//
+// Logger.trace("Found entries: " + result.size());
+//
+// if (result.size() == 0) {
+// Logger.trace("No entries found.");
+// result = new ArrayList<OnlineApplication>();
+//
+// }
+// return result;
+// }
+//
+// @SuppressWarnings("rawtypes")
+// public static List<OnlineApplication> searchOnlineApplications(String id) {
+// MiscUtil.assertNotNull(id, "OnlineApplictionID");
+// Logger.trace("Getting OnlineApplication with ID " + id + " from database.");
+//
+// List<OnlineApplication> result;
+// EntityManager session = ConfigurationDBUtils.getCurrentSession();
+//
+// javax.persistence.Query query = session.createQuery(QUERIES.get("searchOnlineApplicationsWithID"));
+// query.setParameter("id", "%" + id + "%");
+//
+// result = query.getResultList();
+//
+// Logger.trace("Found entries: " + result.size());
+//
+// if (result.size() == 0) {
+// Logger.trace("No entries found.");
+// return null;
+// }
+//
+// return result;
+// }
+//
+// public static UserDatabase getUserWithID(long id) {
+// MiscUtil.assertNotNull(id, "UserID");
+// Logger.trace("Getting Userinformation with ID " + id + " from database.");
+//
+// List<UserDatabase> result;
+// EntityManager session = ConfigurationDBUtils.getCurrentSession();
+//
+// javax.persistence.Query query = session.createQuery(QUERIES.get("getUserWithUserID"));
+// query.setParameter("id", id);
+// result = query.getResultList();
+//
+// Logger.trace("Found entries: " + result.size());
+//
+// if (result.size() == 0) {
+// Logger.trace("No entries found.");
+// return null;
+// }
+// return (UserDatabase) result.get(0);
+// }
+//
+// public static UserDatabase getUsersWithOADBID(long id) {
+// MiscUtil.assertNotNull(id, "OADBID");
+// Logger.trace("Getting Userinformation with OADBID " + id + " from database.");
+//
+// List<UserDatabase> result;
+// EntityManager session = ConfigurationDBUtils.getCurrentSession();
+//
+// javax.persistence.Query query = session.createQuery(QUERIES.get("getUsersWithOADBID"));
+// query.setParameter("id", id);
+// result = query.getResultList();
+//
+// Logger.trace("Found entries: " + result.size());
+//
+// if (result.size() == 0) {
+// Logger.trace("No entries found.");
+// return null;
+// }
+// return (UserDatabase) result.get(0);
+// }
+//
+// public static UserDatabase getUserWithUserName(String username) {
+// MiscUtil.assertNotNull(username, "UserName");
+// Logger.trace("Getting Userinformation with ID " + username + " from database.");
+//
+// List<UserDatabase> result;
+// EntityManager session = ConfigurationDBUtils.getCurrentSession();
+//
+// javax.persistence.Query query = session.createQuery(QUERIES.get("getUserWithUserUsername"));
+// query.setParameter("username", username);
+// result = query.getResultList();
+//
+// Logger.trace("Found entries: " + result.size());
+//
+// if (result.size() == 0) {
+// Logger.trace("No entries found.");
+// return null;
+// }
+// return (UserDatabase) result.get(0);
+// }
+//
+// public static UserDatabase getUserWithUserBPKWBPK(String bpkwbpk) {
+// MiscUtil.assertNotNull(bpkwbpk, "bpk/wbpk");
+// Logger.trace("Getting Userinformation with ID " + bpkwbpk + " from database.");
+//
+// List<UserDatabase> result;
+// EntityManager session = ConfigurationDBUtils.getCurrentSession();
+//
+// javax.persistence.Query query = session.createQuery(QUERIES.get("getUserWithUserBPKWBPK"));
+// query.setParameter("bpk", bpkwbpk);
+// result = query.getResultList();
+//
+// Logger.trace("Found entries: " + result.size());
+//
+// if (result.size() == 0) {
+// Logger.trace("No entries found.");
+// return null;
+// }
+// return (UserDatabase) result.get(0);
+// }
+//
+// public static UserDatabase getNewUserWithTokken(String tokken) {
+// MiscUtil.assertNotNull(tokken, "bpk/wbpk");
+// Logger.trace("Getting Userinformation with Tokken " + tokken + " from database.");
+//
+// List<UserDatabase> result;
+// EntityManager session = ConfigurationDBUtils.getCurrentSession();
+//
+// javax.persistence.Query query = session.createQuery(QUERIES.get("getNewUserWithUserTokken"));
+// query.setParameter("tokken", tokken);
+// result = query.getResultList();
+//
+// Logger.trace("Found entries: " + result.size());
+//
+// if (result.size() == 0) {
+// Logger.trace("No entries found.");
+// return null;
+// }
+// return (UserDatabase) result.get(0);
+// }
+//
+// public static List<UserDatabase> getAllNewUsers() {
+// Logger.trace("Get all new Users from Database");
+//
+// List<UserDatabase> result;
+// EntityManager session = ConfigurationDBUtils.getCurrentSession();
+//
+// javax.persistence.Query query = session.createQuery(QUERIES.get("getAllNewUsers"));
+// result = query.getResultList();
+//
+// Logger.trace("Found entries: " + result.size());
+//
+// if (result.size() == 0) {
+// Logger.trace("No entries found.");
+// return null;
+// }
+// return result;
+// }
+//
+// public static List<UserDatabase> getAllOpenUsersRequests() {
+// Logger.trace("Get all new Users from Database");
+//
+// List<UserDatabase> result;
+// EntityManager session = ConfigurationDBUtils.getCurrentSession();
+//
+// javax.persistence.Query query = session.createQuery(QUERIES.get("getAllOpenUsersRequests"));
+// result = query.getResultList();
+//
+// Logger.trace("Found entries: " + result.size());
+//
+// if (result.size() == 0) {
+// Logger.trace("No entries found.");
+// return null;
+// }
+// return result;
+// }
}
diff --git a/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/ConfigurationDBUtils.java b/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/ConfigurationDBUtils.java
index 3dcfa8aa9..d9f0267df 100644
--- a/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/ConfigurationDBUtils.java
+++ b/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/ConfigurationDBUtils.java
@@ -64,156 +64,170 @@ public final class ConfigurationDBUtils {
}
- /**
- * Checks if a session factory is currently available. If necessary a new
- * session factory is created.
- *
- * @return current (or new) session factory
- * @throws HibernateException
- * thrown if a hibernate error occurs
- */
- public static EntityManager getCurrentSession() {
- if (automaticSessionHandling) {
-
- return entitymanagerfactory.createEntityManager();
- }
-
- EntityManager session = (EntityManager) THREAD_LOCAL_CONFIG.get();
-
- if (session != null && session.isOpen()) {
+// /**
+// * Checks if a session factory is currently available. If necessary a new
+// * session factory is created.
+// *
+// * @return current (or new) session factory
+// * @throws HibernateException
+// * thrown if a hibernate error occurs
+// */
+// public static EntityManager getCurrentSession() {
+// if (automaticSessionHandling) {
+//
+// return entitymanagerfactory.createEntityManager();
+// }
+//
+// EntityManager session = (EntityManager) THREAD_LOCAL_CONFIG.get();
+//
+// if (session != null && session.isOpen()) {
+//
+// //maybe a hack, but sometimes we do not know if the session is closed (session already closed but isOpen()=true)
+// try {
+// javax.persistence.Query query = session.createQuery("select userdatabase from UserDatabase userdatabase");
+// query.getResultList();
+//
+// } catch (Throwable e) {
+// Logger.warn("JPA Session Handling Warning!!!! - This error should not occur.");
+// session = getNewSession();
+// }
+//
+// } else
+// session = getNewSession();
+//
+// return session;
+// }
+//
+// @SuppressWarnings("unchecked")
+// public static EntityManager getNewSession() {
+// if (automaticSessionHandling) {
+// Logger.warn("Session is being automatically handled by hibernate. Therefore this session maybe not being newly created. Use HibernateUtil.getCurrentSession() instead.");
+// return entitymanagerfactory.createEntityManager();
+// }
+// EntityManager session = (EntityManager) THREAD_LOCAL_CONFIG.get();
+// if (session != null ) {
+// Logger.warn("Previous session has not been closed; closing ConfigDB session now.");
+// closeSession();
+// }
+// Logger.debug("Opening new ConfigDB hibernate session...");
+// try {
+// session = entitymanagerfactory.createEntityManager();
+// THREAD_LOCAL_CONFIG.set(session);
+// } catch (HibernateException hex) {
+// Logger.error(hex.getMessage());
+// }
+// return session;
+// }
- //maybe a hack, but sometimes we do not know if the session is closed (session already closed but isOpen()=true)
- try {
- javax.persistence.Query query = session.createQuery("select userdatabase from UserDatabase userdatabase");
- query.getResultList();
-
- } catch (Throwable e) {
- Logger.warn("JPA Session Handling Warning!!!! - This error should not occur.");
- session = getNewSession();
- }
-
- } else
- session = getNewSession();
-
- return session;
- }
-
- @SuppressWarnings("unchecked")
- public static EntityManager getNewSession() {
- if (automaticSessionHandling) {
- Logger.warn("Session is being automatically handled by hibernate. Therefore this session maybe not being newly created. Use HibernateUtil.getCurrentSession() instead.");
- return entitymanagerfactory.createEntityManager();
- }
- EntityManager session = (EntityManager) THREAD_LOCAL_CONFIG.get();
- if (session != null ) {
- Logger.warn("Previous session has not been closed; closing ConfigDB session now.");
- closeSession();
- }
- Logger.debug("Opening new ConfigDB hibernate session...");
- try {
- session = entitymanagerfactory.createEntityManager();
- THREAD_LOCAL_CONFIG.set(session);
- } catch (HibernateException hex) {
- Logger.error(hex.getMessage());
- }
- return session;
- }
+ /**
+ * Closes the current session.
+ *
+ * @throws HibernateException
+ * thrown if session is already closed or a hibernate error
+ * occurs.
+ *
+ * @deprecated
+ */
+@SuppressWarnings("unchecked")
+public static void closeSession() {
- /**
- * Closes the current session.
- *
- * @throws HibernateException
- * thrown if session is already closed or a hibernate error
- * occurs.
- */
- @SuppressWarnings("unchecked")
- public static void closeSession() {
- if (automaticSessionHandling) {
- Logger.warn("Session is being automatically handled by hibernate. Therefore the current session cannot be closed on demand.");
- return;
- }
- Logger.debug("Closing current ConfigDB hibernate session...");
- EntityManager session = (EntityManager) THREAD_LOCAL_CONFIG.get();
- THREAD_LOCAL_CONFIG.set(null);
- if (session != null) {
- try {
- session.close();
-
- } catch (HibernateException hex) {
- Logger.error(hex.getMessage());
- }
- }
- }
-
- public static boolean save(Object dbo) throws MOADatabaseException {
- EntityTransaction tx = null;
-
- try {
- EntityManager session = ConfigurationDBUtils.getCurrentSession();
- tx = session.getTransaction();
-
- synchronized (session) {
- tx.begin();
- session.merge(dbo);
- tx.commit();
-
- session.clear();
- }
- return true;
-
- } catch(HibernateException e) {
- Logger.warn("Error during Config database saveOrUpdate. Rollback.", e);
- tx.rollback();
- throw new MOADatabaseException(e);
- }
- }
-
+}
- public static boolean saveOrUpdate(Object dbo) throws MOADatabaseException {
- EntityTransaction tx = null;
-
- try {
- EntityManager session = ConfigurationDBUtils.getCurrentSession();
- tx = session.getTransaction();
-
- synchronized (session) {
- tx.begin();
-
- session.merge(dbo);
- session.flush();
-
- tx.commit();
-
- //session.clear();
- }
- return true;
-
- } catch(HibernateException e) {
- Logger.warn("Error during Config database saveOrUpdate. Rollback.", e);
- tx.rollback();
- throw new MOADatabaseException(e);
- }
- }
-
- public static boolean delete(Object dbo) {
- EntityTransaction tx = null;
- try {
- EntityManager session = ConfigurationDBUtils.getCurrentSession();
- tx = session.getTransaction();
-
- synchronized (session) {
- tx.begin();
- session.remove(session.contains(dbo) ? dbo : session.merge(dbo));
- tx.commit();
- }
-
- return true;
-
- } catch(HibernateException e) {
- Logger.warn("Error during Config database delete. Rollback.", e);
- tx.rollback();
- return false;
- }
- }
+// /**
+// * Closes the current session.
+// *
+// * @throws HibernateException
+// * thrown if session is already closed or a hibernate error
+// * occurs.
+// */
+// @SuppressWarnings("unchecked")
+// public static void closeSession() {
+// if (automaticSessionHandling) {
+// Logger.warn("Session is being automatically handled by hibernate. Therefore the current session cannot be closed on demand.");
+// return;
+// }
+// Logger.debug("Closing current ConfigDB hibernate session...");
+// EntityManager session = (EntityManager) THREAD_LOCAL_CONFIG.get();
+// THREAD_LOCAL_CONFIG.set(null);
+// if (session != null) {
+// try {
+// session.close();
+//
+// } catch (HibernateException hex) {
+// Logger.error(hex.getMessage());
+// }
+// }
+// }
+//
+// public static boolean save(Object dbo) throws MOADatabaseException {
+// EntityTransaction tx = null;
+//
+// try {
+// EntityManager session = ConfigurationDBUtils.getCurrentSession();
+// tx = session.getTransaction();
+//
+// synchronized (session) {
+// tx.begin();
+// session.merge(dbo);
+// tx.commit();
+//
+// session.clear();
+// }
+// return true;
+//
+// } catch(HibernateException e) {
+// Logger.warn("Error during Config database saveOrUpdate. Rollback.", e);
+// tx.rollback();
+// throw new MOADatabaseException(e);
+// }
+// }
+//
+//
+// public static boolean saveOrUpdate(Object dbo) throws MOADatabaseException {
+// EntityTransaction tx = null;
+//
+// try {
+// EntityManager session = ConfigurationDBUtils.getCurrentSession();
+// tx = session.getTransaction();
+//
+// synchronized (session) {
+// tx.begin();
+//
+// session.merge(dbo);
+// session.flush();
+//
+// tx.commit();
+//
+// //session.clear();
+// }
+// return true;
+//
+// } catch(HibernateException e) {
+// Logger.warn("Error during Config database saveOrUpdate. Rollback.", e);
+// tx.rollback();
+// throw new MOADatabaseException(e);
+// }
+// }
+//
+// public static boolean delete(Object dbo) {
+// EntityTransaction tx = null;
+// try {
+// EntityManager session = ConfigurationDBUtils.getCurrentSession();
+// tx = session.getTransaction();
+//
+// synchronized (session) {
+// tx.begin();
+// session.remove(session.contains(dbo) ? dbo : session.merge(dbo));
+// tx.commit();
+// }
+//
+// return true;
+//
+// } catch(HibernateException e) {
+// Logger.warn("Error during Config database delete. Rollback.", e);
+// tx.rollback();
+// return false;
+// }
+// }
}
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
deleted file mode 100644
index 432991f33..000000000
--- a/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/ConfigurationFromDBExtractor.java
+++ /dev/null
@@ -1,182 +0,0 @@
-//package at.gv.egovernment.moa.id.commons.db;
-//
-//import java.util.ArrayList;
-//import java.util.Date;
-//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;
-//import at.gv.egovernment.moa.id.commons.db.dao.config.GenericConfiguration;
-//import at.gv.egovernment.moa.id.commons.db.dao.config.OnlineApplication;
-//import at.gv.egovernment.moa.id.commons.db.dao.config.SLRequestTemplates;
-//
-//import com.fasterxml.jackson.annotation.JsonProperty;
-//
-///**
-// * This class is used to extract information from a legacy moa-id database.
-// */
-//public class ConfigurationFromDBExtractor {
-//
-// /**
-// * This class should not be instantiated.
-// */
-// private ConfigurationFromDBExtractor() {
-// }
-//
-// /**
-// * Helper method, to query for a single value. NOTE: returns {@code null} if
-// * there is no result, more than one result or if an exception is thrown
-// * while querying the database.
-// *
-// * @param queryString
-// * a jpa query string.
-// * @param clazz
-// * the class type of the expected result.
-// * @return the result of the query or {@code null}.
-// */
-// private static <T> T getSingleValue(String queryString, Class<T> clazz) {
-// T result = null;
-// EntityManager session = ConfigurationDBUtils.getCurrentSession();
-// TypedQuery<T> query = session.createQuery(queryString, clazz);
-// try {
-// result = query.getSingleResult();
-// } catch (Exception e) {
-// return null;
-// }
-// return result;
-// }
-//
-// /**
-// * Helper method, to query for a a list of values. NOTE: the returned list
-// * may be empty but is never {@code null}.
-// *
-// * @param queryString
-// * a jpa query string.
-// * @param clazz
-// * the class type of the elements the expected result list.
-// * @return a list with the result of the query or an empty list.
-// */
-// private static <T> List<T> getListOfValues(String queryString, Class<T> clazz) {
-// List<T> result = new ArrayList<T>();
-// EntityManager session = ConfigurationDBUtils.getCurrentSession();
-// TypedQuery<T> query = session.createQuery(queryString, clazz);
-// try {
-// result = query.getResultList();
-// } catch (Exception e) {
-// return new ArrayList<T>();
-// }
-// return result;
-// }
-//
-// /**
-// * Extracts an {@link AuthComponentGeneral} from the database. NOTE: returns
-// * {@code null} if there is no result, more than one result or if an
-// * exception is thrown while querying the database.
-// *
-// * @return an AuthComponentgeneral or {@code null}.
-// */
-// @JsonProperty(MOAIDConfigurationConstants.AUTH_COMPONENT_GENERAL_KEY)
-// public static AuthComponentGeneral getAuthComponentGeneral() {
-// return getSingleValue("from AuthComponentGeneral", AuthComponentGeneral.class);
-// }
-//
-// /**
-// * Extracts an {@link AuthComponentGeneral} from the database. NOTE: returns
-// * {@code null} if there is no result, more than one result or if an
-// * exception is thrown while querying the database.
-// *
-// * @return an AuthComponentgeneral or {@code null}.
-// */
-// @JsonProperty(MOAIDConfigurationConstants.CHAINING_MODES_KEY)
-// public static ChainingModes getChainingModes() {
-// return (ChainingModes) getSingleValue("from ChainingModes", ChainingModes.class);
-// }
-//
-// /**
-// * Extracts a list of {@link OnlineApplication} from the database. NOTE: the
-// * returned list may be empty but is never {@code null}.
-// *
-// * @return a list of {@link OnlineApplication}.
-// */
-// @JsonProperty(MOAIDConfigurationConstants.ONLINE_APPLICATIONS_KEY)
-// public static List<OnlineApplication> getOnlineApplications() {
-// return getListOfValues("from OnlineApplication", OnlineApplication.class);
-// }
-//
-// /**
-// * Extracts a list of {@link GenericConfiguration} from the database. NOTE:
-// * the returned list may be empty but is never {@code null}.
-// *
-// * @return a list of {@link GenericConfiguration}.
-// */
-// @JsonProperty(MOAIDConfigurationConstants.GENERIC_CONFIGURATION_KEY)
-// public static List<GenericConfiguration> getGenericConfigurations() {
-// return getListOfValues("from GenericConfiguration", GenericConfiguration.class);
-// }
-//
-// /**
-// * Extracts the trusted CA-certificates from the database. NOTE: returns
-// * {@code null} if there is no result, more than one result or if an
-// * exception is thrown while querying the database.
-// *
-// * @return the trusted CA-certificates or {@code null}.
-// */
-// @JsonProperty(MOAIDConfigurationConstants.TRUSTED_CERTIFICATES_KEY)
-// public static String getTrustedCACertificates() {
-// return getSingleValue("select trustedCACertificates from MOAIDConfiguration", String.class);
-// }
-//
-// /**
-// * Extracts a {@link DefaultBKUs} from the database. NOTE: returns
-// * {@code null} if there is no result, more than one result or if an
-// * exception is thrown while querying the database.
-// *
-// * @return a DefaultBKUs or {@code null}.
-// */
-// @JsonProperty(MOAIDConfigurationConstants.DEFAULT_BKUS_KEY)
-// public static DefaultBKUs getDefaultBKUs() {
-// return getSingleValue("select defaultBKUs from MOAIDConfiguration", DefaultBKUs.class);
-// }
-//
-// /**
-// * Extracts a {@link SLRequestTemplates} from the database. NOTE: returns
-// * {@code null} if there is no result, more than one result or if an
-// * exception is thrown while querying the database.
-// *
-// * @return a SLRequestTemplates or {@code null}.
-// */
-// @JsonProperty(MOAIDConfigurationConstants.SLREQUEST_TEMPLATES_KEY)
-// public static SLRequestTemplates getSLRequestTemplates() {
-// return getSingleValue("select SLRequestTemplates from MOAIDConfiguration", SLRequestTemplates.class);
-// }
-//
-// /**
-// * Extracts the moa-id timestamp (last update) from the database. NOTE:
-// * returns {@code null} if there is no result, more than one result or if an
-// * exception is thrown while querying the database.
-// *
-// * @return the moa-id timestamp (last update) or {@code null}.
-// */
-// @JsonProperty(MOAIDConfigurationConstants.TIMESTAMP_ITEM_KEY)
-// public static Date getTimeStampItem() {
-// return getSingleValue("select timestampItem from MOAIDConfiguration", Date.class);
-// }
-//
-// /**
-// * Extracts the date of the last pvp2refresh from the database. NOTE:
-// * returns {@code null} if there is no result, more than one result or if an
-// * exception is thrown while querying the database.
-// *
-// * @return the date of the last pvp2refresh or {@code null}.
-// */
-// @JsonProperty(MOAIDConfigurationConstants.PVP2REFRESH_ITEM_KEY)
-// public static Date getPvp2RefreshItem() {
-// return getSingleValue("select pvp2RefreshItem from MOAIDConfiguration", Date.class);
-// }
-//
-//}
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/DatabaseConfigPropertyImpl.java
index eaeb4e7f7..72cb2fdf4 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/DatabaseConfigPropertyImpl.java
@@ -6,8 +6,12 @@ import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.TypedQuery;
+import org.hibernate.SessionFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Repository;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.transaction.annotation.Transactional;
import at.gv.egiz.components.configuration.api.AbstractConfigurationImpl;
@@ -18,14 +22,15 @@ import at.gv.egovernment.moa.util.MiscUtil;
* Database backed implementation of the DAO interface
*
*/
+@Repository
@Transactional("transactionManager")
-public class ConfigPropertyDaoImpl extends AbstractConfigurationImpl {
+public class DatabaseConfigPropertyImpl extends AbstractConfigurationImpl {
private Logger log = LoggerFactory.getLogger(getClass());
- @PersistenceContext(unitName = "moaidconf")
+ @PersistenceContext(unitName = "config")
private EntityManager em;
-
+
/**
*
* @return EntityManager for database access
@@ -35,10 +40,10 @@ public class ConfigPropertyDaoImpl extends AbstractConfigurationImpl {
}
@Override
- protected List<String> getAllKeys() {
+ protected List<String> getAllKeys() throws ConfigurationException {
if (null == em) {
log.error("No EntityManager set!");
- return null;
+ throw new ConfigurationException("No EntityManager set!");
}
TypedQuery<String> query = em.createQuery("select key from ConfigProperty", String.class);
List<String> result = query.getResultList();
@@ -80,10 +85,11 @@ public class ConfigPropertyDaoImpl extends AbstractConfigurationImpl {
* @see at.gv.egiz.components.configuration.api.AbstractConfigurationImpl#storeKey(java.lang.String, java.lang.String)
*/
@Override
+ @Transactional(value="transactionManager")
protected void storeKey(String key, String value) throws ConfigurationException {
if (null == em) {
log.error("No EntityManager set!");
- return;
+ throw new ConfigurationException("No EntityManager set!");
}
ConfigProperty property = new ConfigProperty();
@@ -93,7 +99,7 @@ public class ConfigPropertyDaoImpl extends AbstractConfigurationImpl {
em.persist(property);
}
-
+
protected void deleteKey(String key) {
log.debug("Deleting entry with key '{}'.", key);
em.remove(em.find(ConfigProperty.class, key));
@@ -107,7 +113,7 @@ public class ConfigPropertyDaoImpl extends AbstractConfigurationImpl {
throws ConfigurationException {
if (null == em) {
log.error("No EntityManager set!");
- return null;
+ throw new ConfigurationException("No EntityManager set!");
}
TypedQuery<String> query = em.createQuery("select key from ConfigProperty dbconfig where dbconfig.key like :key", String.class);
@@ -124,7 +130,7 @@ public class ConfigPropertyDaoImpl extends AbstractConfigurationImpl {
throws ConfigurationException {
if (null == em) {
log.error("No EntityManager set!");
- return null;
+ throw new ConfigurationException("No EntityManager set!");
}
TypedQuery<String> query = em.createQuery("select key from ConfigProperty dbconfig where dbconfig.value like :value", String.class);
diff --git a/id/server/moa-id-commons/src/main/resources/META-INF/persistence.xml b/id/server/moa-id-commons/src/main/resources/META-INF/persistence.xml
index 8ff384eb9..6325ada5f 100644
--- a/id/server/moa-id-commons/src/main/resources/META-INF/persistence.xml
+++ b/id/server/moa-id-commons/src/main/resources/META-INF/persistence.xml
@@ -10,7 +10,7 @@ http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
<class>at.gv.egovernment.moa.id.commons.config.persistence.dal.SOME_CLASS</class>
</persistence-unit>
- <persistence-unit name="moaidconf" transaction-type="RESOURCE_LOCAL">
+ <persistence-unit name="config" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<class>at.gv.egovernment.moa.id.commons.db.dao.config.ConfigProperty</class>
<properties>
diff --git a/id/server/moa-id-commons/src/main/resources/configuration.beans.xml b/id/server/moa-id-commons/src/main/resources/configuration.beans.xml_old
index 732c19721..b3e7526d0 100644
--- a/id/server/moa-id-commons/src/main/resources/configuration.beans.xml
+++ b/id/server/moa-id-commons/src/main/resources/configuration.beans.xml_old
@@ -16,8 +16,9 @@
<bean id="configPropertyDao"
- class="at.gv.egovernment.moa.id.commons.db.dao.config.ConfigPropertyDaoImpl" />
- <bean id="config" class="at.gv.egovernment.moa.id.commons.config.persistence.ConfigurationImpl">
+ class="at.gv.egovernment.moa.id.commons.db.dao.config.DatabaseConfigPropertyImpl" />
+
+ <bean id="config" class="at.gv.egovernment.moa.id.commons.config.persistence.MOAIDConfigurationImpl">
<property name="configPropertyDao" ref="configPropertyDao" />
</bean>
@@ -25,6 +26,8 @@
<bean id="configWrite" class="at.gv.egovernment.moa.id.commons.db.NewConfigurationDBWrite"/>
+ <bean id="moaidauthconfig" class="at.gv.egovernment.moa.id.config.auth.PropertyBasedAuthConfigurationProvider"
+
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" lazy-init="true" destroy-method="close">
<aop:scoped-proxy/>
<property name="driverClassName" value="${dataSource.driverClassName}" />
@@ -46,7 +49,7 @@
<bean name="moaidconf" id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="jpaVendorAdapter" ref="jpaVendorAdapter" />
- <property name="persistenceUnitName" value="moaidconf" />
+ <property name="persistenceUnitName" value="config" />
</bean>
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
diff --git a/id/server/moa-id-commons/src/main/resources/persistence_template.xml b/id/server/moa-id-commons/src/main/resources/persistence_template.xml
index 06706e27a..d9adc4394 100644
--- a/id/server/moa-id-commons/src/main/resources/persistence_template.xml
+++ b/id/server/moa-id-commons/src/main/resources/persistence_template.xml
@@ -3,7 +3,7 @@
http://java.sun.com/xml/ns/persistence/orm http://java.sun.com/xml/ns/persistence/orm_1_0.xsd" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:orm="http://java.sun.com/xml/ns/persistence/orm" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<!-- <persistence-unit name="##generated"> -->
- <persistence-unit name="moaidconf" transaction-type="RESOURCE_LOCAL">
+ <persistence-unit name="config" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<class>at.gv.egovernment.moa.id.commons.db.dao.config.ConfigProperty</class>
<properties>