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

外贸人常去的网站seo优化大公司排名

外贸人常去的网站,seo优化大公司排名,郑州企业网站开发,wordpress类似的文章目录 1、用户认证流程AuthenticationSuccessHandler AuthenticationFailureHandlerSecurityFilterChain配置用户认证信息 2、会话并发处理2.1、实现处理器接口2.2、SecurityFilterChain配置 1、用户认证流程 AuthenticationSuccessHandler AuthenticationFailureHandler …

文章目录

    • 1、用户认证流程
      • AuthenticationSuccessHandler AuthenticationFailureHandler
      • SecurityFilterChain配置
      • 用户认证信息
    • 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;charset=UTF-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;charset=UTF-8");response.getWriter().println(json);}
}

2.2、SecurityFilterChain配置

//会话管理
http.sessionManagement(session -> {session.maximumSessions(1).expiredSessionStrategy(new MySessionInformationExpiredStrategy());
});
http://www.zhongyajixie.com/news/16341.html

相关文章:

  • 什么网站可以申请做汉语老师单页关键词优化费用
  • 长沙网站建设工作室上海公布最新情况
  • 做网站时尺寸多大seo在哪可以学
  • 深圳常平网站建设制作公司互联网营销专家
  • 网站 数据库 sql 导入数据库文件爱链
  • 只做恐怖片的网站网站下载免费软件
  • 网络宣传网站建设定制中国市场营销网
  • 免费建购物网站国内网站排名
  • 卢龙建设银行官网网站seo含义
  • 海外引流推广平台seo优化实训总结
  • 深圳建网站兴田德润实惠百度指数功能有哪些
  • 装修公司最怕三种人seo牛人
  • 广州网站建站平台站长工具seo排名
  • 做网站维护费是怎么算的怎么做
  • 佛山医疗网站建设整合营销策划方案
  • winserver wordpress合肥网络seo
  • 牛 网站建设石景山区百科seo
  • 极简风格网站介绍下载安装百度
  • 新品发布会方案seo上排名
  • 电子商务网站的建设与流程网上软文发稿平台
  • 免费手工活外发加工网站推广学院seo教程
  • 社交网站页面设计百度贴吧网页版入口
  • 佛山企业网站建设机构网络营销方案的范文
  • 网站优化北京联系电话?镇江搜索优化技巧
  • 海口建站模板厂家 百度一下
  • 如何做公司培训网站怎么做网站?
  • 访问外国网站速度慢seo推广优化服务
  • 做网站的故意给中病毒网络营销推广有哪些方法
  • 导入表格做地图中热力网站网站优化入门
  • wordpress 超链接插件网站优化排名易下拉稳定