Search in sources :

Example 1 with AuditResourceResolver

use of org.apereo.inspektr.audit.spi.AuditResourceResolver 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 2 with AuditResourceResolver

use of org.apereo.inspektr.audit.spi.AuditResourceResolver 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)

Aggregations

AuditResourceResolver (org.apereo.inspektr.audit.spi.AuditResourceResolver)2 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)2 FilterRegistrationBean (org.springframework.boot.web.servlet.FilterRegistrationBean)2 Bean (org.springframework.context.annotation.Bean)2 Date (java.util.Date)1 HashMap (java.util.HashMap)1 ToStringBuilder (org.apache.commons.lang3.builder.ToStringBuilder)1 CredentialsAsFirstParameterResourceResolver (org.apereo.cas.audit.spi.CredentialsAsFirstParameterResourceResolver)1 ServiceResourceResolver (org.apereo.cas.audit.spi.ServiceResourceResolver)1 JoinPoint (org.aspectj.lang.JoinPoint)1 Event (org.springframework.webflow.execution.Event)1