shiro 用户权限管理(1)----配置 (springmvc+jpa+hibernate+maven环境)
来源:互联网 发布:苹果 知乎 编辑:程序博客网 时间:2024/05/17 22:54
springmvc.xml 配置增加
<!-- 开启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实现验证登录过程
阅读全文
0 0
- shiro 用户权限管理(1)----配置 (springmvc+jpa+hibernate+maven环境)
- SpringMVC+Apache Shiro+JPA(hibernate)案例教学(四)基于Shiro验证用户权限,且给用户授权
- 将 Shiro 作为应用的权限基础 五:SpringMVC+Apache Shiro+JPA(hibernate)整合配置
- 将 Shiro 作为应用的权限基础 五:SpringMVC+Apache Shiro+JPA(hibernate)整合配置
- SpringMVC+Apache Shiro+JPA(hibernate)案例教学(一)整合配置
- SpringMVC+Apache Shiro+JPA(hibernate)案例教学(一)整合配置
- Springmvc+Hibernate+JPA Maven环境搭
- springmvc+spring+jpa(hibernate)+redis+maven配置
- maven+springMVC+hibernate项目搭建(一基础环境配置)
- maven springmvc hibernate shiro 集成
- maven springmvc hibernate shiro 集成
- SpringMVC+Apache Shiro+JPA(hibernate)案例教学(三)给Shiro登录验证加上验证码
- SpringMVC+Apache Shiro+JPA(hibernate)案例教学(三)给Shiro登录验证加上验证码
- JPA+Hibernate+Maven环境搭建
- springmvc+spring+mybatis+maven项目集成shiro进行用户权限控制
- shiro开发,shiro的环境配置(基于spring+springMVC+redis)
- shiro 用户权限管理(2)-----注册md5加密,登录验证
- Spring+SpringMVC+Hibernate 基本Demo(注解、Maven管理)
- python seek() 有条件的打印出末尾几行
- 【资源共享】《RK3399 VR Sensor 开发指南》
- 蓝牙BLE基础:CC2541 BLE临界资源保护
- 第十一章 字符串和字符串函数
- View绘制流程
- shiro 用户权限管理(1)----配置 (springmvc+jpa+hibernate+maven环境)
- solr进阶
- ubuntu16.04 64位编译安装qt4.8.0和qt creator2.4.1
- 点击元素弹出弹框后,背景不能滚动,关闭弹窗时,恢复滚动,背景元素位置保持不变
- iOS10App如何跳转到系统Wi-Fi设置
- java多线程面试题,三个线程顺序打印ABC
- Postman 常用测试结果验证及使用技巧
- MySQL创建数据库与创建用户以及授权
- 【微信开发】---- 公众号支付