Commit 84d55de0 authored by michael.simon's avatar michael.simon
Browse files

Fix Oidc Client Configuration and add some options

parent 80dd84b0
......@@ -27,6 +27,9 @@ public class ServiceOidcClientEntity extends AbstractBaseEntity {
@Column(name = "wants_elevation")
private Boolean wantsElevation;
@Column(name = "order_criteria")
private Integer orderCriteria;
public ServiceEntity getService() {
return service;
}
......@@ -57,4 +60,12 @@ public class ServiceOidcClientEntity extends AbstractBaseEntity {
public void setWantsElevation(Boolean wantsElevation) {
this.wantsElevation = wantsElevation;
}
public Integer getOrderCriteria() {
return orderCriteria;
}
public void setOrderCriteria(Integer orderCriteria) {
this.orderCriteria = orderCriteria;
}
}
......@@ -14,5 +14,6 @@ public abstract class ServiceOidcClientEntity_ extends edu.kit.scc.webreg.entity
public static volatile SingularAttribute<ServiceOidcClientEntity, ServiceEntity> service;
public static volatile SingularAttribute<ServiceOidcClientEntity, OidcClientConfigurationEntity> clientConfig;
public static volatile SingularAttribute<ServiceOidcClientEntity, ScriptEntity> script;
public static volatile SingularAttribute<ServiceOidcClientEntity, Integer> orderCriteria;
}
......@@ -34,6 +34,7 @@ public class JpaServiceOidcClientDao extends JpaBaseDao<ServiceOidcClientEntity,
CriteriaQuery<ServiceOidcClientEntity> criteria = builder.createQuery(ServiceOidcClientEntity.class);
Root<ServiceOidcClientEntity> root = criteria.from(ServiceOidcClientEntity.class);
criteria.where(builder.equal(root.get(ServiceOidcClientEntity_.clientConfig), clientConfig));
criteria.orderBy(builder.asc(root.get(ServiceOidcClientEntity_.orderCriteria)));
criteria.select(root);
return em.createQuery(criteria).getResultList();
}
......
/*******************************************************************************
* 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.service.oidc;
import java.util.List;
import edu.kit.scc.webreg.entity.oidc.OidcClientConfigurationEntity;
import edu.kit.scc.webreg.entity.oidc.ServiceOidcClientEntity;
import edu.kit.scc.webreg.service.BaseService;
public interface ServiceOidcClientService extends BaseService<ServiceOidcClientEntity, Long> {
List<ServiceOidcClientEntity> findByClientConfig(OidcClientConfigurationEntity clientConfig);
}
/*******************************************************************************
* 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.service.oidc;
import java.util.List;
import javax.ejb.Stateless;
import javax.inject.Inject;
import edu.kit.scc.webreg.dao.BaseDao;
import edu.kit.scc.webreg.dao.oidc.ServiceOidcClientDao;
import edu.kit.scc.webreg.entity.oidc.OidcClientConfigurationEntity;
import edu.kit.scc.webreg.entity.oidc.ServiceOidcClientEntity;
import edu.kit.scc.webreg.service.impl.BaseServiceImpl;
@Stateless
public class ServiceOidcClientServiceImpl extends BaseServiceImpl<ServiceOidcClientEntity, Long> implements ServiceOidcClientService {
private static final long serialVersionUID = 1L;
@Inject
private ServiceOidcClientDao dao;
@Override
public List<ServiceOidcClientEntity> findByClientConfig(OidcClientConfigurationEntity clientConfig) {
return dao.findByClientConfig(clientConfig);
}
@Override
protected BaseDao<ServiceOidcClientEntity, Long> getDao() {
return dao;
}
}
......@@ -11,6 +11,7 @@
package edu.kit.scc.webreg.bean.admin.oidc;
import java.io.Serializable;
import java.util.List;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
......@@ -18,7 +19,9 @@ import javax.faces.event.ComponentSystemEvent;
import javax.inject.Inject;
import edu.kit.scc.webreg.entity.oidc.OidcClientConfigurationEntity;
import edu.kit.scc.webreg.entity.oidc.OidcOpConfigurationEntity;
import edu.kit.scc.webreg.service.oidc.OidcClientConfigurationService;
import edu.kit.scc.webreg.service.oidc.OidcOpConfigurationService;
@ManagedBean
@ViewScoped
......@@ -29,9 +32,13 @@ public class EditOidcClientConfigurationBean implements Serializable {
@Inject
private OidcClientConfigurationService service;
@Inject
private OidcOpConfigurationService opService;
private OidcClientConfigurationEntity entity;
private Long id;
private List<OidcOpConfigurationEntity> opList;
public void preRenderView(ComponentSystemEvent ev) {
if (entity == null) {
......@@ -59,4 +66,10 @@ public class EditOidcClientConfigurationBean implements Serializable {
public void setId(Long id) {
this.id = id;
}
public List<OidcOpConfigurationEntity> getOpList() {
if (opList == null)
opList = opService.findAll();
return opList;
}
}
......@@ -11,6 +11,7 @@
package edu.kit.scc.webreg.bean.admin.oidc;
import java.io.Serializable;
import java.util.List;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
......@@ -18,7 +19,9 @@ import javax.faces.event.ComponentSystemEvent;
import javax.inject.Inject;
import edu.kit.scc.webreg.entity.oidc.OidcClientConfigurationEntity;
import edu.kit.scc.webreg.entity.oidc.ServiceOidcClientEntity;
import edu.kit.scc.webreg.service.oidc.OidcClientConfigurationService;
import edu.kit.scc.webreg.service.oidc.ServiceOidcClientService;
@ManagedBean
@ViewScoped
......@@ -29,7 +32,11 @@ public class ShowOidcClientConfigurationBean implements Serializable {
@Inject
private OidcClientConfigurationService service;
@Inject
private ServiceOidcClientService serviceOidcClientService;
private OidcClientConfigurationEntity entity;
private List<ServiceOidcClientEntity> serviceOidcClientList;
private Long id;
......@@ -37,9 +44,6 @@ public class ShowOidcClientConfigurationBean implements Serializable {
private String newValue;
public void preRenderView(ComponentSystemEvent ev) {
if (entity == null) {
entity = service.findByIdWithAttrs(id, "genericStore");
}
}
public void addGenericStore() {
......@@ -56,6 +60,9 @@ public class ShowOidcClientConfigurationBean implements Serializable {
}
public OidcClientConfigurationEntity getEntity() {
if (entity == null) {
entity = service.findByIdWithAttrs(id, "genericStore");
}
return entity;
}
......@@ -86,4 +93,10 @@ public class ShowOidcClientConfigurationBean implements Serializable {
public void setNewValue(String newValue) {
this.newValue = newValue;
}
public List<ServiceOidcClientEntity> getServiceOidcClientList() {
if (serviceOidcClientList == null)
serviceOidcClientList = serviceOidcClientService.findByClientConfig(getEntity());
return serviceOidcClientList;
}
}
/*******************************************************************************
* 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.converter;
import javax.inject.Inject;
import javax.inject.Named;
import edu.kit.scc.webreg.entity.BaseEntity;
import edu.kit.scc.webreg.service.BaseService;
import edu.kit.scc.webreg.service.oidc.OidcClientConfigurationService;
@Named("oidcClientConfigurationConverter")
public class OidcClientConfigurationConverter extends AbstractConverter {
private static final long serialVersionUID = 1L;
@Inject
private OidcClientConfigurationService service;
@Override
protected BaseService<? extends BaseEntity<Long>, Long> getService() {
return service;
}
}
/*******************************************************************************
* 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.converter;
import javax.inject.Inject;
import javax.inject.Named;
import edu.kit.scc.webreg.entity.BaseEntity;
import edu.kit.scc.webreg.service.BaseService;
import edu.kit.scc.webreg.service.oidc.OidcOpConfigurationService;
@Named("oidcOpConfigurationConverter")
public class OidcOpConfigurationConverter extends AbstractConverter {
private static final long serialVersionUID = 1L;
@Inject
private OidcOpConfigurationService service;
@Override
protected BaseService<? extends BaseEntity<Long>, Long> getService() {
return service;
}
}
......@@ -19,11 +19,11 @@
<h:panelGrid id="baseData" columns="2" columnClasses="labelColumn, elementColumn">
<h:outputText value="#{messages.name}:" />
<h:inputText value="#{addOidcRpConfigurationBean.entity.name}" />
<h:inputText value="#{addOidcClientConfigurationBean.entity.name}" />
</h:panelGrid>
<h:commandButton id="save" action="#{addOidcRpConfigurationBean.save}" value="#{messages.save}"/>
<h:commandButton id="save" action="#{addOidcClientConfigurationBean.save}" value="#{messages.save}"/>
</h:form>
......
......@@ -39,6 +39,14 @@
<bw:inputText id="secretField" label="#{messages.secret}"
value="#{editOidcClientConfigurationBean.entity.secret}" required="false" />
<h:outputText value="#{messages.oidc_op_configuration}:"/>
<h:selectOneMenu value="#{editOidcClientConfigurationBean.entity.opConfiguration}"
converter="#{oidcOpConfigurationConverter}">
<f:selectItem itemLabel="Kein Parent Service" itemValue="#{null}"/>
<f:selectItems value="#{editOidcClientConfigurationBean.opList}"
var="op" itemLabel="#{op.name} (id #{op.id})" itemValue="#{op}"/>
</h:selectOneMenu>
</p:panelGrid>
<h:commandButton id="save" action="#{editOidcClientConfigurationBean.save}" value="#{messages.save}"/>
......
......@@ -24,56 +24,65 @@
<h:form id="form">
<h2><h:outputText value="#{messages.rp_config}: #{showOidcClientConfigurationBean.entity.name}"/></h2>
<div id="panelInline">
<p:panel header="#{messages.rp_config}">
<p:panelGrid id="baseData" columns="2">
<h:outputText value="#{messages.id}:"/>
<h:outputText value="#{showOidcClientConfigurationBean.entity.id}"/>
<p:panel header="#{messages.rp_config}">
<p:panelGrid id="baseData" columns="2">
<h:outputText value="#{messages.name}:"/>
<h:outputText value="#{showOidcClientConfigurationBean.entity.name}"/>
<h:outputText value="#{messages.id}:"/>
<h:outputText value="#{showOidcClientConfigurationBean.entity.id}"/>
<h:outputText value="#{messages.display_name}:"/>
<h:outputText value="#{showOidcClientConfigurationBean.entity.displayName}"/>
<h:outputText value="#{messages.secret}:"/>
<h:outputText value="#{showOidcClientConfigurationBean.entity.secret}"/>
<h:outputText value="#{messages.name}:"/>
<h:outputText value="#{showOidcClientConfigurationBean.entity.name}"/>
<h:outputText value="#{messages.display_name}:"/>
<h:outputText value="#{showOidcClientConfigurationBean.entity.displayName}"/>
<h:outputText value="#{messages.secret}:"/>
<h:outputText value="#{showOidcClientConfigurationBean.entity.secret}"/>
<h:outputText value="#{messages.op_config}:"/>
<h:outputText value="#{showOidcClientConfigurationBean.entity.opConfiguration.name}"/>
<h:outputText value="#{messages.generic_store}:"/>
<h:panelGroup>
<ul>
<ui:repeat var="key" value="#{showOidcClientConfigurationBean.entity.genericStore.keySet().toArray()}">
<li>
<h:panelGrid id="newPropTable" columns="3" columnClasses="labelColumn, elementColumn">
<h:outputText value="#{key}:"/>
<h:outputText value="#{showOidcClientConfigurationBean.entity.genericStore.get(key)}"/>
<h:commandLink value="(#{messages.delete})" action="#{showOidcClientConfigurationBean.removeGenericStore(key)}">
<f:ajax render="@form" />
</h:commandLink>
</h:panelGrid>
</li>
</ui:repeat>
</ul>
<h:panelGrid id="newPropTable" columns="3" columnClasses="labelColumn, elementColumn">
<h:inputText id="key_input" value="#{showOidcClientConfigurationBean.newKey}"/>
<h:inputText id="value_input" value="#{showOidcClientConfigurationBean.newValue}"/>
<h:commandLink value="#{messages.add}" action="#{showOidcClientConfigurationBean.addGenericStore()}">
<f:ajax execute="form" render="form" />
</h:commandLink>
</h:panelGrid>
</h:panelGroup>
</p:panelGrid>
<h:link outcome="edit-client-config.xhtml" value="#{messages.edit}">
<f:param name="id" value="#{showOidcClientConfigurationBean.entity.id}"/>
</h:link>
<h:outputText value="#{messages.oidc_op_configuration}:"/>
<h:outputText value="#{showOidcClientConfigurationBean.entity.opConfiguration.name}"/>
</p:panel>
<h:outputText value="#{messages.generic_store}:"/>
<h:panelGroup>
<ul>
<ui:repeat var="key" value="#{showOidcClientConfigurationBean.entity.genericStore.keySet().toArray()}">
<li>
<h:panelGrid id="newPropTable" columns="3" columnClasses="labelColumn, elementColumn">
<h:outputText value="#{key}:"/>
<h:outputText value="#{showOidcClientConfigurationBean.entity.genericStore.get(key)}"/>
<h:commandLink value="(#{messages.delete})" action="#{showOidcClientConfigurationBean.removeGenericStore(key)}">
<f:ajax render="@form" />
</h:commandLink>
</h:panelGrid>
</li>
</ui:repeat>
</ul>
<h:panelGrid id="newPropTable" columns="3" columnClasses="labelColumn, elementColumn">
<h:inputText id="key_input" value="#{showOidcClientConfigurationBean.newKey}"/>
<h:inputText id="value_input" value="#{showOidcClientConfigurationBean.newValue}"/>
<h:commandLink value="#{messages.add}" action="#{showOidcClientConfigurationBean.addGenericStore()}">
<f:ajax execute="form" render="form" />
</h:commandLink>
</h:panelGrid>
</h:panelGroup>
<p:panel header="#{messages.attribute_scripts}">
</p:panelGrid>
<h:link outcome="edit-client-config.xhtml" value="#{messages.edit}">
<f:param name="id" value="#{showOidcClientConfigurationBean.entity.id}"/>
</h:link>
<ui:repeat var="scc" value="#{showOidcClientConfigurationBean.serviceOidcClientList}">
<h:outputText value="#{scc.script.name} (#{scc.script.id})" /> -
<h:outputText value="#{scc.service.name}" />
<h:outputText value=" (wants elevation: #{scc.wantsElevation})" />
<h:outputText value=" (order criteria: #{scc.orderCriteria})" />
</ui:repeat>
</p:panel>
</div>
</h:form>
</ui:define>
......
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