两套单点登录+两套系统待办跳转bug修复4
This commit is contained in:
		
							parent
							
								
									308edcc188
								
							
						
					
					
						commit
						5305ef9c68
					
				| 
						 | 
				
			
			@ -56,40 +56,32 @@ public class SSOPluginLogin implements ThirdSSOAuthHandler {
 | 
			
		|||
        logger.info(String.format("eoss_ip:%s,client_id:%s,client_secret:%s,重定向地址:%s", ip, client, secret, s));
 | 
			
		||||
        String queryUrlNew = Base64.getEncoder().encodeToString(queryUrlOld.getBytes(StandardCharsets.UTF_8));
 | 
			
		||||
        String redirect = skIP + "/index.html?param=" + queryUrlNew;
 | 
			
		||||
        logger.info(String.format("callTrdSSOLogin→redirect:%s", queryUrlOld));
 | 
			
		||||
        if(queryUrlOld.contains("code")){
 | 
			
		||||
        logger.info(String.format("callTrdSSOLogin→redirect:%s", redirect));
 | 
			
		||||
        if (queryUrlOld.contains("code")) {
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
        String ssourl;
 | 
			
		||||
        String ssoUrl;
 | 
			
		||||
 | 
			
		||||
        try {
 | 
			
		||||
            logger.info(String.format("callTrdSSOLogin→true/false:%s", queryUrlOld.contains("wf_approvalpage")));
 | 
			
		||||
            //非待办登录到首页
 | 
			
		||||
            if (queryUrlOld.contains("wf_approvalpage")) {
 | 
			
		||||
                //待办跳转相关逻辑处理
 | 
			
		||||
                logger.info("callTrdSSOLogin→skip:" + redirect);
 | 
			
		||||
                //重定向的统一认证的地址 获取授权码
 | 
			
		||||
                ssourl = String.format("%s/sso2/authCenter/authorize?client_id=%s&response_type=code&sessionKeep=true&authType=0&redirect_uri=%s",
 | 
			
		||||
                        ip, client, redirect);
 | 
			
		||||
            //退出系统
 | 
			
		||||
            if (httpServletRequest.getRequestURI().contains("/auth/logout.do")) {
 | 
			
		||||
                String userName = UserServiceHelper.getCurrentUser("name").getString("name");
 | 
			
		||||
                DistributeSessionlessCache cache = CacheFactory.getCommonCacheFactory().getDistributeSessionlessCache("customRegion");
 | 
			
		||||
                String userKey = "user_sessionId_" + userName; // 构造存储sessionId的键
 | 
			
		||||
                String sessionId = cache.get(userKey);
 | 
			
		||||
                if (sessionId != null) {
 | 
			
		||||
                    AuthService.logout(ip, sessionId);
 | 
			
		||||
                }
 | 
			
		||||
                //退出系统跳转到eoss登录页
 | 
			
		||||
                ssoUrl = ip + "/service/SGE-project-sctz-master/pc/dist/login.html";
 | 
			
		||||
            } else {
 | 
			
		||||
                //重定向到eoss统一认证的地址 获取授权码code
 | 
			
		||||
                ssourl = String.format("%s/sso2/authCenter/authorize?client_id=%s&response_type=code&sessionKeep=true&authType=0&redirect_uri=%s",
 | 
			
		||||
                ssoUrl = String.format("%s/sso2/authCenter/authorize?client_id=%s&response_type=code&sessionKeep=true&authType=0&redirect_uri=%s",
 | 
			
		||||
                        ip, client, redirect);
 | 
			
		||||
                //退出系统
 | 
			
		||||
                if (httpServletRequest.getRequestURI().contains("/auth/logout.do")) {
 | 
			
		||||
                    String userName = UserServiceHelper.getCurrentUser("name").getString("name");
 | 
			
		||||
                    DistributeSessionlessCache cache = CacheFactory.getCommonCacheFactory().getDistributeSessionlessCache("customRegion");
 | 
			
		||||
                    String userKey = "user_sessionId_" + userName; // 构造存储sessionId的键
 | 
			
		||||
                    String sessionId = cache.get(userKey);
 | 
			
		||||
                    if (sessionId != null) {
 | 
			
		||||
                        AuthService.logout(ip, sessionId);
 | 
			
		||||
                    }
 | 
			
		||||
                    //退出系统跳转到eoss登录页
 | 
			
		||||
                    ssourl = ip + "/service/SGE-project-sctz-master/pc/dist/login.html";
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            logger.info(String.format("callTrdSSOLogin→→sendRedirect:%s", ssourl));
 | 
			
		||||
            httpServletResponse.sendRedirect(ssourl);
 | 
			
		||||
            logger.info(String.format("callTrdSSOLogin→→sendRedirect:%s", ssoUrl));
 | 
			
		||||
            httpServletResponse.sendRedirect(ssoUrl);
 | 
			
		||||
        } catch (IOException e) {
 | 
			
		||||
            throw new RuntimeException(e);
 | 
			
		||||
        }
 | 
			
		||||
| 
						 | 
				
			
			@ -127,19 +119,19 @@ public class SSOPluginLogin implements ThirdSSOAuthHandler {
 | 
			
		|||
        String sessionId = httpServletRequest.getParameter("sessionId");
 | 
			
		||||
        logger.info(String.format("getTrdSSOAuth→sessionId:%s", sessionId));
 | 
			
		||||
        //解码
 | 
			
		||||
        if(StringUtils.isNotEmpty(param) ){
 | 
			
		||||
        if (StringUtils.isNotEmpty(param)) {
 | 
			
		||||
            byte[] decodedBytes = Base64.getDecoder().decode(param);
 | 
			
		||||
            String paramString = new String(decodedBytes, StandardCharsets.UTF_8);
 | 
			
		||||
            //二次重定向到待办页面,并且修改EOSS返回的sessionId的key值
 | 
			
		||||
            try {
 | 
			
		||||
                httpServletResponse.sendRedirect(httpServletRequest.getRequestURI() + "?" + paramString + "&code=" + code+"&eossSessionId="+sessionId);
 | 
			
		||||
                httpServletResponse.sendRedirect(httpServletRequest.getRequestURI() + "?" + paramString + "&code=" + code + "&eossSessionId=" + sessionId);
 | 
			
		||||
            } catch (IOException e) {
 | 
			
		||||
                logger.info(String.format("getTrdSSOAuth→sendRedirect异常:%s", httpServletRequest.getRequestURI() + "?" + paramString + "&code=" + code+"&eossSessionId="+sessionId));
 | 
			
		||||
                logger.info(String.format("getTrdSSOAuth→sendRedirect异常:%s", httpServletRequest.getRequestURI() + "?" + paramString + "&code=" + code + "&eossSessionId=" + sessionId));
 | 
			
		||||
                throw new RuntimeException(e);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        //二次重定向进入
 | 
			
		||||
        if (StringUtils.isNotEmpty(code) && StringUtils.isEmpty(sessionId) ) {
 | 
			
		||||
        if (StringUtils.isNotEmpty(code) && StringUtils.isEmpty(sessionId)) {
 | 
			
		||||
            //调用EOSS获取token接口
 | 
			
		||||
            String access_token = AuthService.accessToken(code, ip, client, secret);
 | 
			
		||||
            logger.info(String.format("getTrdSSOAuth→accessToken返回数据:%s", access_token));
 | 
			
		||||
| 
						 | 
				
			
			@ -155,7 +147,7 @@ public class SSOPluginLogin implements ThirdSSOAuthHandler {
 | 
			
		|||
            result.setUser(user);
 | 
			
		||||
            result.setSucess(true);
 | 
			
		||||
            logger.info("SSO用户登录成功,进入苍穹系统");
 | 
			
		||||
        }else{
 | 
			
		||||
        } else {
 | 
			
		||||
            result.setSucess(false);
 | 
			
		||||
        }
 | 
			
		||||
        return result;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue