use of org.opencastproject.security.impl.jpa.JpaRole in project opencast by opencast.
the class ConfigurableLoginHandler method existingUserLogin.
/**
* Handle an existing user login.
*
* @param id
* The identity of the user, ideally the Shibboleth persistent unique identifier
* @param request
* The request, for accessing any other Shibboleth variables
*/
@Override
public void existingUserLogin(String id, HttpServletRequest request) {
Organization organization = securityService.getOrganization();
// Load the user reference
JpaUserReference userReference = userReferenceProvider.findUserReference(id, organization.getId());
if (userReference == null) {
throw new IllegalStateException("User reference '" + id + "' was not found");
}
// Update the reference
userReference.setName(extractName(request));
userReference.setEmail(extractEmail(request));
userReference.setLastLogin(new Date());
Set<JpaRole> roles = extractRoles(id, request);
userReference.setRoles(roles);
logger.debug("Shibboleth user '{}' logged in", id);
userReferenceProvider.updateUserReference(userReference);
}
use of org.opencastproject.security.impl.jpa.JpaRole in project opencast by opencast.
the class ConfigurableLoginHandler method extractRoles.
/**
* Extracts the roles from the request.
*
* @param request
* the request
* @return the roles
*/
private Set<JpaRole> extractRoles(String id, HttpServletRequest request) {
JpaOrganization organization = fromOrganization(securityService.getOrganization());
Set<JpaRole> roles = new HashSet<JpaRole>();
roles.add(new JpaRole(roleFederationMember, organization));
roles.add(new JpaRole(roleUserPrefix + id, organization));
roles.add(new JpaRole(organization.getAnonymousRole(), organization));
if (headerHomeOrganization != null) {
String homeOrganization = request.getHeader(headerHomeOrganization);
roles.add(new JpaRole(roleOrganizationPrefix + homeOrganization + roleOrganizationSuffix, organization));
}
if (StringUtils.equals(id, bootstrapUserId)) {
roles.add(new JpaRole(GLOBAL_ADMIN_ROLE, organization));
}
return roles;
}
Aggregations