通过AOP切面,对需要的字段统一加解密

工程开发一段时间后,PM提出数据脱敏新需求;
需要加解密的字段太多、要改动的地方太多,那试试用切面处理吧。

import java.lang.annotation.*;

/**
 * @author Mr.superbeyone
 * @description
 * @date 2023-12-22 14:32
 **/

@Retention(RetentionPolicy.RUNTIME)
@Target({
   
   ElementType.FIELD})
@Documented
public @interface XtSm4FieldAnno {
   
   

}

import java.lang.annotation.*;

/**
 * @author Mr.superbeyone
 * @description
 * @date 2023-12-22 14:32
 **/

@Retention(RetentionPolicy.RUNTIME)
@Target({
   
   ElementType.FIELD})
@Documented
public @interface XtNotSm4FieldAnno {
   
   

}

import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
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.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import java.util.*;

/**
 * @author Mr.superbeyone
 * @className 
 * @description
 * @date 2023-12-22 12:43
 **/
@Slf4j
@Aspect
@Order(1)
@Component
public class XtSm4Aspect {
   
   

    //需要特殊处理的字段列表
    private static final List<String> FIELD_LIST = Arrays.asList("idCard", "phone","idNo","customer_phone","customerPhone","id_card");
    
    private static final String PACKAGE_PREFIX ="com.aaaaa";

    @Pointcut("execution(* com.aaaaa.service..*.*(..))")
    public void pointCut() {
   
   

    }

    @Around("pointCut()")
    public 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

superbeyone

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值