commit
ff69438198
|
@ -8,6 +8,7 @@ import io.swagger.v3.oas.annotations.parameters.RequestBody;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import weaver.hrm.HrmUserVarify;
|
import weaver.hrm.HrmUserVarify;
|
||||||
import weaver.hrm.User;
|
import weaver.hrm.User;
|
||||||
|
import weaver.interfaces.schedule.IpSelectUtil;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
@ -19,6 +20,7 @@ import javax.ws.rs.core.Context;
|
||||||
import javax.ws.rs.core.MediaType;
|
import javax.ws.rs.core.MediaType;
|
||||||
import javax.ws.rs.core.Response;
|
import javax.ws.rs.core.Response;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -35,6 +37,7 @@ public class GetLogController {
|
||||||
|
|
||||||
private final GetLogService service = new GetLogService();
|
private final GetLogService service = new GetLogService();
|
||||||
|
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Path("ipList")
|
@Path("ipList")
|
||||||
@Produces(MediaType.APPLICATION_JSON)
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
|
@ -62,6 +65,21 @@ public class GetLogController {
|
||||||
return Response.ok(ApiResult.error("system error!"), MediaType.APPLICATION_JSON).build();
|
return Response.ok(ApiResult.error("system error!"), MediaType.APPLICATION_JSON).build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@POST
|
||||||
|
@Path("collectAll")
|
||||||
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
|
public String collectAllLogInfo(@Context HttpServletRequest request,
|
||||||
|
@Context HttpServletResponse response,
|
||||||
|
@RequestBody Map<String, Object> params) {
|
||||||
|
try {
|
||||||
|
User loginUser = HrmUserVarify.getUser(request, response);
|
||||||
|
return ApiResult.success(service.collectLogInfoAll(loginUser, params));
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("收集全部日志出错" + Util.getErrString(e));
|
||||||
|
return ApiResult.error("system error!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@POST
|
@POST
|
||||||
|
@ -76,7 +94,7 @@ public class GetLogController {
|
||||||
params.put("ecologyPath", path);
|
params.put("ecologyPath", path);
|
||||||
return ApiResult.success(service.collectLogInfo(loginUser, params));
|
return ApiResult.success(service.collectLogInfo(loginUser, params));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("下载文件出错:" + Util.getErrString(e));
|
log.error("收集单台服务器日志出错:" + Util.getErrString(e));
|
||||||
return ApiResult.error("system error!");
|
return ApiResult.error("system error!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,32 +16,39 @@ import java.util.Map;
|
||||||
* @date 2023/7/1 16:24
|
* @date 2023/7/1 16:24
|
||||||
*/
|
*/
|
||||||
public enum LogTypeEnum {
|
public enum LogTypeEnum {
|
||||||
THREAD(1, "0", "log" + File.separator + "thread","thread"),
|
THREAD(1, "0", "log" + File.separator + "thread","thread",""),
|
||||||
ECOLOGY(1, "1", "log","ecology"),
|
ECOLOGY(1, "1", "log","ecology",""),
|
||||||
RESIN(0, "2", "log","Resin"),
|
RESIN(0, "2", "log","Resin",""),
|
||||||
SECURITY(1, "3","WEB-INF" + File.separator + "securitylog","security"),
|
SECURITY(1, "3","WEB-INF" + File.separator + "securitylog","security",""),
|
||||||
INTEGRATION(1,"4", "log" + File.separator + "integration","integration"),
|
INTEGRATION(1,"4", "log" + File.separator + "integration","integration",""),
|
||||||
SQL(1, "5", "log" + File.separator + "sql","sql"),
|
SQL(1, "5", "log" + File.separator + "sql","sql",""),
|
||||||
UTIL_CUS(1,"6", "log" + File.separator + "cus" + File.separator + "util_cus","util_cus"),
|
UTIL_CUS(1,"6", "log" + File.separator + "cus" + File.separator + "util_cus","util_cus",("util_cus" + File.separator)),
|
||||||
SQL_LOG(1,"7","log" + File.separator + "cus" + File.separator + "sql_log","sql_log"),
|
SQL_LOG(1,"7","log" + File.separator + "cus" + File.separator + "sql_log","sql_log", ("sql_log" + File.separator)),
|
||||||
HTTP_UTIL(1,"8","log" + File.separator + "cus" + File.separator + "http_util","http_util");
|
HTTP_UTIL(1,"8","log" + File.separator + "cus" + File.separator + "http_util","http_util", ("http_util" + File.separator));
|
||||||
private final Integer logBelongType;
|
private final Integer logBelongType;
|
||||||
private final String value;
|
private final String value;
|
||||||
private final String logPath;
|
private final String logPath;
|
||||||
private final String key;
|
private final String key;
|
||||||
LogTypeEnum(Integer logBelongType, String value, String logPath,String key) {
|
private final String zipFolderName;
|
||||||
|
LogTypeEnum(Integer logBelongType, String value, String logPath,String key, String zipFolderName) {
|
||||||
this.logBelongType = logBelongType;
|
this.logBelongType = logBelongType;
|
||||||
this.value = value;
|
this.value = value;
|
||||||
this.logPath = logPath;
|
this.logPath = logPath;
|
||||||
this.key = key;
|
this.key = key;
|
||||||
|
this.zipFolderName = zipFolderName;
|
||||||
}
|
}
|
||||||
public final static Map<String, LogTypeEnum> ENUMS = new HashMap<>(16);
|
public final static Map<String, LogTypeEnum> ENUMS = new HashMap<>(16);
|
||||||
|
public final static Map<String, String> KEY_ZIP_FOLDER = new HashMap<>(16);
|
||||||
static {
|
static {
|
||||||
for (LogTypeEnum typeEnum : EnumSet.allOf(LogTypeEnum.class)){
|
for (LogTypeEnum typeEnum : EnumSet.allOf(LogTypeEnum.class)){
|
||||||
ENUMS.put(typeEnum.value,typeEnum);
|
ENUMS.put(typeEnum.value,typeEnum);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
static {
|
||||||
|
for (LogTypeEnum typeEnum : EnumSet.allOf(LogTypeEnum.class)){
|
||||||
|
KEY_ZIP_FOLDER.put(typeEnum.key, typeEnum.zipFolderName);
|
||||||
|
}
|
||||||
|
}
|
||||||
public String getValue() {
|
public String getValue() {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
@ -55,4 +62,8 @@ public enum LogTypeEnum {
|
||||||
public String getKey() {
|
public String getKey() {
|
||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getZipFolderName() {
|
||||||
|
return zipFolderName;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,16 +1,23 @@
|
||||||
package com.api.ebu7dev1.common.getlog.service;
|
package com.api.ebu7dev1.common.getlog.service;
|
||||||
|
|
||||||
import aiyh.utils.Util;
|
import aiyh.utils.Util;
|
||||||
|
import aiyh.utils.excention.CustomerException;
|
||||||
|
import aiyh.utils.httpUtil.ResponeVo;
|
||||||
|
import aiyh.utils.httpUtil.util.HttpUtils;
|
||||||
|
import com.api.ebu7dev1.common.getlog.util.EcTokenUtil;
|
||||||
import com.api.ebu7dev1.common.getlog.util.GetLogUtil;
|
import com.api.ebu7dev1.common.getlog.util.GetLogUtil;
|
||||||
import org.apache.commons.collections.CollectionUtils;
|
import org.apache.commons.collections.CollectionUtils;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
import weaver.hrm.User;
|
import weaver.hrm.User;
|
||||||
|
|
||||||
|
import javax.ws.rs.core.MediaType;
|
||||||
import javax.ws.rs.core.Response;
|
import javax.ws.rs.core.Response;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.util.List;
|
import java.util.*;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
import static net.qiyuesuo.sdk.bean.template.MimeType.zip;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <h1>获取日志</h1>
|
* <h1>获取日志</h1>
|
||||||
|
@ -24,6 +31,14 @@ public class GetLogService {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private final Logger log = Util.getLogger("cus_get_log");
|
||||||
|
|
||||||
|
private final HttpUtils httpUtils = new HttpUtils();
|
||||||
|
|
||||||
|
{
|
||||||
|
httpUtils.getGlobalCache().header.put("Content-Type", MediaType.APPLICATION_JSON); // 全局请求头
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <h1>获取所有的ip地址</h1>
|
* <h1>获取所有的ip地址</h1>
|
||||||
* @author xuanran.wang
|
* @author xuanran.wang
|
||||||
|
@ -43,8 +58,8 @@ public class GetLogService {
|
||||||
String localIp = GetLogUtil.getInnerIp();
|
String localIp = GetLogUtil.getInnerIp();
|
||||||
Set<String> ipList = GetLogUtil.readEcologyProp(weaverPropertiesPath);
|
Set<String> ipList = GetLogUtil.readEcologyProp(weaverPropertiesPath);
|
||||||
if(CollectionUtils.isEmpty(ipList)){
|
if(CollectionUtils.isEmpty(ipList)){
|
||||||
String resinBinPath = resinPath + "bin" + File.separator + "startresin.sh";
|
String resinBinPath = resinPath + "bin" + File.separator;
|
||||||
ipList.addAll(GetLogUtil.readResinProp(resinBinPath));
|
ipList.addAll(GetLogUtil.readResinProp(resinBinPath + "startresin.sh"));
|
||||||
}
|
}
|
||||||
if (ipList.size() != 0) {//没有集群的时候
|
if (ipList.size() != 0) {//没有集群的时候
|
||||||
boolean status = false;
|
boolean status = false;
|
||||||
|
@ -62,17 +77,80 @@ public class GetLogService {
|
||||||
}
|
}
|
||||||
return ipList;
|
return ipList;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String collectLogInfo(User loginUser, Map<String, Object> params) throws FileNotFoundException {
|
/**
|
||||||
|
* <h1><收集全部节点日志/h1>
|
||||||
|
* @author xuanran.wang
|
||||||
|
* @dateTime 2023/7/3 18:53
|
||||||
|
* @param loginUser 登录人
|
||||||
|
* @param params 参数
|
||||||
|
* @return 全部ip的日志zip路径
|
||||||
|
**/
|
||||||
|
public List<Map<String, String>> collectLogInfoAll(User loginUser, Map<String, Object> params) throws FileNotFoundException {
|
||||||
GetLogUtil.checkUser(loginUser);
|
GetLogUtil.checkUser(loginUser);
|
||||||
String startDate = Util.null2String(params.get("startDate"));
|
List<Map<String, String>> result = new ArrayList<>();
|
||||||
String endDate = Util.null2String(params.get("endDate"));
|
try {
|
||||||
String ecologyPath = Util.null2String(params.get("ecologyPath"));
|
List<String> ipList = (List<String>) params.get("ipList");
|
||||||
List<String> logTypeList = (List<String>) params.get("selectLogType");
|
if(CollectionUtils.isNotEmpty(ipList)){
|
||||||
String resinPath = System.getProperty("user.dir") + File.separator;
|
params.remove("ipList");
|
||||||
List<Map<String, String>> path = GetLogUtil.getLogPathByLogType(ecologyPath, resinPath, logTypeList);
|
for (String ip : ipList) {
|
||||||
Map<String, Map<String, List<String>>> map = GetLogUtil.getLogFilePath(path, startDate, endDate);
|
ip = "http://" + ip;
|
||||||
return GetLogUtil.collectLog(ecologyPath, map);
|
Map<String, String> header;
|
||||||
|
try {
|
||||||
|
header = EcTokenUtil.getEcTokenHeader(ip);
|
||||||
|
}catch (Exception e){
|
||||||
|
throw new CustomerException("获取ec_token失败!", e);
|
||||||
|
}
|
||||||
|
ResponeVo responeVo = httpUtils.apiPost(ip + "/api/ebu7-dev1/common/log/collect", params, header);
|
||||||
|
if(200 != responeVo.getCode()) {
|
||||||
|
log.error("ip : [ " + ip + " ], 收集日志接口网络状态码不为200!");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
Map<String, Object> responseMap = responeVo.getResponseMap();
|
||||||
|
int code = (int) responseMap.get("code");
|
||||||
|
if(200 != code){
|
||||||
|
log.error("ip : [ " + ip + " ], 收集日志接口业务逻辑响应码不为200!");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
List<Map<String, String>> zipPath = (List<Map<String, String>>) responseMap.get("data");
|
||||||
|
if(CollectionUtils.isEmpty(zipPath)){
|
||||||
|
log.error("ip : [ " + ip + " ], 收集日志接口返回压缩包路径为空!");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
result.addAll(zipPath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}catch (Exception e){
|
||||||
|
throw new CustomerException(e);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h1>收集单台ip的日志</h1>
|
||||||
|
* @author xuanran.wang
|
||||||
|
* @dateTime 2023/7/3 18:53
|
||||||
|
* @param loginUser 登录人
|
||||||
|
* @param params 参数
|
||||||
|
* @return 单台ip的zip路径
|
||||||
|
**/
|
||||||
|
public List<Map<String, String>> collectLogInfo(User loginUser, Map<String, Object> params) {
|
||||||
|
GetLogUtil.checkUser(loginUser);
|
||||||
|
try {
|
||||||
|
String startDate = Util.null2String(params.get("startDate"));
|
||||||
|
String endDate = Util.null2String(params.get("endDate"));
|
||||||
|
String ecologyPath = Util.null2String(params.get("ecologyPath"));
|
||||||
|
String resinPath = System.getProperty("user.dir") + File.separator;
|
||||||
|
List<String> logTypeList = (List<String>) params.get("logTypeList");
|
||||||
|
List<Map<String, String>> path = GetLogUtil.getLogPathByLogType(ecologyPath, resinPath, logTypeList);
|
||||||
|
Map<String, Map<String, List<String>>> map = GetLogUtil.getLogFilePath(path, startDate, endDate);
|
||||||
|
Map<String, String> res = GetLogUtil.collectLog(ecologyPath, map);
|
||||||
|
return Collections.singletonList(res);
|
||||||
|
}catch (Exception e){
|
||||||
|
log.error("collectLogInfo error : " + e.getMessage());
|
||||||
|
log.error(Util.getErrString(e));
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,117 @@
|
||||||
|
package com.api.ebu7dev1.common.getlog.util;
|
||||||
|
|
||||||
|
import aiyh.utils.Util;
|
||||||
|
import aiyh.utils.excention.CustomerException;
|
||||||
|
import aiyh.utils.httpUtil.ResponeVo;
|
||||||
|
import aiyh.utils.httpUtil.util.HttpUtils;
|
||||||
|
import cn.hutool.core.util.CharsetUtil;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import cn.hutool.crypto.asymmetric.KeyType;
|
||||||
|
import cn.hutool.crypto.asymmetric.RSA;
|
||||||
|
import cn.hutool.http.HttpRequest;
|
||||||
|
import cn.hutool.json.JSONUtil;
|
||||||
|
import com.icbc.api.internal.apache.http.impl.cookie.S;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h1>ec token util</h1>
|
||||||
|
*
|
||||||
|
* @author xuanran.wang
|
||||||
|
* @date 2023/7/3 19:13
|
||||||
|
*/
|
||||||
|
public class EcTokenUtil {
|
||||||
|
/**
|
||||||
|
* 模拟缓存服务
|
||||||
|
*/
|
||||||
|
private static final Map<String,String> SYSTEM_CACHE = new HashMap<>();
|
||||||
|
/**
|
||||||
|
* ecology系统发放的授权许可证(appid)
|
||||||
|
*/
|
||||||
|
private static final String APPID = "cus_get_log";
|
||||||
|
|
||||||
|
private static final HttpUtils httpUtils = new HttpUtils();
|
||||||
|
|
||||||
|
public static Map<String, String> getEcTokenHeader(String address){
|
||||||
|
Map<String, String> header = new HashMap<>();
|
||||||
|
String token = geToken(address);
|
||||||
|
String spk = SYSTEM_CACHE.get("SERVER_PUBLIC_KEY");
|
||||||
|
//封装请求头参数
|
||||||
|
RSA rsa = new RSA(null,spk);
|
||||||
|
//对用户信息进行加密传输,暂仅支持传输OA用户ID
|
||||||
|
String encryptUserid = rsa.encryptBase64("1",CharsetUtil.CHARSET_UTF_8,KeyType.PublicKey);
|
||||||
|
header.put("appid",APPID);
|
||||||
|
header.put("token",token);
|
||||||
|
header.put("userid",encryptUserid);
|
||||||
|
return header;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void regist(String address){
|
||||||
|
//获取当前系统RSA加密的公钥
|
||||||
|
RSA rsa = new RSA();
|
||||||
|
String publicKey = rsa.getPublicKeyBase64();
|
||||||
|
String privateKey = rsa.getPrivateKeyBase64();
|
||||||
|
// 客户端RSA私钥
|
||||||
|
SYSTEM_CACHE.put("LOCAL_PRIVATE_KEY",privateKey);
|
||||||
|
// 客户端RSA公钥
|
||||||
|
SYSTEM_CACHE.put("LOCAL_PUBLIC_KEY",publicKey);
|
||||||
|
Map<String, String> header = new HashMap<>();
|
||||||
|
header.put("appid",APPID);
|
||||||
|
header.put("cpk",publicKey);
|
||||||
|
try {
|
||||||
|
ResponeVo responeVo = httpUtils.apiPost(address + "/api/ec/dev/auth/regist", new HashMap<>(), header);
|
||||||
|
if(responeVo.getCode() != 200){
|
||||||
|
throw new CustomerException("/api/ec/dev/auth/applytoken 接口网络状态码不为200");
|
||||||
|
}
|
||||||
|
Map<String, Object> map = responeVo.getResponseMap();
|
||||||
|
// 打印ECOLOGY响应信息
|
||||||
|
//ECOLOGY返回的系统公钥
|
||||||
|
SYSTEM_CACHE.put("SERVER_PUBLIC_KEY", StrUtil.nullToEmpty((String)map.get("spk")));
|
||||||
|
//ECOLOGY返回的系统密钥
|
||||||
|
SYSTEM_CACHE.put("SERVER_SECRET",StrUtil.nullToEmpty((String)map.get("secrit")));
|
||||||
|
}catch (Exception e){
|
||||||
|
throw new CustomerException("applytoken error : ",e);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 第二步:
|
||||||
|
*
|
||||||
|
* 通过第一步中注册系统返回信息进行获取token信息
|
||||||
|
*/
|
||||||
|
public static String geToken(String address){
|
||||||
|
// 从系统缓存或者数据库中获取ECOLOGY系统公钥和Secret信息
|
||||||
|
String secret = SYSTEM_CACHE.get("SERVER_SECRET");
|
||||||
|
String spk = SYSTEM_CACHE.get("SERVER_PUBLIC_KEY");
|
||||||
|
// 如果为空,说明还未进行注册,调用注册接口进行注册认证与数据更新
|
||||||
|
if (Objects.isNull(secret)||Objects.isNull(spk)){
|
||||||
|
regist(address);
|
||||||
|
// 重新获取最新ECOLOGY系统公钥和Secret信息
|
||||||
|
secret = SYSTEM_CACHE.get("SERVER_SECRET");
|
||||||
|
spk = SYSTEM_CACHE.get("SERVER_PUBLIC_KEY");
|
||||||
|
}
|
||||||
|
// 公钥加密,所以RSA对象私钥为null
|
||||||
|
RSA rsa = new RSA(null,spk);
|
||||||
|
//对秘钥进行加密传输,防止篡改数据
|
||||||
|
String encryptSecret = rsa.encryptBase64(secret, CharsetUtil.CHARSET_UTF_8, KeyType.PublicKey);
|
||||||
|
Map<String, String> header = new HashMap<>();
|
||||||
|
header.put("appid",APPID);
|
||||||
|
header.put("secret",encryptSecret);
|
||||||
|
//调用ECOLOGY系统接口进行注册
|
||||||
|
try {
|
||||||
|
ResponeVo responeVo = httpUtils.apiPost(address + "/api/ec/dev/auth/applytoken", new HashMap<>(), header);
|
||||||
|
if(responeVo.getCode() != 200){
|
||||||
|
throw new CustomerException("/api/ec/dev/auth/applytoken 接口网络状态码不为200");
|
||||||
|
}
|
||||||
|
Map<String, Object> map = responeVo.getResponseMap();
|
||||||
|
return Util.null2DefaultStr(map.get("token"),"");
|
||||||
|
}catch (Exception e){
|
||||||
|
throw new CustomerException("get token error : ",e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -9,6 +9,7 @@ import java.util.*;
|
||||||
import java.util.zip.ZipEntry;
|
import java.util.zip.ZipEntry;
|
||||||
import java.util.zip.ZipOutputStream;
|
import java.util.zip.ZipOutputStream;
|
||||||
|
|
||||||
|
import aiyh.utils.Util;
|
||||||
import aiyh.utils.excention.CustomerException;
|
import aiyh.utils.excention.CustomerException;
|
||||||
import com.api.ebu7dev1.common.getlog.enums.LogTypeEnum;
|
import com.api.ebu7dev1.common.getlog.enums.LogTypeEnum;
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
|
@ -27,8 +28,6 @@ public class GetLogUtil {
|
||||||
throw new CustomerException("无权限查看!");
|
throw new CustomerException("无权限查看!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <h1>读取ec weaver.properties配置文件 返回集群ip</h1>
|
* <h1>读取ec weaver.properties配置文件 返回集群ip</h1>
|
||||||
*
|
*
|
||||||
|
@ -276,19 +275,26 @@ public class GetLogUtil {
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String collectLog(String ecologyPath, Map<String, Map<String, List<String>>> pathListKeyMap) throws FileNotFoundException {
|
public static Map<String, String> collectLog(String ecologyPath, Map<String, Map<String, List<String>>> pathListKeyMap) throws FileNotFoundException {
|
||||||
|
Map<String, String> result = new HashMap<>();
|
||||||
FileOutputStream fos;
|
FileOutputStream fos;
|
||||||
String outPath = ecologyPath + File.separator + "getlog" + File.separator + "log" + File.separator + (System.currentTimeMillis() / 1000);
|
ecologyPath += File.separator;
|
||||||
|
String mills = String.valueOf((System.currentTimeMillis() / 1000));
|
||||||
|
String res = "getlog" + File.separator + "log" + File.separator + mills;
|
||||||
|
ecologyPath += res;
|
||||||
File outFile = null;
|
File outFile = null;
|
||||||
try {
|
try {
|
||||||
outFile = new File(outPath);
|
outFile = new File(ecologyPath);
|
||||||
if (!outFile.exists()) {
|
if (!outFile.exists()) {
|
||||||
outFile.mkdirs();
|
outFile.mkdirs();
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
String outLogPath = outFile + File.separator + getInnerIp() + "_downLog.zip";
|
String innerIp = getInnerIp();
|
||||||
|
String zipFile = File.separator + innerIp + "_downLog.zip";
|
||||||
|
String outLogPath = outFile + zipFile;
|
||||||
|
res = res + zipFile;
|
||||||
fos = new FileOutputStream(outLogPath);
|
fos = new FileOutputStream(outLogPath);
|
||||||
try {
|
try {
|
||||||
ZipOutputStream zos = new ZipOutputStream(fos);
|
ZipOutputStream zos = new ZipOutputStream(fos);
|
||||||
|
@ -301,34 +307,18 @@ public class GetLogUtil {
|
||||||
String basePath = date + File.separator;
|
String basePath = date + File.separator;
|
||||||
List<String> pathList = pathKeyList.getValue();
|
List<String> pathList = pathKeyList.getValue();
|
||||||
for (String path : pathList) {
|
for (String path : pathList) {
|
||||||
if ("sqllog".equals(key)) {
|
String zipFolder;
|
||||||
basePath += ("sqllog" + File.separator);
|
try {
|
||||||
}
|
zipFolder = LogTypeEnum.KEY_ZIP_FOLDER.get(key);
|
||||||
if ("monitorevent".equals(key)) {
|
}catch (Exception e){
|
||||||
basePath += ("event" + File.separator);
|
Util.getLogger().error("the key = " + key + " not found in LogTypeEnum.KEY_ZIP_FOLDER");
|
||||||
}
|
continue;
|
||||||
if ("monitorlog".equals(key)) {
|
|
||||||
basePath += ("monitorlog" + File.separator);
|
|
||||||
}
|
|
||||||
if (key.equals("cus")) {
|
|
||||||
basePath += ("cus" + File.separator);
|
|
||||||
}
|
|
||||||
if (key.equals("util_cus")) {
|
|
||||||
basePath += ("util_cus" + File.separator);
|
|
||||||
}
|
|
||||||
if (key.equals("sql_log")) {
|
|
||||||
basePath += ("sql_log" + File.separator);
|
|
||||||
}
|
|
||||||
if (key.equals("http_util")) {
|
|
||||||
basePath += ("http_util" + File.separator);
|
|
||||||
}
|
}
|
||||||
|
basePath += zipFolder;
|
||||||
compressbyType(path, zos, basePath);
|
compressbyType(path, zos, basePath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
System.out.println("日志文件地址 : " + outLogPath);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
zos.close();
|
zos.close();
|
||||||
} catch (Exception es) {
|
} catch (Exception es) {
|
||||||
|
@ -338,9 +328,11 @@ public class GetLogUtil {
|
||||||
fos.close();
|
fos.close();
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
Util.getLogger().error("collectLog error ", e);
|
||||||
}
|
}
|
||||||
return outLogPath;
|
result.put("ip", innerIp);
|
||||||
|
result.put("zipPath", res);
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -46,8 +46,8 @@ public class UserUpdateToMQController {
|
||||||
userUpdateToMQService.toMQ(id, onlyMark, configName, debug);
|
userUpdateToMQService.toMQ(id, onlyMark, configName, debug);
|
||||||
return ApiResult.success(null);
|
return ApiResult.success(null);
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
log.error(Util.logStr("MeetingController error ! {}", e.getMessage()));
|
log.error(Util.logStr("updateUserInfoToMQ error ! {}", e.getMessage()));
|
||||||
return ApiResult.error(500,"会议取消接口发生异常! 异常信息 :[ " + e.getMessage() + " ]");
|
return ApiResult.error(500,"用户信息更新! 异常信息 :[ " + e.getMessage() + " ]");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,15 +32,47 @@ public class UserUpdateToMQService {
|
||||||
private static final String HRM_TABLE = "hrmresource";
|
private static final String HRM_TABLE = "hrmresource";
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h1>将人员信息发送到队列中</h1>
|
||||||
|
* @author xuanran.wang
|
||||||
|
* @dateTime 2023/7/3 14:14
|
||||||
|
* @param id 人员id
|
||||||
|
* @param onlyMark 配置唯一标识
|
||||||
|
* @param configName 配置文件名称
|
||||||
|
* @param debug 是否开启debug
|
||||||
|
**/
|
||||||
public void toMQ(String id,
|
public void toMQ(String id,
|
||||||
String onlyMark,
|
String onlyMark,
|
||||||
String configName,
|
String configName,
|
||||||
String debug){
|
String debug){
|
||||||
|
toMQ(id, onlyMark, configName, debug, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h1>将人员信息发送到队列中</h1>
|
||||||
|
* @author xuanran.wang
|
||||||
|
* @dateTime 2023/7/3 14:15
|
||||||
|
* @param id 人员id
|
||||||
|
* @param onlyMark 配置唯一标识
|
||||||
|
* @param configName 配置文件名称
|
||||||
|
* @param debug 是否开启debug
|
||||||
|
* @param otherParams 其他参数
|
||||||
|
**/
|
||||||
|
public void toMQ(String id,
|
||||||
|
String onlyMark,
|
||||||
|
String configName,
|
||||||
|
String debug,
|
||||||
|
Map<String, Object> otherParams){
|
||||||
Map<String, Object> userMap = producerMapper.queryUserInfo(id);
|
Map<String, Object> userMap = producerMapper.queryUserInfo(id);
|
||||||
if(MapUtils.isEmpty(userMap)){
|
if(MapUtils.isEmpty(userMap)){
|
||||||
|
// 2300545611688368314
|
||||||
|
// 2300545891688368314
|
||||||
logger.error(Util.logStr("userId: {}, userInfo is empty!"));
|
logger.error(Util.logStr("userId: {}, userInfo is empty!"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if(MapUtils.isNotEmpty(otherParams)){
|
||||||
|
userMap.putAll(otherParams);
|
||||||
|
}
|
||||||
RequestMappingConfig config = dealWithMapping.treeDealWithUniqueCode(onlyMark);
|
RequestMappingConfig config = dealWithMapping.treeDealWithUniqueCode(onlyMark);
|
||||||
dealWithMapping.setMainTable(HRM_TABLE);
|
dealWithMapping.setMainTable(HRM_TABLE);
|
||||||
Map<String, Object> param = dealWithMapping.getRequestParam(userMap, config);
|
Map<String, Object> param = dealWithMapping.getRequestParam(userMap, config);
|
||||||
|
@ -48,7 +80,7 @@ public class UserUpdateToMQService {
|
||||||
logger.error(Util.logStr("userId:{}, 生成json为空!",id));
|
logger.error(Util.logStr("userId:{}, 生成json为空!",id));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(StringUtils.isNotBlank(debug)){
|
if("1".equals(debug)){
|
||||||
logger.info("update user json : \n" + JSONObject.toJSONString(param));
|
logger.info("update user json : \n" + JSONObject.toJSONString(param));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,135 @@
|
||||||
|
package com.customization.shyl.service.impl;
|
||||||
|
|
||||||
|
import aiyh.utils.Util;
|
||||||
|
import aiyh.utils.excention.CustomerException;
|
||||||
|
import aiyh.utils.zwl.common.ToolUtil;
|
||||||
|
import com.api.xuanran.wang.shyl.service.UserUpdateToMQService;
|
||||||
|
import com.weaverboot.frame.ioc.anno.classAnno.WeaIocReplaceComponent;
|
||||||
|
import com.weaverboot.frame.ioc.anno.methodAnno.WeaReplaceBefore;
|
||||||
|
import com.weaverboot.frame.ioc.handler.replace.weaReplaceParam.impl.WeaBeforeReplaceParam;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import weaver.file.Prop;
|
||||||
|
import weaver.hrm.HrmUserVarify;
|
||||||
|
import weaver.hrm.User;
|
||||||
|
import weaver.rsa.security.RSA;
|
||||||
|
import weaver.xuanran.wang.shyl_mq.util.RocketConsumerUtil;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h1>修改密码后 将密码加密放到队列中</h1>
|
||||||
|
*
|
||||||
|
* @author xuanran.wang
|
||||||
|
* @date 2023/7/3 13:35
|
||||||
|
*/
|
||||||
|
@WeaIocReplaceComponent("UpdateHrmInfoAop")
|
||||||
|
public class UpdateHrmInfoAop {
|
||||||
|
|
||||||
|
private UserUpdateToMQService service = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 人员信息修改后
|
||||||
|
* @param weaBeforeReplaceParam 拦截参数
|
||||||
|
*/
|
||||||
|
@WeaReplaceBefore(value = "/api/hrm/password/changePassword", order = 1, description = "人员信息修改前 进行拦截")
|
||||||
|
public void passwordUpdateBefore(WeaBeforeReplaceParam weaBeforeReplaceParam) {
|
||||||
|
Map paramMap = weaBeforeReplaceParam.getParamMap();
|
||||||
|
String newPassword = Util.null2DefaultStr(paramMap.get("passwordnew"),"");
|
||||||
|
if(StringUtils.isBlank(newPassword)){
|
||||||
|
Util.getLogger().error("下发队列新密码不能为空!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Map<String, String> configMap = getMQConfigMap();
|
||||||
|
HttpServletRequest request = weaBeforeReplaceParam.getRequest();
|
||||||
|
HttpServletResponse response = weaBeforeReplaceParam.getResponse();
|
||||||
|
User user = HrmUserVarify.getUser(request, response);
|
||||||
|
String oaPassWordOnlyMark = configMap.get("oaPassWordOnlyMark");
|
||||||
|
String oaPassWordTopicConfigName = configMap.get("oaPassWordTopicConfigName");
|
||||||
|
String decryPassword = RocketConsumerUtil.encryptContent(newPassword);
|
||||||
|
Map<String, Object> map = new HashMap<>();
|
||||||
|
map.put("decryPassword", decryPassword);
|
||||||
|
service.toMQ(String.valueOf(user.getUID()),oaPassWordOnlyMark, oaPassWordTopicConfigName, configMap.get("sendMQ"), map);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 人员信息修改后
|
||||||
|
* @param weaBeforeReplaceParam 拦截参数
|
||||||
|
*/
|
||||||
|
@WeaReplaceBefore(value = "/api/hrm/systeminfo/save", order = 1, description = "人员信息修改前 进行拦截")
|
||||||
|
public void hrmSave(WeaBeforeReplaceParam weaBeforeReplaceParam) {
|
||||||
|
try {
|
||||||
|
Map<String, String> configMap = getMQConfigMap();
|
||||||
|
String oaPassWordOnlyMark = configMap.get("oaPassWordOnlyMark");
|
||||||
|
String oaPassWordTopicConfigName = configMap.get("oaPassWordTopicConfigName");
|
||||||
|
HttpServletRequest request = weaBeforeReplaceParam.getRequest();
|
||||||
|
if(service == null){
|
||||||
|
service = new UserUpdateToMQService();
|
||||||
|
}
|
||||||
|
String id = Util.null2DefaultStr(request.getParameter("id"),"");
|
||||||
|
if(StringUtils.isBlank(id)){
|
||||||
|
Util.getLogger().error("从接口中获取人员id为空!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 解密后的密码
|
||||||
|
String decryPassword = RocketConsumerUtil.encryptContent(Util.null2DefaultStr(parsePassword(request),""));
|
||||||
|
Map<String, Object> map = new HashMap<>();
|
||||||
|
map.put("decryPassword", decryPassword);
|
||||||
|
if(StringUtils.isBlank(decryPassword)){
|
||||||
|
Util.getLogger().error("解密之后密码为空!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
service.toMQ(id,oaPassWordOnlyMark, oaPassWordTopicConfigName, configMap.get("sendMQ"), map);
|
||||||
|
}catch (Exception e){
|
||||||
|
Util.getLogger().error("/api/hrm/systeminfo/save 拦截前置接口出错! " + e.getMessage());
|
||||||
|
Util.getErrString(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h1>解密请求中的密码</h1>
|
||||||
|
* @author xuanran.wang
|
||||||
|
* @dateTime 2023/7/3 14:10
|
||||||
|
* @param request 请求对象
|
||||||
|
* @return 解密后的数据
|
||||||
|
**/
|
||||||
|
private String parsePassword(HttpServletRequest request){
|
||||||
|
String password = weaver.general.Util.null2String(request.getParameter("password"));
|
||||||
|
String loginId = weaver.general.Util.null2String(request.getParameter("loginid"));
|
||||||
|
boolean isRsa = "1".equals(Prop.getPropValue("openRSA", "isrsaopen"));
|
||||||
|
ArrayList<String> passwordList = new ArrayList<>();
|
||||||
|
if (isRsa) {
|
||||||
|
passwordList.add(password);
|
||||||
|
RSA rsa = new RSA();
|
||||||
|
List list = rsa.decryptList(request, passwordList);
|
||||||
|
return Util.null2DefaultStr(list.get(0),"");
|
||||||
|
}
|
||||||
|
Util.getLogger().info("loginId : [ " + loginId + " ], password : [ " + password + " ]");
|
||||||
|
return password;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h1>获取密码修改队列 配置项</h1>
|
||||||
|
* @author xuanran.wang
|
||||||
|
* @dateTime 2023/7/3 14:59
|
||||||
|
* @return 获取密码修改队列 配置项
|
||||||
|
**/
|
||||||
|
public Map<String, String> getMQConfigMap(){
|
||||||
|
ToolUtil toolUtil = new ToolUtil();
|
||||||
|
String oaPassWordOnlyMark = toolUtil.getSystemParamValue("oaPassWordOnlyMark");
|
||||||
|
String oaPassWordTopicConfigName = toolUtil.getSystemParamValue("oaPassWordTopicConfigName");
|
||||||
|
if(StringUtils.isBlank(oaPassWordOnlyMark) || StringUtils.isBlank(oaPassWordTopicConfigName)){
|
||||||
|
throw new CustomerException("系统参数配置表没配置oaPassWordOnlyMark或者oaPassWordTopicConfigName!");
|
||||||
|
}
|
||||||
|
String sendMQ = Util.null2DefaultStr(toolUtil.getSystemParamValue("sendMQ"), "");
|
||||||
|
Map<String, String> res = new HashMap<>();
|
||||||
|
res.put("oaPassWordOnlyMark", oaPassWordOnlyMark);
|
||||||
|
res.put("oaPassWordTopicConfigName", oaPassWordTopicConfigName);
|
||||||
|
res.put("sendMQ", sendMQ);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
}
|
|
@ -5,6 +5,7 @@ import com.google.common.base.Strings;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
import org.apache.commons.collections.MapUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import weaver.conn.RecordSet;
|
import weaver.conn.RecordSet;
|
||||||
|
@ -783,7 +784,12 @@ public class DealWithMapping extends ToolUtil {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case CUS_FIELD: {
|
case CUS_FIELD: {
|
||||||
value = detailMap.get(valueContext.trim());
|
if(MapUtils.isNotEmpty(mainMap)){
|
||||||
|
value = mainMap.get(valueContext.trim());
|
||||||
|
}
|
||||||
|
if ("1".equals(childSource) && MapUtils.isNotEmpty(detailMap)) {
|
||||||
|
value = detailMap.get(valueContext.trim());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case CUS_MAPPER_SQL: {
|
case CUS_MAPPER_SQL: {
|
||||||
|
|
|
@ -0,0 +1,84 @@
|
||||||
|
package weaver.xuanran.wang.common.interfaces;
|
||||||
|
|
||||||
|
import aiyh.utils.zwl.common.ToolUtil;
|
||||||
|
import weaver.general.TimeUtil;
|
||||||
|
import weaver.xuanran.wang.common.entity.CusSuccess;
|
||||||
|
import weaver.xuanran.wang.common.util.RequestMasterPlate;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h1>抽象token</h1>
|
||||||
|
*
|
||||||
|
* @author xuanran.wang
|
||||||
|
* @date 2023/7/4 10:48
|
||||||
|
*/
|
||||||
|
public abstract class CusAbstractTokenConf {
|
||||||
|
protected final RequestMasterPlate requestMasterPlate = new RequestMasterPlate();
|
||||||
|
protected final ToolUtil toolUtil = new ToolUtil();
|
||||||
|
/**
|
||||||
|
* <h2>token</h2>
|
||||||
|
**/
|
||||||
|
protected String token;
|
||||||
|
/**
|
||||||
|
* <h2>时效时间</h2>
|
||||||
|
**/
|
||||||
|
protected Long expiresIn;
|
||||||
|
/**
|
||||||
|
* <h2>创建时间</h2>
|
||||||
|
**/
|
||||||
|
protected String createTime;
|
||||||
|
/**
|
||||||
|
* <h2>过期时间</h2>
|
||||||
|
**/
|
||||||
|
protected Long expiryTime;
|
||||||
|
/**
|
||||||
|
* <h2>设置token</h2>
|
||||||
|
**/
|
||||||
|
protected abstract String setToken(Map<String, Object> response);
|
||||||
|
/**
|
||||||
|
* <h2>设置时效时间</h2>
|
||||||
|
**/
|
||||||
|
protected abstract Long setExpiresIn(Map<String, Object> response);
|
||||||
|
/**
|
||||||
|
* <h2>设置过期时间</h2>
|
||||||
|
**/
|
||||||
|
protected abstract Long setExpiryTime(Map<String, Object> response);
|
||||||
|
/**
|
||||||
|
* <h2>token接口 成功参数</h2>
|
||||||
|
**/
|
||||||
|
protected abstract CusSuccess buildSuccess();
|
||||||
|
/**
|
||||||
|
* <h2>从http接口获取token</h2>
|
||||||
|
**/
|
||||||
|
public abstract Map<String, Object> tokenByHttp();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h1>为子类设置属性</h1>
|
||||||
|
* @author xuanran.wang
|
||||||
|
* @dateTime 2023/7/4 13:44
|
||||||
|
* @param response 接口响应
|
||||||
|
**/
|
||||||
|
public void buildTokenObj(Map<String, Object> response){
|
||||||
|
this.token = setToken(response);
|
||||||
|
this.expiresIn = setExpiresIn(response);
|
||||||
|
this.expiryTime = setExpiryTime(response);
|
||||||
|
this.createTime = TimeUtil.getCurrentTimeString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getToken(){
|
||||||
|
return this.token;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getExpiresIn() {
|
||||||
|
return expiresIn;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCreateTime() {
|
||||||
|
return createTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getExpiryTime() {
|
||||||
|
return expiryTime;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,15 @@
|
||||||
|
package weaver.xuanran.wang.common.interfaces;
|
||||||
|
|
||||||
|
import aiyh.utils.httpUtil.ResponeVo;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h1>自定义解密类</h1>
|
||||||
|
*
|
||||||
|
* @author xuanran.wang
|
||||||
|
* @date 2023/7/4 10:43
|
||||||
|
*/
|
||||||
|
public interface CusDataDecipher {
|
||||||
|
Map<String, Object> decoder(ResponeVo responeVo);
|
||||||
|
}
|
|
@ -9,8 +9,10 @@ import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import weaver.xuanran.wang.common.entity.CusSuccess;
|
import weaver.xuanran.wang.common.entity.CusSuccess;
|
||||||
|
|
||||||
|
import javax.ws.rs.core.MediaType;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <h1>请求模版方法</h1>
|
* <h1>请求模版方法</h1>
|
||||||
|
@ -51,6 +53,9 @@ public class RequestMasterPlate {
|
||||||
responseVo.getEntityString())); // 相应内容
|
responseVo.getEntityString())); // 相应内容
|
||||||
throw new CustomerException(Util.logStr("can not fetch [{}]", url)); // 自定义异常类 create 2022/3/9 2:20 PM 构建日志字符串
|
throw new CustomerException(Util.logStr("can not fetch [{}]", url)); // 自定义异常类 create 2022/3/9 2:20 PM 构建日志字符串
|
||||||
}
|
}
|
||||||
|
if(Objects.isNull(cusSuccess)){
|
||||||
|
return (T) responseVo.getResponseMap();
|
||||||
|
}
|
||||||
Map<String, Object> response;
|
Map<String, Object> response;
|
||||||
if(cusSuccess.getCusDataDecipher() != null){
|
if(cusSuccess.getCusDataDecipher() != null){
|
||||||
response = cusSuccess.getCusDataDecipher().decoder(responseVo);
|
response = cusSuccess.getCusDataDecipher().decoder(responseVo);
|
||||||
|
|
|
@ -0,0 +1,71 @@
|
||||||
|
package weaver.xuanran.wang.common.util;
|
||||||
|
|
||||||
|
import aiyh.utils.Util;
|
||||||
|
import aiyh.utils.excention.CustomerException;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
import weaver.xuanran.wang.common.interfaces.CusAbstractTokenConf;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h1>全局缓存token 超时自动请求处理</h1>
|
||||||
|
*
|
||||||
|
* @author xuanran.wang
|
||||||
|
* @date 2023/7/4 10:31
|
||||||
|
*/
|
||||||
|
public class TokenUtil {
|
||||||
|
private static final Map<String, CusAbstractTokenConf> TOKEN_MAP = new HashMap<>(8);
|
||||||
|
/**
|
||||||
|
* <h1>从本地缓存中获取token</h1>
|
||||||
|
* @author xuanran.wang
|
||||||
|
* @dateTime 2023/7/4 13:44
|
||||||
|
* @param key 指定key
|
||||||
|
* @param conf token配置对象
|
||||||
|
* @return token
|
||||||
|
**/
|
||||||
|
public static String getToken(String key, CusAbstractTokenConf conf){
|
||||||
|
if(Objects.isNull(conf)){
|
||||||
|
throw new CustomerException("conf cant not be null!");
|
||||||
|
}
|
||||||
|
CusAbstractTokenConf token = TOKEN_MAP.get(key);
|
||||||
|
if(token == null){
|
||||||
|
synchronized (TokenUtil.class){
|
||||||
|
token = TOKEN_MAP.get(key);
|
||||||
|
if(token == null){
|
||||||
|
return getTokenByHttp(key, conf);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
long expiryTime = token.getExpiryTime();
|
||||||
|
if(System.currentTimeMillis() >= expiryTime){
|
||||||
|
synchronized (TokenUtil.class){
|
||||||
|
expiryTime = token.getExpiryTime();
|
||||||
|
if(System.currentTimeMillis() >= expiryTime){
|
||||||
|
return getTokenByHttp(key, conf);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return token.getToken();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h1>发请求获取token</h1>
|
||||||
|
* @author xuanran.wang
|
||||||
|
* @dateTime 2023/7/4 13:45
|
||||||
|
* @param key 缓存标识标识
|
||||||
|
* @param obj token配置对象
|
||||||
|
* @return token
|
||||||
|
**/
|
||||||
|
private static synchronized String getTokenByHttp(String key, CusAbstractTokenConf obj){
|
||||||
|
Map<String, Object> response = obj.tokenByHttp();
|
||||||
|
obj.buildTokenObj(response);
|
||||||
|
TOKEN_MAP.put(key, obj);
|
||||||
|
Util.getLogger().info("TOKEN_MAP : " + JSONObject.toJSONString(TOKEN_MAP));
|
||||||
|
return obj.getToken();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -4,7 +4,7 @@ import lombok.AllArgsConstructor;
|
||||||
import lombok.Builder;
|
import lombok.Builder;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
import weaver.xuanran.wang.sh_bigdata.common.service.CusDataDecipher;
|
import weaver.xuanran.wang.common.service.CusDataDecipher;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -0,0 +1,60 @@
|
||||||
|
package weaver.xuanran.wang.shyl_mq.entity;
|
||||||
|
|
||||||
|
import aiyh.utils.Util;
|
||||||
|
import aiyh.utils.excention.CustomerException;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import weaver.xuanran.wang.common.entity.CusSuccess;
|
||||||
|
import weaver.xuanran.wang.common.interfaces.CusAbstractTokenConf;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h1>硬件token</h1>
|
||||||
|
*
|
||||||
|
* @author xuanran.wang
|
||||||
|
* @date 2023/7/4 10:37
|
||||||
|
*/
|
||||||
|
public class SentryLnesaTokenConf extends CusAbstractTokenConf {
|
||||||
|
public static final String TOKEN_KEY = "sentryLnesaToken";
|
||||||
|
private static final CusSuccess TOKEN_SUCCESS = CusSuccess.builder()
|
||||||
|
.errorMsg("msg")
|
||||||
|
.successField("code")
|
||||||
|
.successValue(0)
|
||||||
|
.dataKey("data")
|
||||||
|
.build();
|
||||||
|
@Override
|
||||||
|
protected String setToken(Map<String, Object> response) {
|
||||||
|
return Util.null2DefaultStr(response.get("access_token"),"");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Long setExpiresIn(Map<String, Object> response) {
|
||||||
|
return Long.parseLong(Util.null2DefaultStr(response.get("expires_in"),"0"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Long setExpiryTime(Map<String, Object> response) {
|
||||||
|
long expiresIn = Long.parseLong(Util.null2DefaultStr(response.get("expires_in"), "0"));
|
||||||
|
if(expiresIn == 0){
|
||||||
|
return 0L;
|
||||||
|
}
|
||||||
|
long timeMillis = System.currentTimeMillis();
|
||||||
|
timeMillis += (expiresIn - (5 * 60)) * 1000;
|
||||||
|
return timeMillis;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected CusSuccess buildSuccess() {
|
||||||
|
return TOKEN_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, Object> tokenByHttp() {
|
||||||
|
String url = toolUtil.getSystemParamValue("kqtokenurl");
|
||||||
|
if(StringUtils.isBlank(url)){
|
||||||
|
throw new CustomerException("在系统参数配置表[ uf_systemconfig ] 中没有配置,参数名为 : [ kqtokenurl ] 的配置项!");
|
||||||
|
}
|
||||||
|
return requestMasterPlate.apiGet(url, new HashMap<>(), new HashMap<>(), this.buildSuccess());
|
||||||
|
}
|
||||||
|
}
|
|
@ -2,13 +2,23 @@ package weaver.xuanran.wang.shyl_mq.service.impl;
|
||||||
|
|
||||||
import aiyh.utils.Util;
|
import aiyh.utils.Util;
|
||||||
import aiyh.utils.excention.CustomerException;
|
import aiyh.utils.excention.CustomerException;
|
||||||
|
import aiyh.utils.httpUtil.util.HttpUtils;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyStatus;
|
import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyStatus;
|
||||||
|
import weaver.xuanran.wang.common.entity.CusSuccess;
|
||||||
|
import weaver.xuanran.wang.common.util.RequestMasterPlate;
|
||||||
|
import weaver.xuanran.wang.common.util.TokenUtil;
|
||||||
import weaver.xuanran.wang.shyl_mq.entity.MQMessage;
|
import weaver.xuanran.wang.shyl_mq.entity.MQMessage;
|
||||||
import weaver.xuanran.wang.shyl_mq.entity.ModifyPassWord;
|
import weaver.xuanran.wang.shyl_mq.entity.ModifyPassWord;
|
||||||
|
import weaver.xuanran.wang.shyl_mq.entity.SentryLnesaTokenConf;
|
||||||
import weaver.xuanran.wang.shyl_mq.service.CusInfoActionService;
|
import weaver.xuanran.wang.shyl_mq.service.CusInfoActionService;
|
||||||
|
import weaver.xuanran.wang.shyl_mq.util.RocketConsumerUtil;
|
||||||
|
|
||||||
|
import javax.ws.rs.core.MediaType;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <h1>密码修改业务方法</h1>
|
* <h1>密码修改业务方法</h1>
|
||||||
|
@ -20,10 +30,12 @@ public class PassWordServiceImpl extends CusInfoActionService {
|
||||||
|
|
||||||
private Logger logger = Util.getLogger("mq-consumer-password");
|
private Logger logger = Util.getLogger("mq-consumer-password");
|
||||||
|
|
||||||
|
|
||||||
{
|
{
|
||||||
if(null == logger){
|
if(null == logger){
|
||||||
logger = Util.getLogger("mq-consumer-password");
|
logger = Util.getLogger("mq-consumer-password");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -42,14 +54,13 @@ public class PassWordServiceImpl extends CusInfoActionService {
|
||||||
String content = message.getContent();
|
String content = message.getContent();
|
||||||
ModifyPassWord passWord = JSONObject.parseObject(content, ModifyPassWord.class);
|
ModifyPassWord passWord = JSONObject.parseObject(content, ModifyPassWord.class);
|
||||||
logger.info(Util.logStr("cusPassWordAction messageId: {},UserInfo : {} ",message.getId(),JSONObject.toJSONString(passWord)));
|
logger.info(Util.logStr("cusPassWordAction messageId: {},UserInfo : {} ",message.getId(),JSONObject.toJSONString(passWord)));
|
||||||
// String outKey = passWord.getId();
|
String hrmId= passWord.getId();
|
||||||
// String hrmId = consumerMapper.getHrmIdByOutKey(outKey);
|
if(StringUtils.isBlank(hrmId)){
|
||||||
// if(StringUtils.isBlank(hrmId)){
|
throw new CustomerException(Util.logStr("the userId is {} , id is null!", hrmId));
|
||||||
// throw new CustomerException(Util.logStr("the userId is {} , no personnel information found in oa!", outKey));
|
}
|
||||||
// }
|
if (!consumerMapper.updatePasswordById(hrmId, Util.getEncrypt(RocketConsumerUtil.decryptContent(passWord.getPassword())))) {
|
||||||
// if (!consumerMapper.updatePasswordById(hrmId, Util.getEncrypt(passWord.getPassword()))) {
|
throw new CustomerException("update user password error!");
|
||||||
// throw new CustomerException("update user password error!");
|
}
|
||||||
// }
|
|
||||||
writeInOA(message.getId());
|
writeInOA(message.getId());
|
||||||
return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
|
return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -61,4 +72,5 @@ public class PassWordServiceImpl extends CusInfoActionService {
|
||||||
public ConsumeConcurrentlyStatus cusUpdateAction(MQMessage message) {
|
public ConsumeConcurrentlyStatus cusUpdateAction(MQMessage message) {
|
||||||
return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
|
return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,14 +18,19 @@ import org.apache.rocketmq.common.message.Message;
|
||||||
import org.apache.rocketmq.common.message.MessageExt;
|
import org.apache.rocketmq.common.message.MessageExt;
|
||||||
import org.apache.rocketmq.remoting.common.RemotingHelper;
|
import org.apache.rocketmq.remoting.common.RemotingHelper;
|
||||||
import org.apache.rocketmq.remoting.exception.RemotingException;
|
import org.apache.rocketmq.remoting.exception.RemotingException;
|
||||||
|
import weaver.xuanran.wang.common.entity.CusSuccess;
|
||||||
import weaver.xuanran.wang.common.util.CusInfoToOAUtil;
|
import weaver.xuanran.wang.common.util.CusInfoToOAUtil;
|
||||||
|
import weaver.xuanran.wang.common.util.RequestMasterPlate;
|
||||||
|
import weaver.xuanran.wang.common.util.TokenUtil;
|
||||||
import weaver.xuanran.wang.shyl_mq.RocketMQFactory;
|
import weaver.xuanran.wang.shyl_mq.RocketMQFactory;
|
||||||
import weaver.xuanran.wang.shyl_mq.constant.RocketMQConstant;
|
import weaver.xuanran.wang.shyl_mq.constant.RocketMQConstant;
|
||||||
import weaver.xuanran.wang.shyl_mq.entity.MQMessage;
|
import weaver.xuanran.wang.shyl_mq.entity.MQMessage;
|
||||||
|
import weaver.xuanran.wang.shyl_mq.entity.SentryLnesaTokenConf;
|
||||||
import weaver.xuanran.wang.shyl_mq.mapper.ConsumerMapper;
|
import weaver.xuanran.wang.shyl_mq.mapper.ConsumerMapper;
|
||||||
import weaver.xuanran.wang.shyl_mq.service.CusInfoActionService;
|
import weaver.xuanran.wang.shyl_mq.service.CusInfoActionService;
|
||||||
import weaver.zwl.common.ToolUtil;
|
import weaver.zwl.common.ToolUtil;
|
||||||
|
|
||||||
|
import javax.ws.rs.core.MediaType;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
|
@ -43,6 +48,11 @@ public class RocketConsumerUtil {
|
||||||
private static final ToolUtil tool = new ToolUtil();
|
private static final ToolUtil tool = new ToolUtil();
|
||||||
private static final int ERROR_LOG_ID;
|
private static final int ERROR_LOG_ID;
|
||||||
private static final ToolUtil toolUtil = new ToolUtil();
|
private static final ToolUtil toolUtil = new ToolUtil();
|
||||||
|
private static final RequestMasterPlate masterPlate = new RequestMasterPlate();
|
||||||
|
public static final CusSuccess CRYPT_SUCCESS =
|
||||||
|
CusSuccess.builder().errorMsg("msg").successField("code").successValue(0).build();
|
||||||
|
|
||||||
|
private static final SentryLnesaTokenConf tokenConf = new SentryLnesaTokenConf();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
ERROR_LOG_ID = Util.getIntValue(tool.getSystemParamValue("mqErrorLogModelId"), -1);
|
ERROR_LOG_ID = Util.getIntValue(tool.getSystemParamValue("mqErrorLogModelId"), -1);
|
||||||
|
@ -218,5 +228,57 @@ public class RocketConsumerUtil {
|
||||||
} while (!sendOk);
|
} while (!sendOk);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h1>进行数据解密</h1>
|
||||||
|
* @author xuanran.wang
|
||||||
|
* @dateTime 2023/7/4 14:26
|
||||||
|
* @param content 加密后的内容
|
||||||
|
* @return 解密后的数据
|
||||||
|
**/
|
||||||
|
public static String decryptContent(String content){
|
||||||
|
String decryptUrl = Util.null2DefaultStr(toolUtil.getSystemParamValue("decryptUrl"), "");
|
||||||
|
if(StringUtils.isBlank(decryptUrl)){
|
||||||
|
throw new CustomerException("请先在系统参数配置表 [ uf_systemconf ] 中配置 [ decryptUrl ] 参数");
|
||||||
|
}
|
||||||
|
Map<String, Object> map = new HashMap<>();
|
||||||
|
map.put("cipherText", content);
|
||||||
|
String token = TokenUtil.getToken(SentryLnesaTokenConf.TOKEN_KEY, tokenConf);
|
||||||
|
Map<String, String> header = new HashMap<>();
|
||||||
|
header.put("Content-Type", MediaType.APPLICATION_JSON);
|
||||||
|
header.put("Authorization", "Bearer " + token);
|
||||||
|
Map<String, Object> result = masterPlate.apiPost(decryptUrl, map, header, RocketConsumerUtil.CRYPT_SUCCESS);
|
||||||
|
String decry = Util.null2DefaultStr(result.get("data"), "");
|
||||||
|
if(StringUtils.isBlank(decry)){
|
||||||
|
throw new CustomerException("解密接口返回数据为空! 请求参数 : [ " + JSONObject.toJSONString(map) + " ]");
|
||||||
|
}
|
||||||
|
return decry;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h1>进行数据加密</h1>
|
||||||
|
* @author xuanran.wang
|
||||||
|
* @dateTime 2023/7/4 14:26
|
||||||
|
* @param content 加密后的内容
|
||||||
|
* @return 解密后的数据
|
||||||
|
**/
|
||||||
|
public static String encryptContent(String content){
|
||||||
|
String encryptUrl = Util.null2DefaultStr(toolUtil.getSystemParamValue("encryptUrl"), "");
|
||||||
|
if(StringUtils.isBlank(encryptUrl)){
|
||||||
|
throw new CustomerException("请先在系统参数配置表 [ uf_systemconf ] 中配置 [ decryptUrl ] 参数");
|
||||||
|
}
|
||||||
|
Map<String, Object> map = new HashMap<>();
|
||||||
|
map.put("plain", content);
|
||||||
|
String token = TokenUtil.getToken(SentryLnesaTokenConf.TOKEN_KEY, tokenConf);
|
||||||
|
Map<String, String> header = new HashMap<>();
|
||||||
|
header.put("Content-Type", MediaType.APPLICATION_FORM_URLENCODED);
|
||||||
|
header.put("Authorization", "Bearer " + token);
|
||||||
|
Map<String, Object> result = masterPlate.apiGet(encryptUrl, map, header, RocketConsumerUtil.CRYPT_SUCCESS);
|
||||||
|
String encrypt = Util.null2DefaultStr(result.get("data"), "");
|
||||||
|
if(StringUtils.isBlank(encrypt)){
|
||||||
|
throw new CustomerException("加密接口返回数据为空! 请求参数 : [ " + JSONObject.toJSONString(map) + " ]");
|
||||||
|
}
|
||||||
|
return encrypt;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,18 @@
|
||||||
package ebu7dev1.common.getlog;
|
package ebu7dev1.common.getlog;
|
||||||
|
|
||||||
|
import aiyh.utils.httpUtil.ResponeVo;
|
||||||
|
import aiyh.utils.httpUtil.util.HttpUtils;
|
||||||
import basetest.BaseTest;
|
import basetest.BaseTest;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.api.ebu7dev1.common.getlog.service.GetLogService;
|
import com.api.ebu7dev1.common.getlog.service.GetLogService;
|
||||||
|
import com.api.ebu7dev1.common.getlog.util.EcTokenUtil;
|
||||||
import com.api.ebu7dev1.common.getlog.util.GetLogUtil;
|
import com.api.ebu7dev1.common.getlog.util.GetLogUtil;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import javax.ws.rs.core.MediaType;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
@ -21,6 +26,11 @@ public class CusTest extends BaseTest {
|
||||||
|
|
||||||
private final GetLogService service = new GetLogService();
|
private final GetLogService service = new GetLogService();
|
||||||
|
|
||||||
|
private final HttpUtils httpUtils = new HttpUtils();
|
||||||
|
{
|
||||||
|
httpUtils.getGlobalCache().header.put("Content-Type", MediaType.APPLICATION_JSON); // 全局请求头
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testA() throws FileNotFoundException {
|
public void testA() throws FileNotFoundException {
|
||||||
List<String> list = new ArrayList<>();
|
List<String> list = new ArrayList<>();
|
||||||
|
@ -35,4 +45,18 @@ public class CusTest extends BaseTest {
|
||||||
System.out.println(JSONObject.toJSONString(map));
|
System.out.println(JSONObject.toJSONString(map));
|
||||||
// GetLogUtil.com(base, map);
|
// GetLogUtil.com(base, map);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testB(){
|
||||||
|
// String address = "https://ecology.yeyaguitu.cn/";
|
||||||
|
String address = "http://10.0.4.12:8090/api/ec/dev/auth/regist";
|
||||||
|
Map<String, String> header = EcTokenUtil.getEcTokenHeader(address);
|
||||||
|
System.out.println("header : " + header);
|
||||||
|
try {
|
||||||
|
ResponeVo responeVo = httpUtils.apiGet(address + "/api/ebu7-dev1/common/log/ipList", header);
|
||||||
|
System.out.println("responeVo : " + JSONObject.toJSONString(responeVo));
|
||||||
|
}catch (Exception e){
|
||||||
|
System.out.println("e : " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,15 @@
|
||||||
package xuanran.wang.shyl.dataasync;
|
package xuanran.wang.shyl.dataasync;
|
||||||
|
|
||||||
import basetest.BaseTest;
|
import basetest.BaseTest;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.api.xuanran.wang.shyl.service.UserUpdateToMQService;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import weaver.rsa.security.RSA;
|
import weaver.xuanran.wang.common.interfaces.CusAbstractTokenConf;
|
||||||
|
import weaver.xuanran.wang.common.util.TokenUtil;
|
||||||
|
import weaver.xuanran.wang.shyl_mq.entity.SentryLnesaTokenConf;
|
||||||
|
import weaver.xuanran.wang.shyl_mq.util.RocketConsumerUtil;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <h1></h1>
|
* <h1></h1>
|
||||||
|
@ -13,10 +18,15 @@ import java.util.List;
|
||||||
* @date 2023/7/3 11:49
|
* @date 2023/7/3 11:49
|
||||||
*/
|
*/
|
||||||
public class TestPassword extends BaseTest {
|
public class TestPassword extends BaseTest {
|
||||||
|
private final UserUpdateToMQService service = new UserUpdateToMQService();
|
||||||
@Test
|
@Test
|
||||||
public void testA(){
|
public void testA() throws InterruptedException {
|
||||||
RSA var15 = new RSA();
|
String encryptContent = RocketConsumerUtil.encryptContent("wxr12345435");
|
||||||
String decrypt = var15.decrypt("cY5Y2bIDOnQCGfmmAHTH6g48qhAw+b3DbAPndeT1KxkK0z5K5kyBA5cbE8mfJYdjhK6WQ2W5/YfIHAWDNQxP1UCGzFSjmBbUkx5oJFlhm0G+s/AwsxqsiFU2uFVqKpyfJP/Xdm0ux6bNfUSu8KoqfrB6h6HonGPmXQc2fATQ66urHC7mnpvC6XGOQ/0K7z0grcLv59PuKU5AkZpn2LZ/qMeaGWkAaBOB2Ko9xc8lBnvppyN23cozde2CVyoD8s59otp543oSN6MFHpkLVk2C1Uew8arZhEP+04VJdGhABtLX1H5X+N/hG20dlH5HxWlvYkc6H9qaKv89XvcXdg072Q==``RSA``");
|
System.out.println("encryptContent : " + encryptContent);
|
||||||
System.out.println(decrypt);
|
|
||||||
|
Thread.sleep(60000);
|
||||||
|
String decryptContent = RocketConsumerUtil.decryptContent(encryptContent);
|
||||||
|
System.out.println("decryptContent : " + decryptContent );
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue