From 3c1480dfafaa14c4a1780ad2a70326e7a36a9b65 Mon Sep 17 00:00:00 2001 From: Peter Hormanns <peter.hormanns@hostsharing.net> Date: Tue, 17 May 2011 16:56:34 +0200 Subject: [PATCH] logout-Link --- hsarweb/WebContent/VAADIN/themes/hs/layout/header.html | 8 ++++ hsarweb/conf/WEB-INF/web.xml | 18 ++++++++ hsarweb/src/de/hsadmin/web/MainApplication.java | 26 +++++++++---- hsarweb/src/de/hsadmin/logout/LogoutServlet.java | 32 ++++++++++++++++ 4 files changed, 75 insertions(+), 9 deletions(-) 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 @@ +<div style="width:100%; background-image:url(../../hs/icons/bg.png);"> + <div style="margin: 0px; vertical-align:top; float:left; "> + <img src="../../hs/icons/logo.png" alt="Hostsharing Logo" / > + </div> + <div style="margin: 0px; height:70px; vertical-align:top; text-align:right; "> + <a href="/hsarweb/logout" style="margin-right:20px; text-decoration:none; font-family:Arial,Helvetica,sans-serif; color:white; " >logout</a> + </div> +</div> \ 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 @@ <context-param> <param-name>serverName</param-name> - <param-value>http://agnes.ostwall195.de:8080</param-value> + <param-value>https://@ADMIN_HOST@:@ADMIN_PORT@</param-value> </context-param> <context-param> <param-name>backendURL</param-name> @@ -68,6 +68,15 @@ </filter-mapping> <servlet> + <servlet-name>Logout Servlet</servlet-name> + <servlet-class>de.hsadmin.logout.LogoutServlet</servlet-class> + <init-param> + <param-name>redirect</param-name> + <param-value>https://@LOGIN_HOST@:@LOGIN_PORT@/cas/logout</param-value> + </init-param> + </servlet> + + <servlet> <servlet-name>HSAdmin Web</servlet-name> <servlet-class>com.vaadin.terminal.gwt.server.ApplicationServlet</servlet-class> <init-param> @@ -76,10 +85,17 @@ <param-value>de.hsadmin.web.MainApplication</param-value> </init-param> </servlet> + + <servlet-mapping> + <servlet-name>Logout Servlet</servlet-name> + <url-pattern>/logout</url-pattern> + </servlet-mapping> + <servlet-mapping> <servlet-name>HSAdmin Web</servlet-name> <url-pattern>/*</url-pattern> </servlet-mapping> + <welcome-file-list> <welcome-file>index.html</welcome-file> <welcome-file>index.jsp</welcome-file> 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.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; @@ -43,6 +47,8 @@ private Remote remote; private Map<String, Module> modules; private Locale requestLocale; + + private CustomLayout header; @Override @@ -68,14 +74,18 @@ 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(); -- Gitblit v1.9.3