|
@@ -3,13 +3,14 @@ package com.dragoninfo.dcuc.auth.audit.service.log;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import com.dragoninfo.dcuc.auth.audit.config.AuditConfig;
|
|
|
import com.dragoninfo.dcuc.auth.audit.constance.AuditConstance;
|
|
|
-import com.dragoninfo.dcuc.auth.audit.dto.AuthorizeHandlerDto;
|
|
|
-import com.dragoninfo.dcuc.auth.audit.dto.AuthorizeLogDto;
|
|
|
-import com.dragoninfo.dcuc.auth.audit.dto.AuthorizeObjectDto;
|
|
|
-import com.dragoninfo.dcuc.auth.audit.dto.AuthorizeSubjectDto;
|
|
|
+import com.dragoninfo.dcuc.auth.audit.dto.*;
|
|
|
+import com.dragoninfo.dcuc.auth.audit.enums.AuthenticationTypeEnum;
|
|
|
import com.dragoninfo.dcuc.auth.audit.enums.AuthorizeTypeEnum;
|
|
|
+import com.dragoninfo.dcuc.auth.audit.enums.RiskProgrammeTypeEnum;
|
|
|
import com.dragonsoft.auditlog.collection.qmtj.LogSendComponent;
|
|
|
import com.dragonsoft.auditlog.collection.qmtj.pojo.req.AuthBusLog;
|
|
|
+import com.dragonsoft.auditlog.collection.qmtj.pojo.req.AuthenticationBusLog;
|
|
|
+import com.dragonsoft.auditlog.collection.qmtj.pojo.req.AuthenticationRiskLog;
|
|
|
import com.google.common.util.concurrent.ThreadFactoryBuilder;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
@@ -49,16 +50,19 @@ public class QmAuditPushService {
|
|
|
@Autowired
|
|
|
private AuditConfig config;
|
|
|
|
|
|
-
|
|
|
+ /**
|
|
|
+ * 推送授权日志
|
|
|
+ * @param authorizeLogDto
|
|
|
+ */
|
|
|
public void pushAuthorizeLog(AuthorizeLogDto authorizeLogDto) {
|
|
|
Boolean qmEnabled = config.getQmEnabled();
|
|
|
if(null == qmEnabled || !qmEnabled) {
|
|
|
return;
|
|
|
}
|
|
|
- executor.submit(()-> pushLogMessage(authorizeLogDto));
|
|
|
+ executor.submit(()-> pushLogToAudit(authorizeLogDto));
|
|
|
}
|
|
|
|
|
|
- private void pushLogMessage(AuthorizeLogDto authorizeLogDto) {
|
|
|
+ private void pushLogToAudit(AuthorizeLogDto authorizeLogDto) {
|
|
|
String sysId = config.getSysId();
|
|
|
String logType = AuditConstance.AUDIT_LOG_TYPE_SQ;
|
|
|
List<AuthBusLog> busLogs = getAuthBusLog(authorizeLogDto);
|
|
@@ -74,13 +78,13 @@ public class QmAuditPushService {
|
|
|
if(null == typeEnum) {
|
|
|
return new ArrayList<>();
|
|
|
}
|
|
|
- Map<String, String> map = getOperateAndAuth(typeEnum);
|
|
|
+ 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);
|
|
|
}
|
|
|
|
|
|
- private Map<String, String> getOperateAndAuth(AuthorizeTypeEnum typeEnum) {
|
|
|
+ private Map<String, String> getSQOperateAndAuthType(AuthorizeTypeEnum typeEnum) {
|
|
|
Map<String, String> map = new HashMap<>();
|
|
|
switch (typeEnum) {
|
|
|
case GNSQ:
|
|
@@ -118,7 +122,7 @@ public class QmAuditPushService {
|
|
|
if(StringUtils.isAnyBlank(authType, operateType)) {
|
|
|
return list;
|
|
|
}
|
|
|
- String timeStr = getTimeStr(authorizeLogDto);
|
|
|
+ String timeStr = getTimeStr(authorizeLogDto.getCreateTime());
|
|
|
AuthorizeHandlerDto handlerDto = authorizeLogDto.getAuthorizeHandlers().get(0);
|
|
|
List<AuthorizeSubjectDto> subjectDtos = authorizeLogDto.getAuthorizeSubjects();
|
|
|
List<AuthorizeObjectDto> objectDtos = authorizeLogDto.getAuthorizeObjects();
|
|
@@ -127,8 +131,7 @@ public class QmAuditPushService {
|
|
|
authBusLog.setAuthType(authType);
|
|
|
//设置操作者
|
|
|
authBusLog.setOperateType(operateType);
|
|
|
- String operateUserId = handlerDto.getHandlerId();
|
|
|
- authBusLog.setOperateUserId(operateUserId);
|
|
|
+ authBusLog.setOperateUserId(handlerDto.getHandlerId());
|
|
|
authBusLog.setOperateUserName(handlerDto.getHandlerName());
|
|
|
authBusLog.setOperateUserIdcard(handlerDto.getHandlerIdcard());
|
|
|
authBusLog.setOperateOrgCode(handlerDto.getHandlerOrgCode());
|
|
@@ -151,14 +154,173 @@ public class QmAuditPushService {
|
|
|
return list;
|
|
|
}
|
|
|
|
|
|
- private String getTimeStr(AuthorizeLogDto authorizeLogDto) {
|
|
|
- Date createTime = authorizeLogDto.getCreateTime();
|
|
|
+ private String getTimeStr(Date createTime) {
|
|
|
String timeStr = "";
|
|
|
if(null != createTime) {
|
|
|
long time = createTime.getTime();
|
|
|
timeStr = String.valueOf(time);
|
|
|
+ timeStr = timeStr.substring(0, timeStr.length() - 3);
|
|
|
}
|
|
|
return timeStr;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 推送鉴权日志
|
|
|
+ * @param authenticationLogDto
|
|
|
+ */
|
|
|
+ public void pushAuthenticationLog(AuthenticationLogDto authenticationLogDto) {
|
|
|
+ Boolean qmEnabled = config.getQmEnabled();
|
|
|
+ if(null == qmEnabled || !qmEnabled) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ executor.submit(()-> pushAuthenticationLogToAudit(authenticationLogDto));
|
|
|
+ }
|
|
|
+
|
|
|
+ private void pushAuthenticationLogToAudit(AuthenticationLogDto authenticationLogDto) {
|
|
|
+ String sysId = config.getSysId();
|
|
|
+ String logType = AuditConstance.AUDIT_LOG_TYPE_JQ;
|
|
|
+ List<AuthenticationBusLog> busLogs = getAuthenticationBusLog(authenticationLogDto);
|
|
|
+ if(CollectionUtils.isNotEmpty(busLogs)) {
|
|
|
+ log.debug("QmAuditPushService pushAuthenticationLogMessage START");
|
|
|
+ logSendComponent.sendAuthenticationBusLog(sysId, logType, busLogs);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<AuthenticationBusLog> getAuthenticationBusLog(AuthenticationLogDto authenticationLogDto) {
|
|
|
+ String authenticationType = authenticationLogDto.getAuthenticationType();
|
|
|
+ AuthenticationTypeEnum typeEnum = AuthenticationTypeEnum.getByAuthenticationType(authenticationType);
|
|
|
+ if(null == typeEnum) {
|
|
|
+ return new ArrayList<>();
|
|
|
+ }
|
|
|
+ String authType = getJQAuthType(typeEnum);
|
|
|
+ return constructAuthenticationBusLogs(authenticationLogDto, authType);
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<AuthenticationBusLog> constructAuthenticationBusLogs(AuthenticationLogDto dto, String authType) {
|
|
|
+ List<AuthenticationBusLog> list = new ArrayList<>();
|
|
|
+ if(StringUtils.isBlank(authType)) {
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+ AuthenticationBusLog busLog = new AuthenticationBusLog();
|
|
|
+ String timeStr = getTimeStr(dto.getCreateTime());
|
|
|
+ busLog.setOperateTime(timeStr);
|
|
|
+ busLog.setAuthType(authType);
|
|
|
+ busLog.setAuthIp(dto.getTerminalId());
|
|
|
+ busLog.setAuthIdcard(dto.getUserIdcard());
|
|
|
+ busLog.setAuthResult(dto.getState());
|
|
|
+ busLog.setAuthTaskId(dto.getAuthTaskId());
|
|
|
+ busLog.setAuthusername(dto.getUserName());
|
|
|
+ busLog.setOrgcode(dto.getUserOrgCode());
|
|
|
+ busLog.setOrgcodename(dto.getUserOrgName());
|
|
|
+ busLog.setUserToken(dto.getUserToken());
|
|
|
+ List<AuthenticationContentDto> content = dto.getContent();
|
|
|
+ getAuthenticationContent(authType, busLog, content);
|
|
|
+ list.add(busLog);
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void getAuthenticationContent(String authType, AuthenticationBusLog busLog, List<AuthenticationContentDto> content) {
|
|
|
+ String codes = "";
|
|
|
+ if (AuditConstance.AUDIT_AUTH_TYPE_GNJQ.equals(authType)) {
|
|
|
+ codes = content
|
|
|
+ .stream()
|
|
|
+ .map(AuthenticationContentDto::getContentId)
|
|
|
+ .collect(Collectors.joining(","));
|
|
|
+ busLog.setAuthFunctionCode(codes);
|
|
|
+ } else if (AuditConstance.AUDIT_AUTH_TYPE_FWJQ.equals(authType)) {
|
|
|
+ codes = content
|
|
|
+ .stream()
|
|
|
+ .map(AuthenticationContentDto::getContentId)
|
|
|
+ .collect(Collectors.joining(","));
|
|
|
+ busLog.setAuthServiceCode(codes);
|
|
|
+ } else if (AuditConstance.AUDIT_AUTH_TYPE_SJJQ.equals(authType)) {
|
|
|
+ codes = content
|
|
|
+ .stream()
|
|
|
+ .map(AuthenticationContentDto::getContentName)
|
|
|
+ .collect(Collectors.joining(","));
|
|
|
+ busLog.setFieldSetCode(codes);
|
|
|
+ } else if (AuditConstance.AUDIT_AUTH_TYPE_YYJQ.equals(authType)) {
|
|
|
+ codes = content
|
|
|
+ .stream()
|
|
|
+ .map(AuthenticationContentDto::getContentId)
|
|
|
+ .collect(Collectors.joining(","));
|
|
|
+ busLog.setAuthAppCode(codes);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private String getJQAuthType(AuthenticationTypeEnum typeEnum) {
|
|
|
+ String authType = "";
|
|
|
+ switch (typeEnum) {
|
|
|
+ case FWJJQ:
|
|
|
+ authType = AuditConstance.AUDIT_AUTH_TYPE_FWJQ;
|
|
|
+ break;
|
|
|
+ case GNJJQ:
|
|
|
+ authType = AuditConstance.AUDIT_AUTH_TYPE_GNJQ;
|
|
|
+ break;
|
|
|
+ case YYJJQ:
|
|
|
+ authType = AuditConstance.AUDIT_AUTH_TYPE_YYJQ;
|
|
|
+ break;
|
|
|
+ case SJJJQ:
|
|
|
+ authType = AuditConstance.AUDIT_AUTH_TYPE_SJJQ;
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ return authType;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 推送风险日志
|
|
|
+ * @param risksDtos
|
|
|
+ */
|
|
|
+ public void pushRiskLog(List<RiskPushLogDto> risksDtos) {
|
|
|
+ Boolean qmEnabled = config.getQmEnabled();
|
|
|
+ if(null == qmEnabled || !qmEnabled) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ executor.submit(()-> pushRiskLogToAudit(risksDtos));
|
|
|
+ }
|
|
|
+
|
|
|
+ private void pushRiskLogToAudit(List<RiskPushLogDto> risksDtos) {
|
|
|
+ if(CollectionUtils.isEmpty(risksDtos)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ List<AuthenticationRiskLog> pushLogs = new ArrayList<>();
|
|
|
+ for (RiskPushLogDto risksDto : risksDtos) {
|
|
|
+ RiskProgrammeTypeEnum riskTypeEnum = RiskProgrammeTypeEnum.getByType(risksDto.getRiskType());
|
|
|
+ if(null == riskTypeEnum) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ String mainType = getMainType(riskTypeEnum);
|
|
|
+ if(null == mainType) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ AuthenticationRiskLog riskPushLog = new AuthenticationRiskLog();
|
|
|
+ String timeStr = getTimeStr(risksDto.getCreateTime());
|
|
|
+ riskPushLog.setTime(timeStr);
|
|
|
+ riskPushLog.setContent(risksDto.getRiskContent());
|
|
|
+ riskPushLog.setTaskId(risksDto.getTerminalIPs());
|
|
|
+ riskPushLog.setMainType(mainType);
|
|
|
+ riskPushLog.setType(riskTypeEnum.getLabel());
|
|
|
+ pushLogs.add(riskPushLog);
|
|
|
+ }
|
|
|
+ if(pushLogs.size() >0) {
|
|
|
+ String sysId = config.getSysId();
|
|
|
+ String logType = AuditConstance.AUDIT_LOG_TYPE_FXBS;
|
|
|
+ logSendComponent.sendAuthenticationRiskLog(sysId, logType, pushLogs);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private String getMainType(RiskProgrammeTypeEnum riskType) {
|
|
|
+ switch (riskType) {
|
|
|
+ case DSJPFJQFX:
|
|
|
+ case DSJPFHBMDMZFX:
|
|
|
+ return AuditConstance.AUDIT_RISK_MAIN_TYPE_PFJQ;
|
|
|
+ case JQBYTJBWZFX:
|
|
|
+ return AuditConstance.AUDIT_RISK_MAIN_TYPE_JQSB;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
}
|