shiro 与spring的集成
1.导入spring与shiro的jar包
2.在web.xml 文件中配置shiro的shiroFilter
<filter>
<filter-name>shiroFilter</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
<init-param>
<!-- 表示bean的生命周期由servlet管理 -->
<param-name>targetFilterLifecycle</param-name>
<param-value>true</param-value>
</init-param>
<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>
3.在applicationContext.xml 文件中配置SecurityManager和Realm
<bean id="shiroFilter" class="org.apache.shiro.spring.web.ShiroFilterFactoryBean">
<property name="securityManager" ref="securityManager"/>
<property name="loginUrl" value="/login.jsp"/>
<property name="unauthorizedUrl" value="/login.jsp"/>
<!-- shiro 的过滤器执行链 -->
<property name="filterChainDefinitions">
<value>
/login.jsp = anon
/user/login.do = anon
/user/logout.do = logout
/** = authc
</value>
</property>
</bean>
<bean id="securityManager" class="org.apache.shiro.web.mgt.DefaultWebSecurityManager">
<property name="realm" ref="userRealm"/>
<property name="sessionManager" ref="sessionManager"/>
<property name="rememberMeManager" ref="rememberMeManager"/>
</bean>
<bean id="rememberMeManager" class="org.apache.shiro.web.mgt.CookieRememberMeManager">
<property name="cookie" ref="rememberMeCookie"/>
</bean>
<bean id="rememberMeCookie" class="org.apache.shiro.web.servlet.SimpleCookie">
<!-- 设置cookie的存活时间 -->
<property name="maxAge" value="604800"/>
<!-- 设置cookie的名称 -->
<property name="name" value="rememberMe"/>
</bean>
<bean id="userRealm" class="com.edu.aynu.oalist.beans.Relam">
</bean>
<bean id="sessionManager" class="org.apache.shiro.web.session.mgt.DefaultWebSessionManager">
<property name="globalSessionTimeout" value="300000"/>
<property name="deleteInvalidSession" value="true"></property>
</bean>
shiro 与spring的集成的更多相关文章
- [原]CAS和Shiro在spring中集成
shiro是权限管理框架,现在已经会利用它如何控制权限.为了能够为多个系统提供统一认证入口,又研究了单点登录框架cas.因为二者都会涉及到对session的管理,所以需要进行集成. Shiro在1.2 ...
- Java-Shiro(三):Shiro与Spring MVC集成
新建Java Daynamic Web项目 导入Spring.SpringMVC依赖包: 导入Spring & Spring MVC包(导入如下所有开发包): Spring AOP依赖扩展包: ...
- spring中集成shiro
Shiro的组件都是JavaBean/POJO式的组件,所以非常容易使用Spring进行组件管理,可以非常方便的从ini配置迁移到Spring进行管理,且支持JavaSE应用及Web应用的集成. 在示 ...
- Spring Boot 集成Shiro和CAS
Spring Boot 集成Shiro和CAS 标签: springshirocas 2016-01-17 23:03 35765人阅读 评论(22) 收藏 举报 分类: Spring(42) 版 ...
- 解决Spring Boot集成Shiro,配置类使用Autowired无法注入Bean问题
如题,最近使用spring boot集成shiro,在shiroFilter要使用数据库动态给URL赋权限的时候,发现 @Autowired 注入的bean都是null,无法注入mapper.搜了半天 ...
- Spring Boot集成Shiro实战
Spring Boot集成Shiro权限验证框架,可参考: https://shiro.apache.org/spring-boot.html 引入依赖 <dependency> < ...
- Spring项目集成ShiroFilter简单配置
Shiros是我们开发中常用的用来实现权限控制的一种工具包,它主要有认证.授权.加密.会话管理.与Web集成.缓存等功能.我是从事javaweb工作的,我就经常遇到需要实现权限控制的项目,之前我们都是 ...
- Apache Shiro:【1】Shiro基础及Web集成
Apache Shiro:[1]Shiro基础及Web集成 Apache Shiro是什么 Apache Shiro是一个强大且易于使用的Java安全框架,提供了认证.授权.加密.会话管理,与spri ...
- 81. Spring Boot集成JSP疑问【从零开始学Spring Boot】
[原创文章,转载请注明出处] 针对文章: ()Spring Boot 添加JSP支持[从零开始学Spring Boot] 有网友提了这么一些疑问: 1.Spring Boot使用jsp时,仍旧可以打成 ...
随机推荐
- CUDA H624解码性能测试
测试环境: Cpu: Inter(R)Core(TM)i7-4790 CPU @3.6GHZ GPU: NVIDIA GeForce GTX960* 1 操作系统: W ...
- Linux中常用的函数
1.devm_kzalloc() 函数 devm_kzalloc() 和kzalloc()一样都是内核内存分配函数,但是devm_kzalloc()是跟设备(device)有关的,当设备(device ...
- ballerina 学习二十九 数据库操作
ballerina 数据操作也是比较方便的,官方也我们提供了数据操作的抽象,但是我们还是依赖数据库驱动的. 数据库驱动还是jdbc模式的 项目准备 项目结构 ├── mysql_demo │ ├── ...
- goss 简单快捷的服务器测试检验工具
goss 是一个简单.快捷的服务器测试检验工具,dgoss 是一个包装可以支持基于容器的开发模式 同时可以暴露测试结果为一个http endpoint,比较方便. 使用goss容器运行 使用数据卷的模 ...
- Ribbon Status Bar
https://documentation.devexpress.com/#WindowsForms/CustomDocument2498 官方文档说明 A Ribbon Status Bar (Ri ...
- windows7 64位下git和tortoisegit的安装和使用
githttps://github.com/git-for-windows/git/releases tortoisegit安装下载https://tortoisegit.org/download/ ...
- bzoj 3687 简单题——bitset
题目:https://www.lydsy.com/JudgeOnline/problem.php?id=3687 关于 bitset :https://blog.csdn.net/snowy_smil ...
- SVN 环境搭建 需要注意的地方
一. 服务器上安装的软件: 先 安装 Subversion 下载的地址:http://www.sliksvn.com/en/download 安装 TortoiseSVN 下载地址:http:/ ...
- Asp.Net中使用Newtonsoft.Json转换,读取,写入
using Newtonsoft.Json;using Newtonsoft.Json.Converters; //把Json字符串反序列化为对象目标对象 = JsonConvert.Deserial ...
- WPF Demo1
<Window x:Class="Demo1.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/ ...