Search in sources :

Example 1 with ClientInfoThreadLocalFilter

use of org.apereo.inspektr.common.web.ClientInfoThreadLocalFilter in project cas by apereo.

the class CasManagementAuditConfiguration method casClientInfoLoggingFilter.

@Bean
public FilterRegistrationBean casClientInfoLoggingFilter() {
    final FilterRegistrationBean bean = new FilterRegistrationBean();
    bean.setFilter(new ClientInfoThreadLocalFilter());
    bean.setUrlPatterns(Collections.singleton("/*"));
    bean.setName("CAS Client Info Logging Filter");
    bean.setAsyncSupported(true);
    return bean;
}
Also used : ClientInfoThreadLocalFilter(org.apereo.inspektr.common.web.ClientInfoThreadLocalFilter) FilterRegistrationBean(org.springframework.boot.web.servlet.FilterRegistrationBean) FilterRegistrationBean(org.springframework.boot.web.servlet.FilterRegistrationBean) Bean(org.springframework.context.annotation.Bean)

Example 2 with ClientInfoThreadLocalFilter

use of org.apereo.inspektr.common.web.ClientInfoThreadLocalFilter in project cas by apereo.

the class CasCoreAuditConfiguration method casClientInfoLoggingFilter.

@Bean
public FilterRegistrationBean casClientInfoLoggingFilter() {
    final AuditProperties audit = casProperties.getAudit();
    final FilterRegistrationBean bean = new FilterRegistrationBean();
    bean.setFilter(new ClientInfoThreadLocalFilter());
    bean.setUrlPatterns(Collections.singleton("/*"));
    bean.setName("CAS Client Info Logging Filter");
    bean.setAsyncSupported(true);
    final Map<String, String> initParams = new HashMap<>();
    if (StringUtils.isNotBlank(audit.getAlternateClientAddrHeaderName())) {
        initParams.put(ClientInfoThreadLocalFilter.CONST_IP_ADDRESS_HEADER, audit.getAlternateClientAddrHeaderName());
    }
    if (StringUtils.isNotBlank(audit.getAlternateServerAddrHeaderName())) {
        initParams.put(ClientInfoThreadLocalFilter.CONST_SERVER_IP_ADDRESS_HEADER, audit.getAlternateServerAddrHeaderName());
    }
    initParams.put(ClientInfoThreadLocalFilter.CONST_USE_SERVER_HOST_ADDRESS, String.valueOf(audit.isUseServerHostAddress()));
    bean.setInitParameters(initParams);
    return bean;
}
Also used : AuditProperties(org.apereo.cas.configuration.model.core.audit.AuditProperties) HashMap(java.util.HashMap) ClientInfoThreadLocalFilter(org.apereo.inspektr.common.web.ClientInfoThreadLocalFilter) FilterRegistrationBean(org.springframework.boot.web.servlet.FilterRegistrationBean) FilterRegistrationBean(org.springframework.boot.web.servlet.FilterRegistrationBean) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean)

Aggregations

ClientInfoThreadLocalFilter (org.apereo.inspektr.common.web.ClientInfoThreadLocalFilter)2 FilterRegistrationBean (org.springframework.boot.web.servlet.FilterRegistrationBean)2 Bean (org.springframework.context.annotation.Bean)2 HashMap (java.util.HashMap)1 AuditProperties (org.apereo.cas.configuration.model.core.audit.AuditProperties)1 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)1