From c418c3f88decb6ab98d0c088a68b177b1e9ee9ad Mon Sep 17 00:00:00 2001
From: xiaoyong931011 <15274802129@163.com>
Date: Mon, 08 Jun 2020 12:08:34 +0800
Subject: [PATCH] 20200608 代码提交
---
src/main/java/com/xcong/excoin/configurations/security/CustomAuthenticationEntryPoint.java | 4 +++-
src/main/java/com/xcong/excoin/configurations/security/CustomAccessDeniedHandler.java | 3 ++-
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/src/main/java/com/xcong/excoin/configurations/security/CustomAccessDeniedHandler.java b/src/main/java/com/xcong/excoin/configurations/security/CustomAccessDeniedHandler.java
index e59b286..34f840f 100644
--- a/src/main/java/com/xcong/excoin/configurations/security/CustomAccessDeniedHandler.java
+++ b/src/main/java/com/xcong/excoin/configurations/security/CustomAccessDeniedHandler.java
@@ -19,7 +19,8 @@
public class CustomAccessDeniedHandler implements AccessDeniedHandler {
@Override
public void handle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, AccessDeniedException e) throws IOException, ServletException {
- Result result = Result.loginFail("fail");
+ Result result = Result.loginFail("Forbidden");
httpServletResponse.getWriter().write(new ObjectMapper().writeValueAsString(result));
+ httpServletResponse.setStatus(HttpServletResponse.SC_FORBIDDEN);
}
}
diff --git a/src/main/java/com/xcong/excoin/configurations/security/CustomAuthenticationEntryPoint.java b/src/main/java/com/xcong/excoin/configurations/security/CustomAuthenticationEntryPoint.java
index a28ffb8..7f8444c 100644
--- a/src/main/java/com/xcong/excoin/configurations/security/CustomAuthenticationEntryPoint.java
+++ b/src/main/java/com/xcong/excoin/configurations/security/CustomAuthenticationEntryPoint.java
@@ -6,6 +6,7 @@
import org.springframework.security.web.AuthenticationEntryPoint;
import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@@ -18,9 +19,10 @@
@Override
public void commence(HttpServletRequest httpServletRequest, HttpServletResponse response, AuthenticationException e) throws IOException, ServletException {
- Result result = Result.loginFail("fail");
+ Result result = Result.loginFail("Unauthorized");
response.setCharacterEncoding("UTF-8");
response.setContentType("application/json; charset=utf-8");
response.getWriter().write(new ObjectMapper().writeValueAsString(result));
+ response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
}
}
--
Gitblit v1.9.1