|
@@ -1,16 +1,9 @@
|
|
|
package nckd.jimin.jyyy.bd.common.oauth;
|
|
|
|
|
|
-import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import kd.bos.dataentity.entity.DynamicObject;
|
|
|
import kd.bos.dataentity.entity.DynamicObjectCollection;
|
|
|
-import kd.bos.dataentity.resource.ResManager;
|
|
|
import kd.bos.dc.api.model.Account;
|
|
|
-import kd.bos.entity.AppInfo;
|
|
|
-import kd.bos.entity.AppMetadataCache;
|
|
|
-import kd.bos.entity.param.AppParam;
|
|
|
-import kd.bos.exception.ErrorCode;
|
|
|
-import kd.bos.exception.KDException;
|
|
|
import kd.bos.logging.Log;
|
|
|
import kd.bos.logging.LogFactory;
|
|
|
import kd.bos.login.thirdauth.app.AppAuthResult;
|
|
@@ -20,14 +13,9 @@ import kd.bos.orm.query.QCP;
|
|
|
import kd.bos.orm.query.QFilter;
|
|
|
import kd.bos.sdk.util.KHttpClientUtils;
|
|
|
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
|
|
-import kd.bos.servicehelper.parameter.SystemParamServiceHelper;
|
|
|
-import kd.bos.workflow.exception.WFErrorCode;
|
|
|
-import kd.bos.workflow.exception.WFMessageServiceException;
|
|
|
-import nckd.jimin.jyyy.bd.plugin.msg.ecology.HttpUtils;
|
|
|
import org.apache.commons.codec.binary.Base64;
|
|
|
import org.apache.commons.lang3.ObjectUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
-
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import java.io.IOException;
|
|
|
import java.util.HashMap;
|
|
@@ -78,7 +66,7 @@ public class FanWeiSSOAuthtication extends ThirdAppAuthtication {
|
|
|
if (ObjectUtils.isEmpty(commonParam)) {
|
|
|
logger.info("FanWeiSSOAuthtication:nckd_commonparams is null");
|
|
|
|
|
|
- result.setErrorMessage("FanWeiSSOAuthtication:未配置泛微相关参数");
|
|
|
+ result.setErrorMessage("FanWeiSSOAuthtication:未配置泛微相关参数nckd_commonparams");
|
|
|
return result;
|
|
|
}
|
|
|
|
|
@@ -96,47 +84,74 @@ public class FanWeiSSOAuthtication extends ThirdAppAuthtication {
|
|
|
if(StringUtils.isEmpty(userUrl)){
|
|
|
logger.info("FanWeiSSOAuthtication:getuserinfo is null");
|
|
|
|
|
|
- result.setErrorMessage("FanWeiSSOAuthtication:未配置泛微相关参数");
|
|
|
+ result.setErrorMessage("FanWeiSSOAuthtication:未配置泛微相关参数getuserinfo");
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ String privateKey = mapentity.get("privatekey");
|
|
|
+ if(StringUtils.isEmpty(userUrl)){
|
|
|
+ logger.info("FanWeiSSOAuthtication:privatekey is null");
|
|
|
+
|
|
|
+ result.setErrorMessage("FanWeiSSOAuthtication:未配置泛微相关参数privatekey");
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
+ String syscode = mapentity.get("syscode");
|
|
|
+ if(StringUtils.isEmpty(syscode)){
|
|
|
+ logger.info("FanWeiSSOAuthtication:syscode is null");
|
|
|
+
|
|
|
+ result.setErrorMessage("FanWeiSSOAuthtication:未配置泛微相关参数syscode");
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ String isDecode = mapentity.get("isdecode");
|
|
|
+
|
|
|
String ssouser_dev = mapentity.get("ssouser_dev");
|
|
|
String user = "";
|
|
|
|
|
|
-// String apiResult = "";
|
|
|
-//
|
|
|
-// Map<String, String> header = new HashMap<>();
|
|
|
-// header.put("Content-Type", "application/json; charset=UTF-8");
|
|
|
-//
|
|
|
-// //获取token
|
|
|
-// try {
|
|
|
-// userUrl = userUrl + "?eteams_token=" + token;
|
|
|
-// logger.info("获取泛微用户url:" + userUrl);
|
|
|
-//
|
|
|
-// apiResult = KHttpClientUtils.postjson(userUrl, header, null);
|
|
|
-// } catch (IOException e) {
|
|
|
-// logger.info(e.getMessage());
|
|
|
-//
|
|
|
-// logger.info("FanWeiSSOAuthtication:getuserinfo fail");
|
|
|
-//
|
|
|
-// result.setErrorMessage("FanWeiSSOAuthtication:获取用户异常" + e.getMessage());
|
|
|
-// return result;
|
|
|
-// }
|
|
|
-//
|
|
|
-// if(kd.bos.util.StringUtils.isEmpty(apiResult)){
|
|
|
-// logger.info("FanWeiSSOAuthtication:getuserinfo fail");
|
|
|
-//
|
|
|
-// result.setErrorMessage("FanWeiSSOAuthtication:获取用户异常");
|
|
|
-// return result;
|
|
|
-// }
|
|
|
-//
|
|
|
-// JSONObject userInfo = JSONObject.parseObject(apiResult);
|
|
|
-// if(userInfo.get("mobile") == null){
|
|
|
-// logger.info("FanWeiSSOAuthtication:getuserinfo fail");
|
|
|
-//
|
|
|
-// result.setErrorMessage("FanWeiSSOAuthtication:获取用户异常");
|
|
|
-// return result;
|
|
|
-// }
|
|
|
+ String apiResult = "";
|
|
|
+
|
|
|
+ Map<String, String> header = new HashMap<>();
|
|
|
+ header.put("Content-Type", "application/json; charset=UTF-8");
|
|
|
+
|
|
|
+ //获取token
|
|
|
+ try {
|
|
|
+ userUrl = userUrl + "?eteam_token=" + token + "&xybs=" + syscode;
|
|
|
+
|
|
|
+ logger.info("获取泛微用户url:" + userUrl);
|
|
|
+
|
|
|
+ apiResult = KHttpClientUtils.postjson(userUrl, header, "{}");
|
|
|
+ } catch (IOException e) {
|
|
|
+ logger.info(e.getMessage());
|
|
|
+
|
|
|
+ logger.info("FanWeiSSOAuthtication:getuserinfo fail");
|
|
|
+
|
|
|
+ result.setErrorMessage("FanWeiSSOAuthtication:获取用户异常" + e.getMessage());
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ if(kd.bos.util.StringUtils.isEmpty(apiResult)){
|
|
|
+ logger.info("FanWeiSSOAuthtication:getuserinfo fail");
|
|
|
+
|
|
|
+ result.setErrorMessage("FanWeiSSOAuthtication:获取用户异常");
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ String userJSONString = "";
|
|
|
+ if(isDecode != null && "true".equals(isDecode)) {
|
|
|
+ userJSONString = new String(RSAUtils.decryptByKey(RSAUtils.getPrivateKey(Base64.decodeBase64(privateKey))
|
|
|
+ , Base64.decodeBase64(apiResult.getBytes("UTF-8"))));
|
|
|
+ }
|
|
|
+
|
|
|
+ JSONObject userInfo = JSONObject.parseObject(userJSONString);
|
|
|
+ if(userInfo.get("jobNum") == null){
|
|
|
+ logger.info("FanWeiSSOAuthtication:getuserinfo fail");
|
|
|
+
|
|
|
+ result.setErrorMessage("FanWeiSSOAuthtication:获取用户异常");
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ user = userInfo.getString("jobNum");
|
|
|
|
|
|
if(StringUtils.isNotEmpty(ssouser_dev)){
|
|
|
user = ssouser_dev;
|