Commit f89fd21f authored by michael.simon's avatar michael.simon
Browse files

add a distinct mehtod to update user for a specific service.

parent 21810d0a
......@@ -15,6 +15,7 @@ import java.util.Map;
import org.opensaml.saml2.core.Assertion;
import edu.kit.scc.webreg.entity.ServiceEntity;
import edu.kit.scc.webreg.entity.UserEntity;
import edu.kit.scc.webreg.exc.RegisterException;
......@@ -28,4 +29,8 @@ public interface UserUpdateService {
UserEntity updateUser(UserEntity user, Map<String, List<Object>> attributeMap,
String executor) throws RegisterException;
UserEntity updateUser(UserEntity user,
Map<String, List<Object>> attributeMap, String executor,
ServiceEntity service) throws RegisterException;
}
......@@ -37,9 +37,11 @@ import edu.kit.scc.webreg.entity.EventType;
import edu.kit.scc.webreg.entity.GroupEntity;
import edu.kit.scc.webreg.entity.SamlIdpMetadataEntity;
import edu.kit.scc.webreg.entity.SamlSpConfigurationEntity;
import edu.kit.scc.webreg.entity.ServiceEntity;
import edu.kit.scc.webreg.entity.UserEntity;
import edu.kit.scc.webreg.entity.UserStatus;
import edu.kit.scc.webreg.entity.as.ASUserAttrEntity;
import edu.kit.scc.webreg.entity.as.AttributeSourceServiceEntity;
import edu.kit.scc.webreg.event.EventSubmitter;
import edu.kit.scc.webreg.event.UserEvent;
import edu.kit.scc.webreg.exc.EventSubmitException;
......@@ -110,6 +112,13 @@ public class UserUpdateServiceImpl implements UserUpdateService {
@Override
public UserEntity updateUser(UserEntity user, Map<String, List<Object>> attributeMap, String executor)
throws RegisterException {
return updateUser(user, attributeMap, executor, null);
}
@Override
public UserEntity updateUser(UserEntity user, Map<String, List<Object>> attributeMap, String executor,
ServiceEntity service)
throws RegisterException {
logger.debug("Updating user {}", user.getEppn());
boolean changed = false;
......@@ -152,10 +161,21 @@ public class UserUpdateServiceImpl implements UserUpdateService {
user.setUserStatus(UserStatus.ACTIVE);
user.setLastStatusChange(new Date());
}
List<ASUserAttrEntity> asUserAttrList = asUserAttrService.findForUser(user);
for (ASUserAttrEntity asUserAttr : asUserAttrList) {
changed |= attributeSourceQueryService.updateUserAttributes(user, asUserAttr.getAttributeSource(), executor);
/*
* if service is set, update only attribute sources spcific for this
* service. Else update all (login via web or generic attribute query)
*/
if (service != null) {
for (AttributeSourceServiceEntity asse : service.getAttributeSourceService()) {
changed |= attributeSourceQueryService.updateUserAttributes(user, asse.getAttributeSource(), executor);
}
}
else {
List<ASUserAttrEntity> asUserAttrList = asUserAttrService.findForUser(user);
for (ASUserAttrEntity asUserAttr : asUserAttrList) {
changed |= attributeSourceQueryService.updateUserAttributes(user, asUserAttr.getAttributeSource(), executor);
}
}
Set<GroupEntity> changedGroups = homeOrgGroupService.updateGroupsForUser(user, attributeMap, auditor);
......
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