mirror of
https://github.com/hpd840321/starRiverProperty.git
synced 2026-06-09 08:20:31 +08:00
27c3949045
- .gitignore:显式放行全部 maven-*、scripts、dev-support、frontend、反1、artifacts、历史导出目录
- 新增跟踪:device-manager/device-sdk/legacy-public、davinci-manager、cwos-*、cwos-resource 等源码与附属资源
- davinci FileStorageManagerImpl:Feign Response 关闭、绝对 URL 拉流 SSRF 校验(协议/主机/解析地址)
- davinci OuterCallFeignClient:补充契约说明
- cwos-common-aks AksConstant:final 类 + 私有构造防误实例化
- device-manager DeviceConstant:沿用 DEFAULT_APPLICATIONID 拼写修正
Made-with: Cursor
Former-commit-id: 0a34c76a82
127 lines
4.8 KiB
Java
127 lines
4.8 KiB
Java
/* */ package cn.cloudwalk.service.aop;
|
|
/* */
|
|
/* */ import cn.cloudwalk.cloud.annotation.CloudwalkParamsValidate;
|
|
/* */ import cn.cloudwalk.cloud.result.CloudwalkResult;
|
|
/* */ import java.lang.reflect.Method;
|
|
/* */ import java.util.Iterator;
|
|
/* */ import java.util.Set;
|
|
/* */ import javax.validation.ConstraintViolation;
|
|
/* */ import javax.validation.Validator;
|
|
/* */ import javax.validation.groups.Default;
|
|
/* */ import org.aspectj.lang.ProceedingJoinPoint;
|
|
/* */ import org.aspectj.lang.annotation.Around;
|
|
/* */ import org.aspectj.lang.annotation.Aspect;
|
|
/* */ import org.aspectj.lang.annotation.Pointcut;
|
|
/* */ import org.aspectj.lang.reflect.MethodSignature;
|
|
/* */ import org.slf4j.Logger;
|
|
/* */ import org.slf4j.LoggerFactory;
|
|
/* */ import org.springframework.beans.factory.annotation.Autowired;
|
|
/* */ import org.springframework.context.MessageSource;
|
|
/* */ import org.springframework.context.i18n.LocaleContextHolder;
|
|
/* */ import org.springframework.core.annotation.Order;
|
|
/* */ import org.springframework.stereotype.Component;
|
|
/* */
|
|
/* */
|
|
/* */
|
|
/* */
|
|
/* */
|
|
/* */
|
|
/* */
|
|
/* */
|
|
/* */
|
|
/* */
|
|
/* */
|
|
/* */
|
|
/* */
|
|
/* */
|
|
/* */
|
|
/* */ @Aspect
|
|
/* */ @Order(-100)
|
|
/* */ @Component
|
|
/* */ public class CloudwalkParamsValidateAspect
|
|
/* */ {
|
|
/* 43 */ private final Logger logger = LoggerFactory.getLogger(getClass());
|
|
/* */
|
|
/* */
|
|
/* */
|
|
/* */
|
|
/* */
|
|
/* */ @Autowired
|
|
/* */ private Validator validator;
|
|
/* */
|
|
/* */
|
|
/* */
|
|
/* */
|
|
/* */
|
|
/* */ @Autowired
|
|
/* */ private MessageSource messageSource;
|
|
/* */
|
|
/* */
|
|
/* */
|
|
/* */
|
|
/* */
|
|
/* */ public String getMessage(String code) {
|
|
/* 64 */ return this.messageSource.getMessage(code, null, LocaleContextHolder.getLocale());
|
|
/* */ }
|
|
/* */
|
|
/* */
|
|
/* */
|
|
/* */
|
|
/* */
|
|
/* */ @Pointcut("@annotation(cn.cloudwalk.cloud.annotation.CloudwalkParamsValidate)")
|
|
/* */ public void validatePointcat() {}
|
|
/* */
|
|
/* */
|
|
/* */
|
|
/* */
|
|
/* */
|
|
/* */ @Around("validatePointcat()")
|
|
/* */ public Object around(ProceedingJoinPoint joinPoint) throws Throwable {
|
|
/* 80 */ MethodSignature methodSignature = (MethodSignature)joinPoint.getSignature();
|
|
/* 81 */ Method targetMethod = joinPoint.getTarget().getClass().getMethod(methodSignature
|
|
/* 82 */ .getName(), methodSignature.getParameterTypes());
|
|
/* */
|
|
/* 84 */ this.logger.debug("正在进行对类{}中方法{}进行参数检查开始", joinPoint.getTarget().getClass().getName(), targetMethod.getName());
|
|
/* */
|
|
/* */
|
|
/* 87 */ CloudwalkParamsValidate paramsValidate = targetMethod.<CloudwalkParamsValidate>getAnnotation(CloudwalkParamsValidate.class);
|
|
/* 88 */ if (paramsValidate == null) {
|
|
/* 89 */ return joinPoint.proceed();
|
|
/* */ }
|
|
/* */
|
|
/* */
|
|
/* 93 */ int[] needCheckParamIndexs = paramsValidate.argsIndexs();
|
|
/* 94 */ if (needCheckParamIndexs == null) {
|
|
/* 95 */ return joinPoint.proceed();
|
|
/* */ }
|
|
/* */
|
|
/* */
|
|
/* 99 */ Class<?>[] groupsClazz = paramsValidate.groups();
|
|
/* 100 */ if (groupsClazz == null) {
|
|
/* 101 */ groupsClazz = new Class[] { Default.class };
|
|
/* */ }
|
|
/* */
|
|
/* 104 */ Object[] args = joinPoint.getArgs();
|
|
/* 105 */ for (int index : needCheckParamIndexs) {
|
|
/* 106 */ Object arg = args[index];
|
|
/* */
|
|
/* 108 */ Set<ConstraintViolation<Object>> constraintViolationSet = this.validator.validate(arg, groupsClazz);
|
|
/* 109 */ if (constraintViolationSet != null && constraintViolationSet.size() > 0) {
|
|
/* 110 */ Iterator<ConstraintViolation<Object>> iterator = constraintViolationSet.iterator(); if (iterator.hasNext()) { ConstraintViolation<Object> constraintViolation = iterator.next();
|
|
/* 111 */ String code = constraintViolation.getMessage();
|
|
/* 112 */ return CloudwalkResult.fail(code, getMessage(code)); }
|
|
/* */
|
|
/* */ }
|
|
/* */ }
|
|
/* */
|
|
/* 117 */ this.logger.debug("正在进行对类{}中方法{}进行参数检查通过", joinPoint.getTarget().getClass().getName(), targetMethod.getName());
|
|
/* */
|
|
/* 119 */ return joinPoint.proceed();
|
|
/* */ }
|
|
/* */ }
|
|
|
|
|
|
/* Location: D:\星中心\cw-elevator-application-V1.0.0.20211103\cw-elevator-application-V1.0.0.20211103\lib\cloudwalk-common-service-3.7.2-Brussels-SRX.jar!\cn\cloudwalk\service\aop\CloudwalkParamsValidateAspect.class
|
|
* Java compiler version: 7 (51.0)
|
|
* JD-Core Version: 1.1.3
|
|
*/ |