Joyen.fu
日中则昃,月盈则食。

位于过滤器顶端,第一个起作用的过滤器。SecurityContextPersistenceFilter

在执行其他过滤器之前,率先判断用户的session中是否已经存在一个SecurityContext了。如果存在,就把SecurityContext拿出来,放到SecurityContextHolder中,供Spring Security的其他部分使用。如果不存在,就创建一个SecurityContext出来,还是放到SecurityContextHolder中,供Spring Security的其他部分使用。

过滤链执行完成后如果session尚未保存SecurityContext,则repo.saveContext(contextAfterChainExecution, holder.getRequest(), holder.getResponse());方法调用SaveContextOnUpdateOrErrorResponseWrapper类中的responseWrapper.saveContext(context)进行保存。这个保存可能是response没有提交前。

posted on 2016-03-28 14:50  Joyen.fu  阅读(663)  评论(0编辑  收藏  举报