新oa待办跳转到待办页面bug修复3
This commit is contained in:
parent
262fa0e47e
commit
fecc86a5f5
|
@ -50,10 +50,18 @@ public class SSOPluginLogin implements ThirdSSOAuthHandler {
|
||||||
client = CLIENT_ID;
|
client = CLIENT_ID;
|
||||||
secret = CLIENT_SECRET;
|
secret = CLIENT_SECRET;
|
||||||
}
|
}
|
||||||
if(queryUrl.contains("code")){
|
String ssourl = ip + "/service/SGE-project-sctz-master/pc/dist/login.html";
|
||||||
// httpServletResponse.sendRedirect(ssourl);
|
//图标登录到首页
|
||||||
|
if(!queryUrl.contains("yzjShareOpen.do")){
|
||||||
|
try {
|
||||||
|
//重定向的统一认证的地址 获取授权码
|
||||||
|
ssourl = String.format("%s/sso2/authCenter/authorize?client_id=%s&response_type=code&sessionKeep=true&authType=0&redirect_uri=%s",
|
||||||
|
ip, client, s);
|
||||||
|
logger.info(String.format("重定向地址→sendRedirect:%s", ssourl));
|
||||||
|
httpServletResponse.sendRedirect(ssourl);
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
}else{
|
}else{
|
||||||
queryUrl = Base64.getEncoder().encodeToString(queryUrl.getBytes(StandardCharsets.UTF_8));
|
queryUrl = Base64.getEncoder().encodeToString(queryUrl.getBytes(StandardCharsets.UTF_8));
|
||||||
// String skIp = httpServletRequest.getRemo
|
// String skIp = httpServletRequest.getRemo
|
||||||
|
@ -62,13 +70,12 @@ public class SSOPluginLogin implements ThirdSSOAuthHandler {
|
||||||
String redirect = skUrl+"index.html?param="+queryUrl;
|
String redirect = skUrl+"index.html?param="+queryUrl;
|
||||||
//认证中心的登录地址
|
//认证中心的登录地址
|
||||||
logger.info(String.format("eoss_ip:%s,client_id:%s,client_secret:%s,重定向地址:%s", ip, client, secret, s));
|
logger.info(String.format("eoss_ip:%s,client_id:%s,client_secret:%s,重定向地址:%s", ip, client, secret, s));
|
||||||
String ssourl = ip + "/service/SGE-project-sctz-master/pc/dist/login.html";
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (httpServletRequest.getRequestURI().contains("/auth/logout.do")) {
|
if (httpServletRequest.getRequestURI().contains("/auth/logout.do")) {
|
||||||
String userName = UserServiceHelper.getCurrentUser("name").getString("name");
|
String userName = UserServiceHelper.getCurrentUser("name").getString("name");
|
||||||
DistributeSessionlessCache cache = CacheFactory.getCommonCacheFactory().getDistributeSessionlessCache("customRegion");
|
DistributeSessionlessCache cache = CacheFactory.getCommonCacheFactory().getDistributeSessionlessCache("customRegion");
|
||||||
String userKey = "user_sessionId_" + userName; // 构造一个唯一的键
|
String userKey = "user_sessionId_" + userName; // 构造存储sessionId的键
|
||||||
String sessionId = cache.get(userKey);
|
String sessionId = cache.get(userKey);
|
||||||
if (sessionId != null) {
|
if (sessionId != null) {
|
||||||
AuthService.logout(ip, sessionId);
|
AuthService.logout(ip, sessionId);
|
||||||
|
@ -104,33 +111,34 @@ public class SSOPluginLogin implements ThirdSSOAuthHandler {
|
||||||
client = CLIENT_ID;
|
client = CLIENT_ID;
|
||||||
secret = CLIENT_SECRET;
|
secret = CLIENT_SECRET;
|
||||||
}
|
}
|
||||||
|
|
||||||
//返回的认证结果
|
//返回的认证结果
|
||||||
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));
|
logger.info(String.format("getTrdSSOAuth→授权码code:%s", code));
|
||||||
//获取返回的 sessionId
|
|
||||||
String sessionId = httpServletRequest.getParameter("sessionId");
|
|
||||||
logger.info(String.format("getTrdSSOAuth→sessionId:%s", sessionId));
|
|
||||||
//调用EOSS获取token接口
|
//调用EOSS获取token接口
|
||||||
String access_token = AuthService.accessToken(code, ip, client, secret);
|
String access_token = AuthService.accessToken(code, ip, client, secret);
|
||||||
logger.info(String.format("accessToken返回数据:%s", access_token));
|
logger.info(String.format("accessToken返回数据:%s", access_token));
|
||||||
//调用EOSS获取用户信息接口
|
//调用EOSS获取用户信息接口
|
||||||
String user = AuthService.getUserInfo(access_token, ip, client, secret);
|
String user = AuthService.getUserInfo(access_token, ip, client, secret);
|
||||||
logger.info(String.format("getUserInfo返回数据:%s", user));
|
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
|
//获取返回的 sessionId
|
||||||
|
String sessionId = httpServletRequest.getParameter("sessionId");
|
||||||
|
logger.info(String.format("getTrdSSOAuth→sessionId:%s", sessionId));
|
||||||
|
String userKey = "user_sessionId_" + user;
|
||||||
|
//存储sessionId用于退出系统
|
||||||
|
DistributeSessionlessCache cache = CacheFactory.getCommonCacheFactory().getDistributeSessionlessCache("customRegion");
|
||||||
|
cache.put(userKey, sessionId);
|
||||||
|
//二次重定向到待办页面,并且不携带EOSS返回的sessionId
|
||||||
httpServletResponse.sendRedirect(httpServletRequest.getRequestURI()+"?"+paramString+"&code="+code);
|
httpServletResponse.sendRedirect(httpServletRequest.getRequestURI()+"?"+paramString+"&code="+code);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
logger.error("二次重定向到待办页面异常!"+e.getMessage());
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
result.setSucess(false);
|
result.setSucess(false);
|
||||||
|
|
Loading…
Reference in New Issue