shiro自定义logout filter
虽然shiro有自己默认的logout过滤器,但是,有些时候,我们需要自己定义一下操作,比如说loutgout后,进入指定页面,或者logout后写入日志操作,这个时候,我们可以通过自定义logout filter来实现:
1,自定义一个systemLogout继承字logout filter,并重写preHandle方法
/**
* @author:lyy
* @Date: 2014/10/14 9:33
* @version:
* @Description:
*/
@Service
public class SystemLogout extends LogoutFilter{
@Autowired
LogManDataInf logManDataInfImpl;
@Override
@Override
protected boolean preHandle(ServletRequest request, ServletResponse response) throws Exception {
//在这里执行退出系统前需要清空的数据
Subject subject = getSubject(request, response);
String redirectUrl = getRedirectUrl(request, response, subject);
try {
subject.logout();
} catch (SessionException ise) {
ise.printStackTrace();
}
//跳转到登录页面
issueRedirect(request, response, redirectUrl);
//返回false表示不执行后续的过滤器,直接返回跳转到登录页面
return false;
}
}
2,在配置自定义的filter进入filter chain中
<!-- Shiro 的Web过滤器 -->
<bean id="shiroFilter" class="org.apache.shiro.spring.web.ShiroFilterFactoryBean">
<property name="securityManager" ref="securityManager" />
<property name="loginUrl" value="/login" />
<property name="filters">
<map>
<entry key="logout" value-ref="systemLogout" />
</map>
</property>
<!-- 过虑器链定义,从上向下顺序执行,一般将/**放在最下边 -->
<property name="filterChainDefinitions">
<value>
<!-- 对静态资源设置匿名访问 -->
/resources/** = anon
/taglib/** = anon
<!-- 请求 logout地址,shiro去清除session-->
/logout = logout
/login = anon
<!--/** = anon-->
/** = authc
</value>
</property>
</bean>
shiro自定义logout filter的更多相关文章
- shiro 自定义filter
1.自定义登录filter package com.creatunion.callcenter.filter; import com.alibaba.fastjson.JSONObject; impo ...
- Spring Security笔记:自定义Login/Logout Filter、AuthenticationProvider、AuthenticationToken
在前面的学习中,配置文件中的<http>...</http>都是采用的auto-config="true"这种自动配置模式,根据Spring Securit ...
- 解决shiro自定义filter后,ajax登录无法登录,并且无法显示静态资源的问题
这个问题困扰了我一天,看了下面两个文章,豁然开朗: https://www.cnblogs.com/gj1990/p/8057348.html https://412887952-qq-com.ite ...
- shiro自定义拦截url
在实际项目上,我们针对不同的用户(guste,user,admin,mobile user)等等,需要进入不同的页面,比如,手机端用户需要进入Mobile/这个路径下的,这个时候,我们需要自定义拦截u ...
- Shiro 自定义登陆、授权、拦截器
Shiro 登陆.授权.拦截 按钮权限控制 一.目标 Maven+Spring+shiro 自定义登陆.授权 自定义拦截器 加载数据库资源构建拦截链 使用总结: 1.需要设计的数据库:用户.角色.权限 ...
- 一个自定义 HBase Filter -“通过RowKeys来高性能获取数据”
摘要: 大家在使用HBase和Solr搭建系统中经常遇到的一个问题就是:“我通过SOLR得到了RowKeys后,该怎样去HBase上取数据”.使用现有的Filter性能差劲,网上也没有现成的自定义Fi ...
- MVC之 自定义过滤器(Filter)
MVC之 自定义过滤器(Filter) 一.自定义Filter 自定义Filter需要继承ActionFilterAttribute抽象类,重写其中需要的方法,来看下ActionFilterAttri ...
- spring-cloud-Zuul学习(四)【中级】--自定义zuul Filter详解【重新定义spring cloud实践】
实现自定义zuul Filter 方法很简单,只要继承ZuulFilter跟加入到spring IOC容器即可,zuulFilter是一个抽象类,里面包含以下方法需要我们实现: String fi ...
- Struct2中自定义的Filter无效
解决办法,把自定义的Filter配置放在struct2前 <?xml version="1.0" encoding="UTF-8"?> <we ...
随机推荐
- ARC 098 D - Xor Sum 2
Problem Statement There is an integer sequence A of length N. Find the number of the pairs of intege ...
- yaffs和jffs2简单比较
转:http://blog.chinaunix.net/uid-27675161-id-3392636.html 相关知识引用<嵌入式 Linux 应用开发 完全手册> Nand F ...
- c#异步线程:同步调用,异步调用,异步回调
定义一个异步线程类: public class AsyEventClass { private static ILog logger = LogManager.GetLogger(MethodBase ...
- Android使用 SO 库时要注意的一些问题
常和 SO 库开发打交道的同学来说已经是老生长谈,但是既然要讨论一整个动态加载系列,我想还是有必要说说使用 SO 库时的一些问题. 在项目里使用 SO 库非常简单,在 加载 SD 卡中的 SO 库 中 ...
- VUE的进阶 标签属性数据绑定和拼接
在vue官网把文档扫了一遍后,就开始写网站项目了,没有设计,就百度里找了一个h5的助赢软件的网站把他copy下来,想想有点坏了,接着把内容改改吧.首先开始做一个列表展示vue实例好后,给对象添加默认数 ...
- mysql修改表字段属性类型
例如: 修改表expert_info中的字段birth,允许其为空 >alter table expert_info change birth birth varchar(20) null; 例 ...
- IO流知识点
如何判断是输入还是输出?答:以程序为中心.如何判断是解码还是编码?答:以程序为中心.程序只懂二进制,所以,以二进制转换成字符是解码,字符转换成二进制是编码.1. 首先,File 它是给程序跟文件或文件 ...
- 删除windows服务命令
打开命令框:输入sc delete 服务名 例如删除elasticsearch-service-x64服务 sc delete elasticsearch-service-x64
- 2017.7.7 postgreSQL在插入造成重复时执行更新
参考来自:https://stackoverflow.com/questions/1109061/insert-on-duplicate-update-in-postgresql/1109198#11 ...
- dlsym
在Android源码中发现,会如下使用: dlsym(RTLD_DEFAULT, name); 也就是说 handle=RTLD_DEFAULT,在网上查了下,大致是说会在当前进程中按照 defaul ...