You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

66 lines
3.5 KiB
XML

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="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.xsd">
<bean id="shiroFilter" class="org.apache.shiro.spring.web.ShiroFilterFactoryBean">
<property name="securityManager" ref="securityManager"/>
<property name="loginUrl" value="/index"/><!--登录页面,-->
<property name="successUrl" value="/index.jsp"/><!--登录成功页面,如果自己设置了返回页面,则不跳转-->
<property name="unauthorizedUrl" value="/error"/><!-- 没有权限跳转的地址 -->
<property name="filterChainDefinitions">
<value>
/toLogin=anon <!--表示都可以访问-->
/static/**=anon <!--表示都可以访问-->
/error=authc
/test=anon
/login=anon
/home=perms[home] <!--perms表示需要该权限才能访问的页面-->
/admin=roles["admin"] <!-- roles["admin,user"] 只有拥有admin角色的用户才可访问同时需要拥有多个角色的话用引号引起来中间用逗号隔开-->
<!--/admin=anon-->
/**=authc <!--authc表示需要认证才能访问的页面-->
</value>
</property>
</bean>
<!-- 自定义Realm -->
<bean id="securityManager" class="org.apache.shiro.web.mgt.DefaultWebSecurityManager">
<property name="realm" ref="MyRealm"/>
</bean>
<!-- 注入到自定义Realm -->
<bean id="MyRealm" class="com.emr.shiro.MyRealm">
<!-- 定义凭证匹配器 -->
<!-- <property name="credentialsMatcher" ref="credentialsMatcher"></property>-->
</bean>
<!--第一步:直接配置一个 securityManager -->
<!--<bean id="securityManager" class="org.apache.shiro.web.mgt.DefaultWebSecurityManager">-->
<!--&lt;!&ndash;刚配置时先把这条注释掉等后面写了MyRealm.java时再把它的注释去掉因为如果没有去掉就会在-->
<!--tomcat开启时报一个错误 &ndash;&gt;-->
<!--&lt;!&ndash;<property name="realm" ref="myRealm" /> &ndash;&gt;-->
<!--</bean>-->
<!--<bean id="lifecycleBeanPostProcessor" class="org.apache.shiro.spring.LifecycleBeanPostProcessor"/>-->
<!--&lt;!&ndash; 第三步:把请求路径拦截之后的处理 &ndash;&gt;-->
<!--<bean id="shiroFilter" class="org.apache.shiro.spring.web.ShiroFilterFactoryBean">-->
<!--&lt;!&ndash;shiro整个的处理都由securityManger指定和决定 &ndash;&gt;-->
<!--<property name="securityManager" ref="securityManager"/>-->
<!--&lt;!&ndash; loginUrl==>如果登录成功,跳转到哪个页面,或者执行哪个请求 &ndash;&gt;-->
<!--<property name="loginUrl" value="/login.jsp"/>-->
<!--&lt;!&ndash; 验证通过执行的请求或者跳转 &ndash;&gt;-->
<!--<property name="successUrl" value="/home.jsp"/>-->
<!--&lt;!&ndash; 验证不通过执行的请求或者跳转 &ndash;&gt;-->
<!--<property name="unauthorizedUrl" value="/unauthorized.jsp"/>-->
<!--&lt;!&ndash; 具体的拦截路径和拦截的方式和角色和权限的范围 &ndash;&gt;-->
<!--<property name="filterChainDefinitions">-->
<!--<value>-->
<!--</value>-->
<!--</property>-->
<!--</bean>-->
</beans>