From c5c4d075e58f2d2d98d462ef14c99a9373518994 Mon Sep 17 00:00:00 2001 From: owan Date: Fri, 8 Nov 2024 16:39:15 +0800 Subject: [PATCH] =?UTF-8?q?EOSS=E5=8D=95=E7=82=B9=E7=99=BB=E5=BD=95?= =?UTF-8?q?=E5=88=9D=E7=A8=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/shkd/sys/sys/eoss/AuthService.java | 3 +- .../shkd/sys/sys/eoss/SSOPluginLogin.java | 44 ++++++++++--------- 2 files changed, 24 insertions(+), 23 deletions(-) diff --git a/sys/shkd-sys-sys/src/main/java/shkd/sys/sys/eoss/AuthService.java b/sys/shkd-sys-sys/src/main/java/shkd/sys/sys/eoss/AuthService.java index 60f45d2..2958b89 100644 --- a/sys/shkd-sys-sys/src/main/java/shkd/sys/sys/eoss/AuthService.java +++ b/sys/shkd-sys-sys/src/main/java/shkd/sys/sys/eoss/AuthService.java @@ -59,8 +59,7 @@ public class AuthService { * @return */ public static String getUserInfo(String token,String eoss_ip,String client_id,String client_secret){ -// SystemParamServiceHelper.getP - logger.info("getUserInfo→请求地址:%s", token); + logger.info("getUserInfo→请求token:%s", token); HttpHeaders api_headers = new HttpHeaders();//请求头 api_headers.add("Content-Type", "application/json; charset=utf-8"); HashMap requestBody = new HashMap<>(); diff --git a/sys/shkd-sys-sys/src/main/java/shkd/sys/sys/eoss/SSOPluginLogin.java b/sys/shkd-sys-sys/src/main/java/shkd/sys/sys/eoss/SSOPluginLogin.java index 96f722b..31c7016 100644 --- a/sys/shkd-sys-sys/src/main/java/shkd/sys/sys/eoss/SSOPluginLogin.java +++ b/sys/shkd-sys-sys/src/main/java/shkd/sys/sys/eoss/SSOPluginLogin.java @@ -64,30 +64,32 @@ public class SSOPluginLogin implements ThirdSSOAuthHandler { if (StringUtils.isEmpty(code)){ logger.error("getTrdSSOAuth→统一认证授权码为空"); result.setSucess(false); - } - try { - //TODO:调用accessToken方法 - String data = AuthService.accessToken(code,EOSS_IP,CLIENT_ID,CLIENT_SECRET); - logger.info(String.format("accessToken返回数据:%s",data)); - //TODO:调用getUserInfo方法 - String access_token = JSON.parseObject(data).getString("access_token"); - String user = AuthService.getUserInfo(access_token,EOSS_IP,CLIENT_ID,CLIENT_SECRET); - logger.info(String.format("getUserInfo返回数据:%s",user)); + }else { + try { + //TODO:调用accessToken方法 + String data = AuthService.accessToken(code, EOSS_IP, CLIENT_ID, CLIENT_SECRET); + logger.info(String.format("accessToken返回数据:%s", data)); - JSONObject jsonObject = JSON.parseObject(user); - JSONObject loginUser = jsonObject.getJSONObject("data"); - String loginName = loginUser.getString("loginName");//登录账户 - String userName = loginUser.getString("Nm");//用户姓名 - if(loginName!=null){ - //当前返回类型手机,用户名,email,工号 - result.setUserType(UserName); - result.setUser(loginName); - result.setSucess(true); + //TODO:调用getUserInfo方法 + String access_token = JSON.parseObject(data).getString("access_token"); + String user = AuthService.getUserInfo(access_token, EOSS_IP, CLIENT_ID, CLIENT_SECRET); + logger.info(String.format("getUserInfo返回数据:%s", user)); + + JSONObject jsonObject = JSON.parseObject(user); + JSONObject loginUser = jsonObject.getJSONObject("data"); + String loginName = loginUser.getString("loginName");//登录账户 + String userName = loginUser.getString("Nm");//用户姓名 + if (loginName != null) { + //当前返回类型手机,用户名,email,工号 + result.setUserType(UserName); + result.setUser(loginName); + result.setSucess(true); + logger.info("SSO用户登录成功,进入苍穹系统"); + } + } catch (Exception e) { + e.printStackTrace(); } - } catch (Exception e) { - e.printStackTrace(); } - logger.info("SSO用户登录成功,进入苍穹系统"); return result; } }