From 7b6f65663145b228991794d6390567fbb84dc9c0 Mon Sep 17 00:00:00 2001 From: Thomas Lenz Date: Mon, 20 Jul 2015 13:58:32 +0200 Subject: remove deprecated MOA-ID 2.x configuration DAO functionality --- id/server/moa-id-commons/pom.xml | 15 +- .../config/ConfigurationMigrationUtils.java | 98 +- .../moa/id/commons/config/ConfigurationUtil.java | 6 +- .../moa/id/commons/db/ConfigurationDBRead.java | 802 +++++++-------- .../moa/id/commons/db/ConfigurationDBUtils.java | 454 ++++----- .../moa/id/commons/db/NewConfigurationDBRead.java | 872 ++++++++-------- .../db/dao/config/DatabaseConfigPropertyImpl.java | 2 +- .../src/main/resources/META-INF/persistence.xml | 5 - .../moa-id-commons/src/main/resources/bindings.xjb | 4 +- .../src/main/resources/config/moaid_config_3.0.xsd | 1057 -------------------- .../src/main/resources/configuration.beans.xml_old | 59 -- .../src/main/resources/moaid.migration.beans.xml | 5 - .../src/main/resources/persistence_template.xml | 24 - .../moa/id/commons/db/ConfigurationDBReadTest.java | 2 +- 14 files changed, 1128 insertions(+), 2277 deletions(-) delete mode 100644 id/server/moa-id-commons/src/main/resources/config/moaid_config_3.0.xsd delete mode 100644 id/server/moa-id-commons/src/main/resources/configuration.beans.xml_old delete mode 100644 id/server/moa-id-commons/src/main/resources/persistence_template.xml (limited to 'id/server/moa-id-commons') diff --git a/id/server/moa-id-commons/pom.xml b/id/server/moa-id-commons/pom.xml index 66e42e850..f4adb1368 100644 --- a/id/server/moa-id-commons/pom.xml +++ b/id/server/moa-id-commons/pom.xml @@ -127,6 +127,7 @@ hyperjaxb3-ejb-runtime 0.5.6 + - + - + org.apache.maven.plugins @@ -295,7 +296,7 @@ - + true maven-compiler-plugin diff --git a/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/config/ConfigurationMigrationUtils.java b/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/config/ConfigurationMigrationUtils.java index 4f47efb78..ae481578a 100644 --- a/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/config/ConfigurationMigrationUtils.java +++ b/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/config/ConfigurationMigrationUtils.java @@ -34,55 +34,55 @@ import java.util.Iterator; import java.util.List; import java.util.Map; -import at.gv.egovernment.moa.id.commons.db.dao.config.AttributeProviderPlugin; -import at.gv.egovernment.moa.id.commons.db.dao.config.AuthComponentGeneral; -import at.gv.egovernment.moa.id.commons.db.dao.config.AuthComponentOA; -import at.gv.egovernment.moa.id.commons.db.dao.config.BKUSelectionCustomizationType; -import at.gv.egovernment.moa.id.commons.db.dao.config.BKUURLS; -import at.gv.egovernment.moa.id.commons.db.dao.config.BPKDecryption; -import at.gv.egovernment.moa.id.commons.db.dao.config.CPEPS; -import at.gv.egovernment.moa.id.commons.db.dao.config.ChainingModeType; -import at.gv.egovernment.moa.id.commons.db.dao.config.ChainingModes; -import at.gv.egovernment.moa.id.commons.db.dao.config.ConnectionParameterClientAuthType; -import at.gv.egovernment.moa.id.commons.db.dao.config.Contact; -import at.gv.egovernment.moa.id.commons.db.dao.config.DefaultBKUs; -import at.gv.egovernment.moa.id.commons.db.dao.config.EncBPKInformation; -import at.gv.egovernment.moa.id.commons.db.dao.config.ForeignIdentities; -import at.gv.egovernment.moa.id.commons.db.dao.config.GeneralConfiguration; -import at.gv.egovernment.moa.id.commons.db.dao.config.IdentificationNumber; -import at.gv.egovernment.moa.id.commons.db.dao.config.IdentityLinkSigners; -import at.gv.egovernment.moa.id.commons.db.dao.config.InterfederationGatewayType; -import at.gv.egovernment.moa.id.commons.db.dao.config.InterfederationIDPType; -import at.gv.egovernment.moa.id.commons.db.dao.config.LegacyAllowed; -import at.gv.egovernment.moa.id.commons.db.dao.config.MOAIDConfiguration; -import at.gv.egovernment.moa.id.commons.db.dao.config.MOAKeyBoxSelector; -import at.gv.egovernment.moa.id.commons.db.dao.config.MOASP; -import at.gv.egovernment.moa.id.commons.db.dao.config.Mandates; -import at.gv.egovernment.moa.id.commons.db.dao.config.OAOAUTH20; -import at.gv.egovernment.moa.id.commons.db.dao.config.OAPVP2; -import at.gv.egovernment.moa.id.commons.db.dao.config.OASAML1; -import at.gv.egovernment.moa.id.commons.db.dao.config.OASSO; -import at.gv.egovernment.moa.id.commons.db.dao.config.OASTORK; -import at.gv.egovernment.moa.id.commons.db.dao.config.OAStorkAttribute; -import at.gv.egovernment.moa.id.commons.db.dao.config.OAuth; -import at.gv.egovernment.moa.id.commons.db.dao.config.OnlineApplication; -import at.gv.egovernment.moa.id.commons.db.dao.config.OnlineMandates; -import at.gv.egovernment.moa.id.commons.db.dao.config.Organization; -import at.gv.egovernment.moa.id.commons.db.dao.config.PVP2; -import at.gv.egovernment.moa.id.commons.db.dao.config.Protocols; -import at.gv.egovernment.moa.id.commons.db.dao.config.SAML1; -import at.gv.egovernment.moa.id.commons.db.dao.config.SLRequestTemplates; -import at.gv.egovernment.moa.id.commons.db.dao.config.SSO; -import at.gv.egovernment.moa.id.commons.db.dao.config.STORK; -import at.gv.egovernment.moa.id.commons.db.dao.config.SecurityLayer; -import at.gv.egovernment.moa.id.commons.db.dao.config.StorkAttribute; -import at.gv.egovernment.moa.id.commons.db.dao.config.TemplateType; -import at.gv.egovernment.moa.id.commons.db.dao.config.TemplatesType; -import at.gv.egovernment.moa.id.commons.db.dao.config.TestCredentials; -import at.gv.egovernment.moa.id.commons.db.dao.config.TimeOuts; -import at.gv.egovernment.moa.id.commons.db.dao.config.TransformsInfoType; -import at.gv.egovernment.moa.id.commons.db.dao.config.VerifyAuthBlock; -import at.gv.egovernment.moa.id.commons.db.dao.config.VerifyIdentityLink; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.AttributeProviderPlugin; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.AuthComponentGeneral; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.AuthComponentOA; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.BKUSelectionCustomizationType; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.BKUURLS; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.BPKDecryption; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.CPEPS; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.ChainingModeType; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.ChainingModes; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.ConnectionParameterClientAuthType; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.Contact; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.DefaultBKUs; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.EncBPKInformation; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.ForeignIdentities; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.GeneralConfiguration; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.IdentificationNumber; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.IdentityLinkSigners; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.InterfederationGatewayType; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.InterfederationIDPType; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.LegacyAllowed; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.MOAIDConfiguration; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.MOAKeyBoxSelector; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.MOASP; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.Mandates; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.OAOAUTH20; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.OAPVP2; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.OASAML1; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.OASSO; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.OASTORK; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.OAStorkAttribute; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.OAuth; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.OnlineApplication; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.OnlineMandates; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.Organization; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.PVP2; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.Protocols; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.SAML1; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.SLRequestTemplates; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.SSO; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.STORK; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.SecurityLayer; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.StorkAttribute; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.TemplateType; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.TemplatesType; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.TestCredentials; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.TimeOuts; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.TransformsInfoType; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.VerifyAuthBlock; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.VerifyIdentityLink; import at.gv.egovernment.moa.id.commons.utils.KeyValueUtils; import at.gv.egovernment.moa.id.commons.validation.TargetValidator; import at.gv.egovernment.moa.logging.Logger; 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 399533d3f..762ae44a0 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 @@ -21,9 +21,9 @@ 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.id.commons.db.dao.config.STORK; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.MOAIDConfiguration; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.OnlineApplication; +import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.STORK; import at.gv.egovernment.moa.logging.Logger; import at.gv.egovernment.moa.util.MiscUtil; 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 5c14df671..3836d5a1e 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 @@ -1,403 +1,403 @@ -/******************************************************************************* - * Copyright 2014 Federal Chancellery Austria - * MOA-ID has been developed in a cooperation between BRZ, the Federal - * Chancellery Austria - ICT staff unit, and Graz University of Technology. - * - * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by - * the European Commission - subsequent versions of the EUPL (the "Licence"); - * You may not use this work except in compliance with the Licence. - * You may obtain a copy of the Licence at: - * http://www.osor.eu/eupl/ - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the Licence is distributed on an "AS IS" basis, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the Licence for the specific language governing permissions and - * limitations under the Licence. - * - * This product combines work with different licenses. See the "NOTICE" text - * file for details on the various modules and licenses. - * The "NOTICE" text file is part of the distribution. Any derivative works - * that you distribute must include a readable copy of the "NOTICE" text file. - *******************************************************************************/ -package at.gv.egovernment.moa.id.commons.db; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import javax.persistence.EntityManager; - -import org.apache.commons.lang3.StringEscapeUtils; - -import at.gv.egovernment.moa.id.commons.db.dao.config.MOAIDConfiguration; -import at.gv.egovernment.moa.id.commons.db.dao.config.OnlineApplication; -import at.gv.egovernment.moa.id.commons.db.dao.config.UserDatabase; -import at.gv.egovernment.moa.logging.Logger; -import at.gv.egovernment.moa.util.MiscUtil; -//import org.apache.commons.lang.StringEscapeUtils; - -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * - * @author tlenz - * - * @deprecated - */ - -@SuppressWarnings("rawtypes") -public class ConfigurationDBRead { - - private static Map QUERIES = new HashMap(); - - static { - QUERIES.put("getActiveOnlineApplicationWithID", "select onlineapplication from OnlineApplication onlineapplication where onlineapplication.publicURLPrefix = SUBSTRING(:id, 1, LENGTH(onlineapplication.publicURLPrefix)) and onlineapplication.isActive = '1'"); - QUERIES.put("getOnlineApplicationWithID", "select onlineapplication from OnlineApplication onlineapplication where onlineapplication.publicURLPrefix = SUBSTRING(:id, 1, LENGTH(onlineapplication.publicURLPrefix))"); - QUERIES.put("getOnlineApplicationWithDBID", "select onlineapplication from OnlineApplication onlineapplication where onlineapplication.hjid = :id"); - QUERIES.put("getAllOnlineApplications", "select onlineapplication from OnlineApplication onlineapplication"); - QUERIES.put("getAllActiveOnlineApplications", "select onlineapplication from OnlineApplication onlineapplication where onlineapplication.isActive = '1'"); - QUERIES.put("getAllNewOnlineApplications", "select onlineapplication from OnlineApplication onlineapplication where onlineapplication.isActive = '0' and onlineapplication.isAdminRequired = '1'"); - QUERIES.put("getMOAIDConfiguration", "select moaidconfiguration from MOAIDConfiguration moaidconfiguration"); - QUERIES.put("getUserWithUserID", "select userdatabase from UserDatabase userdatabase where userdatabase.hjid = :id"); - QUERIES.put("getNewUserWithUserTokken", "select userdatabase from UserDatabase userdatabase where userdatabase.userRequestTokken = :tokken"); - QUERIES.put("getAllNewUsers", "select userdatabase from UserDatabase userdatabase where userdatabase.userRequestTokken is null and userdatabase.isAdminRequest = '1' and userdatabase.isMailAddressVerified = '1'"); - QUERIES.put("getAllOpenUsersRequests", "select userdatabase from UserDatabase userdatabase where userdatabase.userRequestTokken is not null and userdatabase.isAdminRequest = '1' and userdatabase.isMailAddressVerified = '0'"); - QUERIES.put("getUserWithUserBPKWBPK", "select userdatabase from UserDatabase userdatabase where userdatabase.bpk = :bpk"); - QUERIES.put("getUserWithUserUsername", "select userdatabase from UserDatabase userdatabase where userdatabase.username = :username"); - QUERIES.put("getAllUsers", "select userdatabase from UserDatabase userdatabase"); - QUERIES.put("getUsersWithOADBID", "select userdatabase from UserDatabase userdatabase inner join userdatabase.onlineApplication oa where oa.hjid = :id"); - 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 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 getAllOnlineApplications() { -// Logger.trace("Get All OnlineApplications from database."); -// -// List 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 getAllNewOnlineApplications() { -// Logger.trace("Get All OnlineApplications from database."); -// -// List 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 getAllUsers() { -// Logger.trace("Get All OnlineApplications from database."); -// -// List 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 getAllActiveOnlineApplications() { -// Logger.trace("Get All active OnlineApplications from database."); -// -// List 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(); -// -// } -// return result; -// } -// -// @SuppressWarnings("rawtypes") -// public static List searchOnlineApplications(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("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 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 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 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); +///******************************************************************************* +// * Copyright 2014 Federal Chancellery Austria +// * MOA-ID has been developed in a cooperation between BRZ, the Federal +// * Chancellery Austria - ICT staff unit, and Graz University of Technology. +// * +// * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by +// * the European Commission - subsequent versions of the EUPL (the "Licence"); +// * You may not use this work except in compliance with the Licence. +// * You may obtain a copy of the Licence at: +// * http://www.osor.eu/eupl/ +// * +// * Unless required by applicable law or agreed to in writing, software +// * distributed under the Licence is distributed on an "AS IS" basis, +// * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// * See the Licence for the specific language governing permissions and +// * limitations under the Licence. +// * +// * This product combines work with different licenses. See the "NOTICE" text +// * file for details on the various modules and licenses. +// * The "NOTICE" text file is part of the distribution. Any derivative works +// * that you distribute must include a readable copy of the "NOTICE" text file. +// *******************************************************************************/ +//package at.gv.egovernment.moa.id.commons.db; +// +//import java.util.ArrayList; +//import java.util.HashMap; +//import java.util.List; +//import java.util.Map; +// +//import javax.persistence.EntityManager; +// +//import org.apache.commons.lang3.StringEscapeUtils; +// +//import at.gv.egovernment.moa.id.commons.db.dao.config.MOAIDConfiguration; +//import at.gv.egovernment.moa.id.commons.db.dao.config.OnlineApplication; +//import at.gv.egovernment.moa.id.commons.db.dao.config.UserDatabase; +//import at.gv.egovernment.moa.logging.Logger; +//import at.gv.egovernment.moa.util.MiscUtil; +////import org.apache.commons.lang.StringEscapeUtils; +// +//import com.fasterxml.jackson.annotation.JsonProperty; +// +///** +// * +// * @author tlenz +// * +// * @deprecated +// */ +// +//@SuppressWarnings("rawtypes") +//public class ConfigurationDBRead { +// +// private static Map QUERIES = new HashMap(); +// +// static { +// QUERIES.put("getActiveOnlineApplicationWithID", "select onlineapplication from OnlineApplication onlineapplication where onlineapplication.publicURLPrefix = SUBSTRING(:id, 1, LENGTH(onlineapplication.publicURLPrefix)) and onlineapplication.isActive = '1'"); +// QUERIES.put("getOnlineApplicationWithID", "select onlineapplication from OnlineApplication onlineapplication where onlineapplication.publicURLPrefix = SUBSTRING(:id, 1, LENGTH(onlineapplication.publicURLPrefix))"); +// QUERIES.put("getOnlineApplicationWithDBID", "select onlineapplication from OnlineApplication onlineapplication where onlineapplication.hjid = :id"); +// QUERIES.put("getAllOnlineApplications", "select onlineapplication from OnlineApplication onlineapplication"); +// QUERIES.put("getAllActiveOnlineApplications", "select onlineapplication from OnlineApplication onlineapplication where onlineapplication.isActive = '1'"); +// QUERIES.put("getAllNewOnlineApplications", "select onlineapplication from OnlineApplication onlineapplication where onlineapplication.isActive = '0' and onlineapplication.isAdminRequired = '1'"); +// QUERIES.put("getMOAIDConfiguration", "select moaidconfiguration from MOAIDConfiguration moaidconfiguration"); +// QUERIES.put("getUserWithUserID", "select userdatabase from UserDatabase userdatabase where userdatabase.hjid = :id"); +// QUERIES.put("getNewUserWithUserTokken", "select userdatabase from UserDatabase userdatabase where userdatabase.userRequestTokken = :tokken"); +// QUERIES.put("getAllNewUsers", "select userdatabase from UserDatabase userdatabase where userdatabase.userRequestTokken is null and userdatabase.isAdminRequest = '1' and userdatabase.isMailAddressVerified = '1'"); +// QUERIES.put("getAllOpenUsersRequests", "select userdatabase from UserDatabase userdatabase where userdatabase.userRequestTokken is not null and userdatabase.isAdminRequest = '1' and userdatabase.isMailAddressVerified = '0'"); +// QUERIES.put("getUserWithUserBPKWBPK", "select userdatabase from UserDatabase userdatabase where userdatabase.bpk = :bpk"); +// QUERIES.put("getUserWithUserUsername", "select userdatabase from UserDatabase userdatabase where userdatabase.username = :username"); +// QUERIES.put("getAllUsers", "select userdatabase from UserDatabase userdatabase"); +// QUERIES.put("getUsersWithOADBID", "select userdatabase from UserDatabase userdatabase inner join userdatabase.onlineApplication oa where oa.hjid = :id"); +// QUERIES.put("searchOnlineApplicationsWithID", "select onlineapplication from OnlineApplication onlineapplication where onlineapplication.friendlyName like :id"); // } // -// public static UserDatabase getUserWithUserBPKWBPK(String bpkwbpk) { -// MiscUtil.assertNotNull(bpkwbpk, "bpk/wbpk"); -// Logger.trace("Getting Userinformation with ID " + bpkwbpk + " from database."); -// -// List 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 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 getAllNewUsers() { -// Logger.trace("Get all new Users from Database"); -// -// List 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 getAllOpenUsersRequests() { -// Logger.trace("Get all new Users from Database"); -// -// List 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 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 getAllOnlineApplications() { +//// Logger.trace("Get All OnlineApplications from database."); +//// +//// List 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 getAllNewOnlineApplications() { +//// Logger.trace("Get All OnlineApplications from database."); +//// +//// List 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 getAllUsers() { +//// Logger.trace("Get All OnlineApplications from database."); +//// +//// List 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 getAllActiveOnlineApplications() { +//// Logger.trace("Get All active OnlineApplications from database."); +//// +//// List 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(); +//// +//// } +//// return result; +//// } +//// +//// @SuppressWarnings("rawtypes") +//// public static List searchOnlineApplications(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("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 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 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 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 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 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 getAllNewUsers() { +//// Logger.trace("Get all new Users from Database"); +//// +//// List 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 getAllOpenUsersRequests() { +//// Logger.trace("Get all new Users from Database"); +//// +//// List 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 d9f0267df..7f996cca7 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 @@ -1,233 +1,233 @@ -/******************************************************************************* - * Copyright 2014 Federal Chancellery Austria - * MOA-ID has been developed in a cooperation between BRZ, the Federal - * Chancellery Austria - ICT staff unit, and Graz University of Technology. - * - * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by - * the European Commission - subsequent versions of the EUPL (the "Licence"); - * You may not use this work except in compliance with the Licence. - * You may obtain a copy of the Licence at: - * http://www.osor.eu/eupl/ - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the Licence is distributed on an "AS IS" basis, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the Licence for the specific language governing permissions and - * limitations under the Licence. - * - * This product combines work with different licenses. See the "NOTICE" text - * file for details on the various modules and licenses. - * The "NOTICE" text file is part of the distribution. Any derivative works - * that you distribute must include a readable copy of the "NOTICE" text file. - *******************************************************************************/ -package at.gv.egovernment.moa.id.commons.db; - -import java.util.Properties; - -import javax.persistence.EntityManager; -import javax.persistence.EntityManagerFactory; -import javax.persistence.EntityTransaction; -import javax.persistence.Persistence; - -import org.hibernate.HibernateException; - -import at.gv.egovernment.moa.id.commons.db.ex.MOADatabaseException; -import at.gv.egovernment.moa.logging.Logger; - -public final class ConfigurationDBUtils { - - private static EntityManagerFactory entitymanagerfactory; - - @SuppressWarnings("rawtypes") - private static final ThreadLocal THREAD_LOCAL_CONFIG = new ThreadLocal(); - private static boolean automaticSessionHandling = false; - - protected ConfigurationDBUtils() { } - - public static void initHibernate(Properties props) throws MOADatabaseException { - - try { - - Logger.debug("Creating initial session factory..."); - - entitymanagerfactory = - Persistence.createEntityManagerFactory("at.gv.egovernment.moa.id.commons.db.dao.config", - props); - - Logger.debug("Initial ConfigDB session factory successfully created."); - - - } catch (Throwable ex) { - Logger.error("Initial session factory creation failed: " + ex.getMessage()); - throw new MOADatabaseException("Initialization of Configuration Hibernate session factory failed.",ex); - } - } - - -// /** -// * 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()) { +///******************************************************************************* +// * Copyright 2014 Federal Chancellery Austria +// * MOA-ID has been developed in a cooperation between BRZ, the Federal +// * Chancellery Austria - ICT staff unit, and Graz University of Technology. +// * +// * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by +// * the European Commission - subsequent versions of the EUPL (the "Licence"); +// * You may not use this work except in compliance with the Licence. +// * You may obtain a copy of the Licence at: +// * http://www.osor.eu/eupl/ +// * +// * Unless required by applicable law or agreed to in writing, software +// * distributed under the Licence is distributed on an "AS IS" basis, +// * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// * See the Licence for the specific language governing permissions and +// * limitations under the Licence. +// * +// * This product combines work with different licenses. See the "NOTICE" text +// * file for details on the various modules and licenses. +// * The "NOTICE" text file is part of the distribution. Any derivative works +// * that you distribute must include a readable copy of the "NOTICE" text file. +// *******************************************************************************/ +//package at.gv.egovernment.moa.id.commons.db; // -// //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; -// } +//import java.util.Properties; // -// @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()); -// } -// } +//import javax.persistence.EntityManager; +//import javax.persistence.EntityManagerFactory; +//import javax.persistence.EntityTransaction; +//import javax.persistence.Persistence; +// +//import org.hibernate.HibernateException; +// +//import at.gv.egovernment.moa.id.commons.db.ex.MOADatabaseException; +//import at.gv.egovernment.moa.logging.Logger; +// +//public final class ConfigurationDBUtils { +// +// private static EntityManagerFactory entitymanagerfactory; +// +// @SuppressWarnings("rawtypes") +// private static final ThreadLocal THREAD_LOCAL_CONFIG = new ThreadLocal(); +// private static boolean automaticSessionHandling = false; +// +// protected ConfigurationDBUtils() { } +// +// public static void initHibernate(Properties props) throws MOADatabaseException { +// +//// try { +//// +//// Logger.debug("Creating initial session factory..."); +//// +//// entitymanagerfactory = +//// Persistence.createEntityManagerFactory("at.gv.egovernment.moa.id.commons.db.dao.config", +//// props); +//// +//// Logger.debug("Initial ConfigDB session factory successfully created."); +//// +//// +//// } catch (Throwable ex) { +//// Logger.error("Initial session factory creation failed: " + ex.getMessage()); +//// throw new MOADatabaseException("Initialization of Configuration Hibernate session factory failed.",ex); +//// } // } // -// 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); -// } -// } // +//// /** +//// * 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; +//// } +// +// /** +// * 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; +//// } +//// } // -// 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/NewConfigurationDBRead.java b/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/NewConfigurationDBRead.java index 8f6100f84..41c7008e9 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,450 +1,450 @@ -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 java.util.Map; - -import org.springframework.beans.factory.annotation.Autowired; - -import at.gv.egiz.components.configuration.api.ConfigurationException; -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.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; - } - - } - - public static Map getOnlineApplicationKeyValueWithId(String id) { - try { - return conf.getOnlineApplication(id); - - } catch (ConfigurationException e) { - Logger.warn("OnlineApplication with Id: " + id + " not found.", e); - return null; - - } - } - - - - /** - * - * @return - */ - public static List getAllUsers() { - Logger.trace("Get All Users from database."); - +//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 java.util.Map; +// +//import org.springframework.beans.factory.annotation.Autowired; +// +//import at.gv.egiz.components.configuration.api.ConfigurationException; +//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.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; +// } +// +// } +// +// public static Map getOnlineApplicationKeyValueWithId(String id) { +// try { +// return conf.getOnlineApplication(id); +// +// } catch (ConfigurationException e) { +// Logger.warn("OnlineApplication with Id: " + id + " not found.", e); +// return null; +// +// } +// } +// +// +// +// /** +// * +// * @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; +// +// //TODO!!! +// return null; +// } +// +// /** +// * +// * @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); +// +// //TODO!!! +// return null; +// +// } +// +// /** +// * +// * @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 -// List result = conf.getList("getAllUsers", UserDatabase.class); +// // 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; - - //TODO!!! - return null; - } - - /** - * - * @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); - - //TODO!!! - return null; - - } - - /** - * - * @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; - } - +// } +// +// /** +// * +// * @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 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); +// 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; // } - - /** - * - * @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; - } - -} +// +// /** +// * +// * @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/dao/config/DatabaseConfigPropertyImpl.java b/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/dao/config/DatabaseConfigPropertyImpl.java index f47b0c9e2..f62d2514f 100644 --- a/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/dao/config/DatabaseConfigPropertyImpl.java +++ b/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/dao/config/DatabaseConfigPropertyImpl.java @@ -165,7 +165,7 @@ public class DatabaseConfigPropertyImpl extends AbstractConfigurationImpl { log.debug("Looking for configuration property for key '{}'.", key); ConfigProperty result = em.find(ConfigProperty.class, key); if (result != null) { - log.debug("Found configuration property {}.", result); + log.trace("Found configuration property {}.", result); } else { log.debug("Unable to find configuration property for key '{}'.", key); } 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 6325ada5f..1f7efd589 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 @@ -5,11 +5,6 @@ http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd" version="2.0"> - - org.hibernate.ejb.HibernatePersistence - at.gv.egovernment.moa.id.commons.config.persistence.dal.SOME_CLASS - - org.hibernate.ejb.HibernatePersistence at.gv.egovernment.moa.id.commons.db.dao.config.ConfigProperty diff --git a/id/server/moa-id-commons/src/main/resources/bindings.xjb b/id/server/moa-id-commons/src/main/resources/bindings.xjb index 21714849b..9d017d02e 100644 --- a/id/server/moa-id-commons/src/main/resources/bindings.xjb +++ b/id/server/moa-id-commons/src/main/resources/bindings.xjb @@ -1,4 +1,4 @@ - - \ No newline at end of file + --> \ No newline at end of file diff --git a/id/server/moa-id-commons/src/main/resources/config/moaid_config_3.0.xsd b/id/server/moa-id-commons/src/main/resources/config/moaid_config_3.0.xsd deleted file mode 100644 index d4686bd5e..000000000 --- a/id/server/moa-id-commons/src/main/resources/config/moaid_config_3.0.xsd +++ /dev/null @@ -1,1057 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - possibility to include common austrian primary - keys in human readable way, english translation not available - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - enthält Parameter der - Authentisierungs-Komponente - - - - - - - - - - - enthält Parameter für die OA - - - - - - spezifiziert den Algorithmus ("pkix" oder - "chaining") für die Zertifikatspfadvalidierung - - - - - - - ein vom SystemDefaultMode abweichender - ChiningMode kann für jeden TrustAnchor gesetzt werden - - - - - - - - - - - - - - - - - verweist auf ein Verzeichnis, das - vertrauenswürdige CA (Zwischen-CA, Wurzel-CA) Zertifikate - enthält. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - enthält Parameter für die Kommunikation mit dem - Security-Layer - - - - - - - - - - - enthaelt Konfiguratiosnparameter für die - Kommunikation mit dem MOA SP Modul - - - - - - - enthält Parameter für die SOAP-Verbindung von - der AUTH-Komponente zu MOA-SP; das Attribut URL enthält den - Endpunkt des Server; wird das Schema "https" verwendet müssen - die Kind-Elemente angegeben werden; wird das Schema "http" - verwendet dürfen keine Kind-Elemente angegeben werden; wird das - Element nicht verwendet dann wird MOA-SP über das API - aufgerufen - - - - - - enthält Parameter für die Überprüfung der - Personenbindung - - - - - - - - - - - enthält Parameter für die Überprüfung des - AUTH-Blocks - - - - - - - - - - - - - - - enthält Informationen über akzeptierte Signers - des IdentityLinks - - - - - - - akzeptierte Signer des IdentityLinks werden - per X509SubjectName (Kodierung nach RFC 2253) identifiziert - - - - - - - - - - - - Verbindungsparameter zum SZR-Gateway - (GetIdentityLink) - - - - - - Verbindungsparameter zu den Country-PEPS - (C-PEPS) - - - - - - - - - - - - Verbindungsparameter zum - Online-Vollmachten-Service - - - - - - - - - - - das Attribut filename verweist auf eine Datei mit - globalem Element TransformsInfo vom Typ sl10:TransformsInfo; diese - TransformsInfo werden in den CreateXMLSignatureRequest fuer die - Signatur des AUTH-Blocks inkludiert - - - - - - - - - - - - - - - - - - - das Attribut URL spezifiziert die Lage des - Templates - - - - - - - Verifikation zusaetzlicher Infoboxen - - - - - - Optionales DefaultTrustprofil für die - Überprüfung aller weiteren Infoboxen - - - - - - - - - - - - - Spezifiziert die Lage von XML Schemas - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - enthält Parameter über die OA, die die - Authentisierungs-Komponente betreffen - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - URL zu einem Verzeichnis, das akzeptierte - Server-Zertifikate der TLS-Verbindung enthält (keine - CA-Zertifikate) - - - - - - - - - - - - - URL zu einem KeyStore, der den privaten - Schlüssel, der für die TLS-Client-Authentisierung verwendet - wird, enthält - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Soll nicht nur bei leerer oder standardisierter - Vollmacht mit unvollständigen Daten, sondern beispielsweise zu - Kontrollzwecken das Eingabeformular immer angezeigt werden, wenn ein - Einschreiten durch berufliche Parteienvertretung geschieht so kann - dies mittels dieses Schalters veranlasst werden - - - - - - - - - - - - Das Attribut spezifiziert die Lage des - Templates, welches der InputProcessor zur Darstellung des - Eingabeformulars nutzen soll - - - - - - - - - - - Default InputProcessor. Konfiguration eines vom - Standardprozess abweichenden Verarbeitungsvorgangs bei der - beruflichen Parteienvertretung. Der Wert dieses Elements ist der - vollständige Klassenname des InputProzessors - - - - - - Default Wert fuer Formularanzeige. Soll nicht nur - bei leerer oder standardisierter Vollmacht mit unvollstaendigen - Daten, sondern beispielsweise zu Kontrollzwecken das - Eingabeformular zur vervollstaendigung der Vertretenendaten immer - angezeigt werden, wenn ein Einschreiten durch berufliche - Parteienvertretung geschieht so kann dies mittels dieses Schalters - veranlasst werden - - - - - - Default Verbindungsparameter zum SZR-Gateway - (für den EGIZ-Demonstrator im internen Netzwerk: - https://129.27.142.5:8443/szr-gateway/services/MandateCreation) - - - - - - Falls keine speziellen beruflichen - ParteienvertreterInnen definiert sind (Element kommt nicht vor), - werden ausschließlich standardisierte Vollmachten mit einer - MandateID="*" akzeptiert - - - - - - - - - - Konfiguration eines vom Standardprozess - abweichenden Verarbeitungsvorgangs bei der beruflichen - Parteienvertretung. Der Wert dieses Elements ist der vollständige - Klassenname des InputProzessors - - - - - - - Optionale Verbindungsparameter zu speziellem - (SZR-)Gateway - - - - - - - OID der Parteienvertretung lt. "Object Identifier - der öffentlichen Verwaltung" - Konvention, Empfehlung. Diese ID - muss mit der MandateID der übermittelten standardisierten Vollmacht - übereinstimmen. Eine Parteienvertretung für standardisierte - Vollmachten mit der MandateID "*" muss nicht definiert werden und - erlaubt eine allgemeine berufliche Parteienvertretung mit - Standardtexten. In anderen Fällen ist eine erlaubte OID mitttels - dieses Attributs zu definieren - - - - - - Legt fest, ob berufliche Parteienvertretung für - natürliche Personen erlaubt ist - - - - - - - - - Legt fest, ob berufliche Parteienvertretung für - juristische Personen erlaubt ist (welche z.B. ein Organwalter nicht - vertreten darf und dieser Wert aus diesem Grund dort false sein - muss) - - - - - - - - - Beschreibender Text, der an Stelle des - Standardtexts bei der Signatur der Anmeldedaten im Falle einer - vorliegenden beruflichen Parteienvertretung zur Signatur vorgelegt - wird - - - - - - - Enthaelt Informationen zu einem KeyStore bzw. Key - zur STORK SAML AuthnRequest Signaturerstellung - - - - - - - - - - Enthaelt Informationen zur Verfikation von - Signaturen einer STORK SAML Response - - - - - - - - - Enthält Informationen zur Erstellung und - Verifikation von STORK SAML Messages - - - - - - - - - - - - URL zu einem KeyStore, der den privaten Schlüssel - zum Erstellen einer Signatur enthält - - - - - - - - - - - - - Name zum Key eines KeyStores, der den privaten - Schlüssel zum Erstellen einer Signatur darstellt - - - - - - - - - - - - - - Enthält Informationen zu einem Citizen Country - PEPS (C-PEPS) - - - - - - - - - - - - - - - Contains STORK related information - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/id/server/moa-id-commons/src/main/resources/configuration.beans.xml_old b/id/server/moa-id-commons/src/main/resources/configuration.beans.xml_old deleted file mode 100644 index b3e7526d0..000000000 --- a/id/server/moa-id-commons/src/main/resources/configuration.beans.xml_old +++ /dev/null @@ -1,59 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/id/server/moa-id-commons/src/main/resources/moaid.migration.beans.xml b/id/server/moa-id-commons/src/main/resources/moaid.migration.beans.xml index a2961b0f6..a0923c03f 100644 --- a/id/server/moa-id-commons/src/main/resources/moaid.migration.beans.xml +++ b/id/server/moa-id-commons/src/main/resources/moaid.migration.beans.xml @@ -29,11 +29,6 @@ - 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 deleted file mode 100644 index d9adc4394..000000000 --- a/id/server/moa-id-commons/src/main/resources/persistence_template.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - org.hibernate.ejb.HibernatePersistence - at.gv.egovernment.moa.id.commons.db.dao.config.ConfigProperty - - - - - - - - diff --git a/id/server/moa-id-commons/src/test/java/at/gv/egovernment/moa/id/commons/db/ConfigurationDBReadTest.java b/id/server/moa-id-commons/src/test/java/at/gv/egovernment/moa/id/commons/db/ConfigurationDBReadTest.java index 896a26064..563959582 100644 --- a/id/server/moa-id-commons/src/test/java/at/gv/egovernment/moa/id/commons/db/ConfigurationDBReadTest.java +++ b/id/server/moa-id-commons/src/test/java/at/gv/egovernment/moa/id/commons/db/ConfigurationDBReadTest.java @@ -83,7 +83,7 @@ // migrateDatabase(methodNames); // // // close the session with the old database -// ConfigurationDBUtils.closeSession(); +// // } // // @Test -- cgit v1.2.3