Commit bcb97739 authored by michael.simon's avatar michael.simon
Browse files

introduce simple local logout bean

parent 42b17fe1
......@@ -61,7 +61,9 @@ public class SessionManager implements Serializable {
// identityId of the actual user
private Long identityId;
// List of logged in account (stored for logout)
private Set<Long> loggedInUserList;
private String accountLinkingPin;
private Map<String, List<Object>> attributeMap;
......@@ -103,6 +105,7 @@ public class SessionManager implements Serializable {
groups = new HashSet<GroupEntity>();
groupNames = new HashSet<String>();
roles = new HashSet<RoleEntity>();
loggedInUserList = new HashSet<Long>();
}
public void clearRoleList() {
......@@ -371,4 +374,8 @@ public class SessionManager implements Serializable {
public void setOriginalFederationShortName(String originalFederationShortName) {
this.originalFederationShortName = originalFederationShortName;
}
public Set<Long> getLoggedInUserList() {
return loggedInUserList;
}
}
......@@ -69,7 +69,7 @@ public class HeadBarBean {
+ "</svg></button>";
}
private String getOrDefault(String key, String defaultString) {
public String getOrDefault(String key, String defaultString) {
if (appConfig.getConfigValue(key) != null) {
return appConfig.getConfigValue(key);
}
......
/*******************************************************************************
* Copyright (c) 2014 Michael Simon.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Public License v3.0
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/gpl.html
*
* Contributors:
* Michael Simon - initial
******************************************************************************/
package edu.kit.scc.webreg.bean;
import java.io.IOException;
import java.io.Serializable;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import javax.faces.context.FacesContext;
import javax.faces.event.ComponentSystemEvent;
import javax.inject.Inject;
import org.slf4j.Logger;
import edu.kit.scc.webreg.entity.identity.IdentityEntity;
import edu.kit.scc.webreg.service.identity.IdentityService;
import edu.kit.scc.webreg.session.SessionManager;
@ManagedBean
@ViewScoped
public class LocalLogoutBean implements Serializable {
private static final long serialVersionUID = 1L;
private IdentityEntity identity;
@Inject
private Logger logger;
@Inject
private IdentityService identityService;
@Inject
private SessionManager sessionManager;
public void preRenderView(ComponentSystemEvent ev) {
if (identity == null) {
identity = identityService.findById(sessionManager.getIdentityId());
}
}
public void startLocalLogout() {
try {
FacesContext.getCurrentInstance().getExternalContext().redirect("/logout/local?redirect=local_logout");
} catch (IOException e) {
logger.warn("Redirect failed", e);
}
}
public IdentityEntity getIdentity() {
return identity;
}
}
......@@ -61,6 +61,8 @@ public class LogoutServlet implements Servlet {
if (redirect != null && (! redirect.equals(""))) {
if (redirect.equalsIgnoreCase("delete"))
response.sendRedirect(ViewIds.DELETE_ALL_PERSONAL_DATA_DONE);
else if (redirect.equalsIgnoreCase("local_logout"))
response.sendRedirect(ViewIds.LOCAL_LOGOUT_DONE);
else
response.sendRedirect(ViewIds.INDEX_USER);
}
......
......@@ -151,6 +151,7 @@ public class ViewIds {
public static final String REGISTER_USER = "/register.xhtml";
public static final String DISCOVERY_LOGIN = "/welcome/index.xhtml";
public static final String DELETE_ALL_PERSONAL_DATA_DONE = "/welcome/delete-all-personal-data-done.xhtml";
public static final String LOCAL_LOGOUT_DONE = "/welcome/local-logout-done.xhtml";
public static final String APPROVE_USER = "/service-approver/approve-user.xhtml";
}
......@@ -27,6 +27,11 @@
<li class="">
<h:link outcome="#{request.contextPath}/user/twofa.xhtml" value="#{messages.my_twofa}" />
</li>
<h:panelGroup rendered="#{headBarBean.getOrDefault('show_local_logout', 'false').equalsIgnoreCase('true')}">
<li class="">
<h:link outcome="#{request.contextPath}/user/local-logout.xhtml" value="#{messages.logout}" />
</li>
</h:panelGroup>
</ul>
</div>
</li>
......
......@@ -25,27 +25,25 @@
<ui:define name="content">
<h:form id="form" prependId="false" class="full form">
<div class="panel">
<h2 style="color: red;"><h:outputText value="#{messages.my_data_delete_all_header}"/></h2>
<h2 style="color: red;"><h:outputText value="#{messages.my_data_delete_all_header}"/></h2>
<p:panel id="blockPanel">
<p:panel id="blockPanel">
<div class="panel">
<h:outputText value="#{messages.my_data_delete_all_text}" escape="false" />
</div>
<div class="panel">
<h:outputText value="#{messages.my_data_delete_all_text}" escape="false" />
</div>
<div style="margin-top: 16px;">
<p:commandButton id="cancel" action="#{deleteAllPersonalDataBean.cancel}"
value="#{messages.cancel}"/>
<p:commandButton id="save" action="#{deleteAllPersonalDataBean.commit}"
value="#{messages.my_data_delete_all_commit}" style="color: red;"/>
</div>
</p:panel>
<p:blockUI block="blockPanel" trigger="save">
<p:graphicImage value="#{resource['/img/ajax-loader.gif']}" alt="#{messages.loading}" />
</p:blockUI>
<div style="margin-top: 16px;">
<p:commandButton id="cancel" action="#{deleteAllPersonalDataBean.cancel}"
value="#{messages.cancel}"/>
<p:commandButton id="save" action="#{deleteAllPersonalDataBean.commit}"
value="#{messages.my_data_delete_all_commit}" style="color: red;"/>
</div>
</p:panel>
<p:blockUI block="blockPanel" trigger="save">
<p:graphicImage value="#{resource['/img/ajax-loader.gif']}" alt="#{messages.loading}" />
</p:blockUI>
</div>
</h:form>
</ui:define>
</ui:composition>
......
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:bw="http://www.scc.kit.edu/bwfacelets"
xmlns:p="http://primefaces.org/ui">
<head>
<title></title>
</head>
<body>
<ui:composition template="/template/default.xhtml">
<ui:param name="title" value="#{messages.title}"/>
<ui:define name="content">
<h:form id="form" prependId="false" class="full fancy form">
<h3 class="full">#{messages.local_logout_header}</h3>
<div class="full"><h:outputText value="#{messages.local_logout_text}"/></div>
<p:panel>
<p:commandButton id="logout" action="#{localLogoutBean.startLocalLogout()}"
value="#{messages.local_logout}" />
<p:blockUI block="logout" trigger="logout">
<p:graphicImage value="#{resource['/img/ajax-loader.gif']}" alt="#{messages.loading}" />
</p:blockUI>
</p:panel>
</h:form>
</ui:define>
</ui:composition>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:bw="http://www.scc.kit.edu/bwfacelets"
xmlns:p="http://primefaces.org/ui">
<head>
<title></title>
</head>
<body>
<ui:composition template="/template/default.xhtml">
<ui:param name="title" value="#{messages.title}"/>
<ui:define name="content">
<h3 class="full">#{messages.local_logout_done_header}</h3>
<div class="full"><h:outputText value="#{messages.local_logout_done_text}"/></div>
</ui:define>
</ui:composition>
</body>
</html>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment