Search in sources :

Example 1 with AuditLoggerName

use of org.apache.syncope.common.lib.types.AuditLoggerName in project syncope by apache.

the class LoggerWrapper method unwrap.

public static List<LoggerTO> unwrap(final Collection<AuditLoggerName> auditNames) {
    List<LoggerTO> result = new ArrayList<>();
    for (AuditLoggerName name : auditNames) {
        LoggerTO loggerTO = new LoggerTO();
        loggerTO.setKey(name.toLoggerName());
        loggerTO.setLevel(LoggerLevel.DEBUG);
        result.add(loggerTO);
    }
    return result;
}
Also used : LoggerTO(org.apache.syncope.common.lib.log.LoggerTO) ArrayList(java.util.ArrayList) AuditLoggerName(org.apache.syncope.common.lib.types.AuditLoggerName)

Example 2 with AuditLoggerName

use of org.apache.syncope.common.lib.types.AuditLoggerName in project syncope by apache.

the class AuditManagerImpl method auditRequested.

@Override
public boolean auditRequested(final AuditElements.EventCategoryType type, final String category, final String subcategory, final String event) {
    AuditEntry auditEntry = new AuditEntry(AuthContextUtils.getUsername(), new AuditLoggerName(type, category, subcategory, event, Result.SUCCESS), null, null, null);
    org.apache.syncope.core.persistence.api.entity.Logger syncopeLogger = loggerDAO.find(auditEntry.getLogger().toLoggerName());
    boolean auditRequested = syncopeLogger != null && syncopeLogger.getLevel() == LoggerLevel.DEBUG;
    if (auditRequested) {
        return true;
    }
    auditEntry = new AuditEntry(AuthContextUtils.getUsername(), new AuditLoggerName(type, category, subcategory, event, Result.FAILURE), null, null, null);
    syncopeLogger = loggerDAO.find(auditEntry.getLogger().toLoggerName());
    auditRequested = syncopeLogger != null && syncopeLogger.getLevel() == LoggerLevel.DEBUG;
    return auditRequested;
}
Also used : AuditLoggerName(org.apache.syncope.common.lib.types.AuditLoggerName)

Example 3 with AuditLoggerName

use of org.apache.syncope.common.lib.types.AuditLoggerName in project syncope by apache.

the class AuditManagerImpl method audit.

@Override
public void audit(final AuditElements.EventCategoryType type, final String category, final String subcategory, final String event, final Result condition, final Object before, final Object output, final Object... input) {
    Throwable throwable = null;
    if (output instanceof Throwable) {
        throwable = (Throwable) output;
    }
    AuditEntry auditEntry = new AuditEntry(AuthContextUtils.getUsername(), new AuditLoggerName(type, category, subcategory, event, condition), before, throwable == null ? output : throwable.getMessage(), input);
    org.apache.syncope.core.persistence.api.entity.Logger syncopeLogger = loggerDAO.find(auditEntry.getLogger().toLoggerName());
    if (syncopeLogger != null && syncopeLogger.getLevel() == LoggerLevel.DEBUG) {
        Logger logger = LoggerFactory.getLogger(AuditLoggerName.getAuditLoggerName(AuthContextUtils.getDomain()));
        Logger eventLogger = LoggerFactory.getLogger(AuditLoggerName.getAuditEventLoggerName(AuthContextUtils.getDomain(), syncopeLogger.getKey()));
        String serializedAuditEntry = POJOHelper.serialize(auditEntry);
        if (throwable == null) {
            logger.debug(serializedAuditEntry);
            eventLogger.debug(POJOHelper.serialize(auditEntry));
        } else {
            logger.debug(serializedAuditEntry, throwable);
            eventLogger.debug(serializedAuditEntry, throwable);
        }
    }
}
Also used : Logger(org.slf4j.Logger) AuditLoggerName(org.apache.syncope.common.lib.types.AuditLoggerName)

Example 4 with AuditLoggerName

use of org.apache.syncope.common.lib.types.AuditLoggerName in project syncope by apache.

the class LoggerLogic method readAudit.

@PreAuthorize("hasRole('" + StandardEntitlement.AUDIT_READ + "')")
@Transactional(readOnly = true)
public LoggerTO readAudit(final String name) {
    for (final AuditLoggerName logger : listAudits()) {
        if (logger.toLoggerName().equals(name)) {
            final LoggerTO loggerTO = new LoggerTO();
            loggerTO.setKey(logger.toLoggerName());
            loggerTO.setLevel(LoggerLevel.DEBUG);
            return loggerTO;
        }
    }
    throw new NotFoundException("Logger " + name);
}
Also used : LoggerTO(org.apache.syncope.common.lib.log.LoggerTO) NotFoundException(org.apache.syncope.core.persistence.api.dao.NotFoundException) AuditLoggerName(org.apache.syncope.common.lib.types.AuditLoggerName) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) Transactional(org.springframework.transaction.annotation.Transactional)

Example 5 with AuditLoggerName

use of org.apache.syncope.common.lib.types.AuditLoggerName in project syncope by apache.

the class SyslogRewriteAuditAppender method getEvents.

@Override
public Set<AuditLoggerName> getEvents() {
    Set<AuditLoggerName> events = new HashSet<>();
    events.add(new AuditLoggerName(AuditElements.EventCategoryType.LOGIC, ResourceLogic.class.getSimpleName(), null, "update", AuditElements.Result.SUCCESS));
    events.add(new AuditLoggerName(AuditElements.EventCategoryType.LOGIC, ConnectorLogic.class.getSimpleName(), null, "update", AuditElements.Result.SUCCESS));
    events.add(new AuditLoggerName(AuditElements.EventCategoryType.LOGIC, ResourceLogic.class.getSimpleName(), null, "delete", AuditElements.Result.SUCCESS));
    return events;
}
Also used : AuditLoggerName(org.apache.syncope.common.lib.types.AuditLoggerName) HashSet(java.util.HashSet)

Aggregations

AuditLoggerName (org.apache.syncope.common.lib.types.AuditLoggerName)10 LoggerTO (org.apache.syncope.common.lib.log.LoggerTO)5 HashSet (java.util.HashSet)3 Test (org.junit.jupiter.api.Test)3 File (java.io.File)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 ArrayList (java.util.ArrayList)1 Properties (java.util.Properties)1 Response (javax.ws.rs.core.Response)1 AuditReportletConf (org.apache.syncope.common.lib.report.AuditReportletConf)1 ConnInstanceTO (org.apache.syncope.common.lib.to.ConnInstanceTO)1 ConnPoolConfTO (org.apache.syncope.common.lib.to.ConnPoolConfTO)1 ImplementationTO (org.apache.syncope.common.lib.to.ImplementationTO)1 ReportTO (org.apache.syncope.common.lib.to.ReportTO)1 ResourceTO (org.apache.syncope.common.lib.to.ResourceTO)1 ConnectorLogic (org.apache.syncope.core.logic.ConnectorLogic)1 ReportLogic (org.apache.syncope.core.logic.ReportLogic)1 ResourceLogic (org.apache.syncope.core.logic.ResourceLogic)1 NotFoundException (org.apache.syncope.core.persistence.api.dao.NotFoundException)1