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

wordpress怎么删除预建网站搜索网站排名

wordpress怎么删除预建网站,搜索网站排名,品牌vi设计公司啊,php网页设计培训在SpringSecurity中,如果我们在认证或者授权的过程中出现了异常会被ExceptionTranslationFilter捕 获到。在ExceptionTranslationFilter中会去判断是认证失败还是授权失败出现的异常。 一、自定义验证异常类 创建exception包,在exception包下创建自定义…

在SpringSecurity中,如果我们在认证或者授权的过程中出现了异常会被ExceptionTranslationFilter捕 获到。在ExceptionTranslationFilter中会去判断是认证失败还是授权失败出现的异常。

一、自定义验证异常类

创建exception包,在exception包下创建自定义CustomerAuthenticationException类,继承 AuthenticationException类

/*** 自定义 认证 验证异常类*/
public class CustomerAuthenticationException extends AuthenticationException {public CustomerAuthenticationException(String message){super(message);}
}

二、登录用户访问无权限资源处理器

创建CustomerAccessDeniedHandler认证用户访问无权限资源时处理器类。

抓捕到AccessDeniedException异常后,进入此处理器

/*** 认证用户  访问无权限资源时处理器*/
@Component
public class CustomerAccessDeniedHandler implements AccessDeniedHandler {@Overridepublic void handle(HttpServletRequest request,HttpServletResponse response,AccessDeniedException accessDeniedException) throws IOException {//设置客户端的响应的内容类型response.setContentType("application/json;charset=UTF-8");//获取输出流ServletOutputStream outputStream = response.getOutputStream();//消除循环引用String result = JSON.toJSONString(R.error().code(700).message("无权限访问, 请联系管理员!"),SerializerFeature.DisableCircularReferenceDetect);outputStream.write(result.getBytes(StandardCharsets.UTF_8));outputStream.flush();outputStream.close();}
}

三、匿名用户访问资源处理器

/*** 匿名用户  访问无权限资源的处理类*/
@Component
public class AnonymousAuthenticationHandler implements AuthenticationEntryPoint {@Overridepublic void commence(HttpServletRequest request,HttpServletResponse response,AuthenticationException authException) throws IOException {//设置客户端的响应的内容类型response.setContentType("application/json;charset=UTF-8");String result = null;//获取输出流ServletOutputStream outputStream = response.getOutputStream();// System.out.println("异常消息:"+authException.getMessage()+",对象:"+authException);if (authException instanceof BadCredentialsException) {// 用户名未找到,可以在这里添加自定义处理逻辑result = JSON.toJSONString(R.error().code(HttpServletResponse.SC_UNAUTHORIZED).message(authException.getMessage()),SerializerFeature.DisableCircularReferenceDetect);} else if (authException instanceof InternalAuthenticationServiceException) {result = JSON.toJSONString(R.error().code(HttpServletResponse.SC_UNAUTHORIZED).message("用户名为空!"),SerializerFeature.DisableCircularReferenceDetect);} else {// 其他身份验证异常处理result = JSON.toJSONString(R.error().code(600).message("匿名用户无权限访问!"),SerializerFeature.DisableCircularReferenceDetect);  //消除循环引用}outputStream.write(result.getBytes(StandardCharsets.UTF_8));outputStream.flush();outputStream.close();}
}

四、改造认证校验过滤器 && 认证失败处理器

/*** 认证校验失败处理类*/
@Component
public class LoginFailureHandler implements AuthenticationFailureHandler {@Overridepublic void onAuthenticationFailure(HttpServletRequest request,HttpServletResponse response,AuthenticationException exception) throws IOException, ServletException {//设置客户端响应编码格式response.setContentType("application/json;charset=UTF-8");//获取输出流ServletOutputStream outputStream= response.getOutputStream();String message = null;//提示信息int code = 500;//错误编码//判断异常类型if(exception instanceof AccountExpiredException){message = "账户过期,登录失败!";}else if(exception instanceof BadCredentialsException){message = "用户名或密码错误,登录失败!";}else if(exception instanceof CredentialsExpiredException){message = "密码过期,登录失败!";}else if(exception instanceof DisabledException){message = "账户被禁用,登录失败!";}else if(exception instanceof LockedException){message = "账户被锁,登录失败!";}else if(exception instanceof InternalAuthenticationServiceException){message = "账户不存在,登录失败!";}else if(exception instanceof CustomerAuthenticationException){message = exception.getMessage();code = 600;}else{message = "登录失败!";}//将错误信息转换成JSONString result = JSON.toJSONString(R.error().code(code).message(message));outputStream.write(result.getBytes(StandardCharsets.UTF_8));outputStream.flush();outputStream.close();}
}

五、配置自定义处理器

http://www.yidumall.com/news/52845.html

相关文章:

  • 电子政务网站建设百度百科查询
  • 新疆生产建设兵团第二中学招生报名网站站长检测工具
  • 网站建设 翰臣科技seo代理计费系统
  • 杭州认证网站建设国际新闻最新消息十条
  • 北京cos网站注册网站免费注册
  • go语言可以做网站吗宁德seo推广
  • 晋城市建设局 网站广州网站优化步骤
  • 做交友类网站适合什么cms空间刷赞网站推广
  • 帮人负责做网站叫什么工作关键词分类哪八种
  • 网站建设费用有哪些方面搜索引擎排名规则
  • 本地的南通网站建设汽油价格最新调整最新消息
  • 院校网站建设对比分析实训报总结百度快照怎么优化排名
  • wordpress 简约单页网站怎么优化
  • 临汾做网站的公司谷歌 google
  • 宣传网站有哪些优化设计官网
  • 淮安做网站找哪家好客户关系管理系统
  • 汕头建站网站模板搜索引擎调词平台
  • python做网站功能测试学校seo推广培训班
  • 做老虎机网站犯法么引流推广多少钱一个
  • 网站建设数据处理国际新闻最新消息今天
  • 如何自做网站seo和sem分别是什么
  • 平面设计专业网站新闻发稿发布平台
  • 成交型网站建设价格seoul
  • 讯美深圳网站建设千万别手贱在百度上搜这些词
  • 淘宝客网站主网站功能
  • 西安网站设计公司安卓aso
  • 帮人做网站要怎么赚钱吗seo推广招聘
  • 交易平台网站怎么做灰色词首页排名接单
  • 《网站开发与应用》试题sem代运营公司
  • 摄影做网站免费网络推广软件有哪些