Search in sources :

Example 1 with FilterRegistrationBean

use of org.springframework.boot.web.servlet.FilterRegistrationBean in project cas by apereo.

the class CasLoggingConfiguration method threadContextMDCServletFilter.

@Bean
public FilterRegistrationBean threadContextMDCServletFilter() {
    final Map<String, String> initParams = new HashMap<>();
    final FilterRegistrationBean bean = new FilterRegistrationBean();
    bean.setFilter(new ThreadContextMDCServletFilter(ticketRegistrySupport, this.ticketGrantingTicketCookieGenerator));
    bean.setUrlPatterns(Collections.singleton("/*"));
    bean.setInitParameters(initParams);
    bean.setName("threadContextMDCServletFilter");
    bean.setOrder(0);
    return bean;
}
Also used : ThreadContextMDCServletFilter(org.apereo.cas.logging.web.ThreadContextMDCServletFilter) HashMap(java.util.HashMap) FilterRegistrationBean(org.springframework.boot.web.servlet.FilterRegistrationBean) FilterRegistrationBean(org.springframework.boot.web.servlet.FilterRegistrationBean) Bean(org.springframework.context.annotation.Bean)

Example 2 with FilterRegistrationBean

use of org.springframework.boot.web.servlet.FilterRegistrationBean in project spring-boot by spring-projects.

the class SampleJersey1Application method jersey.

@Bean
public FilterRegistrationBean<ServletContainer> jersey() {
    FilterRegistrationBean<ServletContainer> bean = new FilterRegistrationBean<>();
    bean.setFilter(new ServletContainer());
    bean.addInitParameter("com.sun.jersey.config.property.packages", "com.sun.jersey;sample.jersey1");
    return bean;
}
Also used : ServletContainer(com.sun.jersey.spi.container.servlet.ServletContainer) FilterRegistrationBean(org.springframework.boot.web.servlet.FilterRegistrationBean) FilterRegistrationBean(org.springframework.boot.web.servlet.FilterRegistrationBean) Bean(org.springframework.context.annotation.Bean)

Example 3 with FilterRegistrationBean

use of org.springframework.boot.web.servlet.FilterRegistrationBean in project cas by apereo.

the class CasFiltersConfiguration method requestParameterSecurityFilter.

@RefreshScope
@Bean
public FilterRegistrationBean requestParameterSecurityFilter() {
    final Map<String, String> initParams = new HashMap<>();
    initParams.put(RequestParameterPolicyEnforcementFilter.PARAMETERS_TO_CHECK, casProperties.getHttpWebRequest().getParamsToCheck());
    initParams.put(RequestParameterPolicyEnforcementFilter.CHARACTERS_TO_FORBID, "none");
    initParams.put(RequestParameterPolicyEnforcementFilter.ALLOW_MULTI_VALUED_PARAMETERS, BooleanUtils.toStringTrueFalse(casProperties.getHttpWebRequest().isAllowMultiValueParameters()));
    initParams.put(RequestParameterPolicyEnforcementFilter.ONLY_POST_PARAMETERS, casProperties.getHttpWebRequest().getOnlyPostParams());
    final FilterRegistrationBean bean = new FilterRegistrationBean();
    bean.setFilter(new RequestParameterPolicyEnforcementFilter());
    bean.setUrlPatterns(Collections.singleton("/*"));
    bean.setName("requestParameterSecurityFilter");
    bean.setInitParameters(initParams);
    bean.setAsyncSupported(true);
    return bean;
}
Also used : HashMap(java.util.HashMap) RequestParameterPolicyEnforcementFilter(org.apereo.cas.security.RequestParameterPolicyEnforcementFilter) FilterRegistrationBean(org.springframework.boot.web.servlet.FilterRegistrationBean) RefreshScope(org.springframework.cloud.context.config.annotation.RefreshScope) FilterRegistrationBean(org.springframework.boot.web.servlet.FilterRegistrationBean) Bean(org.springframework.context.annotation.Bean)

Example 4 with FilterRegistrationBean

use of org.springframework.boot.web.servlet.FilterRegistrationBean in project cas by apereo.

the class CasFiltersConfiguration method responseHeadersSecurityFilter.

@RefreshScope
@Bean
public FilterRegistrationBean responseHeadersSecurityFilter() {
    final HttpWebRequestProperties.Header header = casProperties.getHttpWebRequest().getHeader();
    final Map<String, String> initParams = new HashMap<>();
    initParams.put("enableCacheControl", BooleanUtils.toStringTrueFalse(header.isCache()));
    initParams.put("enableXContentTypeOptions", BooleanUtils.toStringTrueFalse(header.isXcontent()));
    initParams.put("enableStrictTransportSecurity", BooleanUtils.toStringTrueFalse(header.isHsts()));
    initParams.put("enableXFrameOptions", BooleanUtils.toStringTrueFalse(header.isXframe()));
    initParams.put("enableXSSProtection", BooleanUtils.toStringTrueFalse(header.isXss()));
    final FilterRegistrationBean bean = new FilterRegistrationBean();
    bean.setFilter(new ResponseHeadersEnforcementFilter());
    bean.setUrlPatterns(Collections.singleton("/*"));
    bean.setInitParameters(initParams);
    bean.setName("responseHeadersSecurityFilter");
    bean.setAsyncSupported(true);
    return bean;
}
Also used : HashMap(java.util.HashMap) HttpWebRequestProperties(org.apereo.cas.configuration.model.core.web.security.HttpWebRequestProperties) ResponseHeadersEnforcementFilter(org.apereo.cas.security.ResponseHeadersEnforcementFilter) FilterRegistrationBean(org.springframework.boot.web.servlet.FilterRegistrationBean) RefreshScope(org.springframework.cloud.context.config.annotation.RefreshScope) FilterRegistrationBean(org.springframework.boot.web.servlet.FilterRegistrationBean) Bean(org.springframework.context.annotation.Bean)

Example 5 with FilterRegistrationBean

use of org.springframework.boot.web.servlet.FilterRegistrationBean in project cas by apereo.

the class CasFiltersConfiguration method characterEncodingFilter.

@RefreshScope
@Bean
public FilterRegistrationBean characterEncodingFilter() {
    final FilterRegistrationBean bean = new FilterRegistrationBean();
    bean.setFilter(new CharacterEncodingFilter(casProperties.getHttpWebRequest().getWeb().getEncoding(), casProperties.getHttpWebRequest().getWeb().isForceEncoding()));
    bean.setUrlPatterns(Collections.singleton("/*"));
    bean.setName("characterEncodingFilter");
    bean.setAsyncSupported(true);
    return bean;
}
Also used : CharacterEncodingFilter(org.springframework.web.filter.CharacterEncodingFilter) FilterRegistrationBean(org.springframework.boot.web.servlet.FilterRegistrationBean) RefreshScope(org.springframework.cloud.context.config.annotation.RefreshScope) FilterRegistrationBean(org.springframework.boot.web.servlet.FilterRegistrationBean) Bean(org.springframework.context.annotation.Bean)

Aggregations

FilterRegistrationBean (org.springframework.boot.web.servlet.FilterRegistrationBean)23 Bean (org.springframework.context.annotation.Bean)21 ServletRegistrationBean (org.springframework.boot.web.servlet.ServletRegistrationBean)10 HashMap (java.util.HashMap)4 RefreshScope (org.springframework.cloud.context.config.annotation.RefreshScope)4 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)3 Filter (javax.servlet.Filter)2 HttpWebRequestProperties (org.apereo.cas.configuration.model.core.web.security.HttpWebRequestProperties)2 ClientInfoThreadLocalFilter (org.apereo.inspektr.common.web.ClientInfoThreadLocalFilter)2 Test (org.junit.Test)2 ConditionalOnBean (org.springframework.boot.autoconfigure.condition.ConditionalOnBean)2 ConditionalOnProperty (org.springframework.boot.autoconfigure.condition.ConditionalOnProperty)2 RegistrationBean (org.springframework.boot.web.servlet.RegistrationBean)2 WebStatFilter (com.alibaba.druid.support.http.WebStatFilter)1 CsrfFilter (com.erudika.scoold.utils.CsrfFilter)1 ServletContainer (com.sun.jersey.spi.container.servlet.ServletContainer)1 DispatcherType (javax.servlet.DispatcherType)1 ServletContext (javax.servlet.ServletContext)1 AuditProperties (org.apereo.cas.configuration.model.core.audit.AuditProperties)1 ThreadContextMDCServletFilter (org.apereo.cas.logging.web.ThreadContextMDCServletFilter)1