use of org.reflections.util.ConfigurationBuilder in project cas by apereo.
the class OidcProfileScopeToAttributesFilter method configureAttributeReleasePoliciesByScope.
private void configureAttributeReleasePoliciesByScope() {
final OidcProperties oidc = casProperties.getAuthn().getOidc();
final String packageName = BaseOidcScopeAttributeReleasePolicy.class.getPackage().getName();
final Reflections reflections = new Reflections(new ConfigurationBuilder().filterInputsBy(new FilterBuilder().includePackage(packageName)).setUrls(ClasspathHelper.forPackage(packageName)).setScanners(new SubTypesScanner(true)));
final Set<Class<? extends BaseOidcScopeAttributeReleasePolicy>> subTypes = reflections.getSubTypesOf(BaseOidcScopeAttributeReleasePolicy.class);
subTypes.forEach(Unchecked.consumer(t -> {
final BaseOidcScopeAttributeReleasePolicy ex = t.getDeclaredConstructor().newInstance();
if (oidc.getScopes().contains(ex.getScopeName())) {
LOGGER.debug("Found OpenID Connect scope [{}] to filter attributes", ex.getScopeName());
filters.put(ex.getScopeName(), ex);
} else {
LOGGER.debug("OpenID Connect scope [{}] is not configured for use and will be ignored", ex.getScopeName());
}
}));
if (!userScopes.isEmpty()) {
LOGGER.debug("Configuring attributes release policies for user-defined scopes [{}]", userScopes);
userScopes.forEach(t -> filters.put(t.getScopeName(), t));
}
}
use of org.reflections.util.ConfigurationBuilder in project cas by apereo.
the class CasServerProfileRegistrar method locateSubtypesByReflection.
private Object locateSubtypesByReflection(final Function<Class, Object> mapper, final Collector collector, final Class parentType, final Predicate filter, final String packageNamespace) {
final Reflections reflections = new Reflections(new ConfigurationBuilder().setUrls(ClasspathHelper.forPackage(packageNamespace)).setScanners(new SubTypesScanner(false)));
final Set<Class<?>> subTypes = (Set) reflections.getSubTypesOf(parentType);
return subTypes.stream().filter(c -> !Modifier.isInterface(c.getModifiers()) && !Modifier.isAbstract(c.getModifiers()) && filter.test(c)).map(mapper).filter(Objects::nonNull).collect(collector);
}
use of org.reflections.util.ConfigurationBuilder in project cas by apereo.
the class JpaServiceRegistryConfiguration method jpaServicePackagesToScan.
@Bean
public List<String> jpaServicePackagesToScan() {
final Reflections reflections = new Reflections(new ConfigurationBuilder().setUrls(ClasspathHelper.forPackage(CentralAuthenticationService.NAMESPACE)).setScanners(new SubTypesScanner(false)));
final Set<Class<? extends AbstractRegisteredService>> subTypes = reflections.getSubTypesOf(AbstractRegisteredService.class);
return subTypes.stream().map(t -> t.getPackage().getName()).collect(Collectors.toList());
}
use of org.reflections.util.ConfigurationBuilder in project oc-explorer by devgateway.
the class ReflectionsConfiguration method reflections.
@Bean
public Reflections reflections() {
logger.debug("Starting reflections scanners...");
Reflections reflections = new Reflections(new ConfigurationBuilder().setUrls(ClasspathHelper.forPackage("org.devgateway.ocds.persistence.mongo")).setScanners(new SubTypesScanner(), new FieldAnnotationsScanner(), new MethodParameterScanner()));
logger.debug("Configured reflections bean.");
return reflections;
}
Aggregations