shiro kick out user
2016-06-23 08:23
330 查看
You shouldn't try to recreate the session and then operate it, you should get the session via the security manager, using the thread the user was logged into, like so:
If you somehow want to call logout from a different thread, you can use the SessionDAO interface, but you need to do extra configuration to have shiro use a SessionDAO as described here:
http://shiro.apache.org/session-management.html#SessionManagement-SessionStorage
When you have configured it correctly you can do stuff like:
SecurityUtils.getSubject().logout();
If you somehow want to call logout from a different thread, you can use the SessionDAO interface, but you need to do extra configuration to have shiro use a SessionDAO as described here:
http://shiro.apache.org/session-management.html#SessionManagement-SessionStorage
When you have configured it correctly you can do stuff like:
DefaultSecurityManager securityManager = (DefaultSecurityManager) SecurityUtils.getSecurityManager(); DefaultSessionManager sessionManager = (DefaultSessionManager) securityManager.getSessionManager(); Collection<Session> activeSessions = sessionManager.getSessionDAO().getActiveSessions(); for (Session session: activeSessions){ if (sessionId.equals(session.getId()){ session.stop(); } }
相关文章推荐
- GlobalAlloc函数
- 简单创建Android桌面小部件
- SystemParametersInfo函数
- JSTL标签库
- vim 编辑器的使用
- GetSystemInfo函数
- GetVersionEx函数
- 总结这一年多的时间
- linux进程的5个段
- Spring MVC事务配置
- Apache Web服务器安全配置全攻略
- python学习之路-7 模块configparser/xml/shutil/subprocess以及面向对象初级入门
- 关于scala环境配置详解
- 我的shiro之旅: 十二 shiro 踢出用户(同一用户只能一处登录)
- Apache web服务器安全加固
- 音乐播放器——SoundManager API介绍
- leveldb源码阅读知识积累2
- mysql 主从复制配置
- 如何获取原生数据
- Java相对路径读取文件