Search in sources :

Example 41 with Qualifier

use of org.springframework.beans.factory.annotation.Qualifier in project netxms by netxms.

the class DaoContextConfig method dataSource.

@Bean
@Qualifier("systemDataSource")
public DataSource dataSource() throws PropertyVetoException {
    ComboPooledDataSource dataSource = new ComboPooledDataSource();
    ServerSettings.DataSourceConfig dataSourceConfig = settings.getDataSourceConfig(ServerSettings.DC_ID_SYSTEM);
    dataSource.setDriverClass(dataSourceConfig.getDriver());
    dataSource.setJdbcUrl(dataSourceConfig.getUrl());
    dataSource.setUser(dataSourceConfig.getUsername());
    dataSource.setPassword(dataSourceConfig.getPassword());
    dataSource.setTestConnectionOnCheckout(true);
    dataSource.setCheckoutTimeout(3000);
    dataSource.setIdleConnectionTestPeriod(300);
    return dataSource;
}
Also used : ComboPooledDataSource(com.mchange.v2.c3p0.ComboPooledDataSource) ServerSettings(com.radensolutions.reporting.service.ServerSettings) Qualifier(org.springframework.beans.factory.annotation.Qualifier) Bean(org.springframework.context.annotation.Bean)

Example 42 with Qualifier

use of org.springframework.beans.factory.annotation.Qualifier in project cas by apereo.

the class RedisAuthenticationConfiguration method redisPersonAttributeDaos.

@ConditionalOnMissingBean(name = "redisPersonAttributeDaos")
@Bean
@RefreshScope(proxyMode = ScopedProxyMode.DEFAULT)
public BeanContainer<IPersonAttributeDao> redisPersonAttributeDaos(final ConfigurableApplicationContext applicationContext, @Qualifier(CasSSLContext.BEAN_NAME) final CasSSLContext casSslContext, final CasConfigurationProperties casProperties) {
    return BeanSupplier.of(BeanContainer.class).when(CONDITION.given(applicationContext.getEnvironment())).supply(() -> {
        val redis = casProperties.getAuthn().getAttributeRepository().getRedis();
        return BeanContainer.of(redis.stream().filter(r -> StringUtils.isNotBlank(r.getHost())).map(r -> {
            val conn = RedisObjectFactory.newRedisConnectionFactory(r, true, casSslContext);
            val template = RedisObjectFactory.newRedisTemplate(conn);
            template.initialize();
            val cb = new RedisPersonAttributeDao(template);
            cb.setOrder(r.getOrder());
            FunctionUtils.doIfNotNull(r.getId(), cb::setId);
            return cb;
        }).collect(Collectors.toList()));
    }).otherwise(BeanContainer::empty).get();
}
Also used : lombok.val(lombok.val) CasConfigurationProperties(org.apereo.cas.configuration.CasConfigurationProperties) BeanCondition(org.apereo.cas.util.spring.beans.BeanCondition) PasswordEncoderUtils(org.apereo.cas.authentication.support.password.PasswordEncoderUtils) RedisPersonAttributeDao(org.apereo.cas.redis.RedisPersonAttributeDao) PersonDirectoryAttributeRepositoryPlanConfigurer(org.apereo.cas.persondir.PersonDirectoryAttributeRepositoryPlanConfigurer) StringUtils(org.apache.commons.lang3.StringUtils) IPersonAttributeDao(org.apereo.services.persondir.IPersonAttributeDao) BeanSupplier(org.apereo.cas.util.spring.beans.BeanSupplier) RefreshScope(org.springframework.cloud.context.config.annotation.RefreshScope) FunctionUtils(org.apereo.cas.util.function.FunctionUtils) AuthenticationHandler(org.apereo.cas.authentication.AuthenticationHandler) PrincipalFactory(org.apereo.cas.authentication.principal.PrincipalFactory) BeanContainer(org.apereo.cas.util.spring.beans.BeanContainer) EnableConfigurationProperties(org.springframework.boot.context.properties.EnableConfigurationProperties) ConfigurableApplicationContext(org.springframework.context.ConfigurableApplicationContext) Qualifier(org.springframework.beans.factory.annotation.Qualifier) CasRedisTemplate(org.apereo.cas.redis.core.CasRedisTemplate) ServicesManager(org.apereo.cas.services.ServicesManager) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) PrincipalFactoryUtils(org.apereo.cas.authentication.principal.PrincipalFactoryUtils) PrincipalResolver(org.apereo.cas.authentication.principal.PrincipalResolver) RedisAuthenticationHandler(org.apereo.cas.redis.RedisAuthenticationHandler) lombok.val(lombok.val) ScopedProxyMode(org.springframework.context.annotation.ScopedProxyMode) ConditionalOnFeature(org.apereo.cas.util.spring.boot.ConditionalOnFeature) RedisConnectionFactory(org.springframework.data.redis.connection.RedisConnectionFactory) RedisObjectFactory(org.apereo.cas.redis.core.RedisObjectFactory) Collectors(java.util.stream.Collectors) Configuration(org.springframework.context.annotation.Configuration) CasFeatureModule(org.apereo.cas.configuration.support.CasFeatureModule) CasSSLContext(org.apereo.cas.authentication.CasSSLContext) PrincipalNameTransformerUtils(org.apereo.cas.authentication.principal.PrincipalNameTransformerUtils) Bean(org.springframework.context.annotation.Bean) AuthenticationEventExecutionPlanConfigurer(org.apereo.cas.authentication.AuthenticationEventExecutionPlanConfigurer) RedisPersonAttributeDao(org.apereo.cas.redis.RedisPersonAttributeDao) RefreshScope(org.springframework.cloud.context.config.annotation.RefreshScope) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean)

Example 43 with Qualifier

use of org.springframework.beans.factory.annotation.Qualifier in project cas by apereo.

the class SamlIdentityProviderDiscoveryConfiguration method samlIdentityProviderEntityParser.

@Bean
@RefreshScope(proxyMode = ScopedProxyMode.DEFAULT)
@ConditionalOnMissingBean(name = "samlIdentityProviderEntityParser")
public Supplier<List<SamlIdentityProviderEntityParser>> samlIdentityProviderEntityParser(final CasConfigurationProperties casProperties, @Qualifier("builtClients") final Clients builtClients) {
    val parsers = new ArrayList<SamlIdentityProviderEntityParser>();
    val resource = casProperties.getAuthn().getPac4j().getSamlDiscovery().getResource();
    resource.stream().filter(res -> res.getLocation() != null).forEach(Unchecked.consumer(res -> parsers.add(new SamlIdentityProviderEntityParser(res.getLocation()))));
    builtClients.findAllClients().stream().filter(c -> c instanceof SAML2Client).map(SAML2Client.class::cast).forEach(c -> {
        c.init();
        val entity = new SamlIdentityProviderEntity();
        entity.setEntityID(c.getIdentityProviderResolvedEntityId());
        parsers.add(new SamlIdentityProviderEntityParser(entity));
    });
    return () -> parsers;
}
Also used : lombok.val(lombok.val) CasConfigurationProperties(org.apereo.cas.configuration.CasConfigurationProperties) ArgumentExtractor(org.apereo.cas.web.support.ArgumentExtractor) SAML2Client(org.pac4j.saml.client.SAML2Client) FlowBuilderServices(org.springframework.webflow.engine.builder.support.FlowBuilderServices) Supplier(java.util.function.Supplier) RefreshScope(org.springframework.cloud.context.config.annotation.RefreshScope) ArrayList(java.util.ArrayList) Clients(org.pac4j.core.client.Clients) CasWebflowConstants(org.apereo.cas.web.flow.CasWebflowConstants) EnableConfigurationProperties(org.springframework.boot.context.properties.EnableConfigurationProperties) ConfigurableApplicationContext(org.springframework.context.ConfigurableApplicationContext) Qualifier(org.springframework.beans.factory.annotation.Qualifier) ServicesManager(org.apereo.cas.services.ServicesManager) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Unchecked(org.jooq.lambda.Unchecked) FlowDefinitionRegistry(org.springframework.webflow.definition.registry.FlowDefinitionRegistry) lombok.val(lombok.val) ScopedProxyMode(org.springframework.context.annotation.ScopedProxyMode) ConditionalOnFeature(org.apereo.cas.util.spring.boot.ConditionalOnFeature) SamlIdentityProviderEntity(org.apereo.cas.entity.SamlIdentityProviderEntity) Configuration(org.springframework.context.annotation.Configuration) SamlIdentityProviderDiscoveryWebflowConfigurer(org.apereo.cas.web.flow.SamlIdentityProviderDiscoveryWebflowConfigurer) List(java.util.List) AuditableExecution(org.apereo.cas.audit.AuditableExecution) CasFeatureModule(org.apereo.cas.configuration.support.CasFeatureModule) SamlIdentityProviderDiscoveryFeedController(org.apereo.cas.web.SamlIdentityProviderDiscoveryFeedController) DelegatedAuthenticationAccessStrategyHelper(org.apereo.cas.validation.DelegatedAuthenticationAccessStrategyHelper) CasWebflowConfigurer(org.apereo.cas.web.flow.CasWebflowConfigurer) SamlIdentityProviderEntityParser(org.apereo.cas.entity.SamlIdentityProviderEntityParser) Bean(org.springframework.context.annotation.Bean) CasWebflowExecutionPlanConfigurer(org.apereo.cas.web.flow.CasWebflowExecutionPlanConfigurer) ArrayList(java.util.ArrayList) SAML2Client(org.pac4j.saml.client.SAML2Client) SamlIdentityProviderEntityParser(org.apereo.cas.entity.SamlIdentityProviderEntityParser) SamlIdentityProviderEntity(org.apereo.cas.entity.SamlIdentityProviderEntity) RefreshScope(org.springframework.cloud.context.config.annotation.RefreshScope) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean)

Example 44 with Qualifier

use of org.springframework.beans.factory.annotation.Qualifier in project uPortal by Jasig.

the class PersonDirectoryConfiguration method getRequestAttributeMergingDao.

/**
 * Merges attributes from the request with those from other DAOs.
 */
@Bean(name = "requestAttributeMergingDao")
@Qualifier("uPortalInternal")
public IPersonAttributeDao getRequestAttributeMergingDao() {
    final MergingPersonAttributeDaoImpl rslt = new MergingPersonAttributeDaoImpl();
    rslt.setUsernameAttributeProvider(getUsernameAttributeProvider());
    rslt.setMerger(new ReplacingAttributeAdder());
    final List<IPersonAttributeDao> daos = new ArrayList<>();
    daos.add(getRequestAttributesDao());
    daos.add(getCachingPersonAttributeDao());
    rslt.setPersonAttributeDaos(daos);
    return rslt;
}
Also used : ReplacingAttributeAdder(org.apereo.services.persondir.support.merger.ReplacingAttributeAdder) MergingPersonAttributeDaoImpl(org.apereo.services.persondir.support.MergingPersonAttributeDaoImpl) IPersonAttributeDao(org.apereo.services.persondir.IPersonAttributeDao) ArrayList(java.util.ArrayList) Qualifier(org.springframework.beans.factory.annotation.Qualifier) Bean(org.springframework.context.annotation.Bean)

Example 45 with Qualifier

use of org.springframework.beans.factory.annotation.Qualifier in project uPortal by Jasig.

the class PersonDirectoryConfiguration method getCachingPersonAttributeDao.

/**
 * Defines the order that the data providing DAOs are called, results are cached by the outer
 * caching DAO.
 */
@Bean(name = "cachingPersonAttributeDao")
@Qualifier("uPortalInternal")
public IPersonAttributeDao getCachingPersonAttributeDao() {
    final CachingPersonAttributeDaoImpl rslt = new CachingPersonAttributeDaoImpl();
    rslt.setUsernameAttributeProvider(getUsernameAttributeProvider());
    rslt.setCacheNullResults(true);
    rslt.setCacheKeyGenerator(getUserAttributeCacheKeyGenerator());
    rslt.setUserInfoCache(new MapCacheProvider<>(userInfoCache));
    rslt.setCachedPersonAttributesDao(getMergingPersonAttributeDao());
    return rslt;
}
Also used : CachingPersonAttributeDaoImpl(org.apereo.services.persondir.support.CachingPersonAttributeDaoImpl) Qualifier(org.springframework.beans.factory.annotation.Qualifier) Bean(org.springframework.context.annotation.Bean)

Aggregations

Qualifier (org.springframework.beans.factory.annotation.Qualifier)66 Bean (org.springframework.context.annotation.Bean)59 RmiProxyFactoryBean (org.springframework.remoting.rmi.RmiProxyFactoryBean)18 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)12 Configuration (org.springframework.context.annotation.Configuration)7 EnableConfigurationProperties (org.springframework.boot.context.properties.EnableConfigurationProperties)6 lombok.val (lombok.val)5 CasConfigurationProperties (org.apereo.cas.configuration.CasConfigurationProperties)5 ConfigurationProperties (org.springframework.boot.context.properties.ConfigurationProperties)5 RequestResponseClientConfigProperties (org.eclipse.hono.client.RequestResponseClientConfigProperties)4 RefreshScope (org.springframework.cloud.context.config.annotation.RefreshScope)4 ScopedProxyMode (org.springframework.context.annotation.ScopedProxyMode)4 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 HashSet (java.util.HashSet)3 List (java.util.List)3 Collectors (java.util.stream.Collectors)3 ClientFactoryBuilder (com.linecorp.armeria.client.ClientFactoryBuilder)2 IdMCacheConfiguration (eu.bcvsolutions.idm.core.api.config.cache.IdMCacheConfiguration)2 Supplier (java.util.function.Supplier)2