com.feizhaiyou.encrypt.advice.DecryptRequestAdvice Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of encrypt-spring-boot-starter Show documentation
Show all versions of encrypt-spring-boot-starter Show documentation
整合SpringBoot可对Web项目的HTTP接口参数进行脱敏与加解密,通过注解的方式直接使用加解密,支持AES、RSA,可自定义脱敏与加解密配置。
The newest version!
package com.feizhaiyou.encrypt.advice;
import lombok.extern.slf4j.Slf4j;
import java.lang.annotation.Annotation;
import java.util.List;
/**
* @author ls
*/
@Slf4j
public class DecryptRequestAdvice extends AbstractSecurityAdvice {
public DecryptRequestAdvice(int maxDeep, List classPackage) {
DEFAULT_CLEAN_DEPTH = maxDeep;
STANDARD_CLASS = classPackage;
}
@Override
public String handleSecurity(String value, Annotation[] annotations) {
if (securityHandler != null) {
Annotation acquire = securityHandler.acquire(annotations);
// 处理器分优先级,优先级高的处理器优先处理,只要找到一个支持的处理器,后续的处理器不再处理
if (acquire != null) {
value = securityHandler.handleDecrypt(value, acquire);
}
}
return value;
}
/**
* 给请求解密
*
* @param value 需要解密的对象
* @return
* @throws Exception
*/
public Object decrypt(Object value, Annotation[] annotations) throws Exception {
return handleObject(0, DEFAULT_CLEAN_DEPTH, value, annotations);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy