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;
}
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;
}
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);
}
}
}
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);
}
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;
}
Aggregations