Commit 569c36a8 authored by michael.simon's avatar michael.simon
Browse files

Make user props view OIDC compatible

parent f6722e9b
......@@ -8,6 +8,10 @@ import java.util.Map;
import javax.enterprise.context.ApplicationScoped;
import javax.inject.Named;
import com.nimbusds.openid.connect.sdk.claims.UserInfo;
import net.minidev.json.JSONAware;
@Named("attributeMapHelper")
@ApplicationScoped
public class AttributeMapHelper implements Serializable {
......@@ -70,8 +74,14 @@ public class AttributeMapHelper implements Serializable {
if (attributeList != null) {
for (Object o : attributeList) {
if (o != null) {
sb.append(o.toString());
sb.append(separator);
if (o instanceof JSONAware) {
sb.append(((JSONAware) o).toJSONString());
sb.append(separator);
}
else {
sb.append(o.toString());
sb.append(separator);
}
}
}
}
......
......@@ -18,17 +18,23 @@ import javax.faces.bean.ViewScoped;
import javax.faces.event.ComponentSystemEvent;
import javax.inject.Inject;
import com.nimbusds.openid.connect.sdk.claims.ClaimsSet;
import edu.kit.scc.webreg.entity.GroupEntity;
import edu.kit.scc.webreg.entity.RoleEntity;
import edu.kit.scc.webreg.entity.SamlIdpMetadataEntity;
import edu.kit.scc.webreg.entity.SamlUserEntity;
import edu.kit.scc.webreg.entity.UserEntity;
import edu.kit.scc.webreg.entity.identity.IdentityEntity;
import edu.kit.scc.webreg.entity.oidc.OidcUserEntity;
import edu.kit.scc.webreg.service.GroupService;
import edu.kit.scc.webreg.service.RoleService;
import edu.kit.scc.webreg.service.UserService;
import edu.kit.scc.webreg.service.identity.IdentityService;
import edu.kit.scc.webreg.session.SessionManager;
import net.minidev.json.JSONObject;
import net.minidev.json.parser.JSONParser;
import net.minidev.json.parser.ParseException;
@ManagedBean
@ViewScoped
......@@ -46,6 +52,8 @@ public class UserPropertiesBean implements Serializable {
private List<GroupEntity> groupList;
private ClaimsSet claims;
@Inject
private UserService userService;
......@@ -72,6 +80,15 @@ public class UserPropertiesBean implements Serializable {
if (user instanceof SamlUserEntity) {
idpEntity = ((SamlUserEntity) user).getIdp();
}
else if (user instanceof OidcUserEntity) {
JSONParser parser = new JSONParser(JSONParser.MODE_JSON_SIMPLE);
try {
JSONObject jo = parser.parse(user.getAttributeStore().get("claims"), JSONObject.class);
claims = new ClaimsSet(jo);
} catch (ParseException e) {
System.out.println("" + e);
}
}
}
}
......@@ -102,4 +119,8 @@ public class UserPropertiesBean implements Serializable {
public void setUser(UserEntity user) {
this.user = user;
}
public ClaimsSet getClaims() {
return claims;
}
}
......@@ -40,12 +40,12 @@
<bw:outputText label="#{messages.name}" value="#{userPropertiesBean.user.surName}, #{userPropertiesBean.user.givenName}"/>
<bw:outputText label="#{messages.email}" value="#{userPropertiesBean.user.email}"/>
<bw:outputText label="#{messages.eppn}" value="#{userPropertiesBean.user.eppn}"/>
<bw:outputText label="#{messages.persistent_id}" value="#{userPropertiesBean.user.persistentId}"/>
<bw:outputText label="#{messages.persistent_id}" value="#{userPropertiesBean.user.persistentId}" rendered="#{userPropertiesBean.user.class eq 'SamlUserEntity'}"/>
<bw:outputText label="#{messages.uid_number}" value="#{userPropertiesBean.user.uidNumber}"/>
<bw:outputText label="#{messages.primary_group}" value="#{userPropertiesBean.user.primaryGroup.name} (#{userPropertiesBean.user.primaryGroup.gidNumber})"/>
<bw:outputText label="#{messages.idp}" value="#{userPropertiesBean.idpEntity.displayName}"
rendered="#{not empty userPropertiesBean.idpEntity.displayName}"/>
rendered="#{not empty userPropertiesBean.idpEntity and not empty userPropertiesBean.idpEntity.displayName}"/>
</p:panelGrid>
<div class="panel">#{messages.my_data_delete_all}
......
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