标签:action cat ali cycle real 顺序 iso end omr
<!-- shiro过虑器,DelegatingFilterProxy通过代理模式将spring容器中的bean和filter关联起来 --> <filter> <filter-name>shiroFilter</filter-name> <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class> <!-- 设置true由servlet容器控制filter的生命周期 --> <init-param> <param-name>targetFilterLifecycle</param-name> <param-value>true</param-value> </init-param> <!-- 设置spring容器filter的bean id,如果不设置则找与filter-name一致的bean--> <init-param> <param-name>targetBeanName</param-name> <param-value>shiroFilter</param-value> </init-param> </filter> <filter-mapping> <filter-name>shiroFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping>
<!-- Shiro 的Web过滤器 --> <bean id="shiroFilter" class="org.apache.shiro.spring.web.ShiroFilterFactoryBean"> <property name="securityManager" ref="securityManager" /> <!-- loginUrl认证提交地址,如果没有认证将会请求此地址进行认证,请求此地址将由formAuthenticationFilter进行表单认证 --> <property name="loginUrl" value="/login.action" /> <property name="unauthorizedUrl" value="/refuse.jsp" /> <!-- 过虑器链定义,从上向下顺序执行,一般将/**放在最下边 --> <property name="filterChainDefinitions"> <value> <!-- 退出拦截,请求logout.action执行退出操作 --> /logout.action = logout <!-- 无权访问页面 --> /refuse.jsp = anon <!-- roles[XX]表示有XX角色才可访问 --> /item/list.action = roles[item],authc /js/** anon /images/** anon /styles/** anon /validatecode.jsp anon /item/* authc <!-- user表示身份认证通过或通过记住我认证通过的可以访问 --> /** = authc </value> </property> </bean> <!-- 安全管理器 --> <bean id="securityManager" class="org.apache.shiro.web.mgt.DefaultWebSecurityManager"> <property name="realm" ref="userRealm" /> </bean> <!-- 自定义 realm --> <bean id="userRealm" class="cn.ssm.realm.CustomRealm1"> </bean>
public class CustomRealm1 extends AuthorizingRealm { protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token) throws AuthenticationException { } protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals) { }
<!-- 凭证匹配器 --> <bean id="credentialsMatcher" class="org.apache.shiro.authc.credential.HashedCredentialsMatcher"> <property name="hashAlgorithmName" value="md5" /> <property name="hashIterations" value="1" /> </bean> <!-- 自定义 realm --> <bean id="userRealm" class="cn.ssm.realm.CustomRealm1"> <property name="credentialsMatcher" ref="credentialsMatcher" /> </bean>
<!-- 开启aop,对类代理 --> <aop:config proxy-target-class="true"></aop:config> <!-- 开启shiro注解支持 --> <bean class=" org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor"> <property name="securityManager" ref="securityManager" /> </bean>
标签:action cat ali cycle real 顺序 iso end omr
原文地址:https://www.cnblogs.com/durui/p/9319311.html