use of org.apache.syncope.common.lib.types.ResourceOperation in project syncope by apache.
the class LoggerLogic method listAuditEvents.
@PreAuthorize("hasRole('" + StandardEntitlement.AUDIT_LIST + "') or hasRole('" + StandardEntitlement.NOTIFICATION_LIST + "')")
public List<EventCategoryTO> listAuditEvents() {
// use set to avoid duplications or null elements
Set<EventCategoryTO> events = new HashSet<>();
try {
ResourcePatternResolver resourcePatternResolver = new PathMatchingResourcePatternResolver();
MetadataReaderFactory metadataReaderFactory = new CachingMetadataReaderFactory(resourcePatternResolver);
String packageSearchPath = ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX + ClassUtils.convertClassNameToResourcePath(SystemPropertyUtils.resolvePlaceholders(this.getClass().getPackage().getName())) + "/**/*.class";
Resource[] resources = resourcePatternResolver.getResources(packageSearchPath);
for (Resource resource : resources) {
if (resource.isReadable()) {
final MetadataReader metadataReader = metadataReaderFactory.getMetadataReader(resource);
final Class<?> clazz = Class.forName(metadataReader.getClassMetadata().getClassName());
if (clazz.isAnnotationPresent(Component.class) && AbstractLogic.class.isAssignableFrom(clazz)) {
EventCategoryTO eventCategoryTO = new EventCategoryTO();
eventCategoryTO.setCategory(clazz.getSimpleName());
for (Method method : clazz.getDeclaredMethods()) {
if (Modifier.isPublic(method.getModifiers()) && !eventCategoryTO.getEvents().contains(method.getName())) {
eventCategoryTO.getEvents().add(method.getName());
}
}
events.add(eventCategoryTO);
}
}
}
// SYNCOPE-608
EventCategoryTO authenticationControllerEvents = new EventCategoryTO();
authenticationControllerEvents.setCategory(AuditElements.AUTHENTICATION_CATEGORY);
authenticationControllerEvents.getEvents().add(AuditElements.LOGIN_EVENT);
events.add(authenticationControllerEvents);
events.add(new EventCategoryTO(EventCategoryType.PROPAGATION));
events.add(new EventCategoryTO(EventCategoryType.PULL));
events.add(new EventCategoryTO(EventCategoryType.PUSH));
for (AnyTypeKind anyTypeKind : AnyTypeKind.values()) {
resourceDAO.findAll().forEach(resource -> {
EventCategoryTO propEventCategoryTO = new EventCategoryTO(EventCategoryType.PROPAGATION);
EventCategoryTO pullEventCategoryTO = new EventCategoryTO(EventCategoryType.PULL);
EventCategoryTO pushEventCategoryTO = new EventCategoryTO(EventCategoryType.PUSH);
propEventCategoryTO.setCategory(anyTypeKind.name().toLowerCase());
propEventCategoryTO.setSubcategory(resource.getKey());
pullEventCategoryTO.setCategory(anyTypeKind.name().toLowerCase());
pushEventCategoryTO.setCategory(anyTypeKind.name().toLowerCase());
pullEventCategoryTO.setSubcategory(resource.getKey());
pushEventCategoryTO.setSubcategory(resource.getKey());
for (ResourceOperation resourceOperation : ResourceOperation.values()) {
propEventCategoryTO.getEvents().add(resourceOperation.name().toLowerCase());
}
pullEventCategoryTO.getEvents().add(ResourceOperation.DELETE.name().toLowerCase());
for (UnmatchingRule unmatching : UnmatchingRule.values()) {
String event = UnmatchingRule.toEventName(unmatching);
pullEventCategoryTO.getEvents().add(event);
pushEventCategoryTO.getEvents().add(event);
}
for (MatchingRule matching : MatchingRule.values()) {
String event = MatchingRule.toEventName(matching);
pullEventCategoryTO.getEvents().add(event);
pushEventCategoryTO.getEvents().add(event);
}
events.add(propEventCategoryTO);
events.add(pullEventCategoryTO);
events.add(pushEventCategoryTO);
});
}
EventCategoryTO eventCategoryTO = new EventCategoryTO(EventCategoryType.TASK);
eventCategoryTO.setCategory(PullJobDelegate.class.getSimpleName());
events.add(eventCategoryTO);
eventCategoryTO = new EventCategoryTO(EventCategoryType.TASK);
eventCategoryTO.setCategory(PushJobDelegate.class.getSimpleName());
events.add(eventCategoryTO);
} catch (Exception e) {
LOG.error("Failure retrieving audit/notification events", e);
}
return new ArrayList<>(events);
}
Aggregations