Example usage for org.springframework.security.web.access.intercept FilterSecurityInterceptor FilterSecurityInterceptor

List of usage examples for org.springframework.security.web.access.intercept FilterSecurityInterceptor FilterSecurityInterceptor

Introduction

In this page you can find the example usage for org.springframework.security.web.access.intercept FilterSecurityInterceptor FilterSecurityInterceptor.

Prototype

FilterSecurityInterceptor

Source Link

Usage

From source file:org.lightadmin.core.config.context.LightAdminSecurityConfiguration.java

@Bean
@Autowired/*  w ww  .  ja va  2s.com*/
public Filter filterSecurityInterceptor(AuthenticationManager authenticationManager) throws Exception {
    FilterSecurityInterceptor filter = new FilterSecurityInterceptor();
    filter.setAuthenticationManager(authenticationManager);
    filter.setAccessDecisionManager(new AffirmativeBased(Arrays
            .<AccessDecisionVoter<? extends Object>>asList((AccessDecisionVoter<Object>) new RoleVoter())));
    filter.setSecurityMetadataSource(securityMetadataSource());
    filter.afterPropertiesSet();
    return filter;
}

From source file:nu.localhost.tapestry5.springsecurity.services.SecurityModule.java

@Marker(SpringSecurityServices.class)
public static HttpServletRequestFilter buildFilterSecurityInterceptor(
        @SpringSecurityServices final AccessDecisionManager accessDecisionManager,
        @SpringSecurityServices final AuthenticationManager manager,
        final Collection<RequestInvocationDefinition> contributions) throws Exception {

    FilterSecurityInterceptor interceptor = new FilterSecurityInterceptor();
    LinkedHashMap<RequestMatcher, Collection<ConfigAttribute>> requestMap = convertCollectionToLinkedHashMap(
            contributions);/*from   www  .  j  av a2  s  .  c  o m*/
    DefaultFilterInvocationSecurityMetadataSource source = new DefaultFilterInvocationSecurityMetadataSource(
            requestMap);
    interceptor.setAccessDecisionManager(accessDecisionManager);
    interceptor.setAlwaysReauthenticate(false);
    interceptor.setAuthenticationManager(manager);
    interceptor.setSecurityMetadataSource(source);
    interceptor.setValidateConfigAttributes(true);
    interceptor.afterPropertiesSet();
    return new HttpServletRequestFilterWrapper(interceptor);
}

From source file:ch.astina.hesperid.web.services.SecurityModule.java

/**
 * Checks if access to the HTTP resource is allowed (
 * {@link org.springframework.security.access.intercept.AbstractSecurityInterceptor#beforeInvocation(Object)}
 * ) and throws {@link org.springframework.security.access.AccessDeniedException} otherwise
 *//*from   ww w .java 2s  .  co  m*/
@Marker(SpringSecurityServices.class)
public static HttpServletRequestFilter buildFilterSecurityInterceptor(
        @SpringSecurityServices final AccessDecisionManager accessDecisionManager,
        @SpringSecurityServices final AuthenticationManager manager,
        final Collection<RequestInvocationDefinition> contributions) throws Exception {
    FilterSecurityInterceptor interceptor = new FilterSecurityInterceptor();
    LinkedHashMap<RequestKey, Collection<ConfigAttribute>> requestMap = convertCollectionToLinkedHashMap(
            contributions);
    DefaultFilterInvocationSecurityMetadataSource source = new DefaultFilterInvocationSecurityMetadataSource(
            new AntUrlPathMatcher(true), requestMap);
    interceptor.setAccessDecisionManager(accessDecisionManager);
    interceptor.setAlwaysReauthenticate(false);
    interceptor.setAuthenticationManager(manager);
    interceptor.setSecurityMetadataSource(source);
    interceptor.setValidateConfigAttributes(true);
    interceptor.afterPropertiesSet();
    return new HttpServletRequestFilterWrapper(interceptor);
}

From source file:org.springframework.security.config.http.DefaultFilterChainValidatorTests.java

@Before
public void setUp() throws Exception {
    AnonymousAuthenticationFilter aaf = new AnonymousAuthenticationFilter("anonymous");
    fsi = new FilterSecurityInterceptor();
    fsi.setAccessDecisionManager(accessDecisionManager);
    fsi.setSecurityMetadataSource(metadataSource);
    AuthenticationEntryPoint authenticationEntryPoint = new LoginUrlAuthenticationEntryPoint("/login");
    ExceptionTranslationFilter etf = new ExceptionTranslationFilter(authenticationEntryPoint);
    DefaultSecurityFilterChain securityChain = new DefaultSecurityFilterChain(AnyRequestMatcher.INSTANCE, aaf,
            etf, fsi);//from w w w .ja v  a2 s .c  o  m
    fcp = new FilterChainProxy(securityChain);
    validator = new DefaultFilterChainValidator();

    ReflectionTestUtils.setField(validator, "logger", logger);
}