【Shiro】六、Apache Shiro Session管理
1、Session的介绍
关于Session
会话:从启动一个Session到关闭这个Session作为一个会话,是对客户端和服务器端交互的一种封装,带有时效性
会话的产生:
一般从容器中产生
Web container:Web容器,如Tomcat,这些容器对Session进行了实现,可以产生Session
EJB Stateful Session Beans:比较少用
会话的应用:
Mobile
Web
分布式集群
Shiro Session
基于POJO
可以自定义Session存储的方式,保存到内存、文件、数据库都可以
容器无关的集群
客户端访问多样化
事件监听
主机地址记忆,可以知道由哪台主机创建
Web使用透明化,不需要关心Session怎么创建,只需要知道如何使用
支持SSO,单点登录
使用Session
Subject currentUser = SecurityUtils.getSubject(); Session session = currentUser.getSession(true); session.setAttribute("someKey", somValue);
subject.getSession(flag)
如果subject存在session,直接返回session
如果subject不存在session,flag=true,则创建一个新的Ssssion并返回
如果subject不存在session,flag=false,则返回null
类似servlet中的Session
支持所有应用,适合但不限于Web应用
2、SessionManager
DefaultSessionManager:默认实现
Session Timeout:Session的有效期
Session Listeners:面向事件、实现SessionListener接口
Session Storage:Session的保存形式
SessionDAO接口抽象
in-memory-only:默认,使用内存保存Session
EHCache SessionDAO:使用磁盘保存Session的实现
EhCache SessionDAO的使用
配置ehcache.xml
Session Cache Name
Session IDs
SessionIdGenerator组件:用于生成SessionID
JavaUuidSessionIdGenerator:默认实现,使用Java的uuid
自定义
Session Validation
判断Session是否过期
Lazy Validation:使用的时候才判断
Session孤儿(orphan):使用Lazy时,某些Session过期了,仍长期存在。
SessionValidationScheduler
定期删除Session孤儿
ExecutorServiceSessionValidationScheduler:默认实现
自定义SessionValidationScheduler
关闭Session Validation
关闭Session删除功能
3、Session集群
用于实现Session的集群
Shiro支持分布式缓存
Web容器环境
Native环境
基于POJO多层架构
支持集群的SessionDAO
透明的SessionManager
支持集成多种分布式缓存服务器
EnterpriseCacheSessionDAO
activeSessionsCache
第三方集成
Ehcache+Terracotta
Zookeeper
4、Session和用户状态
有状态的应用
Shiro默认使用Session保存认证状态
通过SessionId获取用户状态
无状态的应用
自定义混合方案
SessionStorageEvaluator
转载于:https://www.cnblogs.com/LiveYourLife/p/9093573.html
【Shiro】六、Apache Shiro Session管理相关推荐
- Shiro学习--Apache Shiro Architecture(Shiro架构)
Apache Shiro Architecture 参考 http://shiro.apache.org/architecture.html 本文有点翻译的意思,是为了梳理Shiro的知识而做的Shi ...
- 【Shiro】shiro的Session管理
[Shiro]shiro的Session管理 1. Session管理介绍 2. JavaSE环境下 3. JavaEE环境下 4. Session监听 5. Session检测 1. Session ...
- Apache shiro 权限
2021SC@SDUSC 文档目录 Apache shiro学习文档 第一章 Apache Shiro 概述 第二章 Apache Shiro 架构 第三章 Apache Shiro 配置 3.1 配 ...
- Apache Shiro 使用手册---转载
原文地址:http://www.360doc.com/content/12/0104/13/834950_177177202.shtml (一)Shiro架构介绍 一.什么是Shiro Apache ...
- Apache Shiro java安全框架
什么是Apache Shiro? Apache Shiro(发音为"shee-roh",日语"堡垒(Castle)"的意思)是一个强大易用的Java安全框架,提 ...
- Apache Shiro入门
Apache Shiro入门 @(Shiro)[shiro,安全框架] Apache Shiro入门 Apache Shiro基本概述 Apache Shiro基本概念 使用Shiro能做什么 Shi ...
- 让 Apache Shiro 保护你的应用
让 Apache Shiro 保护你的应用 作者:Les Hazlewood 译者:胡伟红 查看英文原文: Application Security With Apache Shiro 在尝试保护你的 ...
- 让Apache Shiro保护你的应用
目录 什么是Apache Shiro? 为何要创建Apache Shiro? 今天,你为何愿意使用Apache Shiro? 谁在用Shiro? 核心概念:Subject,SecurityManage ...
- Shiro学习总结(2)——Apache Shiro快速入门教程
第一部分 什么是Apache Shiro 1.什么是 apache shiro : Apache Shiro是一个功能强大且易于使用的Java安全框架,提供了认证,授权,加密,和会话管理 如同 spr ...
- Apache shiro 漏洞总结
目录 Shiro简介 漏洞复现 CVE-2016-4437(Apache shiro反序列化漏洞) 影响版本 指纹信息 漏洞原理 环境搭建 漏洞复现 CVE-2020-1957(Shiro 认证绕过漏 ...
最新文章
- 吵疯了,Pull Request到底是个啥?
- php怎么写获取手机剪切板到搜索栏,如何根据指定的剪切板获取html?
- 5000字“肝”了这篇IP协议
- 【es】ElasticSearch 插件开发
- 美国CISA 列出300个已遭利用漏洞,督促组织机构及时修复
- eureka 之前的服务如何关闭_Eureka 中的幽灵
- bzoj 4765: 普通计算姬(分块+树状数组)
- Ubuntu下安装UDK
- 计算机应用个人职业发展规划简短,个人职业生涯规划
- MySQL 系统自带的数据库有哪些?每个数据库的作用是什么?
- 无阻塞实时检测键盘输入
- STM32多路红外发送
- 干支纪年法简便算法_高中化学分类学法指导,附高考化学必记知识点及规律
- linux mint软件包,在Linux Mint上安装R软件包的问题18.1
- java常见的面试题
- 【LeetCode之栈和队列】:关于栈和队列经典的OJ题(用C语言实现,附图详解)
- iOS 开发的资源整理
- node.js实现图片上传
- 最受程序员欢迎的公司榜单发布:2015 IT人才招聘趋势分析
- mac虚拟摄像头插件_Mobiola WebCamera(网络虚拟摄像头) V2.4 Mac版
热门文章
- 简化java_Java泛型太复杂了?如何简化?
- java openxml 操作 word_OpenXML操作word
- android 控件发光_如何在android中的按钮周围制作动画/常量发光效果?
- Java里进制转换(二进制、八进制、十进制、十六进制)
- Android开发笔记(五十)定时器AlarmManager
- c 命令行简易计算器
- jsp,jstl checkbox 回显方法
- iOS开发值多线程简单介绍
- Unit25 Congratulation
- 用java读取word2003和word2007的内容