Search in sources :

Example 6 with Bean

use of org.springframework.context.annotation.Bean in project cas by apereo.

the class CasCoreAuditConfiguration method nullableReturnValueResourceResolver.

@Bean
public AuditResourceResolver nullableReturnValueResourceResolver() {
    return new AuditResourceResolver() {

        @Override
        public String[] resolveFrom(final JoinPoint joinPoint, final Object o) {
            if (o == null) {
                return new String[0];
            }
            if (o instanceof Event) {
                final Event event = Event.class.cast(o);
                final String sourceName = event.getSource().getClass().getSimpleName();
                final String result = new ToStringBuilder(event, ToStringStyle.NO_CLASS_NAME_STYLE).append("event", event.getId()).append("timestamp", new Date(event.getTimestamp())).append("source", sourceName).toString();
                return new String[] { result };
            }
            return returnValueResourceResolver().resolveFrom(joinPoint, o);
        }

        @Override
        public String[] resolveFrom(final JoinPoint joinPoint, final Exception e) {
            return returnValueResourceResolver().resolveFrom(joinPoint, e);
        }
    };
}
Also used : ToStringBuilder(org.apache.commons.lang3.builder.ToStringBuilder) AuditResourceResolver(org.apereo.inspektr.audit.spi.AuditResourceResolver) Event(org.springframework.webflow.execution.Event) Date(java.util.Date) JoinPoint(org.aspectj.lang.JoinPoint) FilterRegistrationBean(org.springframework.boot.web.servlet.FilterRegistrationBean) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean)

Example 7 with Bean

use of org.springframework.context.annotation.Bean in project cas by apereo.

the class CasCoreAuditConfiguration method auditResourceResolverMap.

@Bean
public Map<String, AuditResourceResolver> auditResourceResolverMap() {
    final Map<String, AuditResourceResolver> map = new HashMap<>();
    map.put("AUTHENTICATION_RESOURCE_RESOLVER", new CredentialsAsFirstParameterResourceResolver());
    map.put("CREATE_TICKET_GRANTING_TICKET_RESOURCE_RESOLVER", this.messageBundleAwareResourceResolver());
    map.put("CREATE_PROXY_GRANTING_TICKET_RESOURCE_RESOLVER", this.messageBundleAwareResourceResolver());
    map.put("DESTROY_TICKET_GRANTING_TICKET_RESOURCE_RESOLVER", this.ticketResourceResolver());
    map.put("DESTROY_PROXY_GRANTING_TICKET_RESOURCE_RESOLVER", this.ticketResourceResolver());
    map.put("GRANT_SERVICE_TICKET_RESOURCE_RESOLVER", new ServiceResourceResolver());
    map.put("GRANT_PROXY_TICKET_RESOURCE_RESOLVER", new ServiceResourceResolver());
    map.put("VALIDATE_SERVICE_TICKET_RESOURCE_RESOLVER", this.ticketResourceResolver());
    map.put("SAVE_SERVICE_RESOURCE_RESOLVER", returnValueResourceResolver());
    map.put("CHANGE_PASSWORD_RESOURCE_RESOLVER", returnValueResourceResolver());
    map.put("TRUSTED_AUTHENTICATION_RESOURCE_RESOLVER", returnValueResourceResolver());
    map.put("ADAPTIVE_RISKY_AUTHENTICATION_RESOURCE_RESOLVER", returnValueResourceResolver());
    map.put("AUTHENTICATION_EVENT_RESOURCE_RESOLVER", nullableReturnValueResourceResolver());
    return map;
}
Also used : ServiceResourceResolver(org.apereo.cas.audit.spi.ServiceResourceResolver) HashMap(java.util.HashMap) AuditResourceResolver(org.apereo.inspektr.audit.spi.AuditResourceResolver) CredentialsAsFirstParameterResourceResolver(org.apereo.cas.audit.spi.CredentialsAsFirstParameterResourceResolver) FilterRegistrationBean(org.springframework.boot.web.servlet.FilterRegistrationBean) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean)

Example 8 with Bean

use of org.springframework.context.annotation.Bean in project cas by apereo.

the class CasCoreAuthenticationConfiguration method authenticationEventExecutionPlan.

@ConditionalOnMissingBean(name = "authenticationEventExecutionPlan")
@Autowired
@Bean
public AuthenticationEventExecutionPlan authenticationEventExecutionPlan(final List<AuthenticationEventExecutionPlanConfigurer> configurers) {
    final DefaultAuthenticationEventExecutionPlan plan = new DefaultAuthenticationEventExecutionPlan();
    configurers.forEach(c -> {
        final String name = StringUtils.removePattern(c.getClass().getSimpleName(), "\\$.+");
        LOGGER.debug("Configuring authentication execution plan [{}]", name);
        c.configureAuthenticationExecutionPlan(plan);
    });
    return plan;
}
Also used : DefaultAuthenticationEventExecutionPlan(org.apereo.cas.authentication.DefaultAuthenticationEventExecutionPlan) 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 9 with Bean

use of org.springframework.context.annotation.Bean in project cas by apereo.

the class CasCoreAuthenticationSupportConfiguration method authenticationExceptionHandler.

@Bean
public AuthenticationExceptionHandler authenticationExceptionHandler() {
    final AuthenticationExceptionHandler h = new AuthenticationExceptionHandler();
    h.setErrors(casProperties.getAuthn().getExceptions().getExceptions());
    return h;
}
Also used : AuthenticationExceptionHandler(org.apereo.cas.web.flow.AuthenticationExceptionHandler) Bean(org.springframework.context.annotation.Bean)

Example 10 with Bean

use of org.springframework.context.annotation.Bean in project cas by apereo.

the class CasCoreMonitorConfiguration method healthCheckMonitor.

@ConditionalOnMissingBean(name = "healthCheckMonitor")
@Bean
public Monitor healthCheckMonitor() {
    final Map<String, Monitor> beans = applicationContext.getBeansOfType(Monitor.class, false, true);
    final Set<Monitor> monitors = beans.entrySet().stream().map(Map.Entry::getValue).collect(Collectors.toSet());
    final int freeMemThreshold = casProperties.getMonitor().getFreeMemThreshold();
    if (freeMemThreshold > 0) {
        monitors.add(new MemoryMonitor(freeMemThreshold));
    }
    final MonitorProperties.Warn warn = casProperties.getMonitor().getSt().getWarn();
    if (warn.getThreshold() > 0) {
        final SessionMonitor bean = new SessionMonitor(ticketRegistry, warn.getThreshold(), warn.getThreshold());
        monitors.add(bean);
    }
    return new HealthCheckMonitor(monitors);
}
Also used : MemoryMonitor(org.apereo.cas.monitor.MemoryMonitor) HealthCheckMonitor(org.apereo.cas.monitor.HealthCheckMonitor) SessionMonitor(org.apereo.cas.monitor.SessionMonitor) Monitor(org.apereo.cas.monitor.Monitor) MemoryMonitor(org.apereo.cas.monitor.MemoryMonitor) HealthCheckMonitor(org.apereo.cas.monitor.HealthCheckMonitor) Map(java.util.Map) SessionMonitor(org.apereo.cas.monitor.SessionMonitor) MonitorProperties(org.apereo.cas.configuration.model.core.monitor.MonitorProperties) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean)

Aggregations

Bean (org.springframework.context.annotation.Bean)3865 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)1065 RefreshScope (org.springframework.cloud.context.config.annotation.RefreshScope)444 ConditionalOnBean (org.springframework.boot.autoconfigure.condition.ConditionalOnBean)389 ConditionalOnClass (org.springframework.boot.autoconfigure.condition.ConditionalOnClass)309 lombok.val (lombok.val)294 HashMap (java.util.HashMap)285 Lazy (org.springframework.context.annotation.Lazy)257 LocalContainerEntityManagerFactoryBean (org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean)190 FilterRegistrationBean (org.springframework.boot.web.servlet.FilterRegistrationBean)151 Map (java.util.Map)150 ServletRegistrationBean (org.springframework.boot.web.servlet.ServletRegistrationBean)110 Properties (java.util.Properties)94 Autowired (org.springframework.beans.factory.annotation.Autowired)92 ArrayList (java.util.ArrayList)79 Primary (org.springframework.context.annotation.Primary)75 Qualifier (org.springframework.beans.factory.annotation.Qualifier)71 CamelContextAware (org.apache.camel.CamelContextAware)69 ThreadPoolTaskExecutor (org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor)68 JpaTransactionManager (org.springframework.orm.jpa.JpaTransactionManager)59