Commit c3caf057 authored by Gradl, Tobias's avatar Gradl, Tobias
Browse files

725: Migrate user profile page / information

Task-Url: https://minfba.de.dariah.eu/mantisbt/view.php?id=725
parent 79677439
......@@ -18,7 +18,7 @@ public class SAMLAuthenticationProvider extends org.springframework.security.sam
protected Object getUserDetails(SAMLCredential credential) {
if (this.getAttributeAggregationService()!=null) {
credential = this.getAttributeAggregationService().aggregateIfRequired(credential);
}
}
return super.getUserDetails(credential);
}
}
......@@ -8,12 +8,12 @@ import org.springframework.security.saml.SAMLCredential;
import eu.dariah.de.dariahsp.Constants.AUTHENTICATION_STAGE;
import eu.dariah.de.dariahsp.Constants.REQUIRED_ATTRIBUTE_CHECKLOGIC;
import eu.dariah.de.dariahsp.saml.SAMLAttribute;
import eu.dariah.de.dariahsp.saml.attributequery.options.SAMLAttributeGroup;
import eu.dariah.de.dariahsp.saml.attributequery.options.SAMLAttributeQueryExclusionOptions;
import eu.dariah.de.dariahsp.saml.attributequery.options.SAMLAttributeQueryOptions;
import eu.dariah.de.dariahsp.saml.attributequery.options.SAMLRequiredAttributes;
import eu.dariah.de.dariahsp.saml.model.SAMLAggregatedCredential;
import eu.dariah.de.dariahsp.saml.model.SAMLAttribute;
public class SAMLAttributeAggregationService {
......
......@@ -3,7 +3,7 @@ package eu.dariah.de.dariahsp.saml.attributequery.options;
import java.util.List;
import eu.dariah.de.dariahsp.Constants.REQUIRED_ATTRIBUTE_CHECKLOGIC;
import eu.dariah.de.dariahsp.saml.SAMLAttribute;
import eu.dariah.de.dariahsp.saml.model.SAMLAttribute;
import eu.dariah.de.minfba.core.util.conversion.BaseConfigurationConvertible;
public class SAMLAttributeGroup extends BaseConfigurationConvertible {
......
......@@ -9,7 +9,7 @@ import org.slf4j.LoggerFactory;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import eu.dariah.de.dariahsp.saml.SAMLAttribute;
import eu.dariah.de.dariahsp.saml.model.SAMLAttribute;
public class SAMLAttributeQueryOptions implements Serializable, Cloneable {
protected static final Logger logger = LoggerFactory.getLogger(SAMLAttributeQueryOptions.class);
......
package eu.dariah.de.dariahsp.saml;
package eu.dariah.de.dariahsp.saml.model;
import eu.dariah.de.minfba.core.util.conversion.BaseConfigurationConvertible;
......
......@@ -3,7 +3,6 @@ package eu.dariah.de.dariahsp.saml.model;
import java.util.List;
import eu.dariah.de.dariahsp.model.UserImpl;
import eu.dariah.de.dariahsp.saml.SAMLAttribute;
public class SAMLUserImpl extends UserImpl {
private static final long serialVersionUID = -906528575049375837L;
......
......@@ -9,6 +9,7 @@ import org.opensaml.saml2.core.Attribute;
import org.opensaml.saml2.core.NameID;
import org.opensaml.xml.XMLObject;
import org.opensaml.xml.schema.XSString;
import org.opensaml.xml.schema.impl.XSStringImpl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.security.core.userdetails.UserDetails;
......@@ -22,8 +23,8 @@ import eu.dariah.de.dariahsp.model.Role;
import eu.dariah.de.dariahsp.model.RoleImpl;
import eu.dariah.de.dariahsp.model.User;
import eu.dariah.de.dariahsp.model.UserImpl;
import eu.dariah.de.dariahsp.saml.SAMLAttribute;
import eu.dariah.de.dariahsp.saml.model.SAMLAggregatedCredential;
import eu.dariah.de.dariahsp.saml.model.SAMLAttribute;
import eu.dariah.de.dariahsp.saml.model.SAMLUserImpl;
public abstract class BaseUserService implements UserService, SAMLUserDetailsService {
......@@ -38,6 +39,12 @@ public abstract class BaseUserService implements UserService, SAMLUserDetailsSer
public static final String DEFAULT_LOCAL_DOMAIN = "LOCAL";
private String defaultAuthority;
public String getDefaultAuthority() { return defaultAuthority; }
public void setDefaultAuthority(String defaultAuthority) { this.defaultAuthority = defaultAuthority; }
@Override
public final UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
return this.loadUserByUsername(this.getLocalDomain(), username);
......@@ -95,6 +102,13 @@ public abstract class BaseUserService implements UserService, SAMLUserDetailsSer
String fetchEndpoint = null;
Collection<Role> roles = new ArrayList<Role>();
RoleImpl r;
if (this.getDefaultAuthority()!=null && !this.getDefaultAuthority().isEmpty()) {
r = new RoleImpl();
r.setAuthority(this.getDefaultAuthority());
roles.add(r);
}
for (Attribute attr : credential.getAttributes()) {
if (attr.getName().toLowerCase().equals(SAML_ID_ATTR_NAME.toLowerCase())) {
......@@ -104,7 +118,7 @@ public abstract class BaseUserService implements UserService, SAMLUserDetailsSer
if (attr.getAttributeValues()!=null && attr.getAttributeValues().size()>0) {
for (XMLObject a : attr.getAttributeValues()) {
if (a instanceof XSString) {
RoleImpl r = new RoleImpl();
r = new RoleImpl();
r.setAuthority(((XSString)a).getValue().trim().toLowerCase());
roles.add(r);
}
......@@ -156,8 +170,8 @@ public abstract class BaseUserService implements UserService, SAMLUserDetailsSer
a.setNameFormat(aIn.getNameFormat());
a.setName(aIn.getName());
a.setFriendlyName(aIn.getFriendlyName());
a.setValue(xVal.toString());
a.setValue(xVal instanceof XSStringImpl ? ((XSStringImpl)xVal).getValue() : xVal.toString());
result.add(a);
}
}
......
......@@ -42,7 +42,7 @@
<!-- SAML messages -->
<logger name="PROTOCOL_MESSAGE">
<level value="debug" />
<level value="info" />
</logger>
</configuration>
\ No newline at end of file
......@@ -49,7 +49,9 @@
<!-- This probably needs to be changed to a persisting extension of BaseUserService -->
<bean id="userDetailsService" class="eu.dariah.de.dariahsp.sample.service.CachingUserServiceImpl" />
<bean id="userDetailsService" class="eu.dariah.de.dariahsp.sample.service.CachingUserServiceImpl">
<property name="defaultAuthority" value="Authenticated User" />
</bean>
<bean id="redirectionAwareFilter" class="eu.dariah.de.dariahsp.web.RedirectionAwareFilterBean" />
......
......@@ -27,61 +27,58 @@
<div id="main-content">
<h2>Home</h2>
<sf:form class="form-horizontal" style="clear: both;" modelAttribute="user" method="post" commandName="user" action="profile">
<form class="form-horizontal">
<fieldset>
<sf:hidden path="id" />
<legend>Your assigned privileges</legend>
<div class="control-group">
<label class="control-label" for="user_roles">Assigned roles: </label>
<div class="controls">
<select class="input-xlarge uneditable-input" multiple id="user_roles">
<c:forEach items="${authorityList}" var="authority">
<option>${authority.authority}</option>
</c:forEach>
</select>
</div>
</div>
<legend>Information from your identity providers</legend>
<div class="control-group">
<label class="control-label" for="user_endpoint">Original identity Provider: </label>
<div class="controls">
<sf:input disabled="true" class="input-xxlarge uneditable-input" path="endpointName" id="user_endpoint" />
<sf:errors path="endpointName" cssClass="error" />
<div class="form-group">
<label class="col-sm-3 control-label" for="user_endpoint">Original identity Provider: </label>
<div class="col-sm-9">
<p class="form-control-static">${user.endpointName}</p>
</div>
</div>
<div class="control-group">
<label class="control-label" for="user_username">Username: </label>
<div class="controls">
<sf:input disabled="true" class="input-xxlarge uneditable-input" path="username" id="user_username" />
<sf:errors path="username" cssClass="error" />
<div class="form-group">
<label class="col-sm-3 control-label" for="user_username">Username: </label>
<div class="col-sm-9">
<p class="form-control-static">${user.username}</p>
</div>
</div>
<div class="control-group">
<label class="control-label" for="user_username">Attributes: </label>
<div class="controls">
<div class="form-group">
<label class="col-sm-3 control-label" for="user_username">Home IdP Attributes: </label>
<div class="col-sm-9">
<c:if test="${user.originalAttributes!=null}">
<ul>
<ul class="form-control-static" style="padding-left: 20px;">
<c:forEach items="${user.originalAttributes}" var="attr">
<li>${attr.friendlyName}</li>
<li><strong>${attr.friendlyName}</strong>: ${attr.value}</li>
</c:forEach>
</ul>
</c:if>
</div>
</div>
<div class="control-group">
<label class="control-label" for="user_username">Aggregated attributes: </label>
<div class="controls">
<div class="form-group">
<label class="col-sm-3 control-label" for="user_username">Aggregated attributes: </label>
<div class="col-sm-9">
<c:if test="${user.aggregatedAttributes!=null}">
<ul>
<ul class="form-control-static" style="padding-left: 20px;">
<c:forEach items="${user.aggregatedAttributes}" var="attr">
<li>${attr.friendlyName}</li>
<li><strong>${attr.friendlyName}</strong>: ${attr.value}</li>
</c:forEach>
</ul>
</c:if>
</div>
</div>
<legend>Your assigned privileges</legend>
<div class="form-group">
<label class="col-sm-3 control-label" for="user_roles">Assigned roles: </label>
<div class="col-sm-9">
<select class="form-control uneditable-input" multiple id="user_roles">
<c:forEach items="${authorityList}" var="authority">
<option>${authority.authority}</option>
</c:forEach>
</select>
</div>
</div>
</fieldset>
</sf:form>
</form>
</div>
</div>
......
Supports Markdown
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