Commit 7ddd74e5 authored by michael.simon's avatar michael.simon
Browse files

add admin view for identities

parent d41f4093
/*******************************************************************************
* 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.admin;
import java.io.IOException;
import java.io.Serializable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
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 edu.kit.scc.webreg.dao.GenericSortOrder;
import edu.kit.scc.webreg.dao.ops.MultipathOrPredicate;
import edu.kit.scc.webreg.dao.ops.PathObjectValue;
import edu.kit.scc.webreg.entity.UserEntity;
import edu.kit.scc.webreg.service.UserService;
import edu.kit.scc.webreg.util.FacesMessageGenerator;
@ManagedBean
@ViewScoped
public class FindIdentityBean implements Serializable {
private static final long serialVersionUID = 1L;
@Inject
private FacesMessageGenerator messageGenerator;
@Inject
private UserService userService;
private UserEntity selectedUser;
public void preRenderView(ComponentSystemEvent ev) {
}
public List<UserEntity> completeUser(String part) {
Map<String, Object> filterMap = new HashMap<String, Object>();
filterMap.put("eppn", new MultipathOrPredicate(
new PathObjectValue("eppn", part),
new PathObjectValue("surName", part),
new PathObjectValue("givenName", part)
));
return userService.findAllPaging(0, 10, "eppn", GenericSortOrder.ASC, filterMap, null);
}
public String searchUser() {
if (selectedUser == null) {
messageGenerator.addErrorMessage("Error", "User not found");
return null;
}
else {
try {
FacesContext.getCurrentInstance().getExternalContext().redirect("show-admin-identity.xhtml?id=" + selectedUser.getIdentity().getId());
} catch (IOException e) {
messageGenerator.addErrorMessage("Error", "Can't redirect to details page");
}
return "";
}
}
public UserEntity getSelectedUser() {
return selectedUser;
}
public void setSelectedUser(UserEntity selectedUser) {
this.selectedUser = selectedUser;
}
}
......@@ -11,37 +11,61 @@
package edu.kit.scc.webreg.bean.admin;
import java.io.Serializable;
import java.util.List;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import javax.faces.event.ComponentSystemEvent;
import javax.inject.Inject;
import org.primefaces.model.LazyDataModel;
import edu.kit.scc.webreg.entity.UserEntity;
import edu.kit.scc.webreg.entity.identity.IdentityEntity;
import edu.kit.scc.webreg.model.GenericLazyDataModelImpl;
import edu.kit.scc.webreg.service.UserService;
import edu.kit.scc.webreg.service.identity.IdentityService;
import edu.kit.scc.webreg.util.FacesMessageGenerator;
@ManagedBean
@ViewScoped
public class ListIdentityBean implements Serializable {
public class ShowAdminIdentityBean implements Serializable {
private static final long serialVersionUID = 1L;
private LazyDataModel<IdentityEntity> list;
@Inject
private FacesMessageGenerator messageGenerator;
@Inject
private UserService userService;
@Inject
private IdentityService service;
private IdentityEntity identity;
private List<UserEntity> userList;
private Long id;
public void preRenderView(ComponentSystemEvent ev) {
}
public LazyDataModel<IdentityEntity> getIdentityEntityList() {
if (list == null) {
list = new GenericLazyDataModelImpl<IdentityEntity, IdentityService, Long>(service, "users");
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public IdentityEntity getIdentity() {
if (identity == null) {
identity = service.findById(id);
}
return list;
}
return identity;
}
public List<UserEntity> getUserList() {
if (userList == null) {
userList = userService.findByIdentity(getIdentity());
}
return userList;
}
}
......@@ -15,7 +15,7 @@
<f:metadata>
<f:event type="javax.faces.event.PreRenderViewEvent"
listener="#{listIdentityBean.preRenderView}" />
listener="#{findIdentityBean.preRenderView}" />
</f:metadata>
<ui:composition template="/template/default-admin.xhtml">
......@@ -24,27 +24,35 @@
<ui:define name="content">
<h:form id="form">
<p:messages id="messageBox" showDetail="true" escape="false" />
<p:panelGrid columns="2">
<h:outputLabel value="Eppn" for="@next" />
<p:autoComplete id="userAutocompl" multiple="false" value="#{findIdentityBean.selectedUser}"
completeMethod="#{findIdentityBean.completeUser}" minQueryLength="2"
var="u" itemLabel="#{u.eppn}" itemValue="#{u}" converter="#{userConverter}"
forceSelection="true">
<p:column style="width:20%">
<h:outputText value="#{u.id}" />
</p:column>
<p:column>
<h:outputText value="#{u.eppn}" />
</p:column>
<p:column>
<h:outputText value="#{u.surName}" />
</p:column>
<p:column>
<h:outputText value="#{u.givenName}" />
</p:column>
</p:autoComplete>
</p:panelGrid>
<p:focus for="userAutocompl" />
<p:dataTable id="dataTable" var="identity" value="#{listIdentityBean.identityEntityList}" paginator="true"
lazy="true" rows="15">
<p:column sortBy="#{identity.id}" style="width:48px;">
<f:facet name="header">
<h:outputText value="#{messages.id}" />
</f:facet>
<h:outputText value="#{identity.id}"/>
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="#{messages.eppn}" />
</f:facet>
<ui:repeat var="user" value="#{identity.users}">
<h:link outcome="show-user.xhtml" value="#{user.eppn}">
<f:param name="id" value="#{user.id}"/>
</h:link><br/>
</ui:repeat>
</p:column>
</p:dataTable>
<p:outputPanel style="margin-bottom: 16px;">
<p:commandButton action="#{findIdentityBean.searchUser()}" value="Search" update="form"/>
</p:outputPanel>
</h:form>
</ui:define>
......
<!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"
xmlns:of="http://omnifaces.org/functions">
<head>
<title></title>
</head>
<body>
<f:view>
<f:metadata>
<f:viewParam name="id" value="#{showAdminIdentityBean.id}"/>
<f:event type="javax.faces.event.PreRenderViewEvent"
listener="#{showAdminIdentityBean.preRenderView}" />
</f:metadata>
<ui:composition template="/template/default-admin.xhtml">
<ui:param name="title" value="#{messages.title}"/>
<ui:define name="content">
<h:form id="form">
<h3>Show identity: <h:outputText value="#{showAdminIdentityBean.identity.id}" /></h3>
<p:panelGrid columns="2">
<bw:outputText label="#{messages.twofa_userid}" value="#{showAdminIdentityBean.identity.twoFaUserId}"/>
<bw:outputText label="#{messages.twofa_username}" value="#{showAdminIdentityBean.identity.twoFaUserName}"/>
</p:panelGrid>
<p:repeat var="user" value="#{showAdminIdentityBean.userList}">
<p:panel rendered="#{user.class.simpleName eq 'SamlUserEntity'}">
<f:facet name="header">
#{user.id} - #{user.eppn} - (#{user.idp.displayName})
</f:facet>
<p:panelGrid columns="2">
<h:outputLabel value="#{messages.name}" for="@next"/>
<h:outputText value="#{user.surName}, #{user.givenName}" />
<h:outputLabel value="#{messages.email}" for="@next"/>
<h:outputText value="#{user.email}" />
<h:outputLabel value="#{messages.eppn}" for="@next"/>
<h:outputText value="#{user.eppn}" />
<h:outputLabel value="#{messages.persistent_id}" for="@next"/>
<h:outputText value="#{user.persistentId}" />
<h:outputLabel value="#{messages.uid_number}" for="@next"/>
<h:outputText value="#{user.uidNumber}" />
<h:outputLabel value="#{messages.primary_group}" for="@next"/>
<h:outputText value="#{user.primaryGroup.name} (#{user.primaryGroup.gidNumber})" />
<h:outputLabel value="#{messages.idp}" for="@next"/>
<h:outputText value="#{user.idp.displayName}" />
</p:panelGrid>
</p:panel>
<p:panel rendered="#{user.class.simpleName eq 'OidcUserEntity'}">
<f:facet name="header">
#{user.id} - #{user.eppn} - (#{user.issuer.displayName})
</f:facet>
<p:panelGrid columns="2">
<h:outputLabel value="#{messages.name}" for="@next"/>
<h:outputText value="#{user.surName}, #{user.givenName}" />
<h:outputLabel value="#{messages.email}" for="@next"/>
<h:outputText value="#{user.email}" />
<h:outputLabel value="#{messages.eppn}" for="@next"/>
<h:outputText value="#{user.eppn}" />
<h:outputLabel value="#{messages.subject_id}" for="@next"/>
<h:outputText value="#{user.subjectId}" />
<h:outputLabel value="#{messages.uid_number}" for="@next"/>
<h:outputText value="#{user.uidNumber}" />
<h:outputLabel value="#{messages.primary_group}" for="@next"/>
<h:outputText value="#{user.primaryGroup.name} (#{user.primaryGroup.gidNumber})" />
<h:outputLabel value="#{messages.issuer}" for="@next"/>
<h:outputText value="#{user.issuer.displayName}" />
</p:panelGrid>
</p:panel>
</p:repeat>
</h:form>
</ui:define>
</ui:composition>
</f:view>
</body>
</html>
......@@ -32,6 +32,9 @@
<div class="submenu-title">#{messages.admin}</div>
<div class="submenu-content">
<ul>
<li><span class="ui-icon ui-icon-person" style="display:inline-block; vertical-align: bottom;" />
<h:link outcome="/admin/user/find-identity.xhtml" value="#{messages.identites}" />
</li>
<li><span class="ui-icon ui-icon-person" style="display:inline-block; vertical-align: bottom;" />
<h:link outcome="/admin/user/list-users.xhtml" value="#{messages.users}" />
</li>
......
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