use of org.apache.syncope.core.persistence.api.dao.AccountRuleConfClass in project syncope by apache.
the class ClassPathScanImplementationLookup method load.
@Override
@SuppressWarnings("unchecked")
public void load() {
classNames = new EnumMap<>(ImplementationType.class);
for (ImplementationType type : ImplementationType.values()) {
classNames.put(type, new HashSet<>());
}
jwtSSOProviderClasses = new HashSet<>();
reportletClasses = new HashMap<>();
accountRuleClasses = new HashMap<>();
passwordRuleClasses = new HashMap<>();
correlationRuleClasses = new HashMap<>();
auditAppenderClasses = new HashSet<>();
ClassPathScanningCandidateComponentProvider scanner = new ClassPathScanningCandidateComponentProvider(false);
scanner.addIncludeFilter(new AssignableTypeFilter(JWTSSOProvider.class));
scanner.addIncludeFilter(new AssignableTypeFilter(Reportlet.class));
scanner.addIncludeFilter(new AssignableTypeFilter(AccountRule.class));
scanner.addIncludeFilter(new AssignableTypeFilter(PasswordRule.class));
scanner.addIncludeFilter(new AssignableTypeFilter(PullCorrelationRule.class));
scanner.addIncludeFilter(new AssignableTypeFilter(ItemTransformer.class));
scanner.addIncludeFilter(new AssignableTypeFilter(SchedTaskJobDelegate.class));
scanner.addIncludeFilter(new AssignableTypeFilter(ReconFilterBuilder.class));
scanner.addIncludeFilter(new AssignableTypeFilter(LogicActions.class));
scanner.addIncludeFilter(new AssignableTypeFilter(PropagationActions.class));
scanner.addIncludeFilter(new AssignableTypeFilter(PullActions.class));
scanner.addIncludeFilter(new AssignableTypeFilter(PushActions.class));
scanner.addIncludeFilter(new AssignableTypeFilter(Validator.class));
scanner.addIncludeFilter(new AssignableTypeFilter(RecipientsProvider.class));
scanner.addIncludeFilter(new AssignableTypeFilter(AuditAppender.class));
scanner.findCandidateComponents(getBasePackage()).forEach(bd -> {
try {
Class<?> clazz = ClassUtils.resolveClassName(bd.getBeanClassName(), ClassUtils.getDefaultClassLoader());
boolean isAbstractClazz = Modifier.isAbstract(clazz.getModifiers());
if (JWTSSOProvider.class.isAssignableFrom(clazz) && !isAbstractClazz) {
classNames.get(ImplementationType.JWT_SSO_PROVIDER).add(clazz.getName());
jwtSSOProviderClasses.add(clazz);
}
if (Reportlet.class.isAssignableFrom(clazz) && !isAbstractClazz) {
ReportletConfClass annotation = clazz.getAnnotation(ReportletConfClass.class);
if (annotation == null) {
LOG.warn("Found Reportlet {} without declared configuration", clazz.getName());
} else {
classNames.get(ImplementationType.REPORTLET).add(clazz.getName());
reportletClasses.put(annotation.value(), (Class<? extends Reportlet>) clazz);
}
}
if (AccountRule.class.isAssignableFrom(clazz) && !isAbstractClazz) {
AccountRuleConfClass annotation = clazz.getAnnotation(AccountRuleConfClass.class);
if (annotation == null) {
LOG.warn("Found account policy rule {} without declared configuration", clazz.getName());
} else {
classNames.get(ImplementationType.ACCOUNT_RULE).add(clazz.getName());
accountRuleClasses.put(annotation.value(), (Class<? extends AccountRule>) clazz);
}
}
if (PasswordRule.class.isAssignableFrom(clazz) && !isAbstractClazz) {
PasswordRuleConfClass annotation = clazz.getAnnotation(PasswordRuleConfClass.class);
if (annotation == null) {
LOG.warn("Found password policy rule {} without declared configuration", clazz.getName());
} else {
classNames.get(ImplementationType.PASSWORD_RULE).add(clazz.getName());
passwordRuleClasses.put(annotation.value(), (Class<? extends PasswordRule>) clazz);
}
}
if (PullCorrelationRule.class.isAssignableFrom(clazz) && !isAbstractClazz) {
PullCorrelationRuleConfClass annotation = clazz.getAnnotation(PullCorrelationRuleConfClass.class);
if (annotation == null) {
LOG.warn("Found pull correlation rule {} without declared configuration", clazz.getName());
} else {
classNames.get(ImplementationType.ACCOUNT_RULE).add(clazz.getName());
correlationRuleClasses.put(annotation.value(), (Class<? extends PullCorrelationRule>) clazz);
}
}
if (ItemTransformer.class.isAssignableFrom(clazz) && !isAbstractClazz && !clazz.equals(JEXLItemTransformerImpl.class)) {
classNames.get(ImplementationType.ITEM_TRANSFORMER).add(clazz.getName());
}
if (SchedTaskJobDelegate.class.isAssignableFrom(clazz) && !isAbstractClazz && !PullJobDelegate.class.isAssignableFrom(clazz) && !PushJobDelegate.class.isAssignableFrom(clazz) && !GroupMemberProvisionTaskJobDelegate.class.isAssignableFrom(clazz)) {
classNames.get(ImplementationType.TASKJOB_DELEGATE).add(bd.getBeanClassName());
}
if (ReconFilterBuilder.class.isAssignableFrom(clazz) && !isAbstractClazz) {
classNames.get(ImplementationType.RECON_FILTER_BUILDER).add(bd.getBeanClassName());
}
if (LogicActions.class.isAssignableFrom(clazz) && !isAbstractClazz) {
classNames.get(ImplementationType.LOGIC_ACTIONS).add(bd.getBeanClassName());
}
if (PropagationActions.class.isAssignableFrom(clazz) && !isAbstractClazz) {
classNames.get(ImplementationType.PROPAGATION_ACTIONS).add(bd.getBeanClassName());
}
if (PullActions.class.isAssignableFrom(clazz) && !isAbstractClazz) {
classNames.get(ImplementationType.PULL_ACTIONS).add(bd.getBeanClassName());
}
if (PushActions.class.isAssignableFrom(clazz) && !isAbstractClazz) {
classNames.get(ImplementationType.PUSH_ACTIONS).add(bd.getBeanClassName());
}
if (Validator.class.isAssignableFrom(clazz) && !isAbstractClazz) {
classNames.get(ImplementationType.VALIDATOR).add(bd.getBeanClassName());
}
if (RecipientsProvider.class.isAssignableFrom(clazz) && !isAbstractClazz) {
classNames.get(ImplementationType.RECIPIENTS_PROVIDER).add(bd.getBeanClassName());
}
if (AuditAppender.class.isAssignableFrom(clazz) && !isAbstractClazz) {
classNames.get(ImplementationType.AUDIT_APPENDER).add(clazz.getName());
auditAppenderClasses.add(clazz);
}
} catch (Throwable t) {
LOG.warn("Could not inspect class {}", bd.getBeanClassName(), t);
}
});
classNames = Collections.unmodifiableMap(classNames);
LOG.debug("Implementation classes found: {}", classNames);
jwtSSOProviderClasses = Collections.unmodifiableSet(jwtSSOProviderClasses);
reportletClasses = Collections.unmodifiableMap(reportletClasses);
accountRuleClasses = Collections.unmodifiableMap(accountRuleClasses);
passwordRuleClasses = Collections.unmodifiableMap(passwordRuleClasses);
correlationRuleClasses = Collections.unmodifiableMap(correlationRuleClasses);
auditAppenderClasses = Collections.unmodifiableSet(auditAppenderClasses);
}
Aggregations