Search in sources :

Example 1 with SecurityContextHolderAwareRequestFilter

use of org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter in project spring-security by spring-projects.

the class ServletApiConfigurerTests method checkSecurityContextAwareAndLogoutFilterHasSameSizeAndHasLogoutSuccessEventPublishingLogoutHandler.

@Test
public void checkSecurityContextAwareAndLogoutFilterHasSameSizeAndHasLogoutSuccessEventPublishingLogoutHandler() {
    this.spring.register(ServletApiWithLogoutConfig.class);
    SecurityContextHolderAwareRequestFilter scaFilter = getFilter(SecurityContextHolderAwareRequestFilter.class);
    LogoutFilter logoutFilter = getFilter(LogoutFilter.class);
    LogoutHandler lfLogoutHandler = getFieldValue(logoutFilter, "handler");
    assertThat(lfLogoutHandler).isInstanceOf(CompositeLogoutHandler.class);
    List<LogoutHandler> scaLogoutHandlers = getFieldValue(scaFilter, "logoutHandlers");
    List<LogoutHandler> lfLogoutHandlers = getFieldValue(lfLogoutHandler, "logoutHandlers");
    assertThat(scaLogoutHandlers).hasSameSizeAs(lfLogoutHandlers);
    assertThat(scaLogoutHandlers).hasAtLeastOneElementOfType(LogoutSuccessEventPublishingLogoutHandler.class);
    assertThat(lfLogoutHandlers).hasAtLeastOneElementOfType(LogoutSuccessEventPublishingLogoutHandler.class);
}
Also used : SecurityContextHolderAwareRequestFilter(org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter) LogoutFilter(org.springframework.security.web.authentication.logout.LogoutFilter) LogoutSuccessEventPublishingLogoutHandler(org.springframework.security.web.authentication.logout.LogoutSuccessEventPublishingLogoutHandler) LogoutHandler(org.springframework.security.web.authentication.logout.LogoutHandler) CompositeLogoutHandler(org.springframework.security.web.authentication.logout.CompositeLogoutHandler) Test(org.junit.jupiter.api.Test)

Example 2 with SecurityContextHolderAwareRequestFilter

use of org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter in project syncope by apache.

the class DefaultRolesPrefixPostProcessor method postProcessAfterInitialization.

@Override
public Object postProcessAfterInitialization(final Object bean, final String beanName) {
    if (bean instanceof DefaultMethodSecurityExpressionHandler) {
        ((DefaultMethodSecurityExpressionHandler) bean).setDefaultRolePrefix(null);
    }
    if (bean instanceof DefaultWebSecurityExpressionHandler) {
        ((DefaultWebSecurityExpressionHandler) bean).setDefaultRolePrefix(null);
    }
    if (bean instanceof SecurityContextHolderAwareRequestFilter) {
        SecurityContextHolderAwareRequestFilter filter = (SecurityContextHolderAwareRequestFilter) bean;
        filter.setRolePrefix(StringUtils.EMPTY);
        try {
            filter.afterPropertiesSet();
        } catch (ServletException e) {
            throw new FatalBeanException(e.getMessage(), e);
        }
    }
    return bean;
}
Also used : DefaultWebSecurityExpressionHandler(org.springframework.security.web.access.expression.DefaultWebSecurityExpressionHandler) ServletException(javax.servlet.ServletException) FatalBeanException(org.springframework.beans.FatalBeanException) SecurityContextHolderAwareRequestFilter(org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter) DefaultMethodSecurityExpressionHandler(org.springframework.security.access.expression.method.DefaultMethodSecurityExpressionHandler)

Example 3 with SecurityContextHolderAwareRequestFilter

use of org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter in project motech by motech.

the class SecurityRuleBuilder method addSecurityContextHolderAwareRequestFilter.

private void addSecurityContextHolderAwareRequestFilter(List<Filter> filters) throws ServletException {
    SecurityContextHolderAwareRequestFilter securityFilter = new SecurityContextHolderAwareRequestFilter();
    securityFilter.setTrustResolver(new AuthenticationTrustResolverImpl());
    securityFilter.afterPropertiesSet();
    filters.add(securityFilter);
}
Also used : AuthenticationTrustResolverImpl(org.springframework.security.authentication.AuthenticationTrustResolverImpl) SecurityContextHolderAwareRequestFilter(org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter)

Aggregations

SecurityContextHolderAwareRequestFilter (org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter)3 ServletException (javax.servlet.ServletException)1 Test (org.junit.jupiter.api.Test)1 FatalBeanException (org.springframework.beans.FatalBeanException)1 DefaultMethodSecurityExpressionHandler (org.springframework.security.access.expression.method.DefaultMethodSecurityExpressionHandler)1 AuthenticationTrustResolverImpl (org.springframework.security.authentication.AuthenticationTrustResolverImpl)1 DefaultWebSecurityExpressionHandler (org.springframework.security.web.access.expression.DefaultWebSecurityExpressionHandler)1 CompositeLogoutHandler (org.springframework.security.web.authentication.logout.CompositeLogoutHandler)1 LogoutFilter (org.springframework.security.web.authentication.logout.LogoutFilter)1 LogoutHandler (org.springframework.security.web.authentication.logout.LogoutHandler)1 LogoutSuccessEventPublishingLogoutHandler (org.springframework.security.web.authentication.logout.LogoutSuccessEventPublishingLogoutHandler)1