From 3c1480dfafaa14c4a1780ad2a70326e7a36a9b65 Mon Sep 17 00:00:00 2001 From: Peter Hormanns Date: Tue, 17 May 2011 14:56:34 +0000 Subject: [PATCH] logout-Link --- .../VAADIN/themes/hs/layout/header.html | 8 +++++ hsarweb/conf/WEB-INF/web.xml | 18 ++++++++++- .../src/de/hsadmin/logout/LogoutServlet.java | 32 +++++++++++++++++++ .../src/de/hsadmin/web/MainApplication.java | 26 ++++++++++----- 4 files changed, 75 insertions(+), 9 deletions(-) create mode 100644 hsarweb/WebContent/VAADIN/themes/hs/layout/header.html create mode 100644 hsarweb/src/de/hsadmin/logout/LogoutServlet.java diff --git a/hsarweb/WebContent/VAADIN/themes/hs/layout/header.html b/hsarweb/WebContent/VAADIN/themes/hs/layout/header.html new file mode 100644 index 0000000..1d37064 --- /dev/null +++ b/hsarweb/WebContent/VAADIN/themes/hs/layout/header.html @@ -0,0 +1,8 @@ +
+
+ Hostsharing Logo +
+
+ logout +
+
\ No newline at end of file diff --git a/hsarweb/conf/WEB-INF/web.xml b/hsarweb/conf/WEB-INF/web.xml index fc6e8d0..efabea9 100644 --- a/hsarweb/conf/WEB-INF/web.xml +++ b/hsarweb/conf/WEB-INF/web.xml @@ -7,7 +7,7 @@ serverName - http://agnes.ostwall195.de:8080 + https://@ADMIN_HOST@:@ADMIN_PORT@ backendURL @@ -67,6 +67,15 @@ /* + + Logout Servlet + de.hsadmin.logout.LogoutServlet + + redirect + https://@LOGIN_HOST@:@LOGIN_PORT@/cas/logout + + + HSAdmin Web com.vaadin.terminal.gwt.server.ApplicationServlet @@ -76,10 +85,17 @@ de.hsadmin.web.MainApplication + + + Logout Servlet + /logout + + HSAdmin Web /* + index.html index.jsp diff --git a/hsarweb/src/de/hsadmin/logout/LogoutServlet.java b/hsarweb/src/de/hsadmin/logout/LogoutServlet.java new file mode 100644 index 0000000..783f1ea --- /dev/null +++ b/hsarweb/src/de/hsadmin/logout/LogoutServlet.java @@ -0,0 +1,32 @@ +package de.hsadmin.logout; + +import java.io.IOException; + +import javax.servlet.ServletConfig; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; + +public class LogoutServlet extends HttpServlet { + + private static final long serialVersionUID = 1L; + + private String redirectURL; + + @Override + protected void doGet(HttpServletRequest req, HttpServletResponse resp) + throws ServletException, IOException { + HttpSession session = req.getSession(); + session.invalidate(); + resp.sendRedirect(redirectURL); + } + + @Override + public void init(ServletConfig config) throws ServletException { + redirectURL = config.getInitParameter("redirect"); + } + + +} diff --git a/hsarweb/src/de/hsadmin/web/MainApplication.java b/hsarweb/src/de/hsadmin/web/MainApplication.java index 0d22c72..4b84e9e 100644 --- a/hsarweb/src/de/hsadmin/web/MainApplication.java +++ b/hsarweb/src/de/hsadmin/web/MainApplication.java @@ -18,16 +18,20 @@ import com.vaadin.terminal.ExternalResource; import com.vaadin.terminal.Terminal; import com.vaadin.terminal.ThemeResource; import com.vaadin.terminal.gwt.server.HttpServletRequestListener; +import com.vaadin.ui.Button; import com.vaadin.ui.Component; +import com.vaadin.ui.CustomLayout; import com.vaadin.ui.Embedded; import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.Link; import com.vaadin.ui.TabSheet; import com.vaadin.ui.VerticalLayout; import com.vaadin.ui.Window; +import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.TabSheet.SelectedTabChangeEvent; import com.vaadin.ui.TabSheet.Tab; import com.vaadin.ui.Window.Notification; +import com.vaadin.ui.themes.BaseTheme; import de.hsadmin.web.config.LocaleConfig; import de.hsadmin.web.config.ModuleConfig; @@ -44,6 +48,8 @@ public class MainApplication extends Application implements HttpServletRequestLi private Map modules; private Locale requestLocale; + private CustomLayout header; + @Override public void init() { @@ -68,14 +74,18 @@ public class MainApplication extends Application implements HttpServletRequestLi Window mainWindow = new Window(localeConfig.getText("applicationtitle")); VerticalLayout verticalLayout = new VerticalLayout(); verticalLayout.setSizeFull(); - HorizontalLayout banner = new HorizontalLayout(); - Embedded image = new Embedded(null, new ThemeResource("../hs/icons/logo.png")); - image.setMimeType("image/png"); - Embedded bgImage = new Embedded(null, new ThemeResource("../hs/icons/bg.png")); - bgImage.setMimeType("image/png"); - banner.addComponent(image); - banner.addComponent(bgImage); - banner.setExpandRatio(bgImage, 1.0f); +// HorizontalLayout banner = new HorizontalLayout(); +// Embedded image = new Embedded(null, new ThemeResource("../hs/icons/logo.png")); +// image.setMimeType("image/png"); +// Embedded bgImage = new Embedded(null, new ThemeResource("../hs/icons/bg.png")); +// bgImage.setMimeType("image/png"); +// Link logout = new Link("logout", new ExternalResource(localeConfig.getText("logout.link"))); +// banner.addComponent(image); +// banner.addComponent(bgImage); +// banner.addComponent(logout); +// banner.setExpandRatio(bgImage, 1.0f); +// verticalLayout.addComponent(banner); + CustomLayout banner = new CustomLayout("../../hs/layout/header"); verticalLayout.addComponent(banner); TabSheet tabs = new TabSheet(); tabs.setSizeFull();