2
我试图在我的web应用程序中实现弹簧安全。 问题是我的网络可以在两种环境下工作,b2b和b2c。主机弹出FilterSecurityInterceptor过滤网址
b2b环境需要通过用户名和密码以及b2c仅在几页中进行弹簧安全控制。
例如:
www.myb2b.com/home -> login required
www.myb2c.com/home -> no login required
www.myb2c.com/private/admin -> login required
最重要的滤波器是所述第一和第二,第三个它可以通过其它系统实现。
我该怎么做?
我想配置一个自定义FilterSecurityInterceptor来覆盖doFilter功能。但我有错误的问题。
我appContext-网络security.xml文件(不完全因为仍在开发中):
<beans:beans
xmlns="http://www.springframework.org/schema/security"
xmlns:beans="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security-3.1.xsd">
<http auto-config="false" use-expressions="true" entry-point-ref="loginUrlAuthenticationEntryPoint">
<custom-filter position="FILTER_SECURITY_INTERCEPTOR" ref="filterSecurityInterceptor" />
<intercept-url pattern="/**" access="ROLE_USER" />
</http>
<beans:bean id="loginUrlAuthenticationEntryPoint" class="org.springframework.security.web.authentication.LoginUrlAuthenticationEntryPoint">
<beans:property name="loginFormUrl" value="/login"/>
</beans:bean>
<beans:bean id="filterSecurityInterceptor" class="com.hotelbeds.tuiuk.web.spring.CustomSecurityInterceptor">
<beans:property name="observeOncePerRequest" value="true"/>
<beans:property name="authenticationManager" ref="authenticationManager" />
<beans:property name="accessDecisionManager" ref="accessDecisionManager" />
</beans:bean>
<beans:bean id="accessDecisionManager" class="org.springframework.security.access.vote.AffirmativeBased">
<beans:property name="decisionVoters">
<beans:list>
<beans:bean class="org.springframework.security.access.vote.RoleVoter" />
</beans:list>
</beans:property>
</beans:bean>
<authentication-manager alias="authenticationManager">
<authentication-provider>
<password-encoder hash="sha-256" />
<user-service>
<user name="admin"
password="8c6976e5b5410415bde908bd4dee15dfb167a9c873fc4bb8a81f6f2ab448a918"
authorities="ROLE_ADMIN" />
<user name="user"
password="04f8996da763b7a969b1028ee3007569eaf3a635486ddab211d512c85b9df8fb"
authorities="ROLE_USER" />
</user-service>
</authentication-provider>
</authentication-manager>
</beans:beans>