当前位置: 首页 > news >正文

晋江网站有什么职业做学习网站开发教程

晋江网站有什么职业做,学习网站开发教程,网站团队介绍,拍摄宣传片收费标准web如何取得用户信息 之前说过SecurityContextHolder默认使用的是ThreadLocal来进行存储的#xff0c;而且每次都会清除#xff0c;但是web每次请求都会验证用户权限#xff0c;这是如何做到的呢#xff1f; 这是通过SecurityContextPersistenceFilter来实现的#xff0…web如何取得用户信息 之前说过SecurityContextHolder默认使用的是ThreadLocal来进行存储的而且每次都会清除但是web每次请求都会验证用户权限这是如何做到的呢 这是通过SecurityContextPersistenceFilter来实现的每次请求过来都会session中来获取SecurityContext然后设置到SecurityContextHolder中请求结束后再清除掉 public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain)throws IOException, ServletException {HttpServletRequest request (HttpServletRequest) req;HttpServletResponse response (HttpServletResponse) res;if (request.getAttribute(FILTER_APPLIED) ! null) {// ensure that filter is only applied once per requestchain.doFilter(request, response);return;}request.setAttribute(FILTER_APPLIED, Boolean.TRUE);HttpRequestResponseHolder holder new HttpRequestResponseHolder(request,response);// 从session获取SecurityContextSecurityContext contextBeforeChainExecution repo.loadContext(holder);try {// 将SecurityContext存入SecurityContextHolderSecurityContextHolder.setContext(contextBeforeChainExecution);chain.doFilter(holder.getRequest(), holder.getResponse());}finally {SecurityContext contextAfterChainExecution SecurityContextHolder.getContext();// Crucial removal of SecurityContextHolder contents - do this before anything// else.SecurityContextHolder.clearContext();// 存储SecurityContextrepo.saveContext(contextAfterChainExecution, holder.getRequest(),holder.getResponse());request.removeAttribute(FILTER_APPLIED);} }loadContext获取SecurityContext 使用HttpSessionSecurityContextRepository public SecurityContext loadContext(HttpRequestResponseHolder requestResponseHolder) {HttpServletRequest request requestResponseHolder.getRequest();HttpServletResponse response requestResponseHolder.getResponse();HttpSession httpSession request.getSession(false);// 从session中获取SecurityContextSecurityContext context readSecurityContextFromSession(httpSession);if (context null) {context generateNewContext();}SaveToSessionResponseWrapper wrappedResponse new SaveToSessionResponseWrapper(response, request, httpSession ! null, context);requestResponseHolder.setResponse(wrappedResponse);return context; }从session中获取SecurityContext private SecurityContext readSecurityContextFromSession(HttpSession httpSession) {final boolean debug logger.isDebugEnabled();if (httpSession null) {return null;}// Session exists, so try to obtain a context from it.Object contextFromSession httpSession.getAttribute(springSecurityContextKey);if (contextFromSession null) {return null;}// Everything OK. The only non-null return from this method.return (SecurityContext) contextFromSession; }存储SecurityContext public void saveContext(SecurityContext context, HttpServletRequest request,HttpServletResponse response) {SaveContextOnUpdateOrErrorResponseWrapper responseWrapper WebUtils.getNativeResponse(response,SaveContextOnUpdateOrErrorResponseWrapper.class);if (!responseWrapper.isContextSaved()) {responseWrapper.saveContext(context);} }protected void saveContext(SecurityContext context) {final Authentication authentication context.getAuthentication();HttpSession httpSession request.getSession(false);// See SEC-776if (authentication null || trustResolver.isAnonymous(authentication)) {if (httpSession ! null authBeforeExecution ! null) {// SEC-1587 A non-anonymous context may still be in the session// SEC-1735 remove if the contextBeforeExecution was not anonymoushttpSession.removeAttribute(springSecurityContextKey);}return;}if (httpSession null) {httpSession createNewSessionIfAllowed(context);}// If HttpSession exists, store current SecurityContext but only if it has// actually changed in this thread (see SEC-37, SEC-1307, SEC-1528)if (httpSession ! null) {// We may have a new session, so check also whether the context attribute// is set SEC-1561if (contextChanged(context)|| httpSession.getAttribute(springSecurityContextKey) null) {// 存到session中httpSession.setAttribute(springSecurityContextKey, context);}} }https://zhhll.icu/2024/框架/springSecurity/7.web如何取得用户信息/
http://www.hkea.cn/news/14583417/

相关文章:

  • 做路牌的网站做网站赚几百万
  • 泉州专业做网站app网站
  • 苏州 网站设计it外包服务平台
  • 无锡外贸网站建设wordpress分类目录样式
  • 广州智能建站软件关于化妆品网站成功案例
  • 河南省建设厅网站资质平移办法网页后台常用设计尺寸
  • 做网站所需要的代码6网站建设dream
  • 什么是网站主机ip域名查询网
  • 查询网站备案信息优化设计答案
  • 80s无水印视频素材网站下载均安建网站
  • 网站建设推广seo广东省建设工程协会网站
  • 广州网站策划公司制作个人网页费用
  • 学校门户网站开发火车头wordpress获取不到分类
  • 网站拖拽广州天河区房价2022年最新房价
  • 大学生创意电子产品设计电子商务seo
  • 夏天做哪些网站致富厦门网站排名优化软件
  • 内蒙古城乡建设和住房建设厅网站php综合网站源码
  • 商务网站的建设步骤网站源码站
  • 织梦网站统计代码制作网页的网站费用属于资本性支出吗
  • 广州天河建网站的公司c2c模式平台有哪些
  • wordpress网站响应速度插件广东网络公司网站建设
  • 做好网站建设工作总结网站建设牜金手指花总十四
  • 建行手机网站个人网站可以做论坛
  • 湖州建设企业网站罗湖附近网站建设公司
  • 政务网站建设办法3d建模学费一般多少钱
  • 做公司网站要注意哪些问题本地推广最有效的方法
  • 饶阳营销型网站建设费用王者荣誉网站怎么做
  • dede织梦做的网站 栏目页有切换js 怎么循环子栏目 调子栏目skech做网站交互流程
  • 网站建设难点襄阳门做网站
  • 哪个网站seo做的最好家具设计案例