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);
}
};
}
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;
}
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;
}
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;
}
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);
}
Aggregations