新oa待办跳转到待办页面bug修复2
This commit is contained in:
parent
f0c4e59c55
commit
262fa0e47e
|
@ -2,7 +2,6 @@ package shkd.sys.sys.eoss;
|
||||||
|
|
||||||
import kd.bos.cache.CacheFactory;
|
import kd.bos.cache.CacheFactory;
|
||||||
import kd.bos.cache.DistributeSessionlessCache;
|
import kd.bos.cache.DistributeSessionlessCache;
|
||||||
import kd.bos.exception.KDBizException;
|
|
||||||
import kd.bos.logging.Log;
|
import kd.bos.logging.Log;
|
||||||
import kd.bos.logging.LogFactory;
|
import kd.bos.logging.LogFactory;
|
||||||
import kd.bos.login.thirdauth.ThirdSSOAuthHandler;
|
import kd.bos.login.thirdauth.ThirdSSOAuthHandler;
|
||||||
|
@ -57,9 +56,7 @@ public class SSOPluginLogin implements ThirdSSOAuthHandler {
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
queryUrl = Base64.getEncoder().encodeToString(queryUrl.getBytes(StandardCharsets.UTF_8));
|
queryUrl = Base64.getEncoder().encodeToString(queryUrl.getBytes(StandardCharsets.UTF_8));
|
||||||
// String skIp = httpServletRequest.getRemoteAddr();
|
// String skIp = httpServletRequest.getRemo
|
||||||
// String skUrl = httpServletRequest.getRequestURL().toString();
|
|
||||||
// skUrl = skUrl.substring(0, skUrl.indexOf("ierp"));
|
|
||||||
String skUrl = RevProxyUtil.getURLContextPath(httpServletRequest);
|
String skUrl = RevProxyUtil.getURLContextPath(httpServletRequest);
|
||||||
logger.info("获取地址:"+skUrl);
|
logger.info("获取地址:"+skUrl);
|
||||||
String redirect = skUrl+"index.html?param="+queryUrl;
|
String redirect = skUrl+"index.html?param="+queryUrl;
|
||||||
|
@ -112,11 +109,26 @@ public class SSOPluginLogin implements ThirdSSOAuthHandler {
|
||||||
UserAuthResult result = new UserAuthResult();
|
UserAuthResult result = new UserAuthResult();
|
||||||
//获取返回的授权码
|
//获取返回的授权码
|
||||||
String code = httpServletRequest.getParameter("code");
|
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");
|
String param = httpServletRequest.getParameter("param");
|
||||||
|
//解码
|
||||||
if(param!=null){
|
if(param!=null){
|
||||||
byte[] decodedBytes = Base64.getDecoder().decode(param);
|
byte[] decodedBytes = Base64.getDecoder().decode(param);
|
||||||
String paramString = new String(decodedBytes, StandardCharsets.UTF_8);
|
String paramString = new String(decodedBytes, StandardCharsets.UTF_8);
|
||||||
try {
|
try {
|
||||||
|
//二次重定向到待办页面,并且去除EOSS返回的sessionId
|
||||||
httpServletResponse.sendRedirect(httpServletRequest.getRequestURI()+"?"+paramString+"&code="+code);
|
httpServletResponse.sendRedirect(httpServletRequest.getRequestURI()+"?"+paramString+"&code="+code);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
|
@ -124,45 +136,18 @@ public class SSOPluginLogin implements ThirdSSOAuthHandler {
|
||||||
result.setSucess(false);
|
result.setSucess(false);
|
||||||
return result;
|
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);
|
result.setUserType(UserProperType.UserName);
|
||||||
if (StringUtils.isEmpty(code)) {
|
if (StringUtils.isEmpty(code)) {
|
||||||
logger.error("getTrdSSOAuth→授权码code为空");
|
logger.error("getTrdSSOAuth→授权码code为空");
|
||||||
result.setSucess(false);
|
result.setSucess(false);
|
||||||
return result;
|
return result;
|
||||||
} else if (StringUtils.isNotEmpty(code)) {
|
} else if (StringUtils.isNotEmpty(code) && user != null) {
|
||||||
try {
|
//当前返回类型手机,用户名,email,工号
|
||||||
//TODO:调用accessToken方法
|
result.setUserType(UserProperType.UserName);
|
||||||
String access_token = AuthService.accessToken(code, ip, client, secret);
|
result.setUser(user);
|
||||||
logger.info(String.format("accessToken返回数据:%s", access_token));
|
result.setSucess(true);
|
||||||
|
logger.info("SSO用户登录成功,进入苍穹系统");
|
||||||
//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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue