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

change audit trails

parent b4aed304
......@@ -147,7 +147,8 @@ public class UserCreateServiceImpl implements UserCreateService {
auditor.logAction(user.getEppn(), "CREATE USER", null, null, AuditStatus.SUCCESS);
auditor.finishAuditTrail();
auditor.commitAuditTrail();
UserEvent userEvent = new UserEvent(user);
try {
......
......@@ -352,6 +352,7 @@ public class UserUpdater implements Serializable {
message += " InnerCause: " + e.getCause().getMessage();
auditor.logAction(idpEntity.getEntityId(), "SAML ATTRIBUTE QUERY", user.getEppn(), message, AuditStatus.FAIL);
auditor.finishAuditTrail();
auditor.commitAuditTrail();
updateIdpStatus(SamlIdpMetadataEntityStatus.FAULTY, idpEntity);
}
......@@ -495,6 +496,7 @@ public class UserUpdater implements Serializable {
user.setUserStatus(toStatus);
user.setLastStatusChange(new Date());
logger.debug("{}: change user status from {} to {}", user.getEppn(), fromStatus, toStatus);
auditor.logAction(user.getEppn(), "CHANGE STATUS", fromStatus + " -> " + toStatus,
"Change status " + fromStatus + " -> " + toStatus, AuditStatus.SUCCESS);
}
......@@ -504,6 +506,8 @@ public class UserUpdater implements Serializable {
registry.setRegistryStatus(toStatus);
registry.setLastStatusChange(new Date());
logger.debug("{} {} {}: change registry status from {} to {}", new Object[] {
registry.getUser().getEppn(), registry.getService().getShortName(), registry.getId(), fromStatus, toStatus });
RegistryAuditor registryAuditor = new RegistryAuditor(auditDao, auditDetailDao, appConfig);
registryAuditor.setParent(parentAuditor);
registryAuditor.startAuditTrail(parentAuditor.getActualExecutor());
......
......@@ -123,6 +123,8 @@ public class ApprovalServiceImpl implements ApprovalService {
}
auditor.finishAuditTrail();
if (parentAuditor == null)
auditor.commitAuditTrail();
}
@Override
......@@ -191,6 +193,8 @@ public class ApprovalServiceImpl implements ApprovalService {
eventSubmitter.submit(serviceRegisterEvent, eventList, EventType.SERVICE_REGISTER, executor);
auditor.finishAuditTrail();
if (parentAuditor == null)
auditor.commitAuditTrail();
} catch (Throwable t) {
throw new RegisterException(t);
......
......@@ -109,6 +109,7 @@ public class AttributeSourceQueryServiceImpl implements AttributeSourceQueryServ
asUserAttr.setLastQuery(new Date());
asUserAttr = asUserAttrDao.persist(asUserAttr);
auditor.finishAuditTrail();
auditor.commitAuditTrail();
return changed;
}
......
......@@ -193,12 +193,16 @@ public class RegisterUserServiceImpl implements RegisterUserService {
logger.debug("Registering {} for approval {}", user.getEppn(), registry.getApprovalBean());
auditor.logAction(user.getEppn(), "STARTING APPROVAL", "registry-" + registry.getId(), "Approval is started: " + registry.getApprovalBean(), AuditStatus.SUCCESS);
auditor.finishAuditTrail();
if (parentAuditor == null)
auditor.commitAuditTrail();
approvalService.registerApproval(registry, auditor);
}
else {
logger.debug("No approval role for service {}. AutoApproving {}", service.getName(), user.getEppn());
auditor.logAction(user.getEppn(), "STARTING AUTO APPROVE", "registry-" + registry.getId(), "Autoapproving registry", AuditStatus.SUCCESS);
auditor.finishAuditTrail();
if (parentAuditor == null)
auditor.commitAuditTrail();
approvalService.approve(registry, executor, auditor);
}
......@@ -291,6 +295,8 @@ public class RegisterUserServiceImpl implements RegisterUserService {
logger.debug("Persist service Flags took {}ms", (System.currentTimeMillis() - a)); a = System.currentTimeMillis();
auditor.finishAuditTrail();
auditor.commitAuditTrail();
}
catch (Throwable t) {
throw new RegisterException(t);
......@@ -352,6 +358,7 @@ public class RegisterUserServiceImpl implements RegisterUserService {
((GroupCapable) workflow).deleteGroup(group, service, auditor);
auditor.finishAuditTrail();
auditor.commitAuditTrail();
}
catch (Throwable t) {
throw new RegisterException(t);
......@@ -434,6 +441,8 @@ public class RegisterUserServiceImpl implements RegisterUserService {
registry = registryDao.persist(registry);
auditor.finishAuditTrail();
if (parentAuditor == null)
auditor.commitAuditTrail();
} catch (Throwable t) {
throw new RegisterException(t);
......@@ -492,6 +501,8 @@ public class RegisterUserServiceImpl implements RegisterUserService {
eventSubmitter.submit(serviceRegisterEvent, eventList, EventType.SERVICE_DEREGISTER, executor);
auditor.finishAuditTrail();
auditor.commitAuditTrail();
} catch (RegisterException e) {
throw e;
} catch (Throwable t) {
......@@ -531,6 +542,8 @@ public class RegisterUserServiceImpl implements RegisterUserService {
registry = registryDao.persist(registry);
auditor.finishAuditTrail();
auditor.commitAuditTrail();
} catch (RegisterException e) {
throw e;
} catch (Throwable t) {
......@@ -560,6 +573,7 @@ public class RegisterUserServiceImpl implements RegisterUserService {
registry = registryDao.persist(registry);
auditor.finishAuditTrail();
auditor.commitAuditTrail();
} catch (RegisterException e) {
throw e;
} catch (Throwable t) {
......@@ -696,6 +710,7 @@ public class RegisterUserServiceImpl implements RegisterUserService {
registry = registryDao.persist(registry);
auditor.finishAuditTrail();
auditor.commitAuditTrail();
}
@Override
......
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