手赚入口:http://szjx.top
HttpSessionEventPublisher
实现了HttpSessionListener接口,监听session的创建和销毁事件,通过ApplicationContext发布对应的事件HttpSessionCreatedEvent HttpSessionDestroyedEvent //监听session创建事件 public void sessionCreated(HttpSessionEvent event) { HttpSessionCreatedEvent e = new HttpSessionCreatedEvent(event.getSession()); //发布事件 getContext(event.getSession().getServletContext()).publishEvent(e); } //监听session销毁事件 public void sessionDestroyed(HttpSessionEvent event) { HttpSessionDestroyedEvent e = new HttpSessionDestroyedEvent(event.getSession()); //发布事件 getContext(event.getSession().getServletContext()).publishEvent(e); }
SessionRegistry , SessionInformation
SessionInformation :记录认证用户的session信息 。
lastRequest:最后一次访问次数
principal:认证用户信息
sessionId:session的id
expired:是否过期
SessionRegistry :
保存了所有认证成功后用户的SessionInformation信息,每次用户访问服务器的会从sessionRegistry中查询出当前用户的session信息 ,判断是否过期以及刷新最后一次方法时间,默认的实现类SessionRegistryImpl,监听了session的销毁事件,若销毁,那么删除掉session信息,有两个属性:
/** <principal:Object,SessionIdSet> 以认证用户对象做key,多个sessionId 为value 。一个用户可以对应多个不同的session,表示同一个帐号可以同时在不同的浏览器上登录,可以配置最大允许同时登录的数*/ private final ConcurrentMap<Object,Set<String>> principals = new ConcurrentHashMap<Object,Set<String>>(); /** <sessionId:Object,SessionInformation> 以sessionid为key SessionInformation为value */ private final Map<String, SessionInformation> sessionIds = new ConcurrentHashMap<String, SessionInformation>();
SessionAuthenticationStrategy
void onAuthentication(Authentication authentication, HttpServletRequest request, HttpServletResponse response) throws SessionAuthenticationException;
有多个实现类:
ChangeSessionIdAuthenticationStrategy:
调用HttpServletRequest的changeSessionId方法改变sessionid
SessionFixationProtectionStrategy:
首先让原来的session过期,然后创建一个新的session,把原来session的属性拷贝到新的session中
http://xpenxpen.iteye.com/blog/1664075
RegisterSessionAuthenticationStrategy:
用户认证成功后sessionRegistry调用registerNewSession,保存用户的信息和session
ConcurrentSessionControlAuthenticationStrategy:
允许用户同时在线数,有一个maximumSessions属性,默认是1。通过sessionRegistry判断用户数是否已经超过了最大允许数,若超过了,那么就让最近一个的session过期(让上一个用户强制下线)
CompositeSessionAuthenticationStrategy:组合使用多个SessionAuthenticationStrategy
实现控制同时在线用户数
1. 在web.xml中添加listener
<listener> <listener-class> org.springframework.security.web.session.HttpSessionEventPublisher </listener-class> </listener>
2. 在security.xml中添加代码:
<security:http> <security:intercept-url pattern="/**" access="ROLE_USER"/> <security:form-login/> <security:logout logout-url="/logout"/> <security:session-management> <security:concurrency-control max-sessions="1"/> </security:session-management> </security:http>
默认创建的SessionAuthenticationStrategy是组合CompositeSessionAuthenticationStrategy:设置的SessionAuthenticationStrategy有:RegisterSessionAuthenticationStrategy ConcurrentSessionControlAuthenticationStrategy SessionFixationProtectionStrategy
小忆智库:http://blog.xiaoyizhiku.cn/
相关推荐
实现会话控制,权限控制,免登陆的spring security完整项目 博文链接:https://abc08010051.iteye.com/blog/1995886
Session Management Flaws 会话管理: 因为HTTP是没有状态的,之前认证缺陷的也会涉及到类似的知识点,由于每次请求完成后链接就会断开,当客户端再次发起请求的时候,服务端就识别不了客户端的状态,而会话管理就是...
诊所会议管理 构建设置 # install dependencies npm install # serve with hot reload at localhost:8080 npm run dev # build for production with minification npm run build # build for production and view ...
OWASP Security Shepherd靶机环境 会话管理挑战题1~4解题思路分享
Angular 会话管理安装###Bower 安装 SessionManagement 模块的最简单方法是将 bower 包包含到您的解决方案中bower install symanto-angular-sessionmanagement --save 之后,您只需要将模块和所需的模块添加到您的 ...
Flask-Login provides user session management for Flask. It handles the common tasks of logging in, logging out, and remembering your users' sessions over extended periods of time. Flask-Login is not ...
会话管理 该类用于维护和管理网站的会话。 通过本课程,您可以: 开始会话。 重新生成会话 ID。 检查会话是否有效。 关闭会话。 在这个类中,可以使用用户的指纹来验证会话。 指纹包括安全词、IP 地址、浏览器...
轻松的会话管理: 初始化。 请求身份验证。 检索所有会话。 撤销本届会议。 撤销所有其他会议。 撤销所有会议。 可选的可识别会话(IP地址,操作系统,浏览器)。 通过中间件进行身份验证。 完全可定制,但...
akka-http-session使用cookie或自定义标头+本地存储提供Web和移动应用程序中客户端会话管理的指令,并具有可选的格式支持。 提供了以及代码示例(使用Java,但易于转换为Scala),该示例回答了有关会话如何工作,...
中继方添加了指向OP的check_session_iframe的隐藏iFrame。 中继方iframe使用postMessage轮询OP iframe,其格式为Client ID + " " + Session State 。 中继方从OP iframe接收回具有应用会话状态的postMessage。配置...
Session Management Function,会话管理功能:会话管理(例如会话建立、修改和释放等)、IP地址分配,用户面功能的选择与控制等 5G核心网接口 Policy Control Function,策略控制功能:为控制面功能提供策略信息、...
New Session Manager(NSM)是通过将独立程序分组为会话来辅助音乐制作的工具。通过充分利用协作应用程序的潜力,您的工作流程变得易于管理,强大且快速。 NSM仍然在各个方面都是免费的:免费,免费共享和使用,...
WebGoat里面关于会话劫持(Hijack a Session)这个课程的标准答案里面除了使用WebScarab以外还使用了其他的工具来找出合法的SessionID以完成这个课程,实际上这个课程完全可以只使用WebScarab来完成。
当您启动Emacs时,Session软件包会从您的上一个会话中恢复各种变量(例如,输入历史记录)。 它还提供了一个菜单,其中包含最近更改/访问的文件,并在您重新访问i时恢复该文件的位置(例如,点)。
会话-Viminfo-管理该插件对Vim的内置:... 工作区: Vim中所有带有“ workspace:”前缀的提示消息均来自此Session-Viminfo-Management插件。 默认值: 工作空间文件的默认名称是:workspace.sessionworkspace.vimi
7. PHP中的会话管理(Session Management)是什么?请说明如何在PHP中管理会话。 8. PHP中如何连接数据库(Database Connection)?请说明在PHP中如何与MySQL数据库建立连接。 9. 什么是PHP中的动态网页(Dynamic ...
MongoSessionStore是兼容会话存储的使用无论是或。 它还允许与任何(或没有!)Mongo ODM一起使用的自定义Mongo会话存储。 MongoSessionStore版本3与Rails 4.0到5.2兼容。 有关Rails 3的支持,请查看问题了解选项,...
烧瓶登录 Flask-Login提供Flask的用户会话管理。 它处理登录,注销和记住用户会话的常见任务。 Flask-Login未绑定到任何特定的数据库系统或权限模型。 唯一的要求是您的用户对象实现一些方法,并且提供对扩展的回调...
Apache Shiro是一个强大易用的Java安全框架,提供了认证、授权、加密和会话管理等功能: Authentication 认证 - 用户身份识别,常被称为用户“登录”;...Session Management 会话管理 - 每个用户会话时效性的状态。
管理用户会话和服务器进程 31 使用 Access Management Console 创建报告 31 使用 Access Management Console 配置应用程序访问权限 32 使用 Access Management Console 创建跟踪日志 32 查看 Citrix 修补程序信息 32...