shiro 用户权限管理(1)----配置 (springmvc+jpa+hibernate+maven环境)
2017-06-30 17:21
956 查看
springmvc.xml 配置增加
ehcache.xml配置
appcationContext.xml :
web.xml:
项目目录结构:
![](http://img.blog.csdn.net/20170630165701355?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvZmVuZ2NhaTAxMjM=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast)
自定义的ShiroDbRealm 类 继承AuthorizingRealm实现验证登录过程
![](http://img.blog.csdn.net/20170630170001215?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvZmVuZ2NhaTAxMjM=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast)
<!-- 开启Shiro注解的Spring配置方式的beans。在lifecycleBeanPostProcessor之后运行 --> <bean class="org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator" depends-on="lifecycleBeanPostProcessor" /> <bean class="org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor"> <property name="securityManager" ref="securityManager" /> </bean> <bean id="lifecycleBeanPostProcessor" class="org.apache.shiro.spring.LifecycleBeanPostProcessor" /> <!-- shiro为集成spring --> <bean class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver"> <property name="exceptionMappings"> <props> <prop key="org.apache.shiro.authz.UnauthorizedException">/system/error</prop> </props> </property> </bean>
ehcache.xml配置
<?xml version="1.0" encoding="UTF-8"?> <ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="ehcache.xsd" updateCheck="true" monitoring="autodetect" dynamicConfig="true"> <defaultCache maxElementsInMemory="10000" eternal="false" timeToIdleSeconds="120" timeToLiveSeconds="120" overflowToDisk="true" maxElementsOnDisk="10000000" diskPersistent="false" diskExpiryThreadIntervalSeconds="120" memoryStoreEvictionPolicy="LRU" /> </ehcache>
appcationContext.xml :
<!-- 項目自定义的Realm --> <bean id="shiroDbRealm" class="org.shiro.demo.service.realm.ShiroDbRealm" > <!--fc添加 MD5加密 begin--> <property name="credentialsMatcher"> <bean class="org.apache.shiro.authc.credential.HashedCredentialsMatcher"> <!--加密算法名称--> <property name="hashIterations" value="2"></property> <!--配置加密的次数--> </bean> </property> <!--fc添加 MD5加密 end--> </bean> <!-- Shiro Filter --> <bean id="shiroFilter"<!--要跟web.xml中的名称一致--> class="org.apache.shiro.spring.web.ShiroFilterFactoryBean"> <property name="securityManager" ref="securityManager" /> <property name="loginUrl" value="/" /> <property name="successUrl" value="/system/main" /> <property name="unauthorizedUrl" value="/system/error" /> <property name="filterChainDefinitions"> <value> /main/**= anon /login = anon /validateCode = anon /** = authc </value> </property> </bean>
web.xml:
<!-- Shiro filter --> <filter> <filter-name>shiroFilter</filter-name> <filter-class> org.springframework.web.filter.DelegatingFilterProxy </filter-class> <init-param> <param-name>targetFilterLifecycle</param-name> <param-value>true</param-value> </init-param> </filter> <filter-mapping> <filter-name>shiroFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping>
项目目录结构:
自定义的ShiroDbRealm 类 继承AuthorizingRealm实现验证登录过程
相关文章推荐
- SpringMVC+Apache Shiro+JPA(hibernate)案例教学(二)基于SpringMVC+Shiro的用户登录权限验证
- SpringMVC+Apache Shiro+JPA(hibernate)案例教学(四)基于Shiro验证用户权限,且给用户授权
- SpringMVC+Apache Shiro+JPA(hibernate)案例教学(二)基于SpringMVC+Shiro的用户登录权限验证
- SpringMVC+Apache Shiro+JPA(hibernate)案例教学(二)基于SpringMVC+Shiro的用户登录权限验证
- SpringMVC+Apache Shiro+JPA(hibernate)案例教学(四)基于Shiro验证用户权限,且给用户授权
- 将 Shiro 作为应用的权限基础 五:SpringMVC+Apache Shiro+JPA(hibernate)整合配置
- SpringMVC+Apache Shiro+JPA(hibernate)案例教学(四)基于Shiro验证用户权限,且给用户授权
- 将 Shiro 作为应用的权限基础 五:SpringMVC+Apache Shiro+JPA(hibernate)整合配置
- SpringMVC+Apache Shiro+JPA(hibernate)案例教学(四)基于Shiro验证用户权限,且给用户授权
- spring mvc +hibernate +spring +shiro 实现权限管理详细配置
- springmvc+spring+mybatis+maven项目集成shiro进行用户权限控制【转】
- SpringMVC+Spring Data JPA+Shiro+EasyUI简单权限管理系统
- springmvc+spring+mybatis+maven项目集成shiro进行用户权限控制【转】
- SpringMVC+Apache Shiro+JPA(hibernate)案例教学(一)整合配置
- SpringMVC+Apache Shiro+JPA(hibernate)整合配置
- springmvc+spring+mybatis+maven项目集成shiro进行用户权限控制【转】
- maven+springMVC+hibernate项目搭建(一基础环境配置)
- springmvc+spring+mybatis+maven项目集成shiro进行用户权限控制【转】
- Springmvc+Hibernate+JPA Maven环境搭
- SpringMVC+Apache Shiro+JPA(hibernate)案例教学(一)整合配置