From 85fb370615811e03b23210174e586a0959c4fdbf Mon Sep 17 00:00:00 2001 From: macro Date: Sun, 10 Nov 2019 10:46:03 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=97=A0=E7=94=A8=E7=BB=84?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../component/GoAccessDeniedHandler.java | 23 ------------------- .../component/GoAuthenticationEntryPoint.java | 23 ------------------- .../GoAuthenticationFailureHandler.java | 23 ------------------- .../GoAuthenticationSuccessHandler.java | 23 ------------------- .../component/GoLogoutSuccessHandler.java | 23 ------------------- 5 files changed, 115 deletions(-) delete mode 100644 mall-portal/src/main/java/com/macro/mall/portal/component/GoAccessDeniedHandler.java delete mode 100644 mall-portal/src/main/java/com/macro/mall/portal/component/GoAuthenticationEntryPoint.java delete mode 100644 mall-portal/src/main/java/com/macro/mall/portal/component/GoAuthenticationFailureHandler.java delete mode 100644 mall-portal/src/main/java/com/macro/mall/portal/component/GoAuthenticationSuccessHandler.java delete mode 100644 mall-portal/src/main/java/com/macro/mall/portal/component/GoLogoutSuccessHandler.java diff --git a/mall-portal/src/main/java/com/macro/mall/portal/component/GoAccessDeniedHandler.java b/mall-portal/src/main/java/com/macro/mall/portal/component/GoAccessDeniedHandler.java deleted file mode 100644 index 103eab9..0000000 --- a/mall-portal/src/main/java/com/macro/mall/portal/component/GoAccessDeniedHandler.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.macro.mall.portal.component; - -import cn.hutool.json.JSONUtil; -import com.macro.mall.common.api.CommonResult; -import org.springframework.security.access.AccessDeniedException; -import org.springframework.security.web.access.AccessDeniedHandler; - -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; - -/** - * Created by macro on 2018/8/6. - */ -public class GoAccessDeniedHandler implements AccessDeniedHandler{ - @Override - public void handle(HttpServletRequest request, HttpServletResponse response, AccessDeniedException accessDeniedException) throws IOException, ServletException { - response.setHeader("Content-Type", "application/json;charset=utf-8"); - response.getWriter().print(JSONUtil.parse(CommonResult.forbidden(accessDeniedException.getMessage()))); - response.getWriter().flush(); - } -} diff --git a/mall-portal/src/main/java/com/macro/mall/portal/component/GoAuthenticationEntryPoint.java b/mall-portal/src/main/java/com/macro/mall/portal/component/GoAuthenticationEntryPoint.java deleted file mode 100644 index 7da2442..0000000 --- a/mall-portal/src/main/java/com/macro/mall/portal/component/GoAuthenticationEntryPoint.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.macro.mall.portal.component; - -import cn.hutool.json.JSONUtil; -import com.macro.mall.common.api.CommonResult; -import org.springframework.security.core.AuthenticationException; -import org.springframework.security.web.AuthenticationEntryPoint; - -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; - -/** - * Created by macro on 2018/8/6. - */ -public class GoAuthenticationEntryPoint implements AuthenticationEntryPoint { - @Override - public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authException) throws IOException, ServletException { - response.setHeader("Content-Type", "application/json;charset=utf-8"); - response.getWriter().print(JSONUtil.parse(CommonResult.unauthorized(authException.getMessage()))); - response.getWriter().flush(); - } -} diff --git a/mall-portal/src/main/java/com/macro/mall/portal/component/GoAuthenticationFailureHandler.java b/mall-portal/src/main/java/com/macro/mall/portal/component/GoAuthenticationFailureHandler.java deleted file mode 100644 index 2f338e8..0000000 --- a/mall-portal/src/main/java/com/macro/mall/portal/component/GoAuthenticationFailureHandler.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.macro.mall.portal.component; - -import cn.hutool.json.JSONUtil; -import com.macro.mall.common.api.CommonResult; -import org.springframework.security.core.AuthenticationException; -import org.springframework.security.web.authentication.AuthenticationFailureHandler; - -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; - -/** - * Created by macro on 2018/8/6. - */ -public class GoAuthenticationFailureHandler implements AuthenticationFailureHandler { - @Override - public void onAuthenticationFailure(HttpServletRequest request, HttpServletResponse response, AuthenticationException exception) throws IOException, ServletException { - response.setHeader("Content-Type", "application/json;charset=utf-8"); - response.getWriter().print(JSONUtil.parse(CommonResult.failed("登录失败,用户名或密码错误!"))); - response.getWriter().flush(); - } -} diff --git a/mall-portal/src/main/java/com/macro/mall/portal/component/GoAuthenticationSuccessHandler.java b/mall-portal/src/main/java/com/macro/mall/portal/component/GoAuthenticationSuccessHandler.java deleted file mode 100644 index c3f6c7c..0000000 --- a/mall-portal/src/main/java/com/macro/mall/portal/component/GoAuthenticationSuccessHandler.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.macro.mall.portal.component; - -import cn.hutool.json.JSONUtil; -import com.macro.mall.common.api.CommonResult; -import org.springframework.security.core.Authentication; -import org.springframework.security.web.authentication.AuthenticationSuccessHandler; - -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; - -/** - * Created by macro on 2018/8/6. - */ -public class GoAuthenticationSuccessHandler implements AuthenticationSuccessHandler { - @Override - public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException, ServletException { - response.setHeader("Content-Type", "application/json;charset=utf-8"); - response.getWriter().print(JSONUtil.parse(CommonResult.success(null,"登录成功"))); - response.getWriter().flush(); - } -} diff --git a/mall-portal/src/main/java/com/macro/mall/portal/component/GoLogoutSuccessHandler.java b/mall-portal/src/main/java/com/macro/mall/portal/component/GoLogoutSuccessHandler.java deleted file mode 100644 index 13ec6fc..0000000 --- a/mall-portal/src/main/java/com/macro/mall/portal/component/GoLogoutSuccessHandler.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.macro.mall.portal.component; - -import cn.hutool.json.JSONUtil; -import com.macro.mall.common.api.CommonResult; -import org.springframework.security.core.Authentication; -import org.springframework.security.web.authentication.logout.LogoutSuccessHandler; - -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; - -/** - * Created by macro on 2018/8/6. - */ -public class GoLogoutSuccessHandler implements LogoutSuccessHandler { - @Override - public void onLogoutSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException, ServletException { - response.setHeader("Content-Type", "application/json;charset=utf-8"); - response.getWriter().print(JSONUtil.parse(CommonResult.success(null,"已注销"))); - response.getWriter().flush(); - } -}