aboutsummaryrefslogtreecommitdiff
path: root/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/AuthenticationSessionCleaner.java
diff options
context:
space:
mode:
Diffstat (limited to 'id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/AuthenticationSessionCleaner.java')
-rw-r--r--id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/AuthenticationSessionCleaner.java43
1 files changed, 38 insertions, 5 deletions
diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/AuthenticationSessionCleaner.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/AuthenticationSessionCleaner.java
index 1f12675ca..a1ba00e02 100644
--- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/AuthenticationSessionCleaner.java
+++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/AuthenticationSessionCleaner.java
@@ -3,6 +3,14 @@
package at.gv.egovernment.moa.id.auth;
+import java.util.Date;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import at.gv.egovernment.moa.id.config.auth.AuthConfiguration;
+import at.gv.egovernment.moa.id.storage.IAuthenticationSessionStoreage;
+import at.gv.egovernment.moa.id.storage.ITransactionStorage;
import at.gv.egovernment.moa.id.util.MOAIDMessageProvider;
import at.gv.egovernment.moa.logging.Logger;
@@ -13,22 +21,47 @@ import at.gv.egovernment.moa.logging.Logger;
* @author Paul Ivancsics
* @version $Id$
*/
+@Service("AuthenticationSessionCleaner")
public class AuthenticationSessionCleaner implements Runnable {
+ @Autowired private IAuthenticationSessionStoreage authenticationSessionStorage;
+ @Autowired private ITransactionStorage transactionStorage;
+ @Autowired protected AuthConfiguration authConfig;
+
/** interval the <code>AuthenticationSessionCleaner</code> is run in */
private static final long SESSION_CLEANUP_INTERVAL = 5 * 60; // 5 min
/**
* Runs the thread. Cleans the <code>AuthenticationServer</code> session store
* and authentication data store from garbage, then sleeps for given interval, and restarts.
+ *
+ * Cleans up expired session and authentication data stores.
+ *
*/
public void run() {
while (true) {
try {
Logger.debug("AuthenticationSessionCleaner run");
- BaseAuthenticationServer.cleanup();
- }
- catch (Exception e) {
+ Date now = new Date();
+
+ try {
+ int sessionTimeOutCreated = authConfig.getSSOCreatedTimeOut() * 1000;
+ int sessionTimeOutUpdated = authConfig.getSSOUpdatedTimeOut() * 1000;
+ int authDataTimeOut = authConfig.getTransactionTimeOut() * 1000;
+
+ //clean AuthenticationSessionStore
+ authenticationSessionStorage.clean(now, sessionTimeOutCreated, sessionTimeOutUpdated);
+
+ //clean TransactionStorage
+ transactionStorage.clean(now, authDataTimeOut);
+
+
+ } catch (Exception e) {
+ Logger.error("Session cleanUp FAILED!" , e);
+
+ }
+
+ } catch (Exception e) {
Logger.error(MOAIDMessageProvider.getInstance().getMessage("cleaner.01", null), e);
}
try {
@@ -42,10 +75,10 @@ public class AuthenticationSessionCleaner implements Runnable {
/**
* start the sessionCleaner
*/
- public static void start() {
+ public static void start(Runnable clazz) {
// start the session cleanup thread
Thread sessionCleaner =
- new Thread(new AuthenticationSessionCleaner(), "AuthenticationSessionCleaner");
+ new Thread(clazz, "AuthenticationSessionCleaner");
sessionCleaner.setName("SessionCleaner");
sessionCleaner.setDaemon(true);
sessionCleaner.setPriority(Thread.MIN_PRIORITY);