Search in sources :

Example 1 with DefaultFilterInvocationSecurityMetadataSource

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

the class ChannelSecurityConfigurer method configure.

@Override
public void configure(H http) throws Exception {
    ChannelDecisionManagerImpl channelDecisionManager = new ChannelDecisionManagerImpl();
    channelDecisionManager.setChannelProcessors(getChannelProcessors(http));
    channelDecisionManager = postProcess(channelDecisionManager);
    channelFilter.setChannelDecisionManager(channelDecisionManager);
    DefaultFilterInvocationSecurityMetadataSource filterInvocationSecurityMetadataSource = new DefaultFilterInvocationSecurityMetadataSource(requestMap);
    channelFilter.setSecurityMetadataSource(filterInvocationSecurityMetadataSource);
    channelFilter = postProcess(channelFilter);
    http.addFilter(channelFilter);
}
Also used : ChannelDecisionManagerImpl(org.springframework.security.web.access.channel.ChannelDecisionManagerImpl) DefaultFilterInvocationSecurityMetadataSource(org.springframework.security.web.access.intercept.DefaultFilterInvocationSecurityMetadataSource)

Example 2 with DefaultFilterInvocationSecurityMetadataSource

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

the class FilterSecurityMetadataSourceBeanDefinitionParserTests method interceptUrlsSupportPropertyPlaceholders.

// SEC-1201
@Test
public void interceptUrlsSupportPropertyPlaceholders() {
    System.setProperty("secure.url", "/secure");
    System.setProperty("secure.role", "ROLE_A");
    setContext("<b:bean class='org.springframework.beans.factory.config.PropertyPlaceholderConfigurer'/>" + "<filter-security-metadata-source id='fids' use-expressions='false'>" + "   <intercept-url pattern='${secure.url}' access='${secure.role}'/>" + "</filter-security-metadata-source>");
    DefaultFilterInvocationSecurityMetadataSource fids = (DefaultFilterInvocationSecurityMetadataSource) this.appContext.getBean("fids");
    Collection<ConfigAttribute> cad = fids.getAttributes(createFilterInvocation("/secure", "GET"));
    assertThat(cad).isNotNull();
    assertThat(cad).hasSize(1);
    assertThat(cad.contains(new SecurityConfig("ROLE_A"))).isTrue();
}
Also used : ConfigAttribute(org.springframework.security.access.ConfigAttribute) SecurityConfig(org.springframework.security.access.SecurityConfig) DefaultFilterInvocationSecurityMetadataSource(org.springframework.security.web.access.intercept.DefaultFilterInvocationSecurityMetadataSource) Test(org.junit.Test)

Example 3 with DefaultFilterInvocationSecurityMetadataSource

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

the class FilterSecurityMetadataSourceBeanDefinitionParserTests method parsingMinimalConfigurationIsSuccessful.

@Test
public void parsingMinimalConfigurationIsSuccessful() {
    setContext("<filter-security-metadata-source id='fids' use-expressions='false'>" + "   <intercept-url pattern='/**' access='ROLE_A'/>" + "</filter-security-metadata-source>");
    DefaultFilterInvocationSecurityMetadataSource fids = (DefaultFilterInvocationSecurityMetadataSource) this.appContext.getBean("fids");
    Collection<ConfigAttribute> cad = fids.getAttributes(createFilterInvocation("/anything", "GET"));
    assertThat(cad).isNotNull();
    assertThat(cad.contains(new SecurityConfig("ROLE_A"))).isTrue();
}
Also used : ConfigAttribute(org.springframework.security.access.ConfigAttribute) SecurityConfig(org.springframework.security.access.SecurityConfig) DefaultFilterInvocationSecurityMetadataSource(org.springframework.security.web.access.intercept.DefaultFilterInvocationSecurityMetadataSource) Test(org.junit.Test)

Aggregations

DefaultFilterInvocationSecurityMetadataSource (org.springframework.security.web.access.intercept.DefaultFilterInvocationSecurityMetadataSource)3 Test (org.junit.Test)2 ConfigAttribute (org.springframework.security.access.ConfigAttribute)2 SecurityConfig (org.springframework.security.access.SecurityConfig)2 ChannelDecisionManagerImpl (org.springframework.security.web.access.channel.ChannelDecisionManagerImpl)1