private void executeAuditCode(final String currentPrincipal, final String[] auditableResources,
                                  final ProceedingJoinPoint joinPoint, final Object retVal, final String action) {
        val clientInfo = clientInfoResolver.resolveFrom(joinPoint, retVal);
        val actionDate = auditActionDateProvider.get();
        val runtimeInfo = new AspectJAuditPointRuntimeInfo(joinPoint);

        Assert.notNull(currentPrincipal, "'principal' cannot be null.\n" + getDiagnosticInfo(runtimeInfo));
        Assert.notNull(action, "'actionPerformed' cannot be null.\n" + getDiagnosticInfo(runtimeInfo));
        Assert.notNull(actionDate, "'whenActionPerformed' cannot be null.\n" + getDiagnosticInfo(runtimeInfo));
        Assert.notNull(clientInfo.getClientIpAddress(), "'clientIpAddress' cannot be null.\n" + getDiagnosticInfo(runtimeInfo));
        Assert.notNull(clientInfo.getServerIpAddress(), "'serverIpAddress' cannot be null.\n" + getDiagnosticInfo(runtimeInfo));

        for (val auditableResource : auditableResources) {
            Assert.notNull(auditableResource, "'resourceOperatedUpon' cannot be null.\n" + getDiagnosticInfo(runtimeInfo));
            val auditContext = new AuditActionContext(currentPrincipal, auditableResource, action, "CAS", actionDate, clientInfo);

            try {
                for (val manager : auditTrailManagers) {
                    manager.setAuditFormat(this.auditFormat);
                    manager.record(auditContext);
                }
            } catch (final Throwable e) {
                if (this.failOnAuditFailures) {
                    throw e;
                }
                LOGGER.error("Failed to record audit context for [{}] and principal [{}]",
                    auditContext.getActionPerformed(), auditContext.getPrincipal());
                LoggingUtils.error(LOGGER, e);
            }
        }
    }
Handle audit trail.

@param joinPoint the join point
@param audit     the audit
@return the object
@throws Throwable the throwable
core/cas-server-core-audit-api/src/main/java/org/apereo/inspektr/audit/AuditTrailManagementAspect.java