changeset 4214:e39ac9767a69

Implement UserService method to remove current user from session For being able to logout a user UserService must provide a method the remove the current user object from the session. Part of flys/issue916 (Logout: "Abmelden" Knopf mit Funktion belegen)
author Björn Ricks <bjoern.ricks@intevation.de>
date Tue, 23 Oct 2012 09:57:42 +0200
parents 0674d89210f5
children c179cd02177d
files flys-client/src/main/java/de/intevation/flys/client/client/services/UserService.java flys-client/src/main/java/de/intevation/flys/client/client/services/UserServiceAsync.java flys-client/src/main/java/de/intevation/flys/client/server/UserServiceImpl.java
diffstat 3 files changed, 14 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/flys-client/src/main/java/de/intevation/flys/client/client/services/UserService.java	Tue Oct 23 07:39:09 2012 +0200
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/services/UserService.java	Tue Oct 23 09:57:42 2012 +0200
@@ -24,5 +24,10 @@
      */
     User getCurrentUser(String locale)
     throws AuthenticationException;
+
+    /**
+     * Removes the current user object from the session
+     */
+    void logoutCurrentUser();
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-client/src/main/java/de/intevation/flys/client/client/services/UserServiceAsync.java	Tue Oct 23 07:39:09 2012 +0200
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/services/UserServiceAsync.java	Tue Oct 23 09:57:42 2012 +0200
@@ -15,5 +15,7 @@
     void getCurrentUser(
         String locale,
         AsyncCallback<User> callback);
+
+    void logoutCurrentUser(AsyncCallback<Void> callback);
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-client/src/main/java/de/intevation/flys/client/server/UserServiceImpl.java	Tue Oct 23 07:39:09 2012 +0200
+++ b/flys-client/src/main/java/de/intevation/flys/client/server/UserServiceImpl.java	Tue Oct 23 09:57:42 2012 +0200
@@ -1,5 +1,7 @@
 package de.intevation.flys.client.server;
 
+import javax.servlet.http.HttpSession;
+
 import org.w3c.dom.Element;
 
 import org.apache.log4j.Logger;
@@ -60,5 +62,10 @@
         logger.error("No users existing in the server.");
         throw new AuthenticationException(ERROR_NO_USERS);
     }
+
+    public void logoutCurrentUser() {
+        HttpSession session = this.getThreadLocalRequest().getSession();
+        session.setAttribute("user", null);
+    }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org