如何绕过i18n文件夹中所有文件的Spring安全过滤器

时间:2014-04-19 21:29:06

标签: spring security

我在Web.xml中定义了springSecurityFilterChain

    <filter-name>springSecurityFilterChain</filter-name>
    <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter-mapping>
  <filter-name>springSecurityFilterChain</filter-name>
   <url-pattern>/*</url-pattern>       
</filter-mapping>

在安全文件(security-config-cas.xml)中。我定义旁路如下:

<bean id="springSecurityFilterChain" class="org.springframework.security.web.FilterChainProxy">
    <constructor-arg>
        <list>
            <security:filter-chain pattern="/i18n/**"
                filters="none" />
        </list>
    </constructor-arg>
</bean> 

我的应用程序正在Websphere上部署......似乎此配置无效,因为在运行应用程序时仍然存在以下异常输出。

[4/11/14 10:27:32:993 EDT] 00000e71过滤器E com.ibm.ws.webcontainer.filter.FilterInstanceWrapper doFilter SRVE8109W:过滤器弹出的未捕获异常springSecurityFilterChain:java.io.FileNotFoundException:/ i18n /messages_en-us.properties     在com.ibm.ws.webcontainer.extension.DefaultExtensionProcessor.handleRequest(DefaultExtensionProcessor.java:700)     在com.ibm.ws.webcontainer.filter.WebAppFilterChain.invokeTarget(WebAppFilterChain.java:136)     在com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:97)     在org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:186)     在org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:160)     在org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)     在org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:259)     在com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:195)     在com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:91)     在com.csc.fsg.pcdSecurity.filter.CASFilter.doFilter(CASFilter.java:663)     在com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:195)     在com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:91)     在org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)     在org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)     在com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:195)     在com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:91)     在com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:928)     在com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:1025)     在com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3761)     在com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:304)     在com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:975)     在com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1662)     在com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:195)     在com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:459)     在com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewRequest(HttpInboundLink.java:526)     在com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.processRequest(HttpInboundLink.java:312)     在com.ibm.ws.http.channel.inbound.impl.HttpICLReadCallback.complete(HttpICLReadCallback.java:87)     at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:165)     在com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)     at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)     在com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:138)     在com.ibm.io.async.ResultHandler.complete(ResultHandler.java:204)     在com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:775)     在com.ibm.io.async.ResultHandler $ 2.run(ResultHandler.java:905)     在com.ibm.ws.util.ThreadPool $ Worker.run(ThreadPool.java:1815)

我尝试了另一种方式

<bean id="filterChainProxy" class="org.springframework.security.web.FilterChainProxy">
    <security:filter-chain-map request-matcher="ant">
      <security:filter-chain pattern="/i18n/**" filters="none"/>
    </security:filter-chain-map>
</bean> <alias name="filterChainProxy" alias="springSecurityFilterChain"/>

但是当我添加别名时,我的项目无法正常工作..登录主页并加载这么长时间......如果我缺少任何配置?

请建议。

1 个答案:

答案 0 :(得分:0)

你probalby可以使用像

这样的东西
<http pattern="/your-folder/**" secure="none">
</http>

或者使用intercept-url(在spring-servlet.xml上)

<intercept-url pattern="/your-folder/**" access="IS_AUTHENTICATED_ANONYMOUSLY" /> 

根据您使用Spring的方式,可能需要将以下内容添加到dispatcher-servelt.xml

<mvc:resources mapping="/your-folder/**" location="/your-folder/" />