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

ps个人网站建设西宁建设网站的公司

ps个人网站建设,西宁建设网站的公司,做网站推广员图片处理问题,猎头公司网站模板文章目录 1、用户认证流程AuthenticationSuccessHandler AuthenticationFailureHandlerSecurityFilterChain配置用户认证信息 2、会话并发处理2.1、实现处理器接口2.2、SecurityFilterChain配置 1、用户认证流程 AuthenticationSuccessHandler AuthenticationFailureHandler … 文章目录 1、用户认证流程AuthenticationSuccessHandler AuthenticationFailureHandlerSecurityFilterChain配置用户认证信息 2、会话并发处理2.1、实现处理器接口2.2、SecurityFilterChain配置 1、用户认证流程 AuthenticationSuccessHandler AuthenticationFailureHandler 登录成功后调用AuthenticationSuccessHandler登录失败后调用AuthenticationFailureHandler public class SecurityAuthenticationSuccessHandler implements AuthenticationSuccessHandler {Overridepublic void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException, ServletException {//获取用户身份信息Object principal authentication.getPrincipal();//创建结果对象HashMap result new HashMap();result.put(code, 0);result.put(message, 登录成功);result.put(data, principal);//转换成json字符串String json JSON.toJSONString(result);//返回响应response.setContentType(application/json;charsetUTF-8);response.getWriter().println(json);} } SecurityFilterChain配置 form.successHandler(new SecurityAuthenticationSuccessHandler()) //认证成功时的处理用户认证信息 RestController public class IndexController {GetMapping(/)public Map index(){System.out.println(index controller);SecurityContext context SecurityContextHolder.getContext();//存储认证对象的上下文Authentication authentication context.getAuthentication();//认证对象String username authentication.getName();//用户名Object principal authentication.getPrincipal();//身份Object credentials authentication.getCredentials();//凭证(脱敏)Collection? extends GrantedAuthority authorities authentication.getAuthorities();//权限System.out.println(username);System.out.println(principal);System.out.println(credentials);System.out.println(authorities);//创建结果对象HashMap result new HashMap();result.put(code, 0);result.put(data, username);return result;} }2、会话并发处理 后登录的账号会使先登录的账号失效 2.1、实现处理器接口 实现接口SessionInformationExpiredStrategy package com.atguigu.securitydemo.config;public class MySessionInformationExpiredStrategy implements SessionInformationExpiredStrategy {Overridepublic void onExpiredSessionDetected(SessionInformationExpiredEvent event) throws IOException, ServletException {//创建结果对象HashMap result new HashMap();result.put(code, -1);result.put(message, 该账号已从其他设备登录);//转换成json字符串String json JSON.toJSONString(result);HttpServletResponse response event.getResponse();//返回响应response.setContentType(application/json;charsetUTF-8);response.getWriter().println(json);} }2.2、SecurityFilterChain配置 //会话管理 http.sessionManagement(session - {session.maximumSessions(1).expiredSessionStrategy(new MySessionInformationExpiredStrategy()); });
http://www.yingshimen.cn/news/82098/

相关文章:

  • 哪里可以做外贸网站开通网站必须做域名空间
  • 网站开发的排期网站建设中山
  • 企业内部门户网站建设惠州做百度网站多少
  • 新手如何自己建网站30_10_郑州网站制作
  • 湖北建设银行官方网站首页营销网红
  • 网站 架构设计购物网站怎么做推广
  • 苏州建网站多少钱网络营销培训课程
  • 电子商务网站开发过程论文6wordpress文章伪静态
  • 在线编辑图片的网站有哪些杭州做网站套餐
  • 网站建设有哪种方式社区app网站模板下载
  • 做公司 网站建设做文案策划需要知道些什么网站
  • 东莞网站优化推广方案夜无忧论坛官网
  • 巢湖路桥建设集团有限公司网站国外对于网站开发
  • WordPress建站步骤高端网站建设熊掌号
  • 西安代做毕业设计网站黄岛网站建设多少钱
  • 做网站 用哪个网盘好试用网站如何做
  • 建设阅读网站的目的广告公司怎么找客户资源
  • o2o系统网站建设网站推广怎么优化
  • pc端网站建设哪里有网站开发项目进度安排
  • 精彩的网格布局网站android应用商店
  • 天津网站制作维护固始县住房和城乡规划建设局网站
  • dede无法更新网站主页到降龙网络专业做网站
  • 贵州建设厅网站在建工程查询自己做网站费用
  • 电商的网站怎么做的好北京网上注册公司流程
  • 做一张简单的app网站多钱电商网站项目经验介绍
  • 长沙公司网站开发车培训网站建设
  • 海西电子商务网站建设wordpress主题+插件
  • 网站后台如何做下载连接双鱼儿 网站建设
  • 备案 网站 漏接 电话互联网广告
  • 网站源码设计导航仪企业网站源码