From d23645e976981bc9b670eea1d469fe8a36be309c Mon Sep 17 00:00:00 2001
From: KKSU <15274802129@163.com>
Date: Wed, 17 Apr 2024 17:19:53 +0800
Subject: [PATCH] 55测试环境

---
 src/main/java/com/xcong/excoin/configurations/security/CustomAuthenticationEntryPoint.java |   20 +++++++++++++++-----
 1 files changed, 15 insertions(+), 5 deletions(-)

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 7f8444c..98b1cdd 100644
--- a/src/main/java/com/xcong/excoin/configurations/security/CustomAuthenticationEntryPoint.java
+++ b/src/main/java/com/xcong/excoin/configurations/security/CustomAuthenticationEntryPoint.java
@@ -1,6 +1,7 @@
 package com.xcong.excoin.configurations.security;
 
 import com.fasterxml.jackson.databind.ObjectMapper;
+import com.xcong.excoin.common.contants.AppContants;
 import com.xcong.excoin.common.response.Result;
 import org.springframework.security.core.AuthenticationException;
 import org.springframework.security.web.AuthenticationEntryPoint;
@@ -19,10 +20,19 @@
 
     @Override
     public void commence(HttpServletRequest httpServletRequest, HttpServletResponse response, AuthenticationException e) throws IOException, ServletException {
-        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);
+        String timeOut = response.getHeader("TimeOut");
+        if (AppContants.TIME_OUT.equals(timeOut)) {
+            Result result = Result.timeOut("Time Out");
+            response.setCharacterEncoding("UTF-8");
+            response.setContentType("application/json; charset=utf-8");
+            response.getWriter().write(new ObjectMapper().writeValueAsString(result));
+            response.setStatus(HttpServletResponse.SC_REQUEST_TIMEOUT);
+        } else {
+            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