Search in sources :

Example 6 with ConditionalOnMissingBean

use of org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean in project cas by apereo.

the class CasCoreTicketsConfiguration method ticketCatalog.

@ConditionalOnMissingBean(name = "ticketCatalog")
@Autowired
@Bean
public TicketCatalog ticketCatalog(final List<TicketCatalogConfigurer> configurers) {
    final DefaultTicketCatalog plan = new DefaultTicketCatalog();
    configurers.forEach(c -> {
        final String name = StringUtils.removePattern(c.getClass().getSimpleName(), "\\$.+");
        LOGGER.debug("Configuring ticket metadata registration plan [{}]", name);
        c.configureTicketCatalog(plan);
    });
    return plan;
}
Also used : DefaultTicketCatalog(org.apereo.cas.ticket.DefaultTicketCatalog) Autowired(org.springframework.beans.factory.annotation.Autowired) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean)

Example 7 with ConditionalOnMissingBean

use of org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean in project cas by apereo.

the class CasCoreConfiguration method authenticationServiceSelectionPlan.

@ConditionalOnMissingBean(name = "authenticationServiceSelectionPlan")
@Autowired
@Bean
public AuthenticationServiceSelectionPlan authenticationServiceSelectionPlan(final List<AuthenticationServiceSelectionStrategyConfigurer> configurers) {
    final DefaultAuthenticationServiceSelectionPlan plan = new DefaultAuthenticationServiceSelectionPlan();
    configurers.forEach(c -> {
        final String name = StringUtils.removePattern(c.getClass().getSimpleName(), "\\$.+");
        LOGGER.debug("Configuring authentication request service selection strategy plan [{}]", name);
        c.configureAuthenticationServiceSelectionStrategy(plan);
    });
    return plan;
}
Also used : DefaultAuthenticationServiceSelectionPlan(org.apereo.cas.authentication.DefaultAuthenticationServiceSelectionPlan) Autowired(org.springframework.beans.factory.annotation.Autowired) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean)

Example 8 with ConditionalOnMissingBean

use of org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean in project cas by apereo.

the class ElectronicFenceConfiguration method authenticationRiskEvaluator.

@ConditionalOnMissingBean(name = "authenticationRiskEvaluator")
@Bean
@RefreshScope
public AuthenticationRiskEvaluator authenticationRiskEvaluator() {
    final RiskBasedAuthenticationProperties risk = casProperties.getAuthn().getAdaptive().getRisk();
    final Set<AuthenticationRequestRiskCalculator> calculators = new HashSet<>();
    if (risk.getIp().isEnabled()) {
        calculators.add(ipAddressAuthenticationRequestRiskCalculator());
    }
    if (risk.getAgent().isEnabled()) {
        calculators.add(userAgentAuthenticationRequestRiskCalculator());
    }
    if (risk.getDateTime().isEnabled()) {
        calculators.add(dateTimeAuthenticationRequestRiskCalculator());
    }
    if (risk.getGeoLocation().isEnabled()) {
        calculators.add(geoLocationAuthenticationRequestRiskCalculator());
    }
    if (calculators.isEmpty()) {
        LOGGER.warn("No risk calculators are defined to examine authentication requests");
    }
    return new DefaultAuthenticationRiskEvaluator(calculators);
}
Also used : RiskBasedAuthenticationProperties(org.apereo.cas.configuration.model.core.authentication.RiskBasedAuthenticationProperties) DefaultAuthenticationRiskEvaluator(org.apereo.cas.impl.engine.DefaultAuthenticationRiskEvaluator) UserAgentAuthenticationRequestRiskCalculator(org.apereo.cas.impl.calcs.UserAgentAuthenticationRequestRiskCalculator) IpAddressAuthenticationRequestRiskCalculator(org.apereo.cas.impl.calcs.IpAddressAuthenticationRequestRiskCalculator) DateTimeAuthenticationRequestRiskCalculator(org.apereo.cas.impl.calcs.DateTimeAuthenticationRequestRiskCalculator) GeoLocationAuthenticationRequestRiskCalculator(org.apereo.cas.impl.calcs.GeoLocationAuthenticationRequestRiskCalculator) AuthenticationRequestRiskCalculator(org.apereo.cas.api.AuthenticationRequestRiskCalculator) HashSet(java.util.HashSet) 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 9 with ConditionalOnMissingBean

use of org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean in project cas by apereo.

the class ElectronicFenceConfiguration method blockAuthenticationContingencyPlan.

@ConditionalOnMissingBean(name = "blockAuthenticationContingencyPlan")
@Bean
@RefreshScope
public AuthenticationRiskContingencyPlan blockAuthenticationContingencyPlan() {
    final BlockAuthenticationContingencyPlan b = new BlockAuthenticationContingencyPlan();
    configureContingencyPlan(b);
    return b;
}
Also used : BlockAuthenticationContingencyPlan(org.apereo.cas.impl.plans.BlockAuthenticationContingencyPlan) 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 10 with ConditionalOnMissingBean

use of org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean in project zipkin by openzipkin.

the class ZipkinElasticsearchAwsStorageAutoConfiguration method credentials.

/** By default, get credentials from the {@link DefaultAWSCredentialsProviderChain} */
@Bean
@ConditionalOnMissingBean
AWSCredentials.Provider credentials() {
    return new AWSCredentials.Provider() {

        AWSCredentialsProvider delegate = new DefaultAWSCredentialsProviderChain();

        @Override
        public AWSCredentials get() {
            com.amazonaws.auth.AWSCredentials result = delegate.getCredentials();
            String sessionToken = result instanceof AWSSessionCredentials ? ((AWSSessionCredentials) result).getSessionToken() : null;
            return new AWSCredentials(result.getAWSAccessKeyId(), result.getAWSSecretKey(), sessionToken);
        }
    };
}
Also used : DefaultAWSCredentialsProviderChain(com.amazonaws.auth.DefaultAWSCredentialsProviderChain) AWSSessionCredentials(com.amazonaws.auth.AWSSessionCredentials) AWSCredentialsProvider(com.amazonaws.auth.AWSCredentialsProvider) AWSCredentialsProvider(com.amazonaws.auth.AWSCredentialsProvider) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean)

Aggregations

ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)807 Bean (org.springframework.context.annotation.Bean)807 ConditionalOnBean (org.springframework.boot.autoconfigure.condition.ConditionalOnBean)339 ConditionalOnClass (org.springframework.boot.autoconfigure.condition.ConditionalOnClass)298 RefreshScope (org.springframework.cloud.context.config.annotation.RefreshScope)251 Lazy (org.springframework.context.annotation.Lazy)227 lombok.val (lombok.val)210 HashMap (java.util.HashMap)190 Map (java.util.Map)113 CamelContextAware (org.apache.camel.CamelContextAware)69 RuntimeCamelException (org.apache.camel.RuntimeCamelException)45 DataFormatFactory (org.apache.camel.spi.DataFormatFactory)45 EnableConfigurationProperties (org.springframework.boot.context.properties.EnableConfigurationProperties)29 Scope (org.springframework.context.annotation.Scope)26 Autowired (org.springframework.beans.factory.annotation.Autowired)23 Configuration (org.springframework.context.annotation.Configuration)21 Qualifier (org.springframework.beans.factory.annotation.Qualifier)20 DefaultChainingMultifactorAuthenticationBypassProvider (org.apereo.cas.authentication.bypass.DefaultChainingMultifactorAuthenticationBypassProvider)19 CasConfigurationProperties (org.apereo.cas.configuration.CasConfigurationProperties)19 AuthenticationMultifactorAuthenticationProviderBypassEvaluator (org.apereo.cas.authentication.bypass.AuthenticationMultifactorAuthenticationProviderBypassEvaluator)17