From 560be817c1342d4da523760ba38433c4c0f52983 Mon Sep 17 00:00:00 2001
From: liujie <1793218484@qq.com>
Date: 星期二, 12 五月 2026 10:56:09 +0800
Subject: [PATCH] Merge branch '1.1' 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