Search in sources :

Example 11 with FilterSecurityInterceptor

use of org.springframework.security.web.access.intercept.FilterSecurityInterceptor in project spring-security by spring-projects.

the class Issue55Tests method multiHttpWebSecurityConfigurerAdapterDefaultsToAutowired.

@Test
public void multiHttpWebSecurityConfigurerAdapterDefaultsToAutowired() throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
    TestingAuthenticationToken token = new TestingAuthenticationToken("test", "this");
    this.spring.register(MultiWebSecurityConfigurerAdapterDefaultsAuthManagerConfig.class);
    this.spring.getContext().getBean(FilterChainProxy.class);
    FilterSecurityInterceptor filter = (FilterSecurityInterceptor) findFilter(FilterSecurityInterceptor.class, 0);
    assertThat(filter.getAuthenticationManager().authenticate(token)).isEqualTo(CustomAuthenticationManager.RESULT);
    FilterSecurityInterceptor secondFilter = (FilterSecurityInterceptor) findFilter(FilterSecurityInterceptor.class, 1);
    assertThat(secondFilter.getAuthenticationManager().authenticate(token)).isEqualTo(CustomAuthenticationManager.RESULT);
}
Also used : FilterSecurityInterceptor(org.springframework.security.web.access.intercept.FilterSecurityInterceptor) TestingAuthenticationToken(org.springframework.security.authentication.TestingAuthenticationToken) Test(org.junit.jupiter.api.Test)

Example 12 with FilterSecurityInterceptor

use of org.springframework.security.web.access.intercept.FilterSecurityInterceptor in project spring-security by spring-projects.

the class Issue55Tests method webSecurityConfigurerAdapterDefaultToAutowired.

@Test
public void webSecurityConfigurerAdapterDefaultToAutowired() {
    TestingAuthenticationToken token = new TestingAuthenticationToken("test", "this");
    this.spring.register(WebSecurityConfigurerAdapterDefaultsAuthManagerConfig.class);
    this.spring.getContext().getBean(FilterChainProxy.class);
    FilterSecurityInterceptor filter = (FilterSecurityInterceptor) findFilter(FilterSecurityInterceptor.class, 0);
    assertThat(filter.getAuthenticationManager().authenticate(token)).isEqualTo(CustomAuthenticationManager.RESULT);
}
Also used : FilterSecurityInterceptor(org.springframework.security.web.access.intercept.FilterSecurityInterceptor) TestingAuthenticationToken(org.springframework.security.authentication.TestingAuthenticationToken) Test(org.junit.jupiter.api.Test)

Example 13 with FilterSecurityInterceptor

use of org.springframework.security.web.access.intercept.FilterSecurityInterceptor in project spring-security by spring-projects.

the class MiscHttpConfigTests method configureWhenOncePerRequestIsFalseThenFilterSecurityInterceptorExercisedForForwards.

@Test
public void configureWhenOncePerRequestIsFalseThenFilterSecurityInterceptorExercisedForForwards() {
    this.spring.configLocations(xml("OncePerRequest")).autowire();
    FilterSecurityInterceptor filterSecurityInterceptor = getFilter(FilterSecurityInterceptor.class);
    assertThat(filterSecurityInterceptor.isObserveOncePerRequest()).isFalse();
}
Also used : FilterSecurityInterceptor(org.springframework.security.web.access.intercept.FilterSecurityInterceptor) Test(org.junit.jupiter.api.Test)

Aggregations

FilterSecurityInterceptor (org.springframework.security.web.access.intercept.FilterSecurityInterceptor)13 Test (org.junit.jupiter.api.Test)4 FilterInvocationSecurityMetadataSource (org.springframework.security.web.access.intercept.FilterInvocationSecurityMetadataSource)4 Filter (jakarta.servlet.Filter)3 ArrayList (java.util.ArrayList)2 BeforeEach (org.junit.jupiter.api.BeforeEach)2 AccessDecisionManager (org.springframework.security.access.AccessDecisionManager)2 ConfigAttribute (org.springframework.security.access.ConfigAttribute)2 AuthenticationManager (org.springframework.security.authentication.AuthenticationManager)2 TestingAuthenticationToken (org.springframework.security.authentication.TestingAuthenticationToken)2 ExceptionTranslationFilter (org.springframework.security.web.access.ExceptionTranslationFilter)2 AnonymousAuthenticationFilter (org.springframework.security.web.authentication.AnonymousAuthenticationFilter)2 LoginUrlAuthenticationEntryPoint (org.springframework.security.web.authentication.LoginUrlAuthenticationEntryPoint)2 HttpServletRequest (jakarta.servlet.http.HttpServletRequest)1 Collection (java.util.Collection)1 LinkedHashMap (java.util.LinkedHashMap)1 MotechAccessVoter (org.motechproject.security.authentication.MotechAccessVoter)1 ApplicationEventPublisher (org.springframework.context.ApplicationEventPublisher)1 Bean (org.springframework.context.annotation.Bean)1 AccessDecisionVoter (org.springframework.security.access.AccessDecisionVoter)1