From 1fb729e35f4c423cf2a1996cdcc6a213122f4e0e Mon Sep 17 00:00:00 2001 From: Thomas Lenz Date: Fri, 19 Jun 2015 12:14:20 +0200 Subject: fix merge problems --- .../moa/id/commons/config/ConfigurationUtil.java | 452 +++++------ .../id/commons/config/MigrateConfiguration.java | 206 ++--- .../commons/db/ConfigurationFromDBExtractor.java | 364 ++++----- .../moa/id/commons/db/NewConfigurationDBRead.java | 856 ++++++++++----------- .../moa/id/commons/db/NewConfigurationDBWrite.java | 274 +++---- .../utils/MOAHttpProtocolSocketFactory.java | 5 +- 6 files changed, 1078 insertions(+), 1079 deletions(-) (limited to 'id/server/moa-id-commons/src/main') 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 e794951d7..468e4a536 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,226 @@ -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 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.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 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 +// } +// +//} 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 4e8c7dffd..32dd97148 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: - *
    - *
  • transform a MoaID 2 XML configuration XML file to a MoaID 3 property file - *
  • - *
  • read a property file and transfer it's content to a database
  • - *
  • write the content of a database to a property file
  • - *
- */ -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: +// *
    +// *
  • transform a MoaID 2 XML configuration XML file to a MoaID 3 property file +// *
  • +// *
  • read a property file and transfer it's content to a database
  • +// *
  • write the content of a database to a property file
  • +// *
+// */ +//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/db/ConfigurationFromDBExtractor.java b/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/ConfigurationFromDBExtractor.java index f6066d68f..432991f33 100644 --- a/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/ConfigurationFromDBExtractor.java +++ b/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/ConfigurationFromDBExtractor.java @@ -1,182 +1,182 @@ -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 getSingleValue(String queryString, Class clazz) { - T result = null; - EntityManager session = ConfigurationDBUtils.getCurrentSession(); - TypedQuery 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 List getListOfValues(String queryString, Class clazz) { - List result = new ArrayList(); - EntityManager session = ConfigurationDBUtils.getCurrentSession(); - TypedQuery query = session.createQuery(queryString, clazz); - try { - result = query.getResultList(); - } catch (Exception e) { - return new ArrayList(); - } - 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 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 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); - } - -} +//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 getSingleValue(String queryString, Class clazz) { +// T result = null; +// EntityManager session = ConfigurationDBUtils.getCurrentSession(); +// TypedQuery 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 List getListOfValues(String queryString, Class clazz) { +// List result = new ArrayList(); +// EntityManager session = ConfigurationDBUtils.getCurrentSession(); +// TypedQuery query = session.createQuery(queryString, clazz); +// try { +// result = query.getResultList(); +// } catch (Exception e) { +// return new ArrayList(); +// } +// 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 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 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/NewConfigurationDBRead.java b/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/NewConfigurationDBRead.java index 64d8e9d80..66143efad 100644 --- a/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/NewConfigurationDBRead.java +++ b/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/NewConfigurationDBRead.java @@ -1,428 +1,428 @@ -package at.gv.egovernment.moa.id.commons.db; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.Date; -import java.util.List; - -import org.springframework.beans.factory.annotation.Autowired; - -import at.gv.egovernment.moa.id.commons.config.MOAIDConfigurationConstants; -import at.gv.egovernment.moa.id.commons.config.persistence.MOAIDConfiguration; -import at.gv.egovernment.moa.id.commons.db.dao.config.AuthComponentGeneral; -import at.gv.egovernment.moa.id.commons.db.dao.config.ChainingModes; -import at.gv.egovernment.moa.id.commons.db.dao.config.DefaultBKUs; -import at.gv.egovernment.moa.id.commons.db.dao.config.GenericConfiguration; -import at.gv.egovernment.moa.id.commons.db.dao.config.OnlineApplication; -import at.gv.egovernment.moa.id.commons.db.dao.config.SLRequestTemplates; -import at.gv.egovernment.moa.id.commons.db.dao.config.UserDatabase; -import at.gv.egovernment.moa.logging.Logger; - -/** - * - * - */ -public class NewConfigurationDBRead { - - private static MOAIDConfiguration conf; - - @Autowired(required = true) - public void setConfiguration(MOAIDConfiguration conf) { - // https://jira.spring.io/browse/SPR-3845 - NewConfigurationDBRead.conf = conf; - } - - @SuppressWarnings("unchecked") - public static > T nullGuard(T item) { - if (item == null) { - return (T) Collections.emptyList(); - } else { - return item; - } - } - - /** - * - * @return - */ - public static List getAllUsers() { - Logger.trace("Get All Users from database."); - - // select userdatabase from UserDatabase userdatabase - List result = conf.getList("getAllUsers", UserDatabase.class); - if (result.size() == 0) { - Logger.trace("No entries found."); - return null; - } - - return result; - } - - /** - * - * @return - */ - public static List getAllOnlineApplications() { - Logger.trace("Get All OnlineApplications from database."); - - // select onlineapplication from OnlineApplication onlineapplication - return conf.getList(MOAIDConfigurationConstants.ONLINE_APPLICATIONS_KEY, OnlineApplication.class); - - } - - /** - * - * @return - */ - public static List getAllNewOnlineApplications() { - Logger.trace("Get All New OnlineApplications from database."); - - // select onlineapplication from OnlineApplication onlineapplication - // where onlineapplication.isActive = '0' and onlineapplication.isAdminRequired = '1' - List result = new ArrayList(); - List allOAs = getAllOnlineApplications(); - - for (OnlineApplication oa : nullGuard(allOAs)) { - if (!oa.isIsActive() && oa.isIsAdminRequired()) { - result.add(oa); - } - } - - if (result.size() == 0) { - Logger.trace("No entries found."); - return null; - } - - return result; - } - - /** - * - * @return - */ - public static at.gv.egovernment.moa.id.commons.db.dao.config.MOAIDConfiguration getMOAIDConfiguration() { - Logger.trace("Load MOAID Configuration from database."); - - AuthComponentGeneral authComponent = (AuthComponentGeneral) conf.get(MOAIDConfigurationConstants.AUTH_COMPONENT_GENERAL_KEY, - AuthComponentGeneral.class); - - ChainingModes chainingModes = (ChainingModes) conf.get(MOAIDConfigurationConstants.CHAINING_MODES_KEY, ChainingModes.class); - List genericConfigurations = (List) conf.getList( - MOAIDConfigurationConstants.GENERIC_CONFIGURATION_KEY, GenericConfiguration.class); - String trustedCaCertificates = (String) conf.get(MOAIDConfigurationConstants.TRUSTED_CERTIFICATES_KEY, String.class); - DefaultBKUs defaultBKUs = (DefaultBKUs) conf.get(MOAIDConfigurationConstants.DEFAULT_BKUS_KEY, DefaultBKUs.class); - SLRequestTemplates slrRequestRemplates = (SLRequestTemplates) conf.get(MOAIDConfigurationConstants.SLREQUEST_TEMPLATES_KEY, - SLRequestTemplates.class); - Date timeStamp = (Date) conf.get(MOAIDConfigurationConstants.TIMESTAMP_ITEM_KEY, Date.class); - Date pvp2Refresh = (Date) conf.get(MOAIDConfigurationConstants.PVP2REFRESH_ITEM_KEY, Date.class); - - // if (authComponent == null || chainingModes == null || trustedCaCertificates == null || defaultBKUs == null - // || slrRequestRemplates == null || timeStamp == null || pvp2Refresh == null - // - // ) { - // // TODO: is there a better approach in case of error? - // Logger.trace("Not all necessary data available. Create fresh instance."); - // return new MOAIDConfiguration(); - // } - - // select moaidconfiguration from MOAIDConfiguration moaidconfiguration - at.gv.egovernment.moa.id.commons.db.dao.config.MOAIDConfiguration result = new at.gv.egovernment.moa.id.commons.db.dao.config.MOAIDConfiguration(); - result.setAuthComponentGeneral(authComponent); - result.setChainingModes(chainingModes); - result.setGenericConfiguration(genericConfigurations); - result.setTrustedCACertificates(trustedCaCertificates); - result.setDefaultBKUs(defaultBKUs); - result.setSLRequestTemplates(slrRequestRemplates); - result.setTimestampItem(timeStamp); - result.setPvp2RefreshItem(pvp2Refresh); - - return result; - } - - /** - * - * @return - */ - public static List getAllActiveOnlineApplications() { - Logger.trace("Get All New OnlineApplications from database."); - - // select onlineapplication from OnlineApplication onlineapplication - // where onlineapplication.isActive = '1' - List result = new ArrayList(); - List allOAs = getAllOnlineApplications(); - - for (OnlineApplication oa : nullGuard(allOAs)) { - if (oa.isIsActive()) { - result.add(oa); - } - } - - if (result.size() == 0) { - Logger.trace("No entries found."); - return null; - } - - return result; - } - - /** - * - * @param id - * @return - */ - public static OnlineApplication getActiveOnlineApplication(String id) { - Logger.trace("Getting Active OnlineApplication with ID " + id + " from database."); - - // select onlineapplication from OnlineApplication onlineapplication - // where onlineapplication.publicURLPrefix = - // SUBSTRING(:id, 1, LENGTH(onlineapplication.publicURLPrefix)) and onlineapplication.isActive = '1' - OnlineApplication result = null; - List allActiveOAs = getAllActiveOnlineApplications(); - - for (OnlineApplication oa : nullGuard(allActiveOAs)) { - String publicUrlPrefix = oa.getPublicURLPrefix(); - if (publicUrlPrefix != null && publicUrlPrefix.length() <= id.length()) { - if ((id.substring(1, publicUrlPrefix.length()).equals(publicUrlPrefix))) { - if (result != null) { - Logger.warn("OAIdentifier match to more then one DB-entry!"); - return null; - } else { - result = oa; - } - } - } - } - - return result; - } - - /** - * - * @param dbid - * @return - */ - public static OnlineApplication getOnlineApplication(long dbid) { - Logger.trace("Getting OnlineApplication with DBID " + dbid + " from database."); - - // select onlineapplication from OnlineApplication onlineapplication where onlineapplication.hjid = :id - OnlineApplication result = null; - List allOAs = getAllOnlineApplications(); - - for (OnlineApplication oa : nullGuard(allOAs)) { - if (oa.getHjid() == dbid) { - result = oa; - break; - } - } - - return result; - } - - /** - * - * @param id - * @return - */ - public static OnlineApplication getOnlineApplication(String id) { - Logger.trace("Getting OnlineApplication with ID " + id + " from database."); - - // select onlineapplication from OnlineApplication onlineapplication - // where onlineapplication.publicURLPrefix = SUBSTRING(:id, 1, LENGTH(onlineapplication.publicURLPrefix)) - OnlineApplication result = null; - List allOAs = getAllOnlineApplications(); - - for (OnlineApplication oa : nullGuard(allOAs)) { - String publicUrlPrefix = oa.getPublicURLPrefix(); - if (publicUrlPrefix != null && publicUrlPrefix.length() <= id.length()) { - if (id.substring(1, publicUrlPrefix.length()).equals(publicUrlPrefix)) { - if (result != null) { - Logger.warn("OAIdentifier match to more then one DB-entry!"); - return null; - } else { - result = oa; - } - } - } - } - - return result; - } - - /** - * - * @param id - * @return - */ - public static List searchOnlineApplications(String id) { - Logger.trace("Getting OnlineApplication with ID " + id + " from database."); - - // select onlineapplication from OnlineApplication onlineapplication - // where onlineapplication.friendlyName like :id - List result = new ArrayList(); - List allOAs = getAllOnlineApplications(); - - for (OnlineApplication oa : nullGuard(allOAs)) { - if (id.equals(oa.getFriendlyName())) { - result.add(oa); - } - } - - if (result.size() == 0) { - Logger.trace("No entries found."); - return null; - } - - return result; - } - - /** - * - * @return - */ - public static List getAllOpenUsersRequests() { - Logger.trace("Get all new Users from Database"); - - // select userdatabase from UserDatabase userdatabase - // where userdatabase.userRequestTokken is not null - // and userdatabase.isAdminRequest = '1' and userdatabase.isMailAddressVerified = '0' - List result = new ArrayList(); - List allUsers = getAllUsers(); - - for (UserDatabase user : nullGuard(allUsers)) { - // TODO check result of query "... userdatabase.userRequestTokken is not null" if Tokken is null -> (null, "NULL", "", ... ?) - if ((user.getUserRequestTokken() != null && !user.getUserRequestTokken().isEmpty() && !user.getUserRequestTokken().equals("NULL")) - && (user.isIsAdminRequest()) && (!user.isIsMailAddressVerified())) { - result.add(user); - } - } - - if (result.size() == 0) { - Logger.trace("No entries found."); - return null; - } - - return result; - } - - /** - * - * @param tokken - * @return - */ - public static UserDatabase getNewUserWithTokken(String tokken) { - Logger.trace("Getting Userinformation with Tokken " + tokken + " from database."); - - // select userdatabase from UserDatabase userdatabase where userdatabase.userRequestTokken = :tokken - UserDatabase result = null; - List allUsers = getAllUsers(); - - for (UserDatabase user : nullGuard(allUsers)) { - if (user.getUserRequestTokken().equals(tokken)) { - result = user; - break; - } - } - - return result; - } - - /** - * - * @param id - * @return - */ - public static UserDatabase getUsersWithOADBID(long id) { - Logger.trace("Getting Userinformation with OADBID " + id + " from database."); - - // select userdatabase from UserDatabase userdatabase - // inner join userdatabase.onlineApplication oa where oa.hjid = :id - UserDatabase result = null; - List allUsers = getAllUsers(); - - boolean quit = false; - for (UserDatabase user : nullGuard(allUsers)) { - - for (OnlineApplication oa : user.getOnlineApplication()) { - - if (oa.getHjid() == id) { - result = user; - quit = true; - break; - } - } - - if (quit) { - break; - } - } - - return result; - } - - /** - * - * @param id - * @return - */ - public static UserDatabase getUserWithID(long id) { - Logger.trace("Getting Userinformation with ID " + id + " from database."); - - // select userdatabase from UserDatabase userdatabase where userdatabase.hjid = :id - UserDatabase result = null; - List allUsers = getAllUsers(); - - for (UserDatabase user : nullGuard(allUsers)) { - if (user.getHjid() == id) { - result = user; - break; - } - } - - return result; - } - - /** - * - * @param username - * @return - */ - public static UserDatabase getUserWithUserName(String username) { - Logger.trace("Getting Userinformation with ID " + username + " from database."); - - // select userdatabase from UserDatabase userdatabase where userdatabase.username = :username - UserDatabase result = null; - List allUsers = getAllUsers(); - - for (UserDatabase user : nullGuard(allUsers)) { - if (user.getUsername().equals(username)) { - result = user; - break; - } - } - - return result; - } - - /** - * - * @param bpkwbpk - * @return - */ - public static UserDatabase getUserWithUserBPKWBPK(String bpkwbpk) { - Logger.trace("Getting Userinformation with ID " + bpkwbpk + " from database."); - - // select userdatabase from UserDatabase userdatabase where userdatabase.bpk = :bpk - UserDatabase result = null; - List allUsers = getAllUsers(); - - for (UserDatabase user : nullGuard(allUsers)) { - if (user.getBpk().equals(bpkwbpk)) { - result = user; - break; - } - } - - return result; - } - -} +//package at.gv.egovernment.moa.id.commons.db; +// +//import java.util.ArrayList; +//import java.util.Collections; +//import java.util.Date; +//import java.util.List; +// +//import org.springframework.beans.factory.annotation.Autowired; +// +//import at.gv.egovernment.moa.id.commons.config.MOAIDConfigurationConstants; +//import at.gv.egovernment.moa.id.commons.config.persistence.MOAIDConfiguration; +//import at.gv.egovernment.moa.id.commons.db.dao.config.AuthComponentGeneral; +//import at.gv.egovernment.moa.id.commons.db.dao.config.ChainingModes; +//import at.gv.egovernment.moa.id.commons.db.dao.config.DefaultBKUs; +//import at.gv.egovernment.moa.id.commons.db.dao.config.GenericConfiguration; +//import at.gv.egovernment.moa.id.commons.db.dao.config.OnlineApplication; +//import at.gv.egovernment.moa.id.commons.db.dao.config.SLRequestTemplates; +//import at.gv.egovernment.moa.id.commons.db.dao.config.UserDatabase; +//import at.gv.egovernment.moa.logging.Logger; +// +///** +// * +// * +// */ +//public class NewConfigurationDBRead { +// +// private static MOAIDConfiguration conf; +// +// @Autowired(required = true) +// public void setConfiguration(MOAIDConfiguration conf) { +// // https://jira.spring.io/browse/SPR-3845 +// NewConfigurationDBRead.conf = conf; +// } +// +// @SuppressWarnings("unchecked") +// public static > T nullGuard(T item) { +// if (item == null) { +// return (T) Collections.emptyList(); +// } else { +// return item; +// } +// } +// +// /** +// * +// * @return +// */ +// public static List getAllUsers() { +// Logger.trace("Get All Users from database."); +// +// // select userdatabase from UserDatabase userdatabase +// List result = conf.getList("getAllUsers", UserDatabase.class); +// if (result.size() == 0) { +// Logger.trace("No entries found."); +// return null; +// } +// +// return result; +// } +// +// /** +// * +// * @return +// */ +// public static List getAllOnlineApplications() { +// Logger.trace("Get All OnlineApplications from database."); +// +// // select onlineapplication from OnlineApplication onlineapplication +// return conf.getList(MOAIDConfigurationConstants.ONLINE_APPLICATIONS_KEY, OnlineApplication.class); +// +// } +// +// /** +// * +// * @return +// */ +// public static List getAllNewOnlineApplications() { +// Logger.trace("Get All New OnlineApplications from database."); +// +// // select onlineapplication from OnlineApplication onlineapplication +// // where onlineapplication.isActive = '0' and onlineapplication.isAdminRequired = '1' +// List result = new ArrayList(); +// List allOAs = getAllOnlineApplications(); +// +// for (OnlineApplication oa : nullGuard(allOAs)) { +// if (!oa.isIsActive() && oa.isIsAdminRequired()) { +// result.add(oa); +// } +// } +// +// if (result.size() == 0) { +// Logger.trace("No entries found."); +// return null; +// } +// +// return result; +// } +// +// /** +// * +// * @return +// */ +// public static at.gv.egovernment.moa.id.commons.db.dao.config.MOAIDConfiguration getMOAIDConfiguration() { +// Logger.trace("Load MOAID Configuration from database."); +// +// AuthComponentGeneral authComponent = (AuthComponentGeneral) conf.get(MOAIDConfigurationConstants.AUTH_COMPONENT_GENERAL_KEY, +// AuthComponentGeneral.class); +// +// ChainingModes chainingModes = (ChainingModes) conf.get(MOAIDConfigurationConstants.CHAINING_MODES_KEY, ChainingModes.class); +// List genericConfigurations = (List) conf.getList( +// MOAIDConfigurationConstants.GENERIC_CONFIGURATION_KEY, GenericConfiguration.class); +// String trustedCaCertificates = (String) conf.get(MOAIDConfigurationConstants.TRUSTED_CERTIFICATES_KEY, String.class); +// DefaultBKUs defaultBKUs = (DefaultBKUs) conf.get(MOAIDConfigurationConstants.DEFAULT_BKUS_KEY, DefaultBKUs.class); +// SLRequestTemplates slrRequestRemplates = (SLRequestTemplates) conf.get(MOAIDConfigurationConstants.SLREQUEST_TEMPLATES_KEY, +// SLRequestTemplates.class); +// Date timeStamp = (Date) conf.get(MOAIDConfigurationConstants.TIMESTAMP_ITEM_KEY, Date.class); +// Date pvp2Refresh = (Date) conf.get(MOAIDConfigurationConstants.PVP2REFRESH_ITEM_KEY, Date.class); +// +// // if (authComponent == null || chainingModes == null || trustedCaCertificates == null || defaultBKUs == null +// // || slrRequestRemplates == null || timeStamp == null || pvp2Refresh == null +// // +// // ) { +// // // TODO: is there a better approach in case of error? +// // Logger.trace("Not all necessary data available. Create fresh instance."); +// // return new MOAIDConfiguration(); +// // } +// +// // select moaidconfiguration from MOAIDConfiguration moaidconfiguration +// at.gv.egovernment.moa.id.commons.db.dao.config.MOAIDConfiguration result = new at.gv.egovernment.moa.id.commons.db.dao.config.MOAIDConfiguration(); +// result.setAuthComponentGeneral(authComponent); +// result.setChainingModes(chainingModes); +// result.setGenericConfiguration(genericConfigurations); +// result.setTrustedCACertificates(trustedCaCertificates); +// result.setDefaultBKUs(defaultBKUs); +// result.setSLRequestTemplates(slrRequestRemplates); +// result.setTimestampItem(timeStamp); +// result.setPvp2RefreshItem(pvp2Refresh); +// +// return result; +// } +// +// /** +// * +// * @return +// */ +// public static List getAllActiveOnlineApplications() { +// Logger.trace("Get All New OnlineApplications from database."); +// +// // select onlineapplication from OnlineApplication onlineapplication +// // where onlineapplication.isActive = '1' +// List result = new ArrayList(); +// List allOAs = getAllOnlineApplications(); +// +// for (OnlineApplication oa : nullGuard(allOAs)) { +// if (oa.isIsActive()) { +// result.add(oa); +// } +// } +// +// if (result.size() == 0) { +// Logger.trace("No entries found."); +// return null; +// } +// +// return result; +// } +// +// /** +// * +// * @param id +// * @return +// */ +// public static OnlineApplication getActiveOnlineApplication(String id) { +// Logger.trace("Getting Active OnlineApplication with ID " + id + " from database."); +// +// // select onlineapplication from OnlineApplication onlineapplication +// // where onlineapplication.publicURLPrefix = +// // SUBSTRING(:id, 1, LENGTH(onlineapplication.publicURLPrefix)) and onlineapplication.isActive = '1' +// OnlineApplication result = null; +// List allActiveOAs = getAllActiveOnlineApplications(); +// +// for (OnlineApplication oa : nullGuard(allActiveOAs)) { +// String publicUrlPrefix = oa.getPublicURLPrefix(); +// if (publicUrlPrefix != null && publicUrlPrefix.length() <= id.length()) { +// if ((id.substring(1, publicUrlPrefix.length()).equals(publicUrlPrefix))) { +// if (result != null) { +// Logger.warn("OAIdentifier match to more then one DB-entry!"); +// return null; +// } else { +// result = oa; +// } +// } +// } +// } +// +// return result; +// } +// +// /** +// * +// * @param dbid +// * @return +// */ +// public static OnlineApplication getOnlineApplication(long dbid) { +// Logger.trace("Getting OnlineApplication with DBID " + dbid + " from database."); +// +// // select onlineapplication from OnlineApplication onlineapplication where onlineapplication.hjid = :id +// OnlineApplication result = null; +// List allOAs = getAllOnlineApplications(); +// +// for (OnlineApplication oa : nullGuard(allOAs)) { +// if (oa.getHjid() == dbid) { +// result = oa; +// break; +// } +// } +// +// return result; +// } +// +// /** +// * +// * @param id +// * @return +// */ +// public static OnlineApplication getOnlineApplication(String id) { +// Logger.trace("Getting OnlineApplication with ID " + id + " from database."); +// +// // select onlineapplication from OnlineApplication onlineapplication +// // where onlineapplication.publicURLPrefix = SUBSTRING(:id, 1, LENGTH(onlineapplication.publicURLPrefix)) +// OnlineApplication result = null; +// List allOAs = getAllOnlineApplications(); +// +// for (OnlineApplication oa : nullGuard(allOAs)) { +// String publicUrlPrefix = oa.getPublicURLPrefix(); +// if (publicUrlPrefix != null && publicUrlPrefix.length() <= id.length()) { +// if (id.substring(1, publicUrlPrefix.length()).equals(publicUrlPrefix)) { +// if (result != null) { +// Logger.warn("OAIdentifier match to more then one DB-entry!"); +// return null; +// } else { +// result = oa; +// } +// } +// } +// } +// +// return result; +// } +// +// /** +// * +// * @param id +// * @return +// */ +// public static List searchOnlineApplications(String id) { +// Logger.trace("Getting OnlineApplication with ID " + id + " from database."); +// +// // select onlineapplication from OnlineApplication onlineapplication +// // where onlineapplication.friendlyName like :id +// List result = new ArrayList(); +// List allOAs = getAllOnlineApplications(); +// +// for (OnlineApplication oa : nullGuard(allOAs)) { +// if (id.equals(oa.getFriendlyName())) { +// result.add(oa); +// } +// } +// +// if (result.size() == 0) { +// Logger.trace("No entries found."); +// return null; +// } +// +// return result; +// } +// +// /** +// * +// * @return +// */ +// public static List getAllOpenUsersRequests() { +// Logger.trace("Get all new Users from Database"); +// +// // select userdatabase from UserDatabase userdatabase +// // where userdatabase.userRequestTokken is not null +// // and userdatabase.isAdminRequest = '1' and userdatabase.isMailAddressVerified = '0' +// List result = new ArrayList(); +// List allUsers = getAllUsers(); +// +// for (UserDatabase user : nullGuard(allUsers)) { +// // TODO check result of query "... userdatabase.userRequestTokken is not null" if Tokken is null -> (null, "NULL", "", ... ?) +// if ((user.getUserRequestTokken() != null && !user.getUserRequestTokken().isEmpty() && !user.getUserRequestTokken().equals("NULL")) +// && (user.isIsAdminRequest()) && (!user.isIsMailAddressVerified())) { +// result.add(user); +// } +// } +// +// if (result.size() == 0) { +// Logger.trace("No entries found."); +// return null; +// } +// +// return result; +// } +// +// /** +// * +// * @param tokken +// * @return +// */ +// public static UserDatabase getNewUserWithTokken(String tokken) { +// Logger.trace("Getting Userinformation with Tokken " + tokken + " from database."); +// +// // select userdatabase from UserDatabase userdatabase where userdatabase.userRequestTokken = :tokken +// UserDatabase result = null; +// List allUsers = getAllUsers(); +// +// for (UserDatabase user : nullGuard(allUsers)) { +// if (user.getUserRequestTokken().equals(tokken)) { +// result = user; +// break; +// } +// } +// +// return result; +// } +// +// /** +// * +// * @param id +// * @return +// */ +// public static UserDatabase getUsersWithOADBID(long id) { +// Logger.trace("Getting Userinformation with OADBID " + id + " from database."); +// +// // select userdatabase from UserDatabase userdatabase +// // inner join userdatabase.onlineApplication oa where oa.hjid = :id +// UserDatabase result = null; +// List allUsers = getAllUsers(); +// +// boolean quit = false; +// for (UserDatabase user : nullGuard(allUsers)) { +// +// for (OnlineApplication oa : user.getOnlineApplication()) { +// +// if (oa.getHjid() == id) { +// result = user; +// quit = true; +// break; +// } +// } +// +// if (quit) { +// break; +// } +// } +// +// return result; +// } +// +// /** +// * +// * @param id +// * @return +// */ +// public static UserDatabase getUserWithID(long id) { +// Logger.trace("Getting Userinformation with ID " + id + " from database."); +// +// // select userdatabase from UserDatabase userdatabase where userdatabase.hjid = :id +// UserDatabase result = null; +// List allUsers = getAllUsers(); +// +// for (UserDatabase user : nullGuard(allUsers)) { +// if (user.getHjid() == id) { +// result = user; +// break; +// } +// } +// +// return result; +// } +// +// /** +// * +// * @param username +// * @return +// */ +// public static UserDatabase getUserWithUserName(String username) { +// Logger.trace("Getting Userinformation with ID " + username + " from database."); +// +// // select userdatabase from UserDatabase userdatabase where userdatabase.username = :username +// UserDatabase result = null; +// List allUsers = getAllUsers(); +// +// for (UserDatabase user : nullGuard(allUsers)) { +// if (user.getUsername().equals(username)) { +// result = user; +// break; +// } +// } +// +// return result; +// } +// +// /** +// * +// * @param bpkwbpk +// * @return +// */ +// public static UserDatabase getUserWithUserBPKWBPK(String bpkwbpk) { +// Logger.trace("Getting Userinformation with ID " + bpkwbpk + " from database."); +// +// // select userdatabase from UserDatabase userdatabase where userdatabase.bpk = :bpk +// UserDatabase result = null; +// List allUsers = getAllUsers(); +// +// for (UserDatabase user : nullGuard(allUsers)) { +// if (user.getBpk().equals(bpkwbpk)) { +// result = user; +// break; +// } +// } +// +// return result; +// } +// +//} diff --git a/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/NewConfigurationDBWrite.java b/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/NewConfigurationDBWrite.java index 69e03db28..a2b1f120e 100644 --- a/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/NewConfigurationDBWrite.java +++ b/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/NewConfigurationDBWrite.java @@ -1,137 +1,137 @@ -package at.gv.egovernment.moa.id.commons.db; - -import java.util.Date; -import java.util.List; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -import at.gv.egovernment.moa.id.commons.config.MOAIDConfigurationConstants; -import at.gv.egovernment.moa.id.commons.config.persistence.MOAIDConfiguration; -import at.gv.egovernment.moa.id.commons.db.dao.config.AuthComponentGeneral; -import at.gv.egovernment.moa.id.commons.db.dao.config.ChainingModes; -import at.gv.egovernment.moa.id.commons.db.dao.config.DefaultBKUs; -import at.gv.egovernment.moa.id.commons.db.dao.config.GenericConfiguration; -import at.gv.egovernment.moa.id.commons.db.dao.config.OnlineApplication; -import at.gv.egovernment.moa.id.commons.db.dao.config.SLRequestTemplates; -import at.gv.egovernment.moa.id.commons.db.dao.config.UserDatabase; - -/** - * This class is used for writing to the key-value database. - */ -@Component -public class NewConfigurationDBWrite { - - private static MOAIDConfiguration conf; - - @Autowired(required = true) - public void setConfiguration(MOAIDConfiguration conf) { - // https://jira.spring.io/browse/SPR-3845 - NewConfigurationDBWrite.conf = conf; - } - - private static boolean saveAuthComponentGeneral(AuthComponentGeneral dbo) { - return conf.set(MOAIDConfigurationConstants.AUTH_COMPONENT_GENERAL_KEY, dbo); - } - - private static boolean saveChainingModes(ChainingModes dbo) { - return conf.set(MOAIDConfigurationConstants.CHAINING_MODES_KEY, dbo); - } - - private static boolean saveOnlineApplication(OnlineApplication dbo) { - - List storedObjects = conf.getList(MOAIDConfigurationConstants.ONLINE_APPLICATIONS_KEY, OnlineApplication.class); - storedObjects.add(dbo); - return conf.set(MOAIDConfigurationConstants.ONLINE_APPLICATIONS_KEY, storedObjects); - } - - private static boolean saveGenericConfiguration(GenericConfiguration dbo) { - - List storedObjects = conf.getList(MOAIDConfigurationConstants.GENERIC_CONFIGURATION_KEY, GenericConfiguration.class); - storedObjects.add(dbo); - return conf.set(MOAIDConfigurationConstants.GENERIC_CONFIGURATION_KEY, storedObjects); - } - - private static boolean saveTrustedCACertificates(String dbo) { - return conf.set(MOAIDConfigurationConstants.TRUSTED_CERTIFICATES_KEY, dbo); - } - - private static boolean saveDefaultBKUs(DefaultBKUs dbo) { - return conf.set(MOAIDConfigurationConstants.DEFAULT_BKUS_KEY, dbo); - } - - private static boolean saveSLRequestTemplates(SLRequestTemplates dbo) { - return conf.set(MOAIDConfigurationConstants.SLREQUEST_TEMPLATES_KEY, dbo); - } - - private static boolean saveTimeStampItem(Date dbo) { - return conf.set(MOAIDConfigurationConstants.TIMESTAMP_ITEM_KEY, dbo); - } - - private static boolean savePvp2RefreshItem(Date dbo) { - return conf.set(MOAIDConfigurationConstants.PVP2REFRESH_ITEM_KEY, dbo); - } - - /** - * Saves the given list of {@link OnlineApplication} objects to database. - * @param oas the list - * @return {@code true} on success; {@code false} otherwise. - */ - public static boolean saveOnlineApplications(List oas) { - return conf.set(MOAIDConfigurationConstants.ONLINE_APPLICATIONS_KEY, oas); - } - - /** - * Saves the given list of {@link GenericConfiguration} objects to database. - * @param gcs the list - * @return {@code true} on success; {@code false} otherwise. - */ - public static boolean saveGenericConfigurations(List gcs) { - return conf.set(MOAIDConfigurationConstants.GENERIC_CONFIGURATION_KEY, gcs); - } - - - /** - * Saves the given object to database - * @param dbo the object to save - * @return {@code true} on success; {@code false} otherwise. - */ - public static boolean save(Object dbo) { - - boolean result = false; - - if (dbo instanceof OnlineApplication) { - - result = saveOnlineApplication((OnlineApplication) dbo); - - } else if (dbo instanceof MOAIDConfiguration) { - - at.gv.egovernment.moa.id.commons.db.dao.config.MOAIDConfiguration moaconfig = - (at.gv.egovernment.moa.id.commons.db.dao.config.MOAIDConfiguration) dbo; - result = true; - - result &= saveAuthComponentGeneral(moaconfig.getAuthComponentGeneral()); - result &= saveChainingModes(moaconfig.getChainingModes()); - result &= saveDefaultBKUs(moaconfig.getDefaultBKUs()); - result &= saveGenericConfigurations(moaconfig.getGenericConfiguration()); - result &= savePvp2RefreshItem(moaconfig.getPvp2RefreshItem()); - result &= saveSLRequestTemplates(moaconfig.getSLRequestTemplates()); - result &= saveTrustedCACertificates(moaconfig.getTrustedCACertificates()); - result &= saveTimeStampItem(moaconfig.getTimestampItem()); - - } else if (dbo instanceof UserDatabase) { - // TODO implement user handling - } - - return result; - } - - /** - * Deletes the object associated with the given key. - * @param key the key - */ - public static void delete(String key) { - conf.set(key, null); - } - -} +//package at.gv.egovernment.moa.id.commons.db; +// +//import java.util.Date; +//import java.util.List; +// +//import org.springframework.beans.factory.annotation.Autowired; +//import org.springframework.stereotype.Component; +// +//import at.gv.egovernment.moa.id.commons.config.MOAIDConfigurationConstants; +//import at.gv.egovernment.moa.id.commons.config.persistence.MOAIDConfiguration; +//import at.gv.egovernment.moa.id.commons.db.dao.config.AuthComponentGeneral; +//import at.gv.egovernment.moa.id.commons.db.dao.config.ChainingModes; +//import at.gv.egovernment.moa.id.commons.db.dao.config.DefaultBKUs; +//import at.gv.egovernment.moa.id.commons.db.dao.config.GenericConfiguration; +//import at.gv.egovernment.moa.id.commons.db.dao.config.OnlineApplication; +//import at.gv.egovernment.moa.id.commons.db.dao.config.SLRequestTemplates; +//import at.gv.egovernment.moa.id.commons.db.dao.config.UserDatabase; +// +///** +// * This class is used for writing to the key-value database. +// */ +//@Component +//public class NewConfigurationDBWrite { +// +// private static MOAIDConfiguration conf; +// +// @Autowired(required = true) +// public void setConfiguration(MOAIDConfiguration conf) { +// // https://jira.spring.io/browse/SPR-3845 +// NewConfigurationDBWrite.conf = conf; +// } +// +// private static boolean saveAuthComponentGeneral(AuthComponentGeneral dbo) { +// return conf.set(MOAIDConfigurationConstants.AUTH_COMPONENT_GENERAL_KEY, dbo); +// } +// +// private static boolean saveChainingModes(ChainingModes dbo) { +// return conf.set(MOAIDConfigurationConstants.CHAINING_MODES_KEY, dbo); +// } +// +// private static boolean saveOnlineApplication(OnlineApplication dbo) { +// +// List storedObjects = conf.getList(MOAIDConfigurationConstants.ONLINE_APPLICATIONS_KEY, OnlineApplication.class); +// storedObjects.add(dbo); +// return conf.set(MOAIDConfigurationConstants.ONLINE_APPLICATIONS_KEY, storedObjects); +// } +// +// private static boolean saveGenericConfiguration(GenericConfiguration dbo) { +// +// List storedObjects = conf.getList(MOAIDConfigurationConstants.GENERIC_CONFIGURATION_KEY, GenericConfiguration.class); +// storedObjects.add(dbo); +// return conf.set(MOAIDConfigurationConstants.GENERIC_CONFIGURATION_KEY, storedObjects); +// } +// +// private static boolean saveTrustedCACertificates(String dbo) { +// return conf.set(MOAIDConfigurationConstants.TRUSTED_CERTIFICATES_KEY, dbo); +// } +// +// private static boolean saveDefaultBKUs(DefaultBKUs dbo) { +// return conf.set(MOAIDConfigurationConstants.DEFAULT_BKUS_KEY, dbo); +// } +// +// private static boolean saveSLRequestTemplates(SLRequestTemplates dbo) { +// return conf.set(MOAIDConfigurationConstants.SLREQUEST_TEMPLATES_KEY, dbo); +// } +// +// private static boolean saveTimeStampItem(Date dbo) { +// return conf.set(MOAIDConfigurationConstants.TIMESTAMP_ITEM_KEY, dbo); +// } +// +// private static boolean savePvp2RefreshItem(Date dbo) { +// return conf.set(MOAIDConfigurationConstants.PVP2REFRESH_ITEM_KEY, dbo); +// } +// +// /** +// * Saves the given list of {@link OnlineApplication} objects to database. +// * @param oas the list +// * @return {@code true} on success; {@code false} otherwise. +// */ +// public static boolean saveOnlineApplications(List oas) { +// return conf.set(MOAIDConfigurationConstants.ONLINE_APPLICATIONS_KEY, oas); +// } +// +// /** +// * Saves the given list of {@link GenericConfiguration} objects to database. +// * @param gcs the list +// * @return {@code true} on success; {@code false} otherwise. +// */ +// public static boolean saveGenericConfigurations(List gcs) { +// return conf.set(MOAIDConfigurationConstants.GENERIC_CONFIGURATION_KEY, gcs); +// } +// +// +// /** +// * Saves the given object to database +// * @param dbo the object to save +// * @return {@code true} on success; {@code false} otherwise. +// */ +// public static boolean save(Object dbo) { +// +// boolean result = false; +// +// if (dbo instanceof OnlineApplication) { +// +// result = saveOnlineApplication((OnlineApplication) dbo); +// +// } else if (dbo instanceof MOAIDConfiguration) { +// +// at.gv.egovernment.moa.id.commons.db.dao.config.MOAIDConfiguration moaconfig = +// (at.gv.egovernment.moa.id.commons.db.dao.config.MOAIDConfiguration) dbo; +// result = true; +// +// result &= saveAuthComponentGeneral(moaconfig.getAuthComponentGeneral()); +// result &= saveChainingModes(moaconfig.getChainingModes()); +// result &= saveDefaultBKUs(moaconfig.getDefaultBKUs()); +// result &= saveGenericConfigurations(moaconfig.getGenericConfiguration()); +// result &= savePvp2RefreshItem(moaconfig.getPvp2RefreshItem()); +// result &= saveSLRequestTemplates(moaconfig.getSLRequestTemplates()); +// result &= saveTrustedCACertificates(moaconfig.getTrustedCACertificates()); +// result &= saveTimeStampItem(moaconfig.getTimestampItem()); +// +// } else if (dbo instanceof UserDatabase) { +// // TODO implement user handling +// } +// +// return result; +// } +// +// /** +// * Deletes the object associated with the given key. +// * @param key the key +// */ +// public static void delete(String key) { +// conf.set(key, null); +// } +// +//} diff --git a/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/utils/MOAHttpProtocolSocketFactory.java b/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/utils/MOAHttpProtocolSocketFactory.java index 3b6fc34ea..2ade63c1c 100644 --- a/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/utils/MOAHttpProtocolSocketFactory.java +++ b/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/utils/MOAHttpProtocolSocketFactory.java @@ -37,7 +37,6 @@ import org.apache.commons.httpclient.ConnectTimeoutException; import org.apache.commons.httpclient.params.HttpConnectionParams; import org.apache.commons.httpclient.protocol.SecureProtocolSocketFactory; -import at.gv.egovernment.moa.id.commons.db.dao.config.ChainingModeType; import at.gv.egovernment.moa.id.commons.ex.MOAHttpProtocolSocketFactoryException; import at.gv.egovernment.moa.id.commons.utils.ssl.SSLConfigurationException; import at.gv.egovernment.moa.id.commons.utils.ssl.SSLUtils; @@ -57,7 +56,7 @@ public class MOAHttpProtocolSocketFactory implements SecureProtocolSocketFactory String certStoreRootDirParam, String trustStoreURL, String acceptedServerCertURL, - ChainingModeType chainingMode, + String chainingMode, boolean checkRevocation ) throws MOAHttpProtocolSocketFactoryException { super(); @@ -68,7 +67,7 @@ public class MOAHttpProtocolSocketFactory implements SecureProtocolSocketFactory certStoreRootDirParam, trustStoreURL, acceptedServerCertURL, - chainingMode.value(), + chainingMode, checkRevocation, null, null, -- cgit v1.2.3