没有合适的资源?快使用搜索试试~ 我知道了~
spring-security多登录页面配置
5星 · 超过95%的资源 需积分: 50 87 下载量 85 浏览量
2012-09-17
16:59:31
上传
评论 2
收藏 8KB TXT 举报
温馨提示
试读
6页
spring-security多登录页面配置,包括前台和后台分开登录界面,注销登录返回不同的界面等。
资源推荐
资源详情
资源评论
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/security"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:context="http://www.springframework.org/schema/context"
xmlns:jee="http://www.springframework.org/schema/jee" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:util="http://www.springframework.org/schema/util" xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:tool="http://www.springframework.org/schema/tool" xmlns:beans="http://www.springframework.org/schema/beans"
xsi:schemaLocation="
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
http://www.springframework.org/schema/tool http://www.springframework.org/schema/tool/spring-tool-3.0.xsd
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.1.xsd"
default-lazy-init="true">
<!-- 不需要进行认证的资源,3.0之后才改为这样配置 -->
<http security="none" pattern="/login.jsp" />
<http security="none" pattern="/admin/login.jsp" />
<http security="none" pattern="/image/**" />
<http security="none" pattern="/css/**" />
<http security="none" pattern="/js/**" />
<!-- 因为要使用自己的权限验证规则,所以这里要配置access-decision-manager-ref
实际上,我只是在accessDecisionManager中增加了一个投票器,其它的属性都比较简单,不多说了 -->
<!-- 另外,为了实现前后台访问使用不同的登录地址,这里增加了一个entry-point-ref-->
<http entry-point-ref="loginUrlEntryPoint" access-decision-manager-ref="accessDecisionManager" access-denied-page="/notaccess.jsp">
<beans:beans xmlns="http://www.springframework.org/schema/security"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:context="http://www.springframework.org/schema/context"
xmlns:jee="http://www.springframework.org/schema/jee" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:util="http://www.springframework.org/schema/util" xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:tool="http://www.springframework.org/schema/tool" xmlns:beans="http://www.springframework.org/schema/beans"
xsi:schemaLocation="
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
http://www.springframework.org/schema/tool http://www.springframework.org/schema/tool/spring-tool-3.0.xsd
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.1.xsd"
default-lazy-init="true">
<!-- 不需要进行认证的资源,3.0之后才改为这样配置 -->
<http security="none" pattern="/login.jsp" />
<http security="none" pattern="/admin/login.jsp" />
<http security="none" pattern="/image/**" />
<http security="none" pattern="/css/**" />
<http security="none" pattern="/js/**" />
<!-- 因为要使用自己的权限验证规则,所以这里要配置access-decision-manager-ref
实际上,我只是在accessDecisionManager中增加了一个投票器,其它的属性都比较简单,不多说了 -->
<!-- 另外,为了实现前后台访问使用不同的登录地址,这里增加了一个entry-point-ref-->
<http entry-point-ref="loginUrlEntryPoint" access-decision-manager-ref="accessDecisionManager" access-denied-page="/notaccess.jsp">
<!-- 后台地址拦截 -->
<intercept-url pattern="/admin/**" access="ROLE_A" />
<!-- 前台地址拦截 -->
<intercept-url pattern="/**" access="ROLE_B" />
<session-management>
<concurrency-control max-sessions="1" />
</session-management>
<!-- 登录过滤器 -->
<custom-filter before="FORM_LOGIN_FILTER" ref="loginFilter"/>
<custom-filter position="FORM_LOGIN_FILTER" ref="adminLoginFilter"/>
<!-- 注销过滤器 -->
<custom-filter before="LOGOUT_FILTER" ref="logoutFilter"/>
<custom-filter position="LOGOUT_FILTER" ref="adminLogoutFilter"/>
</http>
<!-- 认证切入点,这里使用它的目的是保证当用户登录之前就访问前后台时,会跳转到不同的登录页面 -->
<beans:bean id="loginUrlEntryPoint" class="com.dgg.text.userDetals.loginUrlEntryPoint" />
<!-- 登录过滤器,验证前台用户 -->
<beans:bean id="loginFilter"
class="org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter">
<beans:property name="authenticationManager" ref="authenticationManager"/>
<beans:property name="authenticationFailureHandler" ref="failureHandler"/>
<beans:property name="authenticationSuccessHandler" ref="successHandler"/>
<beans:property name="filterProcessesUrl" value="/j_spring_security_check"/>
</beans:bean>
<intercept-url pattern="/admin/**" access="ROLE_A" />
<!-- 前台地址拦截 -->
<intercept-url pattern="/**" access="ROLE_B" />
<session-management>
<concurrency-control max-sessions="1" />
</session-management>
<!-- 登录过滤器 -->
<custom-filter before="FORM_LOGIN_FILTER" ref="loginFilter"/>
<custom-filter position="FORM_LOGIN_FILTER" ref="adminLoginFilter"/>
<!-- 注销过滤器 -->
<custom-filter before="LOGOUT_FILTER" ref="logoutFilter"/>
<custom-filter position="LOGOUT_FILTER" ref="adminLogoutFilter"/>
</http>
<!-- 认证切入点,这里使用它的目的是保证当用户登录之前就访问前后台时,会跳转到不同的登录页面 -->
<beans:bean id="loginUrlEntryPoint" class="com.dgg.text.userDetals.loginUrlEntryPoint" />
<!-- 登录过滤器,验证前台用户 -->
<beans:bean id="loginFilter"
class="org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter">
<beans:property name="authenticationManager" ref="authenticationManager"/>
<beans:property name="authenticationFailureHandler" ref="failureHandler"/>
<beans:property name="authenticationSuccessHandler" ref="successHandler"/>
<beans:property name="filterProcessesUrl" value="/j_spring_security_check"/>
</beans:bean>
剩余5页未读,继续阅读
hdc0225
- 粉丝: 3
- 资源: 5
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
前往页