Commit 2d631c95 authored by michael.simon's avatar michael.simon
Browse files

Add executor to all user updates

parent 3bdb9fbd
......@@ -84,7 +84,7 @@ public class DeregisterLostAccessRegistries extends AbstractExecutableJob {
// user is too old, try update first
logger.info("User {} lastUpdate is older than {}ms. Trying update", user.getEppn(), lastUserUpdate);
try {
userService.updateUserFromIdp(user);
userService.updateUserFromIdp(user, "lost-access-reg-job");
} catch (UserUpdateException e) {
logger.info("Exception while Querying IDP: {}", e.getMessage());
if (e.getCause() != null) {
......
......@@ -77,7 +77,7 @@ public class UpdateAllUserFromIdp extends AbstractExecutableJob {
for (UserEntity user : userList) {
try {
logger.info("Updating user {}", user.getEppn());
userService.updateUserFromIdp(user);
userService.updateUserFromIdp(user, "update-all-users-from-idp-job");
} catch (UserUpdateException e) {
logger.warn("Could not update user {}: {}", user.getEppn(), e);
}
......
......@@ -49,9 +49,9 @@ public interface UserService extends BaseService<UserEntity, Long> {
List<UserEntity> findOrderByFailedUpdateWithLimit(Date date, Integer limit);
UserEntity updateUserFromIdp(UserEntity user) throws UserUpdateException;
UserEntity updateUserFromIdp(UserEntity user, String executor) throws UserUpdateException;
UserEntity updateUserFromIdp(UserEntity user, ServiceEntity service)
UserEntity updateUserFromIdp(UserEntity user, ServiceEntity service, String executor)
throws UserUpdateException;
UserEntity updateUserFromAttribute(UserEntity user,
......
......@@ -8,16 +8,16 @@ import edu.kit.scc.webreg.exc.RestInterfaceException;
public interface UserUpdateService {
Map<String, String> updateUser(String eppn, String serviceShortName,
String localHostName) throws IOException,
String localHostName, String executor) throws IOException,
RestInterfaceException;
Map<String, String> updateUser(Long regId, String localHostName)
Map<String, String> updateUser(Long regId, String localHostName, String executor)
throws IOException, RestInterfaceException;
Map<String, String> updateUser(String eppn, String localHostName)
Map<String, String> updateUser(String eppn, String localHostName, String executor)
throws IOException, RestInterfaceException;
void updateUserAsync(String eppn, String localHostName);
void updateUserAsync(String eppn, String localHostName, String executor);
}
......@@ -191,7 +191,7 @@ public class UserLoginServiceImpl implements UserLoginService, Serializable {
logger.debug("Passwords match: {}", match);
if (match) {
updateUser(user, service);
updateUser(user, service, "login-with-service-password");
List<Object> objectList = checkRules(user, service, registry);
List<OverrideAccess> overrideAccessList = extractOverideAccess(objectList);
......@@ -550,7 +550,7 @@ public class UserLoginServiceImpl implements UserLoginService, Serializable {
return returnList;
}
private void updateUser(UserEntity user, ServiceEntity service) throws UserUpdateFailedException {
private void updateUser(UserEntity user, ServiceEntity service, String executor) throws UserUpdateFailedException {
// Default expiry Time after which an attrq is issued to IDP in millis
Long expireTime = 10000L;
......@@ -567,7 +567,7 @@ public class UserLoginServiceImpl implements UserLoginService, Serializable {
logger.info("Performing attributequery for {} with {}@{}", new Object[] {user.getEppn(),
user.getPersistentId(), user.getIdp().getEntityId()});
user = userUpdater.updateUserFromIdp(user, service);
user = userUpdater.updateUserFromIdp(user, service, executor);
}
} catch (UserUpdateException e) {
logger.warn("Could not update user {}: {}", e.getMessage(), user.getEppn());
......
......@@ -102,15 +102,15 @@ public class UserServiceImpl extends BaseServiceImpl<UserEntity, Long> implement
}
@Override
public UserEntity updateUserFromIdp(UserEntity user)
public UserEntity updateUserFromIdp(UserEntity user, String executor)
throws UserUpdateException {
return userUpdater.updateUserFromIdp(user, null);
return userUpdater.updateUserFromIdp(user, null, executor);
}
@Override
public UserEntity updateUserFromIdp(UserEntity user, ServiceEntity service)
public UserEntity updateUserFromIdp(UserEntity user, ServiceEntity service, String executor)
throws UserUpdateException {
return userUpdater.updateUserFromIdp(user, service);
return userUpdater.updateUserFromIdp(user, executor);
}
@Override
......
......@@ -62,7 +62,7 @@ public class UserUpdateServiceImpl implements UserUpdateService, Serializable {
@Override
public Map<String, String> updateUser(String eppn,
String serviceShortName, String localHostName)
String serviceShortName, String localHostName, String executor)
throws IOException, RestInterfaceException {
UserEntity user = findUser(eppn);
......@@ -77,11 +77,11 @@ public class UserUpdateServiceImpl implements UserUpdateService, Serializable {
if (registry == null)
throw new NoRegistryFoundException("user not registered for service");
return update(user, service, registry, localHostName);
return update(user, service, registry, localHostName, executor);
}
@Override
public Map<String, String> updateUser(String eppn, String localHostName)
public Map<String, String> updateUser(String eppn, String localHostName, String executor)
throws IOException, RestInterfaceException {
UserEntity user = findUser(eppn);
......@@ -89,7 +89,7 @@ public class UserUpdateServiceImpl implements UserUpdateService, Serializable {
throw new NoUserFoundException("no such user");
try {
user = userUpdater.updateUserFromIdp(user);
user = userUpdater.updateUserFromIdp(user, executor);
} catch (UserUpdateException e) {
logger.warn("Could not update user {}: {}", e.getMessage(), user.getEppn());
throw new UserUpdateFailedException("user update failed: " + e.getMessage());
......@@ -106,7 +106,7 @@ public class UserUpdateServiceImpl implements UserUpdateService, Serializable {
@Override
@Asynchronous
public void updateUserAsync(String eppn, String localHostName) {
public void updateUserAsync(String eppn, String localHostName, String executor) {
UserEntity user = findUser(eppn);
if (user == null) {
......@@ -133,7 +133,7 @@ public class UserUpdateServiceImpl implements UserUpdateService, Serializable {
user.getPersistentId(), user.getIdp().getEntityId()});
try {
user = userUpdater.updateUserFromIdp(user);
user = userUpdater.updateUserFromIdp(user, executor);
} catch (UserUpdateException e) {
logger.warn("Could not update user {}: {}", e.getMessage(), user.getEppn());
}
......@@ -141,7 +141,7 @@ public class UserUpdateServiceImpl implements UserUpdateService, Serializable {
}
@Override
public Map<String, String> updateUser(Long regId, String localHostName)
public Map<String, String> updateUser(Long regId, String localHostName, String executor)
throws IOException, RestInterfaceException {
RegistryEntity registry = registryDao.findById(regId);
......@@ -150,10 +150,10 @@ public class UserUpdateServiceImpl implements UserUpdateService, Serializable {
throw new NoRegistryFoundException("registry unknown");
}
return update(registry.getUser(), registry.getService(), registry, localHostName);
return update(registry.getUser(), registry.getService(), registry, localHostName, executor);
}
private Map<String, String> update(UserEntity user, ServiceEntity service, RegistryEntity registry, String localHostName)
private Map<String, String> update(UserEntity user, ServiceEntity service, RegistryEntity registry, String localHostName, String executor)
throws RestInterfaceException {
// Default expiry Time after which an attrq is issued to IDP in millis
......@@ -172,7 +172,7 @@ public class UserUpdateServiceImpl implements UserUpdateService, Serializable {
logger.info("Performing attributequery for {} with {}@{}", new Object[] {user.getEppn(),
user.getPersistentId(), user.getIdp().getEntityId()});
user = userUpdater.updateUserFromIdp(user, service);
user = userUpdater.updateUserFromIdp(user, service, executor);
}
} catch (UserUpdateException e) {
logger.warn("Could not update user {}: {}", e.getMessage(), user.getEppn());
......
......@@ -255,12 +255,12 @@ public class UserUpdater implements Serializable {
return updateUser(user, attributeMap, executor, service);
}
public UserEntity updateUserFromIdp(UserEntity user)
public UserEntity updateUserFromIdp(UserEntity user, String executor)
throws UserUpdateException {
return updateUserFromIdp(user, null);
return updateUserFromIdp(user, null, executor);
}
public UserEntity updateUserFromIdp(UserEntity user, ServiceEntity service)
public UserEntity updateUserFromIdp(UserEntity user, ServiceEntity service, String executor)
throws UserUpdateException {
SamlSpConfigurationEntity spEntity = spDao.findByEntityId(user.getPersistentSpId());
......@@ -271,7 +271,7 @@ public class UserUpdater implements Serializable {
auditor.setDetail("Call IDP " + idpEntity.getEntityId() + " from SP " + spEntity.getEntityId() + " for User " + user.getEppn());
auditor.setIdp(idpEntity);
auditor.setSpConfig(spEntity);
auditor.startAuditTrail("");
auditor.startAuditTrail(executor);
EntityDescriptor idpEntityDescriptor = samlHelper.unmarshal(
idpEntity.getEntityDescriptor(), EntityDescriptor.class, auditor);
......
......@@ -119,7 +119,7 @@ public class ShowUserBean implements Serializable {
logger.info("Trying user update for {}", user.getEppn());
try {
userService.updateUserFromIdp(user);
userService.updateUserFromIdp(user, "user-" + sessionManager.getUserId());
} catch (UserUpdateException e) {
logger.info("Exception while Querying IDP: {}", e.getMessage());
if (e.getCause() != null) {
......
......@@ -115,7 +115,7 @@ public class BulkUserImportBean implements Serializable {
if (userEntity != null) {
logger.debug("User {} already in system", userEntity.getEppn());
try {
userService.updateUserFromIdp(userEntity);
userService.updateUserFromIdp(userEntity, "bulk-import");
} catch (UserUpdateException e) {
logger.warn("AttributeQuery failed", e);
importUser.setStatus("Fehler: " + e.getMessage());
......
......@@ -60,7 +60,7 @@ public class AttributeQueryController {
public Map<String, String> attributeQuery(@PathParam("eppn") String eppn,
@PathParam("service") String serviceShortName, @Context HttpServletRequest request)
throws IOException, ServletException, RestInterfaceException {
return userUpdateService.updateUser(eppn, serviceShortName, request.getLocalName());
return userUpdateService.updateUser(eppn, serviceShortName, request.getLocalName(), "rest-/attrq/eppn/" + serviceShortName + "/" + eppn);
}
@GET
......@@ -68,7 +68,7 @@ public class AttributeQueryController {
@Produces(MediaType.APPLICATION_JSON)
public Map<String, String> attributeQuery(@PathParam("regid") Long regId, @Context HttpServletRequest request)
throws IOException, ServletException, RestInterfaceException {
return userUpdateService.updateUser(regId, request.getLocalName());
return userUpdateService.updateUser(regId, request.getLocalName(), "rest-/attrq/regid/" + regId);
}
@GET
......@@ -80,7 +80,7 @@ public class AttributeQueryController {
AttributeQueryResponse response = new AttributeQueryResponse();
try {
userUpdateService.updateUser(eppn, serviceShortName, request.getLocalName());
userUpdateService.updateUser(eppn, serviceShortName, request.getLocalName(), "rest-/attrq/eppn-xml/" + serviceShortName + "/" + eppn);
}
catch (NoUserFoundException e) {
generateFailXml(response, 400, "ecp login failed", "user-not-found");
......@@ -130,7 +130,7 @@ public class AttributeQueryController {
AttributeQueryResponse response = new AttributeQueryResponse();
try {
userUpdateService.updateUser(regId, request.getLocalName());
userUpdateService.updateUser(regId, request.getLocalName(), "rest-/attrq/regid-xml/" + regId);
}
catch (NoUserFoundException e) {
generateFailXml(response, 400, "ecp login failed", "user-not-found");
......
......@@ -28,7 +28,7 @@ public class UserController {
public Map<String, String> updateUserAsync(@PathParam("eppn") String eppn, @Context HttpServletRequest request)
throws IOException, RestInterfaceException, ServletException {
userUpdateService.updateUserAsync(eppn, request.getLocalName());
userUpdateService.updateUserAsync(eppn, request.getLocalName(), "rest-/user-admin/update-async/" + eppn);
Map<String, String> map = new HashMap<String, String>();
map.put("reuqest", "submitted");
......@@ -41,6 +41,6 @@ public class UserController {
public Map<String, String> updateUser(@PathParam("eppn") String eppn, @Context HttpServletRequest request)
throws IOException, RestInterfaceException, ServletException {
return userUpdateService.updateUser(eppn, request.getLocalName());
return userUpdateService.updateUser(eppn, request.getLocalName(), "rest-/user-admin/update/" + eppn);
}
}
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