Browse Source

add 对接方式

GITZYY 4 months ago
parent
commit
a32a4fc807
20 changed files with 882 additions and 67 deletions
  1. 4 0
      egress-gateway-service-domain/pom.xml
  2. 5 15
      egress-gateway-service-domain/src/main/java/com/hrsk/cloud/eg/domain/api/channel/customized/threedocking/impl/HengYangJiuZhenCreditService.java
  3. 7 9
      egress-gateway-service-domain/src/main/java/com/hrsk/cloud/eg/domain/api/channel/customized/threedocking/impl/HongShengJinFuCreditService.java
  4. 8 10
      egress-gateway-service-domain/src/main/java/com/hrsk/cloud/eg/domain/api/channel/customized/threedocking/impl/HuirongCrmCreditService.java
  5. 84 16
      egress-gateway-service-domain/src/main/java/com/hrsk/cloud/eg/domain/api/channel/customized/threedocking/impl/HuixinCreditService.java
  6. 1 0
      egress-gateway-service-domain/src/main/java/com/hrsk/cloud/eg/domain/api/channel/customized/threedocking/impl/XveYiRongCreditService.java
  7. 0 3
      egress-gateway-service-domain/src/main/java/com/hrsk/cloud/eg/domain/api/channel/customized/threedocking/impl/YiBangDaiCreditService.java
  8. 3 9
      egress-gateway-service-domain/src/main/java/com/hrsk/cloud/eg/domain/api/channel/customized/threedocking/impl/YiLianRongCreditService.java
  9. 1 0
      egress-gateway-service-domain/src/main/java/com/hrsk/cloud/eg/domain/api/channel/customized/threedocking/impl/YiQiHuaCreditService.java
  10. 1 2
      egress-gateway-service-domain/src/main/java/com/hrsk/cloud/eg/domain/api/channel/customized/threedocking/impl/YourongCreditService.java
  11. 1 0
      egress-gateway-service-domain/src/main/java/com/hrsk/cloud/eg/domain/api/channel/guide/resolver/vo/BasicTypeValueObjectResolver.java
  12. 1 0
      egress-gateway-service-domain/src/main/java/com/hrsk/cloud/eg/domain/api/channel/guide/resolver/vo/SpelValueObjectResolver.java
  13. 2 1
      egress-gateway-service-domain/src/main/java/com/hrsk/cloud/eg/domain/api/resolver/result/ApiJsonResultResolver.java
  14. 1 2
      egress-gateway-service-domain/src/main/java/com/hrsk/cloud/eg/domain/api/resolver/vo/ValueObjectResolverManager.java
  15. 95 0
      egress-gateway-service-domain/src/main/java/com/hrsk/cloud/eg/domain/common/AESUtilPkcs7.java
  16. 108 0
      egress-gateway-service-domain/src/main/java/com/hrsk/cloud/eg/domain/common/SM3Util.java
  17. 267 0
      egress-gateway-service-domain/src/main/java/com/hrsk/cloud/eg/domain/common/SM4Util.java
  18. 258 0
      egress-gateway-service-domain/src/main/java/com/hrsk/cloud/eg/domain/common/UserNameUtil.java
  19. 29 0
      egress-gateway-service-domain/src/main/java/com/hrsk/cloud/eg/domain/common/UserUtils.java
  20. 6 0
      pom.xml

+ 4 - 0
egress-gateway-service-domain/pom.xml

@@ -85,5 +85,9 @@
             <groupId>org.apache.commons</groupId>
             <artifactId>commons-io</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.bouncycastle</groupId>
+            <artifactId>bcprov-jdk15on</artifactId>
+        </dependency>
     </dependencies>
 </project>

+ 5 - 15
egress-gateway-service-domain/src/main/java/com/hrsk/cloud/eg/domain/api/channel/customized/threedocking/impl/HengYangJiuZhenCreditService.java

@@ -6,27 +6,21 @@ import com.hrsk.cloud.eg.client.dto.RedisSetDto;
 import com.hrsk.cloud.eg.client.dto.plan.command.EgLoanApiConfigInfoCmd;
 import com.hrsk.cloud.eg.client.dto.user.command.UserBaseInfoCmd;
 import com.hrsk.cloud.eg.client.vo.DataVo;
-import com.hrsk.cloud.eg.clinet.vo.DataVo;
 import com.hrsk.cloud.eg.client.dto.plan.command.PlanCmd;
 
 import com.hrsk.cloud.eg.domain.api.channel.customized.common.ServerCodeEnums;
 import com.hrsk.cloud.eg.domain.api.channel.customized.threedocking.LoanDockingApi;
 import com.hrsk.cloud.eg.domain.api.channel.guide.http.HttpApiRequest;
+import com.hrsk.cloud.eg.domain.api.channel.guide.http.HttpApiRequestConfig;
 import com.hrsk.cloud.eg.domain.api.channel.guide.http.HttpApiResponse;
+import com.hrsk.cloud.eg.domain.common.HeadsUtil;
 import com.hrsk.cloud.eg.domain.common.HessianUtils;
-import com.hrsk.cloud.eg.infrastructure.config.client.HessianUtils;
-import com.hrsk.cloud.eg.infrastructure.loanMannager.threedocking.LoanDockingApi;
-import com.hrsk.cloud.eg.infrastructure.service.EgApiService;
 import lombok.Data;
 import lombok.extern.slf4j.Slf4j;
-import org.springframework.http.HttpEntity;
-import org.springframework.http.HttpHeaders;
-import org.springframework.http.MediaType;
 import org.springframework.stereotype.Component;
 import org.springframework.util.LinkedMultiValueMap;
 import org.springframework.util.MultiValueMap;
 
-import javax.annotation.Resource;
 import java.util.Collections;
 
 /**
@@ -90,16 +84,12 @@ public class HengYangJiuZhenCreditService implements LoanDockingApi {
             params.put("phone", Collections.singletonList(userInfo.getUserMobileMD5()));
             params.put("source", Collections.singletonList(config.getString("source")));
             params.put("city", Collections.singletonList(userInfo.getCityAllName()));
-            HttpHeaders headers = new HttpHeaders();
-            headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
-            HttpEntity<MultiValueMap<String, String>> httpEntity = new HttpEntity<>(params, headers);
-
-
+            HttpApiRequest httpApiRequest=new HttpApiRequest(HttpApiRequestConfig.postRequest(String.valueOf(params),"post",url, HeadsUtil.getFromHeaders(null,null)));
             log.info("credit qualityCheck HengYangJiuZhenCreditService request userId:{}, url:{}, params:{}", userInfo.getUserId(), url, params);
-            String response = null;
+            HttpApiResponse response = null;
             try {
+                 response = httpClientFunc.apply(httpApiRequest);
 //                response =getRestTemplate().postForObject(url,checkInfo, String.class);
-                response = httpRestTemplate.restTemplate().postForEntity(url, httpEntity, String.class).getBody();
             } catch (Exception e) {
                 log.error("衡阳玖臻准入异常,异常信息:{}", e.getMessage(), e);
             }

+ 7 - 9
egress-gateway-service-domain/src/main/java/com/hrsk/cloud/eg/domain/api/channel/customized/threedocking/impl/HongShengJinFuCreditService.java

@@ -1,5 +1,6 @@
 package com.hrsk.cloud.eg.domain.api.channel.customized.threedocking.impl;
 
+import com.alibaba.fastjson2.JSON;
 import com.alibaba.fastjson2.JSONObject;
 import com.google.common.base.Function;
 import com.hrsk.cloud.eg.client.dto.RedisSetDto;
@@ -11,19 +12,17 @@ import com.hrsk.cloud.eg.client.vo.DataVo;
 import com.hrsk.cloud.eg.domain.api.channel.customized.common.ServerCodeEnums;
 import com.hrsk.cloud.eg.domain.api.channel.customized.threedocking.LoanDockingApi;
 import com.hrsk.cloud.eg.domain.api.channel.guide.http.HttpApiRequest;
+import com.hrsk.cloud.eg.domain.api.channel.guide.http.HttpApiRequestConfig;
 import com.hrsk.cloud.eg.domain.api.channel.guide.http.HttpApiResponse;
+import com.hrsk.cloud.eg.domain.common.HeadsUtil;
 import com.hrsk.cloud.eg.domain.common.HessianUtils;
 import com.hrsk.cloud.eg.domain.common.Md5Util;
 import lombok.Data;
 import lombok.extern.slf4j.Slf4j;
-import org.springframework.http.HttpEntity;
-import org.springframework.http.HttpHeaders;
-import org.springframework.http.MediaType;
 import org.springframework.stereotype.Service;
 import org.springframework.util.LinkedMultiValueMap;
 import org.springframework.util.MultiValueMap;
 
-import javax.annotation.Resource;
 
 
 /**
@@ -80,12 +79,11 @@ public class HongShengJinFuCreditService implements LoanDockingApi {
             log.info("弘盛金服开始撞库,请求地址:{},md5:{}", url, phoneMd5);
             MultiValueMap<String, String> params= new LinkedMultiValueMap<String, String>();
             params.add("md5", phoneMd5);
-            String response = null;
+            HttpApiResponse response = null;
             try{
-                HttpHeaders headers = new HttpHeaders();
-                headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
-                HttpEntity<MultiValueMap<String, String>> requestEntity = new HttpEntity<MultiValueMap<String, String>>(params, headers);
-                response = httpRestTemplate.restTemplate().postForEntity(url, requestEntity, String.class).getBody();
+                HttpApiRequest request=new HttpApiRequest(HttpApiRequestConfig.postRequest(String.valueOf(params),"post",url, HeadsUtil.getFromHeaders(null,null)));
+                response = httpClientFunc.apply(request);
+
             } catch (Exception e) {
                 log.error("弘盛金服准入异常,异常信息:{}", e.getMessage(), e);
             }

+ 8 - 10
egress-gateway-service-domain/src/main/java/com/hrsk/cloud/eg/domain/api/channel/customized/threedocking/impl/HuirongCrmCreditService.java

@@ -12,14 +12,13 @@ import com.hrsk.cloud.eg.client.vo.DataVo;
 import com.hrsk.cloud.eg.domain.api.channel.customized.common.ServerCodeEnums;
 import com.hrsk.cloud.eg.domain.api.channel.customized.threedocking.LoanDockingApi;
 import com.hrsk.cloud.eg.domain.api.channel.guide.http.HttpApiRequest;
+import com.hrsk.cloud.eg.domain.api.channel.guide.http.HttpApiRequestConfig;
 import com.hrsk.cloud.eg.domain.api.channel.guide.http.HttpApiResponse;
 import com.hrsk.cloud.eg.domain.common.HessianUtils;
 import com.hrsk.cloud.eg.domain.common.Md5Util;
 import lombok.Data;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
-import org.springframework.http.HttpEntity;
-import org.springframework.http.HttpHeaders;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
@@ -77,13 +76,11 @@ public class HuirongCrmCreditService implements LoanDockingApi {
             checkData.setMerchantNo(product.getBid());
             String requestJson = JSON.toJSONString(checkData);
             log.info("credit qualityCheck HuirongCrmCreditService request userId:{}, url:{},requestParam:{}", userInfo.getUserId(), url, requestJson);
-            ResultHt response = null;
+            HttpApiResponse response = null;
             try {
-               HttpHeaders headers = new HttpHeaders();
-               headers.set("Content-Type", "application/json");
-               HttpEntity httpEntity = new HttpEntity<>(requestJson,headers);
-               //post方式如果出现对接 请求体 为空参考这种方式
-                response = httpRestTemplate.restTemplate().postForObject(url,httpEntity,ResultHt.class);
+               HttpApiRequest httpApiRequest = new HttpApiRequest(HttpApiRequestConfig.postRequest(requestJson,"post",url));
+                response = httpClientFunc.apply(httpApiRequest);
+                //post方式如果出现对接 请求体 为空参考这种方式
               log.info("hui ron result {}",JSONObject.toJSONString(response));
             } catch (Exception e) {
                 log.error("惠融crm准入异常,异常信息:{}", e.getMessage(), e);
@@ -92,10 +89,11 @@ public class HuirongCrmCreditService implements LoanDockingApi {
             if (response == null) {
                 return DataVo.timeout(product.getPlanId(), product.getPlanName());
             }
-            JSONObject data = response.getData();
+
+            JSONObject data =JSONObject.parseObject(response.getData().toString()) ;
             Integer status = data.getInteger("status");
             return Objects.equals(0, status) ? DataVo.success(0, "惠融crm撞库成功", product.getPlanId())
-                    : DataVo.fail(response.getMsg(), product.getPlanId());
+                    : DataVo.fail(data.getString("msg"), product.getPlanId());
         } catch (Exception e) {
             log.error("惠融crm撞库失败", e);
             return DataVo.fail(1, "惠融crm撞库失败,请联系系统管理员", product.getPlanId());

+ 84 - 16
egress-gateway-service-domain/src/main/java/com/hrsk/cloud/eg/domain/api/channel/customized/threedocking/impl/HuixinCreditService.java

@@ -7,25 +7,16 @@ import com.hrsk.cloud.eg.client.dto.plan.command.EgLoanApiConfigInfoCmd;
 import com.hrsk.cloud.eg.client.dto.plan.command.PlanCmd;
 import com.hrsk.cloud.eg.client.dto.user.command.UserBaseInfoCmd;
 import com.hrsk.cloud.eg.client.vo.DataVo;
-import com.hrsk.cloud.eg.clinet.vo.DataVo;
 import com.hrsk.cloud.eg.domain.api.channel.customized.common.ServerCodeEnums;
 import com.hrsk.cloud.eg.domain.api.channel.customized.threedocking.LoanDockingApi;
 import com.hrsk.cloud.eg.domain.api.channel.guide.http.HttpApiRequest;
+import com.hrsk.cloud.eg.domain.api.channel.guide.http.HttpApiRequestConfig;
 import com.hrsk.cloud.eg.domain.api.channel.guide.http.HttpApiResponse;
 import com.hrsk.cloud.eg.domain.common.HessianUtils;
-import com.hrsk.cloud.eg.infrastructure.config.client.HessianUtils;
-import com.hrsk.cloud.eg.infrastructure.loanMannager.threedocking.LoanDockingApi;
-import com.hrsk.cloud.eg.infrastructure.service.EgApiService;
-import com.hrsk.cloud.eg.infrastructure.utils.StringDecodeUtils;
 import lombok.Data;
 import lombok.extern.slf4j.Slf4j;
-import org.springframework.http.HttpEntity;
-import org.springframework.http.HttpHeaders;
-import org.springframework.http.MediaType;
-import org.springframework.http.ResponseEntity;
 import org.springframework.stereotype.Component;
 
-import javax.annotation.Resource;
 import java.util.Objects;
 
 /**
@@ -107,12 +98,10 @@ public class HuixinCreditService implements LoanDockingApi {
             String url = huiXinJointDTO.getString("url") + qualityCheckPath;
             log.info("credit qualityCheck HuixinCreditService request userId:{}, url:{}, data:{}", userInfo.getUserId(), url, param);
 
-            ResponseEntity<String> response = null;
+            HttpApiResponse response = null;
             try {
-                HttpHeaders headers = new HttpHeaders();
-                headers.setContentType(MediaType.valueOf("application/json;UTF-8"));
-                HttpEntity<ResultHt> entity = new HttpEntity(param, headers);
-                response = httpRestTemplate.restTemplate().postForEntity(url, entity, String.class);
+                HttpApiRequest httpApiRequest=new HttpApiRequest(HttpApiRequestConfig.postRequest(JSONObject.toJSONString(param),"post",url));
+                response = httpClientFunc.apply(httpApiRequest);
             } catch (Exception e) {
                 log.error("汇鑫准入异常,异常信息:{}", e.getMessage(), e);
             }
@@ -122,7 +111,8 @@ public class HuixinCreditService implements LoanDockingApi {
                 return DataVo.timeout(product.getPlanId(), product.getPlanName());
             }
 
-            JSONObject jsonObject = JSONObject.parseObject(StringDecodeUtils.decodeUnicode(response.getBody()));
+
+            JSONObject jsonObject = JSONObject.parseObject(decodeUnicode(JSONObject.toJSONString(response.getData())));
 
             return Objects.equals(200, jsonObject.getInteger("code")) && Objects.equals("true", jsonObject.getString("status")) ?
                     DataVo.success(0, "汇鑫撞库成功", product.getPlanId())
@@ -133,4 +123,82 @@ public class HuixinCreditService implements LoanDockingApi {
         }
 
     }
+    /**
+     * unicode转汉字
+     *
+     * @param @param  theString
+     * @param @return 设定文件
+     * @return String 返回类型
+     * @throws
+     * @Title: decodeUnicode
+     * @Description:
+     */
+    public static String decodeUnicode(String theString) {
+        char aChar;
+        int len = theString.length();
+        StringBuffer outBuffer = new StringBuffer(len);
+        for (int x = 0; x < len; ) {
+            aChar = theString.charAt(x++);
+            if (aChar == '\\') {
+                aChar = theString.charAt(x++);
+                if (aChar == 'u') {
+                    int value = 0;
+                    for (int i = 0; i < 4; i++) {
+                        aChar = theString.charAt(x++);
+                        switch (aChar) {
+                            case '0':
+                            case '1':
+                            case '2':
+                            case '3':
+                            case '4':
+                            case '5':
+                            case '6':
+                            case '7':
+                            case '8':
+                            case '9':
+                                value = (value << 4) + aChar - '0';
+                                break;
+                            case 'a':
+                            case 'b':
+                            case 'c':
+                            case 'd':
+                            case 'e':
+                            case 'f':
+                                value = (value << 4) + 10 + aChar - 'a';
+                                break;
+                            case 'A':
+                            case 'B':
+                            case 'C':
+                            case 'D':
+                            case 'E':
+                            case 'F':
+                                value = (value << 4) + 10 + aChar - 'A';
+                                break;
+                            default:
+                                throw new IllegalArgumentException(
+                                        "Malformed      encoding.");
+                        }
+
+                    }
+                    outBuffer.append((char) value);
+                } else {
+                    if (aChar == 't') {
+                        aChar = '\t';
+                    } else if (aChar == 'r') {
+                        aChar = '\r';
+                    } else if (aChar == 'n') {
+                        aChar = '\n';
+                    } else if (aChar == 'f') {
+                        aChar = '\f';
+                    }
+                    outBuffer.append(aChar);
+                }
+            } else {
+                outBuffer.append(aChar);
+            }
+
+        }
+        return outBuffer.toString();
+
+    }
 }

+ 1 - 0
egress-gateway-service-domain/src/main/java/com/hrsk/cloud/eg/domain/api/channel/customized/threedocking/impl/XveYiRongCreditService.java

@@ -17,6 +17,7 @@ import com.hrsk.cloud.eg.domain.api.channel.guide.http.HttpApiRequest;
 import com.hrsk.cloud.eg.domain.api.channel.guide.http.HttpApiRequestConfig;
 import com.hrsk.cloud.eg.domain.api.channel.guide.http.HttpApiResponse;
 import com.hrsk.cloud.eg.domain.common.HessianUtils;
+import com.hrsk.cloud.eg.domain.common.UserUtils;
 import lombok.Data;
 import lombok.extern.slf4j.Slf4j;
 

+ 0 - 3
egress-gateway-service-domain/src/main/java/com/hrsk/cloud/eg/domain/api/channel/customized/threedocking/impl/YiBangDaiCreditService.java

@@ -20,11 +20,8 @@ import com.hrsk.cloud.eg.domain.common.HessianUtils;
 import com.hrsk.cloud.eg.domain.common.Md5Util;
 import lombok.Data;
 import lombok.extern.slf4j.Slf4j;
-import org.apache.http.HttpResponse;
-import org.apache.http.util.EntityUtils;
 import org.springframework.stereotype.Service;
 
-import javax.annotation.Resource;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;

+ 3 - 9
egress-gateway-service-domain/src/main/java/com/hrsk/cloud/eg/domain/api/channel/customized/threedocking/impl/YiLianRongCreditService.java

@@ -14,17 +14,11 @@ import com.hrsk.cloud.eg.domain.api.channel.customized.threedocking.LoanDockingA
 import com.hrsk.cloud.eg.domain.api.channel.guide.http.HttpApiRequest;
 import com.hrsk.cloud.eg.domain.api.channel.guide.http.HttpApiRequestConfig;
 import com.hrsk.cloud.eg.domain.api.channel.guide.http.HttpApiResponse;
-import com.hrsk.cloud.eg.domain.common.HessianUtils;
-import com.hrsk.cloud.eg.domain.common.Md5Util;
-import com.hrsk.cloud.eg.infrastructure.utils.SM3Util;
-import com.hrsk.cloud.eg.infrastructure.utils.SM4Util;
+import com.hrsk.cloud.eg.domain.common.*;
 import lombok.Data;
 import lombok.extern.slf4j.Slf4j;
-import org.apache.catalina.manager.host.Constants;
-import org.bouncycastle.util.encoders.Base64;
 import org.springframework.stereotype.Service;
-
-import javax.annotation.Resource;
+import  org.bouncycastle.util.encoders.Base64;
 import java.util.*;
 
 /**
@@ -121,7 +115,7 @@ public class YiLianRongCreditService implements LoanDockingApi {
         }
         sb.deleteCharAt(sb.length() - 1);
         try {
-            return Base64.toBase64String(SM3Util.sm3(sb.toString().getBytes(Constants.CHARSET), appSecret.getBytes(Constants.CHARSET)));
+            return Base64.toBase64String(SM3Util.sm3(sb.toString().getBytes("utf-8"), appSecret.getBytes("utf-8")));
         } catch (Exception e) {
             return "";
         }

+ 1 - 0
egress-gateway-service-domain/src/main/java/com/hrsk/cloud/eg/domain/api/channel/customized/threedocking/impl/YiQiHuaCreditService.java

@@ -15,6 +15,7 @@ import com.hrsk.cloud.eg.domain.api.channel.customized.threedocking.LoanDockingA
 import com.hrsk.cloud.eg.domain.api.channel.guide.http.HttpApiRequest;
 import com.hrsk.cloud.eg.domain.api.channel.guide.http.HttpApiRequestConfig;
 import com.hrsk.cloud.eg.domain.api.channel.guide.http.HttpApiResponse;
+import com.hrsk.cloud.eg.domain.common.AESUtilPkcs7;
 import com.hrsk.cloud.eg.domain.common.HessianUtils;
 import lombok.Data;
 import lombok.extern.slf4j.Slf4j;

+ 1 - 2
egress-gateway-service-domain/src/main/java/com/hrsk/cloud/eg/domain/api/channel/customized/threedocking/impl/YourongCreditService.java

@@ -20,10 +20,9 @@ import com.hrsk.cloud.eg.domain.common.HessianUtils;
 import lombok.Data;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.codec.binary.Base64;
-import org.apache.tomcat.util.http.fileupload.IOUtils;
+import org.apache.commons.io.IOUtils;
 import org.springframework.stereotype.Service;
 
-import javax.annotation.Resource;
 import javax.crypto.Cipher;
 import java.io.ByteArrayOutputStream;
 import java.security.*;

+ 1 - 0
egress-gateway-service-domain/src/main/java/com/hrsk/cloud/eg/domain/api/channel/guide/resolver/vo/BasicTypeValueObjectResolver.java

@@ -1,6 +1,7 @@
 package com.hrsk.cloud.eg.domain.api.channel.guide.resolver.vo;
 
 
+import com.hrsk.cloud.eg.domain.api.ApiContext;
 import com.hrsk.cloud.eg.domain.api.channel.guide.common.ValueObject;
 
 /**

+ 1 - 0
egress-gateway-service-domain/src/main/java/com/hrsk/cloud/eg/domain/api/channel/guide/resolver/vo/SpelValueObjectResolver.java

@@ -1,5 +1,6 @@
 package com.hrsk.cloud.eg.domain.api.channel.guide.resolver.vo;
 
+import com.hrsk.cloud.eg.domain.api.ApiContext;
 import com.hrsk.cloud.eg.domain.api.channel.guide.common.ValueObject;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.expression.ExpressionParser;

+ 2 - 1
egress-gateway-service-domain/src/main/java/com/hrsk/cloud/eg/domain/api/resolver/result/ApiJsonResultResolver.java

@@ -1,9 +1,10 @@
 package com.hrsk.cloud.eg.domain.api.resolver.result;
 
-import com.alibaba.cola.exception.BizException;
 import com.google.gson.*;
 import com.hrsk.cloud.eg.domain.api.ApiContext;
 import com.hrsk.cloud.eg.domain.api.ValueObject;
+import com.hrsk.cloud.eg.domain.common.GsonUtils;
+import com.hrsk.pangu.tool.exception.BizException;
 import org.apache.commons.lang3.StringUtils;
 
 import java.util.Map;

+ 1 - 2
egress-gateway-service-domain/src/main/java/com/hrsk/cloud/eg/domain/api/resolver/vo/ValueObjectResolverManager.java

@@ -1,11 +1,10 @@
 package com.hrsk.cloud.eg.domain.api.resolver.vo;
 
-import com.alibaba.cola.exception.BizException;
 import com.google.common.collect.Maps;
 import com.hrsk.cloud.eg.domain.api.ApiContext;
-import com.hrsk.cloud.eg.domain.api.ApiResult;
 import com.hrsk.cloud.eg.domain.api.ValueObject;
 import com.hrsk.cloud.eg.domain.api.common.ValueObjectTypeEnum;
+import com.hrsk.pangu.tool.exception.BizException;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 

+ 95 - 0
egress-gateway-service-domain/src/main/java/com/hrsk/cloud/eg/domain/common/AESUtilPkcs7.java

@@ -0,0 +1,95 @@
+package com.hrsk.cloud.eg.domain.common;
+
+import org.apache.commons.codec.binary.Base64;
+import org.bouncycastle.jce.provider.BouncyCastleProvider;
+
+import javax.crypto.Cipher;
+import javax.crypto.spec.IvParameterSpec;
+import javax.crypto.spec.SecretKeySpec;
+import java.security.Security;
+
+public class AESUtilPkcs7 {
+    /*
+     * 加密用的Key 可以用26个字母和数字组成 使用AES-128-CBC加密模式,key需要为16位。
+     */
+    private static final String key = "nLnE4JFFbF6eAzja";
+    private static final String iv = "EJ9iIPhzB4I5UDfs";
+
+    static{
+        try{
+            Security.addProvider(new BouncyCastleProvider());
+        }catch(Exception e){
+            e.printStackTrace();
+        }
+    }
+
+    /**
+     * @author miracle.qu
+     * @Description AES算法加密明文
+     * @param data 明文
+     * @return 密文
+     */
+    public static String encryptAES(String data,String ekey,String eiv) throws Exception {
+        try {
+
+            Cipher cipher = Cipher.getInstance("AES/CBC/PKCS7Padding");
+
+            SecretKeySpec keyspec = new SecretKeySpec(ekey.getBytes("UTF-8"), "AES");
+            // CBC模式,需要一个向量iv,可增加加密算法的强度
+            IvParameterSpec ivspec = new IvParameterSpec(eiv.getBytes("UTF-8"));
+
+            cipher.init(Cipher.ENCRYPT_MODE, keyspec, ivspec);
+            byte[] encrypted = cipher.doFinal(data.getBytes("UTF-8"));
+            // BASE64做转码。
+            return AESUtilPkcs7.encode(encrypted).trim();
+        } catch (Exception e) {
+            e.printStackTrace();
+            return null;
+        }
+    }
+
+    /**
+     * @author miracle.qu
+     * @Description AES算法解密密文
+     * @param data 密文
+     * @return 明文
+     */
+    public static String decryptAES(String data,String ekey,String eiv) throws Exception {
+        try
+        {
+            //先用base64解密
+            byte[] encrypted1 = AESUtilPkcs7.decode(data);
+
+            Cipher cipher = Cipher.getInstance("AES/CBC/PKCS7Padding");
+            SecretKeySpec keyspec = new SecretKeySpec(ekey.getBytes("UTF-8"), "AES");
+            IvParameterSpec ivspec = new IvParameterSpec(eiv.getBytes("UTF-8"));
+
+            cipher.init(Cipher.DECRYPT_MODE, keyspec, ivspec);
+
+            byte[] original = cipher.doFinal(encrypted1);
+            String originalString = new String(original);
+            return originalString.trim();
+        }
+        catch (Exception e) {
+            e.printStackTrace();
+            return null;
+        }
+    }
+    /**
+     * 编码
+     * @param byteArray
+     * @return
+     */
+    public static String encode(byte[] byteArray) {
+        return new String(new Base64().encode(byteArray));
+    }
+
+    /**
+     * 解码
+     * @param base64EncodedString
+     * @return
+     */
+    public static byte[] decode(String base64EncodedString) {
+        return new Base64().decode(base64EncodedString);
+    }
+}

+ 108 - 0
egress-gateway-service-domain/src/main/java/com/hrsk/cloud/eg/domain/common/SM3Util.java

@@ -0,0 +1,108 @@
+package com.hrsk.cloud.eg.domain.common;
+
+import org.bouncycastle.crypto.digests.SM3Digest;
+import org.bouncycastle.crypto.macs.HMac;
+import org.bouncycastle.crypto.params.KeyParameter;
+import org.bouncycastle.jce.provider.BouncyCastleProvider;
+import org.bouncycastle.pqc.math.linearalgebra.ByteUtils;
+import java.io.UnsupportedEncodingException;
+import java.security.Security;
+import java.util.Arrays;
+import java.util.Objects;
+/**
+ * @author jiwancheng
+ * @date 2020/10/20
+ */
+public class SM3Util {
+    static {
+        Security.addProvider(new BouncyCastleProvider());
+    }
+    /**
+     * 计算SM3摘要值
+     *
+     * @param srcData 原⽂
+     * @return 摘要值,对于SM3算法来说是32字节
+     */
+    public static byte[] hash(byte[] srcData) {
+        SM3Digest digest = new SM3Digest();
+        digest.update(srcData, 0, srcData.length);
+        byte[] hash = new byte[digest.getDigestSize()];
+        digest.doFinal(hash, 0);
+        return hash;
+    }
+    /**
+     * 验证摘要
+     *
+     * @param srcData 原⽂
+     * @param sm3Hash 摘要值
+     * @return 返回true标识验证成功,false标识验证失败
+     */
+    public static boolean verify(byte[] srcData, byte[] sm3Hash) {
+        byte[] newHash = hash(srcData);
+        return Arrays.equals(newHash, sm3Hash);
+    }
+    /**
+     * 计算SM3 Mac值
+     *
+     * @param key
+     * @param srcData
+     * @return
+     */
+    public static String hmac(String key, String srcData) {
+        byte[] hmac = new byte[0];
+        try {
+            hmac = hmac(key.getBytes("utf-8"), srcData.getBytes("utf-8"));
+        } catch (UnsupportedEncodingException e) {
+            e.printStackTrace();
+        }
+        return ByteUtils.toHexString(hmac);
+    }
+    /**
+     * 计算SM3 Mac值
+     *
+     * @param key key值,可以是任意⻓度的字节数组
+     * @param srcData 原⽂
+     * @return Mac值,对于HMac-SM3来说是32字节
+     */
+    public static byte[] hmac(byte[] key, byte[] srcData) {
+        KeyParameter keyParameter = new KeyParameter(key);
+        SM3Digest digest = new SM3Digest();
+        HMac mac = new HMac(digest);
+        mac.init(keyParameter);
+        mac.update(srcData, 0, 1);
+        byte[] result = new byte[mac.getMacSize()];
+        mac.doFinal(result,0);
+        return result;
+    }
+    /**
+     * SM3摘要加密
+     * @param input 需要加密的数据
+     * @param key 密钥
+     * @return 签名
+     **/
+    public static byte[] sm3(byte[] input, byte[] key) {
+        HMac mac = new HMac(new SM3Digest());
+        mac.init(new KeyParameter(key));
+        mac.update(input, 0, input.length);
+        byte[] signByte = new byte[mac.getMacSize()];
+        mac.doFinal(signByte, 0);
+        return signByte;
+    }
+    /**
+     * 判断源数据与加密数据是否⼀致
+     *
+     * @param srcStr 原字符串
+     * @param sm3HexString 16进制字符串
+     * @return 校验结果
+     * @explain 通过验证原数组和⽣成的hash数组是否为同⼀数组,验证2者是否为同⼀数据
+     */
+    public static boolean verifyHmac(String srcStr, String sm3HexString,
+                                     String key) {
+        boolean flag = false;
+        String newHash = hmac(key, srcStr);
+        if (Objects.equals(newHash, sm3HexString)) {
+            flag = true;
+        }
+        return flag;
+    }
+}

+ 267 - 0
egress-gateway-service-domain/src/main/java/com/hrsk/cloud/eg/domain/common/SM4Util.java

@@ -0,0 +1,267 @@
+package com.hrsk.cloud.eg.domain.common;
+
+import org.apache.commons.codec.binary.Hex;
+import org.apache.commons.lang3.StringUtils;
+import org.bouncycastle.jce.provider.BouncyCastleProvider;
+import org.bouncycastle.pqc.math.linearalgebra.ByteUtils;
+import org.bouncycastle.util.encoders.Base64;
+
+import javax.crypto.Cipher;
+import javax.crypto.KeyGenerator;
+import javax.crypto.spec.IvParameterSpec;
+import javax.crypto.spec.SecretKeySpec;
+import java.nio.charset.StandardCharsets;
+import java.security.Key;
+import java.security.SecureRandom;
+import java.security.Security;
+import java.util.Arrays;
+/**
+ * @Author Liu Tao
+ * @Date 2024 03 18 11 56
+ **/
+public class SM4Util {
+    static {
+        Security.addProvider(new BouncyCastleProvider());
+    }
+    public static final String ALGORITHM_NAME = "SM4";
+    private static final String SYSTEM_KEY = "D5AFF760F8A0F095E1268D5EA6A82269";
+    /**
+     * 加密算法/分组加密模式/分组填充⽅式
+     * PKCS5Padding-以8个字节为⼀组进⾏分组加密
+     * 定义分组加密模式使⽤:PKCS5Padding
+     */
+    public static final String ALGORITHM_NAME_ECB_PADDING = "SM4/ECB/PKCS5Padding";
+    private static final String ALGORITHM_CBC_PKCS5PADDING = "SM4/CBC/PKCS5Padding";
+/**
+ * 128-32位16进制;256-64位16进制
+ */
+public static final int DEFAULT_KEY_SIZE = 128;
+    /**
+     * ⾃动⽣成密钥
+     *
+     * @return
+     * @explain
+     */
+    public static String generateKey() {
+        try {
+            byte[] data = generateKey(DEFAULT_KEY_SIZE);
+            return new String(Hex.encodeHex(data, false));
+        } catch (Throwable e) {
+            return null;
+        }
+    }
+    /**
+     * @param keySize
+     * @return
+     * @throws Exception
+     * @explain
+     */
+    public static byte[] generateKey(int keySize) throws Exception {
+        KeyGenerator kg = KeyGenerator.getInstance(ALGORITHM_NAME, BouncyCastleProvider.PROVIDER_NAME);
+        kg.init(keySize, new SecureRandom());
+        return kg.generateKey().getEncoded();
+    }
+    /**
+     * ⽣成ECB暗号
+     *
+     * @param algorithmName 算法名称
+     * @param mode 模式
+     * @param key
+     * @return
+     * @throws Exception
+     * @explain ECB模式(电⼦密码本模式:Electronic codebook)
+     */
+    private static Cipher generateEcbCipher(String algorithmName, int mode, byte[] key) throws Exception {
+        Cipher cipher = Cipher.getInstance(algorithmName, BouncyCastleProvider.PROVIDER_NAME);
+        Key sm4Key = new SecretKeySpec(key, ALGORITHM_NAME);
+        cipher.init(mode, sm4Key);
+        return cipher;
+    }
+    /**
+     * sm4加密
+     *
+     * @param hexKey 16进制密钥(忽略⼤⼩写)
+     * @param paramStr 待加密字符串
+     * @return 返回16进制的加密字符串
+     * @explain 加密模式:ECB
+     * 密⽂⻓度不固定,会随着被加密字符串⻓度的变化⽽变化
+     */
+    public static String encryptEcb(String hexKey, String paramStr) {
+        try {
+            // 16进制字符串-->byte[]
+            byte[] keyData = ByteUtils.fromHexString(hexKey);
+            // String-->byte[]
+            byte[] srcData = paramStr.getBytes("utf-8");
+            // 加密后的数组
+            byte[] cipherArray = encrypt_Ecb_Padding(keyData, srcData);
+            // byte[]-->hexString
+            return ByteUtils.toHexString(cipherArray);
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        }
+    }
+    /**
+     * 将明⽂字符串加密为BASE64
+     *
+     * @param data 要加密的明⽂
+     * @param secretKey 16位密钥
+     * @return 加密后BASE64密⽂
+     * @throws Exception 加密异常
+     */
+    public static String encryptStrToBase64(String data, String secretKey
+    ) throws Exception {
+        return Base64.toBase64String(encrypt(data.getBytes("utf-8"), secretKey));
+    }
+/**
+ * 加密
+ *
+ * @param data 要加密的明⽂
+ * @param secretKey 16位密钥
+ * @return 加密后的密⽂
+ * @throws Exception 加密异常
+ */
+public static byte[] encrypt(byte[] data, String secretKey) throws Exception {
+        return sm4(data, secretKey.getBytes("utf-8"), Cipher.ENCRYPT_MODE);
+    }
+    /**
+     * 将BASE64密⽂解密为明⽂字符串
+     *
+     * @param base64Encrypt 要解密的BASE64密⽂
+     * @param secretKey 16位密钥
+     * @return 解密后的明⽂字符串
+     * @throws Exception 加密异常
+     */
+    public static String decryptBase64ToStr(String base64Encrypt, String
+            secretKey) throws Exception {
+        byte[] decryptByte = decrypt(Base64.decode(base64Encrypt), secretKey);
+        return new String(decryptByte, StandardCharsets.UTF_8);
+    }
+    /**
+     * 解密
+     *
+     * @param data 要解密的密⽂
+     * @param secretKey 16位密钥
+     * @return 解密后的明⽂
+     * @throws Exception 解密异常
+     */
+    public static byte[] decrypt(byte[] data, String secretKey) throws Exception {
+        return sm4(data, secretKey.getBytes("utf-8"), Cipher.DECRYPT_MODE);
+    }
+    /**
+     * SM4对称加解密
+     *
+     * @param input 需要加密或解密的数据
+     * @param key 密钥
+     * @param mode Cipher.ENCRYPT_MODE - 加密;Cipher.DECRYPT_MODE - 解密
+     * @return 密⽂(加密模式)或明⽂(解密模式)
+     * @throws Exception 加解密异常
+     */
+    private static byte[] sm4(byte[] input, byte[] key, int mode) throws
+            Exception{
+        SecretKeySpec sm4Key = new SecretKeySpec(key, ALGORITHM_NAME);
+        Cipher cipher = Cipher.getInstance(ALGORITHM_CBC_PKCS5PADDING, BouncyCastleProvider.PROVIDER_NAME);
+        cipher.init(mode, sm4Key, new IvParameterSpec(new byte[16]));
+        return cipher.doFinal(input);
+    }
+    /**
+     * 加密模式之Ecb
+     *
+     * @param key
+     * @param data
+     * @return
+     * @throws Exception
+     * @explain
+     */
+    public static byte[] encrypt_Ecb_Padding(byte[] key, byte[] data) throws Exception {
+        Cipher cipher = generateEcbCipher(ALGORITHM_NAME_ECB_PADDING, Cipher.ENCRYPT_MODE, key);
+        return cipher.doFinal(data);
+    }
+    /**
+     * sm4解密
+     *
+     * @param hexKey 16进制密钥
+     * @param cipherText 16进制的加密字符串(忽略⼤⼩写)
+     * @return 解密后的字符串
+     * @throws Exception
+     * @explain 解密模式:采⽤ECB
+     */
+    public static String decryptEcb(String hexKey, String cipherText) {
+        // ⽤于接收解密后的字符串
+        String decryptStr = "";
+        // hexString-->byte[]
+        byte[] keyData = ByteUtils.fromHexString(hexKey);
+        // hexString-->byte[]
+        byte[] cipherData = ByteUtils.fromHexString(cipherText);
+        // 解密
+        try {
+            byte[] srcData = decrypt_Ecb_Padding(keyData, cipherData);
+            // byte[]-->String
+            decryptStr = new String(srcData, "utf-8");
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        }
+        return decryptStr;
+    }
+    /**
+     * 解密
+     *
+     * @param key
+     * @param cipherText
+     * @return
+     * @throws Exception
+     * @explain
+     */
+    public static byte[] decrypt_Ecb_Padding(byte[] key, byte[] cipherText) throws Exception {
+        Cipher cipher = generateEcbCipher(ALGORITHM_NAME_ECB_PADDING, Cipher.DECRYPT_MODE, key);
+        return cipher.doFinal(cipherText);
+    }
+    /**
+     * 校验加密前后的字符串是否为同⼀数据
+     *
+     * @param hexKey 16进制密钥(忽略⼤⼩写)
+     * @param cipherText 16进制加密后的字符串
+     * @param paramStr 加密前的字符串
+     * @return 是否为同⼀数据
+     * @throws Exception
+     * @explain
+     */
+    public static boolean verifyEcb(String hexKey, String cipherText, String paramStr) throws Exception {
+        // ⽤于接收校验结果
+        boolean flag = false;
+        // hexString-->byte[]
+        byte[] keyData = ByteUtils.fromHexString(hexKey);
+        // 将16进制字符串转换成数组
+        byte[] cipherData = ByteUtils.fromHexString(cipherText);
+        // 解密
+        byte[] decryptData = decrypt_Ecb_Padding(keyData, cipherData);
+        // 将原字符串转换成byte[]
+        byte[] srcData = paramStr.getBytes("utf-8");
+        // 判断2个数组是否⼀致
+        flag = Arrays.equals(decryptData, srcData);
+        return flag;
+    }
+/**
+ * ⽤系统密钥加密
+ *
+ * @param str
+ * @return
+ */
+public static String encryptSystemKey(String str) {
+    if (StringUtils.isEmpty(str)) {
+        return null;
+    }
+    return SM4Util.encryptEcb(SYSTEM_KEY, str);
+}
+    /**
+     * ⽤系统密钥解密
+     *
+     * @param str
+     * @return
+     */
+    public static String decryptSystemKey(String str) {
+        if (StringUtils.isEmpty(str)) {
+            return null;
+        }
+        return SM4Util.decryptEcb(SYSTEM_KEY, str);
+    }
+ }

+ 258 - 0
egress-gateway-service-domain/src/main/java/com/hrsk/cloud/eg/domain/common/UserNameUtil.java

@@ -0,0 +1,258 @@
+package com.hrsk.cloud.eg.domain.common;
+
+import org.apache.commons.lang3.StringUtils;
+
+import java.util.HashSet;
+import java.util.Set;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * 复姓工具类
+ */
+public class UserNameUtil {
+
+    public static Set<String> DOUBLE_SURNAME_SET = new HashSet<>();
+
+    static {
+        DOUBLE_SURNAME_SET.add("单于");
+        DOUBLE_SURNAME_SET.add("叱干");
+        DOUBLE_SURNAME_SET.add("叱利");
+        DOUBLE_SURNAME_SET.add("车非");
+        DOUBLE_SURNAME_SET.add("车公");
+        DOUBLE_SURNAME_SET.add("车侯");
+        DOUBLE_SURNAME_SET.add("车长");
+        DOUBLE_SURNAME_SET.add("车绵");
+        DOUBLE_SURNAME_SET.add("独孤");
+        DOUBLE_SURNAME_SET.add("大野");
+        DOUBLE_SURNAME_SET.add("独吉");
+        DOUBLE_SURNAME_SET.add("达奚");
+        DOUBLE_SURNAME_SET.add("达官");
+        DOUBLE_SURNAME_SET.add("达仲");
+        DOUBLE_SURNAME_SET.add("达品");
+        DOUBLE_SURNAME_SET.add("哥舒");
+        DOUBLE_SURNAME_SET.add("哥夜");
+        DOUBLE_SURNAME_SET.add("哥翰");
+        DOUBLE_SURNAME_SET.add("哥汗");
+        DOUBLE_SURNAME_SET.add("赫连");
+        DOUBLE_SURNAME_SET.add("呼延");
+        DOUBLE_SURNAME_SET.add("贺兰");
+        DOUBLE_SURNAME_SET.add("黑齿");
+        DOUBLE_SURNAME_SET.add("斛律");
+        DOUBLE_SURNAME_SET.add("斛粟");
+        DOUBLE_SURNAME_SET.add("贺若");
+        DOUBLE_SURNAME_SET.add("贺奴");
+        DOUBLE_SURNAME_SET.add("贺远");
+        DOUBLE_SURNAME_SET.add("贺元");
+        DOUBLE_SURNAME_SET.add("夹谷");
+        DOUBLE_SURNAME_SET.add("吉胡");
+        DOUBLE_SURNAME_SET.add("吉利");
+        DOUBLE_SURNAME_SET.add("吉家");
+        DOUBLE_SURNAME_SET.add("可频");
+        DOUBLE_SURNAME_SET.add("慕容");
+        DOUBLE_SURNAME_SET.add("万俟");
+        DOUBLE_SURNAME_SET.add("万红");
+        DOUBLE_SURNAME_SET.add("万中");
+        DOUBLE_SURNAME_SET.add("抹捻");
+        DOUBLE_SURNAME_SET.add("纳兰");
+        DOUBLE_SURNAME_SET.add("纳西");
+        DOUBLE_SURNAME_SET.add("纳吉");
+        DOUBLE_SURNAME_SET.add("纳罕");
+        DOUBLE_SURNAME_SET.add("纳塞");
+        DOUBLE_SURNAME_SET.add("纳博");
+        DOUBLE_SURNAME_SET.add("纳称");
+        DOUBLE_SURNAME_SET.add("纳勉");
+        DOUBLE_SURNAME_SET.add("普周");
+        DOUBLE_SURNAME_SET.add("仆固");
+        DOUBLE_SURNAME_SET.add("仆散");
+        DOUBLE_SURNAME_SET.add("蒲察");
+        DOUBLE_SURNAME_SET.add("屈突");
+        DOUBLE_SURNAME_SET.add("屈卢");
+        DOUBLE_SURNAME_SET.add("钳耳");
+        DOUBLE_SURNAME_SET.add("是云");
+        DOUBLE_SURNAME_SET.add("索卢");
+        DOUBLE_SURNAME_SET.add("厍狄");
+        DOUBLE_SURNAME_SET.add("拓跋");
+        DOUBLE_SURNAME_SET.add("同蹄");
+        DOUBLE_SURNAME_SET.add("秃发");
+        DOUBLE_SURNAME_SET.add("完颜");
+        DOUBLE_SURNAME_SET.add("完明");
+        DOUBLE_SURNAME_SET.add("完忠");
+        DOUBLE_SURNAME_SET.add("宇文");
+        DOUBLE_SURNAME_SET.add("尉迟");
+        DOUBLE_SURNAME_SET.add("耶律");
+        DOUBLE_SURNAME_SET.add("耶红");
+        DOUBLE_SURNAME_SET.add("也先");
+        DOUBLE_SURNAME_SET.add("耶鲜");
+        DOUBLE_SURNAME_SET.add("耶闻");
+        DOUBLE_SURNAME_SET.add("长孙");
+        DOUBLE_SURNAME_SET.add("长南");
+        DOUBLE_SURNAME_SET.add("长北");
+        DOUBLE_SURNAME_SET.add("长西");
+        DOUBLE_SURNAME_SET.add("长红");
+        DOUBLE_SURNAME_SET.add("长元");
+        DOUBLE_SURNAME_SET.add("长秋");
+        DOUBLE_SURNAME_SET.add("长寸");
+        DOUBLE_SURNAME_SET.add("长李");
+        DOUBLE_SURNAME_SET.add("长云");
+        DOUBLE_SURNAME_SET.add("闻人");
+        DOUBLE_SURNAME_SET.add("巫马");
+        DOUBLE_SURNAME_SET.add("微生");
+        DOUBLE_SURNAME_SET.add("王孙");
+        DOUBLE_SURNAME_SET.add("无庸");
+        DOUBLE_SURNAME_SET.add("夏侯");
+        DOUBLE_SURNAME_SET.add("西门");
+        DOUBLE_SURNAME_SET.add("信平");
+        DOUBLE_SURNAME_SET.add("鲜于");
+        DOUBLE_SURNAME_SET.add("轩辕");
+        DOUBLE_SURNAME_SET.add("相里");
+        DOUBLE_SURNAME_SET.add("新垣");
+        DOUBLE_SURNAME_SET.add("徐离");
+        DOUBLE_SURNAME_SET.add("羊舌");
+        DOUBLE_SURNAME_SET.add("羊角");
+        DOUBLE_SURNAME_SET.add("延陵");
+        DOUBLE_SURNAME_SET.add("於陵");
+        DOUBLE_SURNAME_SET.add("伊祁");
+        DOUBLE_SURNAME_SET.add("吾丘");
+        DOUBLE_SURNAME_SET.add("乐正");
+        DOUBLE_SURNAME_SET.add("只斤");
+        DOUBLE_SURNAME_SET.add("诸葛");
+        DOUBLE_SURNAME_SET.add("颛孙");
+        DOUBLE_SURNAME_SET.add("仲孙");
+        DOUBLE_SURNAME_SET.add("仲长");
+        DOUBLE_SURNAME_SET.add("钟离");
+        DOUBLE_SURNAME_SET.add("宗政");
+        DOUBLE_SURNAME_SET.add("主父");
+        DOUBLE_SURNAME_SET.add("中叔");
+        DOUBLE_SURNAME_SET.add("左人");
+        DOUBLE_SURNAME_SET.add("左丘");
+        DOUBLE_SURNAME_SET.add("宰父");
+        DOUBLE_SURNAME_SET.add("长儿");
+        DOUBLE_SURNAME_SET.add("仉督");
+        DOUBLE_SURNAME_SET.add("百里");
+        DOUBLE_SURNAME_SET.add("北堂");
+        DOUBLE_SURNAME_SET.add("北野");
+        DOUBLE_SURNAME_SET.add("北宫");
+        DOUBLE_SURNAME_SET.add("辟闾");
+        DOUBLE_SURNAME_SET.add("孛尔");
+        DOUBLE_SURNAME_SET.add("淳于");
+        DOUBLE_SURNAME_SET.add("成公");
+        DOUBLE_SURNAME_SET.add("陈生");
+        DOUBLE_SURNAME_SET.add("褚师");
+        DOUBLE_SURNAME_SET.add("端木");
+        DOUBLE_SURNAME_SET.add("东方");
+        DOUBLE_SURNAME_SET.add("东郭");
+        DOUBLE_SURNAME_SET.add("东野");
+        DOUBLE_SURNAME_SET.add("东门");
+        DOUBLE_SURNAME_SET.add("第五");
+        DOUBLE_SURNAME_SET.add("大狐");
+        DOUBLE_SURNAME_SET.add("段干");
+        DOUBLE_SURNAME_SET.add("段阳");
+        DOUBLE_SURNAME_SET.add("带曰");
+        DOUBLE_SURNAME_SET.add("第二");
+        DOUBLE_SURNAME_SET.add("东宫");
+        DOUBLE_SURNAME_SET.add("公孙");
+        DOUBLE_SURNAME_SET.add("公冶");
+        DOUBLE_SURNAME_SET.add("公羊");
+        DOUBLE_SURNAME_SET.add("公良");
+        DOUBLE_SURNAME_SET.add("公西");
+        DOUBLE_SURNAME_SET.add("公孟");
+        DOUBLE_SURNAME_SET.add("高堂");
+        DOUBLE_SURNAME_SET.add("高阳");
+        DOUBLE_SURNAME_SET.add("公析");
+        DOUBLE_SURNAME_SET.add("公肩");
+        DOUBLE_SURNAME_SET.add("公坚");
+        DOUBLE_SURNAME_SET.add("郭公");
+        DOUBLE_SURNAME_SET.add("谷梁");
+        DOUBLE_SURNAME_SET.add("毌将");
+        DOUBLE_SURNAME_SET.add("公乘");
+        DOUBLE_SURNAME_SET.add("毌丘");
+        DOUBLE_SURNAME_SET.add("公户");
+        DOUBLE_SURNAME_SET.add("公广");
+        DOUBLE_SURNAME_SET.add("公仪");
+        DOUBLE_SURNAME_SET.add("公祖");
+        DOUBLE_SURNAME_SET.add("皇甫");
+        DOUBLE_SURNAME_SET.add("黄龙");
+        DOUBLE_SURNAME_SET.add("胡母");
+        DOUBLE_SURNAME_SET.add("何阳");
+        DOUBLE_SURNAME_SET.add("夹谷");
+        DOUBLE_SURNAME_SET.add("九方");
+        DOUBLE_SURNAME_SET.add("即墨");
+        DOUBLE_SURNAME_SET.add("梁丘");
+        DOUBLE_SURNAME_SET.add("闾丘");
+        DOUBLE_SURNAME_SET.add("洛阳");
+        DOUBLE_SURNAME_SET.add("陵尹");
+        DOUBLE_SURNAME_SET.add("冷富");
+        DOUBLE_SURNAME_SET.add("龙丘");
+        DOUBLE_SURNAME_SET.add("令狐");
+        DOUBLE_SURNAME_SET.add("林彭");
+        DOUBLE_SURNAME_SET.add("南宫");
+        DOUBLE_SURNAME_SET.add("南郭");
+        DOUBLE_SURNAME_SET.add("女娲");
+        DOUBLE_SURNAME_SET.add("南伯");
+        DOUBLE_SURNAME_SET.add("南容");
+        DOUBLE_SURNAME_SET.add("南门");
+        DOUBLE_SURNAME_SET.add("南野");
+        DOUBLE_SURNAME_SET.add("欧阳");
+        DOUBLE_SURNAME_SET.add("欧侯");
+        DOUBLE_SURNAME_SET.add("濮阳");
+        DOUBLE_SURNAME_SET.add("青阳");
+        DOUBLE_SURNAME_SET.add("漆雕");
+        DOUBLE_SURNAME_SET.add("亓官");
+        DOUBLE_SURNAME_SET.add("渠丘");
+        DOUBLE_SURNAME_SET.add("壤驷");
+        DOUBLE_SURNAME_SET.add("上官");
+        DOUBLE_SURNAME_SET.add("少室");
+        DOUBLE_SURNAME_SET.add("少叔");
+        DOUBLE_SURNAME_SET.add("司徒");
+        DOUBLE_SURNAME_SET.add("司马");
+        DOUBLE_SURNAME_SET.add("司空");
+        DOUBLE_SURNAME_SET.add("司寇");
+        DOUBLE_SURNAME_SET.add("士孙");
+        DOUBLE_SURNAME_SET.add("申屠");
+        DOUBLE_SURNAME_SET.add("申徒");
+        DOUBLE_SURNAME_SET.add("申鲜");
+        DOUBLE_SURNAME_SET.add("申叔");
+        DOUBLE_SURNAME_SET.add("夙沙");
+        DOUBLE_SURNAME_SET.add("叔先");
+        DOUBLE_SURNAME_SET.add("叔仲");
+        DOUBLE_SURNAME_SET.add("侍其");
+        DOUBLE_SURNAME_SET.add("叔孙");
+        DOUBLE_SURNAME_SET.add("澹台");
+        DOUBLE_SURNAME_SET.add("太史");
+        DOUBLE_SURNAME_SET.add("太叔");
+        DOUBLE_SURNAME_SET.add("太公");
+        DOUBLE_SURNAME_SET.add("屠岸");
+        DOUBLE_SURNAME_SET.add("唐古");
+    }
+
+    public static String parseUserFirstName(String userName){
+        if(StringUtils.isBlank(userName)){
+            return userName;
+        }
+        if(userName.length() > 2){
+            String firstName = userName.substring(0, 2);
+            if (DOUBLE_SURNAME_SET.contains(firstName)) {
+                return firstName;
+            }else{
+                return getFirstWord(userName);
+            }
+        }
+        return userName.substring(0,1);
+    }
+
+    public static String getFirstWord(String name){
+        return name.substring(0,1);
+    }
+
+    public static boolean checkChineseName(String name){
+        if(null == name || StringUtils.isBlank(name)){
+            return true;
+        }
+        String regex = "^[\u4e00-\u9fa5·]{2,12}$";
+        Pattern pattern = Pattern.compile(regex);
+        Matcher matcher = pattern.matcher(name);
+        return matcher.matches();
+    }
+
+}

+ 29 - 0
egress-gateway-service-domain/src/main/java/com/hrsk/cloud/eg/domain/common/UserUtils.java

@@ -0,0 +1,29 @@
+package com.hrsk.cloud.eg.domain.common;
+
+import org.apache.commons.lang3.StringUtils;
+
+/**
+ * @Descrption
+ * @Author: chend
+ * @Date: 2023/4/7
+ * @Version V1.0
+ **/
+public class UserUtils {
+
+    public static String getUserName(String realName,String sex){
+        if(StringUtils.isBlank(realName) || StringUtils.isBlank(sex)){
+            return realName;
+        }
+        String firstName=realName.substring(0, 1);
+        if(realName.startsWith("诸葛")||
+                realName.startsWith("上官")||
+                realName.startsWith("欧阳")||
+                realName.startsWith("东方")||
+                realName.startsWith("公孙")||
+                realName.startsWith("司马")){
+            firstName=realName.substring(0, 2);
+        }
+        return "男".equals(sex)? firstName + "先生":firstName + "女士";
+    }
+
+}

+ 6 - 0
pom.xml

@@ -29,6 +29,7 @@
         <fast2-json>2.0.25</fast2-json>
         <redis.version>2.7.1</redis.version>
         <commons-io.version>1.3.2</commons-io.version>
+        <bouncycastle.version>1.56</bouncycastle.version>
     </properties>
 
     <dependencies>
@@ -157,6 +158,11 @@
                 <artifactId>commons-io</artifactId>
                 <version>${commons-io.version}</version>
             </dependency>
+                    <dependency>
+                        <groupId>org.bouncycastle</groupId>
+                        <artifactId>bcprov-jdk15on</artifactId>
+                        <version>${bouncycastle.version}</version>
+                    </dependency>
         </dependencies>
     </dependencyManagement>