aboutsummaryrefslogtreecommitdiff
path: root/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/storage/AssertionStorage.java
diff options
context:
space:
mode:
Diffstat (limited to 'id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/storage/AssertionStorage.java')
-rw-r--r--id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/storage/AssertionStorage.java33
1 files changed, 31 insertions, 2 deletions
diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/storage/AssertionStorage.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/storage/AssertionStorage.java
index 93cd43651..6692f61c5 100644
--- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/storage/AssertionStorage.java
+++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/storage/AssertionStorage.java
@@ -62,7 +62,7 @@ public class AssertionStorage {
}
- public Object get(String artifact) throws MOADatabaseException {
+ public <T> T get(String artifact, final Class<T> clazz) throws MOADatabaseException {
AssertionStore element = searchInDatabase(artifact);
@@ -71,7 +71,8 @@ public class AssertionStorage {
//check if assertion has the correct class type
try {
- Object test = Class.forName(element.getType()).cast(data);
+ @SuppressWarnings("unchecked")
+ T test = (T) Class.forName(element.getType()).cast(data);
return test;
} catch (Exception e) {
@@ -80,6 +81,31 @@ public class AssertionStorage {
}
}
+ public void clean(long now, long authDataTimeOut) {
+ Date expioredate = new Date(now - authDataTimeOut);
+
+ Session session = HibernateUtil.getCurrentSession();
+ session.beginTransaction();
+ Query query = session.getNamedQuery("getAssertionWithTimeOut");
+ query.setTimestamp("timeout", expioredate);
+ List<AssertionStore> results = query.list();
+ session.getTransaction().commit();
+
+ if (results.size() != 0) {
+ for(AssertionStore result : results) {
+ try {
+ HibernateUtil.delete(result);
+ Logger.info("Remove Assertion with Artifact=" + result.getArtifact()
+ + " after assertion timeout.");
+
+ } catch (HibernateException e){
+ Logger.warn("Assertion with Artifact=" + result.getArtifact()
+ + " not removed after timeout! (Error during Database communication)", e);
+ }
+
+ }
+ }
+ }
public void remove(String artifact) {
@@ -106,6 +132,9 @@ public class AssertionStorage {
query.setString("artifact", artifact);
List result = query.list();
+ //send transaction
+ session.getTransaction().commit();
+
Logger.trace("Found entries: " + result.size());
//Assertion requires an unique artifact