Announcement Announcement Module
No announcement yet.
Spring Security and custom filter chain Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring Security and custom filter chain

    Dear Spring Security community,

    I'm currently working on a solution, that:
    - tries to retrieve roles for an already authenticated user (via a reverse authentication proxy) from a SAP Netweaver portal web service. Here, a custom Spring enabled filter should be used.
    - limits accepted requests based on an IPv4/IPv6 address (range) to prevent by-passing the reverse authentication proxy. Here, I thought I could take the already existing " tcher" class

    Currently, Spring offers the opportunity to integrate custom servlet filters into the Spring IOC container via:

    <!-- delegating to a spring-managed bean that implements a "javax.servlet.Filter". Important: the name of the filter has to match the name of the bean that implements the filter. Note that you need only a single declaration in "web.xml" but you can have several filtering beans chained together in your application context. -->
            <description>Tells the filter to use the servlet container to execute the standard init() and destroy() methods</description>
    <!-- The definition of the Root Spring Container shared by all Servlets and
           Filters. This is needed by the ContextLoaderListener. -->
    Spring IOC.xml
    <bean id="filterChainProxy" class="">
        <!-- new notation syntax since Spring 3.1 -->
    	<!-- most specific URIs appear first as filter chain is read from top to down. Otherwise, more generic filters would overlay specific ones. By default, they use the ANT path request matcher. -->
                <security:filter-chain pattern="/wcms/**" filters="permissionFilter"/>
                <security:filter-chain pattern="/**" filters="WAMUserFilter,PortalRoleProviderFilter"/>
                <security:filter-chain pattern="/**" filters="*" request-matcher-ref="ipMatcher"/>
                <!-- to omit a request pattern from the security filter chain
                <security:filter-chain pattern="" filters="none" -->
    <!-- Standard Spring bean that checks IPv4/IPv6 addresses of requests. Alternative solution: using "http" Spring tag in combination with Spring EL expression "hasIpAddress()" -->
    <bean id="ipMatcher" class="">
        <constructor-arg value=""/>

    I already know: there is an "<http>"-Spring tag available within the Spring security namespace that offers additional Spring EL methods like "hasIpAddress()" within the "intercept-url" tag but I do not know how to integrate my custom filters then. On top, the <http> block always creates a standard set of Spring filters, see: that I might not necessarily need.

    Starting with Spring 3.1, Spring security offers "request-matcher-ref" attributes for "filter-chain" elements. Details see:

    What is your opinion? How to solve that ideally?
    Last edited by hking; Apr 5th, 2013, 04:26 AM.