获取code参数代码修改

This commit is contained in:
owan 2024-11-11 13:28:07 +08:00
parent f198d19b1d
commit d94c8b442b
1 changed files with 8 additions and 6 deletions

View File

@ -1,4 +1,4 @@
package shkd.sys.sys.eoss;
package chuantou;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
@ -7,6 +7,7 @@ import kd.bos.logging.LogFactory;
import kd.bos.login.thirdauth.ThirdSSOAuthHandler;
import kd.bos.login.thirdauth.UserAuthResult;
import org.apache.commons.lang3.StringUtils;
import shkd.sys.sys.eoss.AuthService;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@ -15,9 +16,7 @@ import java.io.IOException;
import static kd.bos.login.thirdauth.UserProperType.UserName;
/**
* @program: laxv-cosmic
* @author: Lang
* @create: 2024-09-27 15:48
* @description: 单点登录-川投统一认证
**/
public class SSOPluginLogin implements ThirdSSOAuthHandler {
@ -33,7 +32,6 @@ public class SSOPluginLogin implements ThirdSSOAuthHandler {
*/
@Override
public void callTrdSSOLogin(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, String s) {
s = "http://10.1.7.85:8022/ierp/auth/callbackTrdSSO.do?tenantNo=ctsk-dev&sandboxNo=2063179586270661632";
//认证中心的登录地址
logger.info(String.format("eoss_ip:%s,client_id:%s,client_secret:%s,重定向地址:%s",EOSS_IP,CLIENT_ID,CLIENT_SECRET,s));
try {
@ -42,7 +40,7 @@ public class SSOPluginLogin implements ThirdSSOAuthHandler {
* 获取授权码
*/
String ssourl=String.format("%s/sso2/authCenter/authorize?client_id=%s&response_type=code&authType=0&redirect_uri=%s",
EOSS_IP,CLIENT_ID,EOSS_IP);
EOSS_IP,CLIENT_ID,s);
logger.info(String.format("重定向地址→sendRedirect%s",ssourl));
httpServletResponse.sendRedirect(ssourl);
} catch (IOException e) {
@ -59,7 +57,11 @@ public class SSOPluginLogin implements ThirdSSOAuthHandler {
@Override
public UserAuthResult getTrdSSOAuth(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) {
logger.info(String.format("getTrdSSOAuth→httpServletRequest%s",httpServletRequest));
String code = httpServletRequest.getParameter("code");
//获取返回的授权码
String queryString = httpServletRequest.getQueryString();
JSONObject queryBody = JSON.parseObject(queryString);
logger.info(String.format("getTrdSSOAuth→queryString%s,授权码:%s",queryString, httpServletRequest.getParameter("code")));
String code = queryBody.getString("code");
//返回的认证结果
UserAuthResult result=new UserAuthResult();
if (StringUtils.isEmpty(code)){