Search in sources :

Example 56 with Qualifier

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

the class ZipkinElasticsearchStorageConfiguration method esTracing.

@Bean
@Qualifier(QUALIFIER)
@ConditionalOnSelfTracing
Consumer<ClientOptionsBuilder> esTracing(Optional<HttpTracing> maybeHttpTracing) {
    if (!maybeHttpTracing.isPresent()) {
        // Alternatively, check why we would ever get here if ConditionalOnSelfTracing matches
        return client -> {
        };
    }
    HttpTracing httpTracing = maybeHttpTracing.get().clientOf("elasticsearch");
    SpanCustomizer spanCustomizer = CurrentSpanCustomizer.create(httpTracing.tracing());
    return client -> {
        client.decorator((delegate, ctx, req) -> {
            // We only need the name if it's available and can unsafely access the partially filled log.
            RequestLog log = ctx.log().partial();
            if (log.isAvailable(RequestLogProperty.NAME)) {
                String name = log.name();
                if (name != null) {
                    // override the span name if set
                    spanCustomizer.name(name);
                }
            }
            return delegate.execute(ctx, req);
        });
        // the tracing decorator is added last so that it encloses the attempt to overwrite the name.
        client.decorator(BraveClient.newDecorator(httpTracing));
    };
}
Also used : CurrentSpanCustomizer(brave.CurrentSpanCustomizer) SessionProtocol(com.linecorp.armeria.common.SessionProtocol) ConditionalOnSelfTracing(zipkin2.server.internal.ConditionalOnSelfTracing) SpanCustomizer(brave.SpanCustomizer) ScheduledFuture(java.util.concurrent.ScheduledFuture) BraveClient(com.linecorp.armeria.client.brave.BraveClient) RequestLog(com.linecorp.armeria.common.logging.RequestLog) Supplier(java.util.function.Supplier) ElasticsearchStorage(zipkin2.elasticsearch.ElasticsearchStorage) NamedThreadFactory(io.micrometer.core.instrument.util.NamedThreadFactory) Value(org.springframework.beans.factory.annotation.Value) ConditionContext(org.springframework.context.annotation.ConditionContext) RequestLogProperty(com.linecorp.armeria.common.logging.RequestLogProperty) EnableConfigurationProperties(org.springframework.boot.context.properties.EnableConfigurationProperties) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) Qualifier(org.springframework.beans.factory.annotation.Qualifier) StorageComponent(zipkin2.storage.StorageComponent) ConditionalOnProperty(org.springframework.boot.autoconfigure.condition.ConditionalOnProperty) ClientFactoryBuilder(com.linecorp.armeria.client.ClientFactoryBuilder) HttpTracing(brave.http.HttpTracing) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Ssl(zipkin2.server.internal.elasticsearch.ZipkinElasticsearchStorageProperties.Ssl) ClientFactory(com.linecorp.armeria.client.ClientFactory) TrustManagerFactory(javax.net.ssl.TrustManagerFactory) Condition(org.springframework.context.annotation.Condition) KeyManagerFactory(javax.net.ssl.KeyManagerFactory) EndpointGroup(com.linecorp.armeria.client.endpoint.EndpointGroup) IOException(java.io.IOException) Executors(java.util.concurrent.Executors) TimeUnit(java.util.concurrent.TimeUnit) Consumer(java.util.function.Consumer) Configuration(org.springframework.context.annotation.Configuration) List(java.util.List) ClientOptionsBuilder(com.linecorp.armeria.client.ClientOptionsBuilder) MeterRegistry(io.micrometer.core.instrument.MeterRegistry) Optional(java.util.Optional) Bean(org.springframework.context.annotation.Bean) Conditional(org.springframework.context.annotation.Conditional) AnnotatedTypeMetadata(org.springframework.core.type.AnnotatedTypeMetadata) HttpTracing(brave.http.HttpTracing) RequestLog(com.linecorp.armeria.common.logging.RequestLog) CurrentSpanCustomizer(brave.CurrentSpanCustomizer) SpanCustomizer(brave.SpanCustomizer) ConditionalOnSelfTracing(zipkin2.server.internal.ConditionalOnSelfTracing) Qualifier(org.springframework.beans.factory.annotation.Qualifier) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean)

Example 57 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 58 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 59 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 60 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)65 Bean (org.springframework.context.annotation.Bean)58 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