新oa待办跳转到待办页面bug修复2

This commit is contained in:
wenlukang1 2025-06-25 17:56:50 +08:00
parent f0c4e59c55
commit 262fa0e47e
1 changed files with 23 additions and 38 deletions

View File

@ -2,7 +2,6 @@ package shkd.sys.sys.eoss;
import kd.bos.cache.CacheFactory;
import kd.bos.cache.DistributeSessionlessCache;
import kd.bos.exception.KDBizException;
import kd.bos.logging.Log;
import kd.bos.logging.LogFactory;
import kd.bos.login.thirdauth.ThirdSSOAuthHandler;
@ -57,9 +56,7 @@ public class SSOPluginLogin implements ThirdSSOAuthHandler {
}else{
queryUrl = Base64.getEncoder().encodeToString(queryUrl.getBytes(StandardCharsets.UTF_8));
// String skIp = httpServletRequest.getRemoteAddr();
// String skUrl = httpServletRequest.getRequestURL().toString();
// skUrl = skUrl.substring(0, skUrl.indexOf("ierp"));
// String skIp = httpServletRequest.getRemo
String skUrl = RevProxyUtil.getURLContextPath(httpServletRequest);
logger.info("获取地址:"+skUrl);
String redirect = skUrl+"index.html?param="+queryUrl;
@ -112,11 +109,26 @@ public class SSOPluginLogin implements ThirdSSOAuthHandler {
UserAuthResult result = new UserAuthResult();
//获取返回的授权码
String code = httpServletRequest.getParameter("code");
logger.info(String.format("getTrdSSOAuth→授权码code%s", code));
//获取返回的 sessionId
String sessionId = httpServletRequest.getParameter("sessionId");
logger.info(String.format("getTrdSSOAuth→sessionId%s", sessionId));
//调用EOSS获取token接口
String access_token = AuthService.accessToken(code, ip, client, secret);
logger.info(String.format("accessToken返回数据%s", access_token));
//调用EOSS获取用户信息接口
String user = AuthService.getUserInfo(access_token, ip, client, secret);
logger.info(String.format("getUserInfo返回数据%s", user));
String userKey = "user_sessionId_" + user;
DistributeSessionlessCache cache = CacheFactory.getCommonCacheFactory().getDistributeSessionlessCache("customRegion");
cache.put(userKey, sessionId);
String param = httpServletRequest.getParameter("param");
//解码
if(param!=null){
byte[] decodedBytes = Base64.getDecoder().decode(param);
String paramString = new String(decodedBytes, StandardCharsets.UTF_8);
try {
//二次重定向到待办页面并且去除EOSS返回的sessionId
httpServletResponse.sendRedirect(httpServletRequest.getRequestURI()+"?"+paramString+"&code="+code);
} catch (IOException e) {
throw new RuntimeException(e);
@ -124,45 +136,18 @@ public class SSOPluginLogin implements ThirdSSOAuthHandler {
result.setSucess(false);
return result;
}
//获取返回的 sessionId
String sessionId = httpServletRequest.getParameter("sessionId");
// String userName = httpServletRequest.getParameter("userName");
// if (userName != null) {
// userName = userName.replace(" ", "+"); // 将空格替换为 +
// }
// logger.info("获取待办链接中参数userName:" + userName);
logger.info(String.format("getTrdSSOAuth→授权码code%s", code));
//二次重定向进入
result.setUserType(UserProperType.UserName);
if (StringUtils.isEmpty(code)) {
logger.error("getTrdSSOAuth→授权码code为空");
result.setSucess(false);
return result;
} else if (StringUtils.isNotEmpty(code)) {
try {
//TODO:调用accessToken方法
String access_token = AuthService.accessToken(code, ip, client, secret);
logger.info(String.format("accessToken返回数据%s", access_token));
//TODO:调用getUserInfo方法
String user = AuthService.getUserInfo(access_token, ip, client, secret);
logger.info(String.format("getUserInfo返回数据%s", user));
if (user != null) {
//当前返回类型手机用户名email工号
result.setUserType(UserProperType.UserName);
result.setUser(user);
result.setSucess(true);
logger.info("SSO用户登录成功进入苍穹系统");
String userKey = "user_sessionId_" + user; // 构造一个唯一的键
DistributeSessionlessCache cache = CacheFactory.getCommonCacheFactory().getDistributeSessionlessCache("customRegion");
cache.put(userKey, sessionId);//将自定义参数加入缓存
}
} catch (Exception e) {
throw new KDBizException("获取用户信息接口异常SSO用户登录失败" + e);
}
} else if (StringUtils.isNotEmpty(code) && user != null) {
//当前返回类型手机用户名email工号
result.setUserType(UserProperType.UserName);
result.setUser(user);
result.setSucess(true);
logger.info("SSO用户登录成功进入苍穹系统");
}
return result;
}