use of com.tremolosecurity.provisioning.objects.AuditLogs in project OpenUnison by TremoloSecurity.
the class SendMessageThread method logAction.
/* (non-Javadoc)
* @see com.tremolosecurity.provisioning.core.ProvisioningEngine#logAction(java.lang.String, boolean, com.tremolosecurity.provisioning.core.ProvisioningEngineImpl.ActionType, int, com.tremolosecurity.provisioning.core.WorkflowImpl, java.lang.String, java.lang.String)
*/
@Override
public void logAction(String target, boolean isEntry, ActionType actionType, int approval, Workflow wf, String attribute, String val) throws ProvisioningException {
Connection con = null;
if (this.maskedAttributes != null && this.maskedAttributes.contains(attribute)) {
val = "##########";
}
StringBuffer line = new StringBuffer();
line.append("target=").append(target);
line.append(" entry=").append(isEntry);
line.append(" ");
switch(actionType) {
case Add:
line.append("Add");
break;
case Delete:
line.append("Delete");
break;
case Replace:
line.append("Replace");
break;
}
line.append(" user=").append(wf.getUser().getUserID()).append(" workflow=").append(wf.getName()).append(" approval=").append(approval).append(" ").append(attribute).append("='").append(val).append("'");
logger.info(line);
if (this.sessionFactory != null) {
org.hibernate.Session session = sessionFactory.openSession();
try {
AuditLogs auditLog = new AuditLogs();
if (isEntry) {
auditLog.setIsEntry(1);
} else {
auditLog.setIsEntry(0);
}
switch(actionType) {
case Add:
auditLog.setAuditLogType(this.auditLogTypes.get("add"));
break;
case Delete:
auditLog.setAuditLogType(this.auditLogTypes.get("delete"));
break;
case Replace:
auditLog.setAuditLogType(this.auditLogTypes.get("replace"));
break;
}
auditLog.setUser(session.load(Users.class, wf.getUserNum()));
if (approval > 0) {
auditLog.setApprovals(session.load(Approvals.class, approval));
} else {
auditLog.setApprovals(null);
}
auditLog.setAttribute(attribute);
auditLog.setVal(val);
auditLog.setWorkflows(session.load(Workflows.class, wf.getId()));
auditLog.setTargets(this.targetIDs.get(target));
session.save(auditLog);
} catch (Exception e) {
logger.error("Could not create audit record", e);
} finally {
session.close();
}
}
}
Aggregations