use of net.shibboleth.idp.attribute.resolver.impl.AttributeResolverImpl in project cas by apereo.
the class ShibbolethAttributeResolverConfiguration method attributeRepository.
@Bean
public IPersonAttributeDao attributeRepository() {
try {
final PropertyPlaceholderConfigurer cfg = new PropertyPlaceholderConfigurer();
final Map<String, Object> result = new HashMap<>();
environment.getPropertySources().forEach(s -> {
if (s instanceof EnumerablePropertySource<?>) {
final EnumerablePropertySource<?> ps = (EnumerablePropertySource<?>) s;
Arrays.asList(ps.getPropertyNames()).forEach(key -> result.put(key, ps.getProperty(key)));
}
});
final Properties p = new Properties();
p.putAll(result);
cfg.setProperties(p);
registerBeanIntoApplicationContext(cfg, "shibboleth.PropertySourcesPlaceholderConfigurer");
final ApplicationContext tempApplicationContext = SpringSupport.newContext(getClass().getName(), casProperties.getShibAttributeResolver().getResources(), Collections.singletonList(cfg), Collections.emptyList(), Collections.emptyList(), this.applicationContext);
final Collection<DataConnector> values = BeanFactoryUtils.beansOfTypeIncludingAncestors(tempApplicationContext, DataConnector.class).values();
final Collection<DataConnector> connectors = new HashSet<>(values);
final AttributeResolverImpl impl = new AttributeResolverImpl();
impl.setId(getClass().getSimpleName());
impl.setApplicationContext(tempApplicationContext);
impl.setAttributeDefinitions(BeanFactoryUtils.beansOfTypeIncludingAncestors(tempApplicationContext, AttributeDefinition.class).values());
impl.setDataConnectors(connectors);
if (!impl.isInitialized()) {
impl.initialize();
}
return new ShibbolethPersonAttributeDao(impl);
} catch (final Exception e) {
LOGGER.warn(e.getMessage(), e);
}
return Beans.newStubAttributeRepository(casProperties.getAuthn().getAttributeRepository());
}
Aggregations