From b7bb5daa5f4ffe1764a363a051a5d6f868168cf9 Mon Sep 17 00:00:00 2001
From: puzhibing <393733352@qq.com>
Date: 星期一, 11 五月 2026 20:56:31 +0800
Subject: [PATCH] Merge branch '1.0' of http://120.76.84.145:10101/gitblit/r/java/Robotaxi into 1.1

---
 xp-robotaxi-common/xp-common-security/src/main/java/com/xiaopeng/common/security/handler/GlobalExceptionHandler.java |   27 ++++++++++++++++++++++++++-
 1 files changed, 26 insertions(+), 1 deletions(-)

diff --git a/xp-robotaxi-common/xp-common-security/src/main/java/com/xiaopeng/common/security/handler/GlobalExceptionHandler.java b/xp-robotaxi-common/xp-common-security/src/main/java/com/xiaopeng/common/security/handler/GlobalExceptionHandler.java
index d5b7ec4..8f71bd9 100644
--- a/xp-robotaxi-common/xp-common-security/src/main/java/com/xiaopeng/common/security/handler/GlobalExceptionHandler.java
+++ b/xp-robotaxi-common/xp-common-security/src/main/java/com/xiaopeng/common/security/handler/GlobalExceptionHandler.java
@@ -1,5 +1,7 @@
 package com.xiaopeng.common.security.handler;
 
+import com.alibaba.fastjson2.JSON;
+import com.alibaba.fastjson2.JSONObject;
 import com.fasterxml.jackson.databind.JsonNode;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.xiaopeng.common.core.constant.HttpStatus;
@@ -13,6 +15,7 @@
 import com.xiaopeng.common.core.utils.StringUtils;
 import com.xiaopeng.common.core.web.domain.AjaxResult;
 import feign.FeignException;
+import org.apache.commons.lang3.RandomStringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -27,6 +30,7 @@
 import org.springframework.web.multipart.MaxUploadSizeExceededException;
 
 import javax.servlet.http.HttpServletRequest;
+import java.util.UUID;
 
 /**
  * 全局异常处理器
@@ -41,6 +45,15 @@
     private String maxFileSize;
     @Value("${spring.servlet.multipart.max-request-size:100MB}")
     private String maxRequestSize;
+
+    @Value("${xiaopeng.xtiger.sso.issuer}")
+    private String issuer;
+
+    @Value("${xiaopeng.xtiger.sso.appId}")
+    private String appId;
+
+    @Value("${xiaopeng.xtiger.sso.serverHost}")
+    private String serverHost;
 
     @Autowired
     private MessageSource messageSource;
@@ -76,7 +89,19 @@
     public AjaxResult notLoginException(NotLoginException e, HttpServletRequest request) {
         String requestURI = request.getRequestURI();
         log.error("请求地址'{}',登录校验失败'{}'", requestURI, e.getMessage());
-        return AjaxResult.error(HttpStatus.UNAUTHORIZED, e.getMessage());
+        String s = UUID.randomUUID().toString();
+        String state1 = s.substring(0, 8) + s.substring(9, 13) + s.substring(14, 18) + s.substring(19, 23) + s.substring(24);
+        String s1 = UUID.randomUUID().toString();
+        String state2 = s1.substring(0, 8) + s.substring(9, 13) + s.substring(14, 18) + s.substring(19, 23) + s.substring(24);
+        String nonce = RandomStringUtils.randomAlphanumeric(6);
+        JSONObject jsonObject = JSON.parseObject("{\n" +
+                "    \"uid\": null,\n" +
+                "    \"username\": null,\n" +
+                "    \"authUrl\": \"" + issuer + "/oidc/auth?scope=openid+profile+offline_access+phone+email&response_type=code&redirect_uri=" + serverHost + "/ssoAuthSdk/callback&state=" + state1 + "&nonce=" + nonce + "&client_id=" + appId + "\",\n" +
+                "    \"logoutUrl\": null,\n" +
+                "    \"callbackUrl\": \"" + serverHost + "/ssoAuthSdk/callback?state=" + state2 + "\"\n" +
+                "  }");
+        return AjaxResult.error(HttpStatus.UNAUTHORIZED, e.getMessage(), jsonObject);
     }
 
     /**

--
Gitblit v1.7.1