|
@@ -21,7 +21,10 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.util.*;
|
|
|
-import java.util.concurrent.*;
|
|
|
+import java.util.concurrent.LinkedBlockingQueue;
|
|
|
+import java.util.concurrent.ThreadFactory;
|
|
|
+import java.util.concurrent.ThreadPoolExecutor;
|
|
|
+import java.util.concurrent.TimeUnit;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
@@ -41,7 +44,7 @@ public class QmAuditPushService {
|
|
|
ThreadPoolExecutor executor = new ThreadPoolExecutor(
|
|
|
20,
|
|
|
50,
|
|
|
- 5*60,
|
|
|
+ 5 * 60,
|
|
|
TimeUnit.SECONDS,
|
|
|
new LinkedBlockingQueue<>(2000),
|
|
|
threadFactory);
|
|
@@ -68,10 +71,10 @@ public class QmAuditPushService {
|
|
|
*/
|
|
|
public void pushTokenReceiveLog(List<TokenOperationDto> dtos) {
|
|
|
Boolean qmEnabled = config.getQmEnabled();
|
|
|
- if(null == qmEnabled || !qmEnabled) {
|
|
|
+ if (null == qmEnabled || !qmEnabled) {
|
|
|
return;
|
|
|
}
|
|
|
- executor.execute(()-> pushTokenLogToAudit(dtos));
|
|
|
+ executor.execute(() -> pushTokenLogToAudit(dtos));
|
|
|
}
|
|
|
|
|
|
private void pushTokenLogToAudit(List<TokenOperationDto> dtos) {
|
|
@@ -81,14 +84,14 @@ public class QmAuditPushService {
|
|
|
String sysId = config.getSysId();
|
|
|
String logType = AuditConstance.AUDIT_LOG_TYPE_LPCZ;
|
|
|
List<TokenOperationLog> operateLogs = getTokenOperateLog(dtos);
|
|
|
- if(CollectionUtils.isNotEmpty(operateLogs)) {
|
|
|
+ if (CollectionUtils.isNotEmpty(operateLogs)) {
|
|
|
log.info("=========推送令牌操作日志=======");
|
|
|
logSendComponent.sendTokenOperateLog(sysId, logType, operateLogs);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private List<TokenOperationLog> getTokenOperateLog(List<TokenOperationDto> dtos) {
|
|
|
- return dtos.stream().map(e-> {
|
|
|
+ return dtos.stream().map(e -> {
|
|
|
TokenOperationLog tokenOperationLog = new TokenOperationLog();
|
|
|
tokenOperationLog.setAction(e.getAction());
|
|
|
tokenOperationLog.setPid(e.getPid());
|
|
@@ -100,45 +103,48 @@ public class QmAuditPushService {
|
|
|
|
|
|
/**
|
|
|
* 推送授权日志
|
|
|
+ *
|
|
|
* @param authorizeLogDto
|
|
|
*/
|
|
|
public void pushAuthorizeLog(AuthorizeLogDto authorizeLogDto) {
|
|
|
Boolean qmEnabled = config.getQmEnabled();
|
|
|
- if(null == qmEnabled || !qmEnabled) {
|
|
|
+ if (null == qmEnabled || !qmEnabled) {
|
|
|
return;
|
|
|
}
|
|
|
- executor.execute(()-> pushAuthorizeLogToAudit(authorizeLogDto));
|
|
|
+ executor.execute(() -> pushAuthorizeLogToAudit(authorizeLogDto));
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 推送鉴权日志
|
|
|
+ *
|
|
|
* @param authenticationLogDto
|
|
|
*/
|
|
|
public void pushAuthenticationLog(AuthenticationLogDto authenticationLogDto) {
|
|
|
Boolean qmEnabled = config.getQmEnabled();
|
|
|
- if(null == qmEnabled || !qmEnabled) {
|
|
|
+ if (null == qmEnabled || !qmEnabled) {
|
|
|
return;
|
|
|
}
|
|
|
- executor.execute(()-> pushAuthenticationLogToAudit(authenticationLogDto));
|
|
|
+ executor.execute(() -> pushAuthenticationLogToAudit(authenticationLogDto));
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 推送风险日志
|
|
|
+ *
|
|
|
* @param risksDtos
|
|
|
*/
|
|
|
public void pushRiskLog(List<RiskPushLogDto> risksDtos) {
|
|
|
Boolean qmEnabled = config.getQmEnabled();
|
|
|
- if(null == qmEnabled || !qmEnabled) {
|
|
|
+ if (null == qmEnabled || !qmEnabled) {
|
|
|
return;
|
|
|
}
|
|
|
- executor.execute(()-> pushRiskLogToAudit(risksDtos));
|
|
|
+ executor.execute(() -> pushRiskLogToAudit(risksDtos));
|
|
|
}
|
|
|
|
|
|
private void pushAuthorizeLogToAudit(AuthorizeLogDto authorizeLogDto) {
|
|
|
String sysId = config.getSysId();
|
|
|
String logType = AuditConstance.AUDIT_LOG_TYPE_SQ;
|
|
|
List<AuthBusLog> busLogs = getAuthBusLog(authorizeLogDto);
|
|
|
- if(CollectionUtils.isNotEmpty(busLogs)) {
|
|
|
+ if (CollectionUtils.isNotEmpty(busLogs)) {
|
|
|
log.info("=========推送审计授权日志=======");
|
|
|
logSendComponent.sendAuthBusLog(sysId, logType, busLogs);
|
|
|
}
|
|
@@ -147,13 +153,13 @@ public class QmAuditPushService {
|
|
|
private List<AuthBusLog> getAuthBusLog(AuthorizeLogDto authorizeLogDto) {
|
|
|
String authorizeType = authorizeLogDto.getAuthorizeType();
|
|
|
AuthorizeTypeEnum typeEnum = AuthorizeTypeEnum.getByAuthorizeType(authorizeType);
|
|
|
- if(null == typeEnum) {
|
|
|
+ if (null == typeEnum) {
|
|
|
return new ArrayList<>();
|
|
|
}
|
|
|
Map<String, String> map = getSQOperateAndAuthType(typeEnum);
|
|
|
String authType = map.get(AUTH_TYPE_KEY);
|
|
|
String operateType = map.get(OPERATE_TYPE_KEY);
|
|
|
- return constructBusLogs(authorizeLogDto, authType ,operateType);
|
|
|
+ return constructBusLogs(authorizeLogDto, authType, operateType);
|
|
|
}
|
|
|
|
|
|
private Map<String, String> getSQOperateAndAuthType(AuthorizeTypeEnum typeEnum) {
|
|
@@ -191,7 +197,7 @@ public class QmAuditPushService {
|
|
|
|
|
|
private List<AuthBusLog> constructBusLogs(AuthorizeLogDto authorizeLogDto, String authType, String operateType) {
|
|
|
List<AuthBusLog> list = new ArrayList<>();
|
|
|
- if(StringUtils.isAnyBlank(authType, operateType)) {
|
|
|
+ if (StringUtils.isAnyBlank(authType, operateType)) {
|
|
|
return list;
|
|
|
}
|
|
|
String timeStr = getTimeStr(authorizeLogDto.getCreateTime());
|
|
@@ -225,6 +231,7 @@ public class QmAuditPushService {
|
|
|
|
|
|
//设置终端ip
|
|
|
authBusLog.setTerminalIP(authorizeLogDto.getTerminalIP());
|
|
|
+ authBusLog.setApproveTaskId("");
|
|
|
list.add(authBusLog);
|
|
|
}
|
|
|
return list;
|
|
@@ -232,7 +239,7 @@ public class QmAuditPushService {
|
|
|
|
|
|
private String getTimeStr(Date createTime) {
|
|
|
String timeStr = "";
|
|
|
- if(null != createTime) {
|
|
|
+ if (null != createTime) {
|
|
|
long time = createTime.getTime();
|
|
|
timeStr = String.valueOf(time);
|
|
|
}
|
|
@@ -244,7 +251,7 @@ public class QmAuditPushService {
|
|
|
String sysId = config.getSysId();
|
|
|
String logType = AuditConstance.AUDIT_LOG_TYPE_JQ;
|
|
|
List<AuthenticationBusLog> busLogs = getAuthenticationBusLog(authenticationLogDto);
|
|
|
- if(CollectionUtils.isNotEmpty(busLogs)) {
|
|
|
+ if (CollectionUtils.isNotEmpty(busLogs)) {
|
|
|
log.info("=========推送审计鉴权日志=======");
|
|
|
logSendComponent.sendAuthenticationBusLog(sysId, logType, busLogs);
|
|
|
}
|
|
@@ -253,7 +260,7 @@ public class QmAuditPushService {
|
|
|
private List<AuthenticationBusLog> getAuthenticationBusLog(AuthenticationLogDto authenticationLogDto) {
|
|
|
String authenticationType = authenticationLogDto.getAuthenticationType();
|
|
|
AuthenticationTypeEnum typeEnum = AuthenticationTypeEnum.getByAuthenticationType(authenticationType);
|
|
|
- if(null == typeEnum) {
|
|
|
+ if (null == typeEnum) {
|
|
|
return new ArrayList<>();
|
|
|
}
|
|
|
String authType = getJQAuthType(typeEnum);
|
|
@@ -262,7 +269,7 @@ public class QmAuditPushService {
|
|
|
|
|
|
private List<AuthenticationBusLog> constructAuthenticationBusLogs(AuthenticationLogDto dto, String authType) {
|
|
|
List<AuthenticationBusLog> list = new ArrayList<>();
|
|
|
- if(StringUtils.isBlank(authType)) {
|
|
|
+ if (StringUtils.isBlank(authType)) {
|
|
|
return list;
|
|
|
}
|
|
|
AuthenticationBusLog busLog = new AuthenticationBusLog();
|
|
@@ -273,7 +280,7 @@ public class QmAuditPushService {
|
|
|
busLog.setAuthIdcard(dto.getUserIdcard());
|
|
|
//推送结果 0:成功 1:失败
|
|
|
String state = dto.getState();
|
|
|
- if(AuthResultEnum.SUC.getValue().equals(state)) {
|
|
|
+ if (AuthResultEnum.SUC.getValue().equals(state)) {
|
|
|
state = AuthResultEnum.FAIL.getValue();
|
|
|
} else {
|
|
|
state = AuthResultEnum.SUC.getValue();
|
|
@@ -343,18 +350,18 @@ public class QmAuditPushService {
|
|
|
}
|
|
|
|
|
|
private void pushRiskLogToAudit(List<RiskPushLogDto> risksDtos) {
|
|
|
- if(CollectionUtils.isEmpty(risksDtos)) {
|
|
|
+ if (CollectionUtils.isEmpty(risksDtos)) {
|
|
|
return;
|
|
|
}
|
|
|
log.info("=========推送审计风险日志=======");
|
|
|
List<AuthenticationRiskLog> pushLogs = new ArrayList<>();
|
|
|
for (RiskPushLogDto risksDto : risksDtos) {
|
|
|
RiskProgrammeTypeEnum riskTypeEnum = RiskProgrammeTypeEnum.getByType(risksDto.getRiskType());
|
|
|
- if(null == riskTypeEnum) {
|
|
|
+ if (null == riskTypeEnum) {
|
|
|
continue;
|
|
|
}
|
|
|
String mainType = getMainType(riskTypeEnum);
|
|
|
- if(null == mainType) {
|
|
|
+ if (null == mainType) {
|
|
|
continue;
|
|
|
}
|
|
|
AuthenticationRiskLog riskPushLog = new AuthenticationRiskLog();
|
|
@@ -364,9 +371,10 @@ public class QmAuditPushService {
|
|
|
riskPushLog.setTaskId(risksDto.getLogIds());
|
|
|
riskPushLog.setMainType(mainType);
|
|
|
riskPushLog.setType(riskTypeEnum.getLabel());
|
|
|
+ riskPushLog.setLevel("");
|
|
|
pushLogs.add(riskPushLog);
|
|
|
}
|
|
|
- if(pushLogs.size() >0) {
|
|
|
+ if (pushLogs.size() > 0) {
|
|
|
String sysId = config.getSysId();
|
|
|
String logType = AuditConstance.AUDIT_LOG_TYPE_FXBS;
|
|
|
logSendComponent.sendAuthenticationRiskLog(sysId, logType, pushLogs);
|