Search in sources :

Example 1 with AuditLogs

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();
        }
    }
}
Also used : DynamicWorkflows(com.tremolosecurity.provisioning.workflows.DynamicWorkflows) Workflows(com.tremolosecurity.provisioning.objects.Workflows) AuditLogs(com.tremolosecurity.provisioning.objects.AuditLogs) Connection(java.sql.Connection) Approvals(com.tremolosecurity.provisioning.objects.Approvals) Users(com.tremolosecurity.provisioning.objects.Users) InvocationTargetException(java.lang.reflect.InvocationTargetException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) InvalidKeyException(java.security.InvalidKeyException) LDAPException(com.novell.ldap.LDAPException) InvalidAlgorithmParameterException(java.security.InvalidAlgorithmParameterException) SocketException(java.net.SocketException) SQLException(java.sql.SQLException) SchedulerException(org.quartz.SchedulerException) IOException(java.io.IOException) MessagingException(javax.mail.MessagingException) IllegalBlockSizeException(javax.crypto.IllegalBlockSizeException) JMSException(javax.jms.JMSException) JAXBException(javax.xml.bind.JAXBException) FileNotFoundException(java.io.FileNotFoundException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) NoSuchPaddingException(javax.crypto.NoSuchPaddingException) BadPaddingException(javax.crypto.BadPaddingException)

Aggregations

LDAPException (com.novell.ldap.LDAPException)1 Approvals (com.tremolosecurity.provisioning.objects.Approvals)1 AuditLogs (com.tremolosecurity.provisioning.objects.AuditLogs)1 Users (com.tremolosecurity.provisioning.objects.Users)1 Workflows (com.tremolosecurity.provisioning.objects.Workflows)1 DynamicWorkflows (com.tremolosecurity.provisioning.workflows.DynamicWorkflows)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 SocketException (java.net.SocketException)1 InvalidAlgorithmParameterException (java.security.InvalidAlgorithmParameterException)1 InvalidKeyException (java.security.InvalidKeyException)1 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1 Connection (java.sql.Connection)1 SQLException (java.sql.SQLException)1 BadPaddingException (javax.crypto.BadPaddingException)1 IllegalBlockSizeException (javax.crypto.IllegalBlockSizeException)1 NoSuchPaddingException (javax.crypto.NoSuchPaddingException)1 JMSException (javax.jms.JMSException)1