|
|
@ -1,11 +1,12 @@
|
|
|
|
package org.dromara.common.encrypt.core;
|
|
|
|
package org.dromara.common.encrypt.core;
|
|
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.util.ReflectUtil;
|
|
|
|
import cn.hutool.core.util.ReflectUtil;
|
|
|
|
import org.dromara.common.encrypt.annotation.EncryptField;
|
|
|
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
|
|
|
import org.dromara.common.encrypt.annotation.EncryptField;
|
|
|
|
|
|
|
|
|
|
|
|
import java.lang.reflect.Field;
|
|
|
|
import java.lang.reflect.Field;
|
|
|
|
import java.util.Arrays;
|
|
|
|
import java.util.Arrays;
|
|
|
|
|
|
|
|
import java.util.HashSet;
|
|
|
|
import java.util.Map;
|
|
|
|
import java.util.Map;
|
|
|
|
import java.util.Set;
|
|
|
|
import java.util.Set;
|
|
|
|
import java.util.concurrent.ConcurrentHashMap;
|
|
|
|
import java.util.concurrent.ConcurrentHashMap;
|
|
|
@ -35,8 +36,13 @@ public class EncryptorManager {
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public Set<Field> getFieldCache(Class<?> sourceClazz) {
|
|
|
|
public Set<Field> getFieldCache(Class<?> sourceClazz) {
|
|
|
|
return fieldCache.computeIfAbsent(sourceClazz, clazz -> {
|
|
|
|
return fieldCache.computeIfAbsent(sourceClazz, clazz -> {
|
|
|
|
Field[] declaredFields = clazz.getDeclaredFields();
|
|
|
|
Set<Field> fieldSet = new HashSet<>();
|
|
|
|
Set<Field> fieldSet = Arrays.stream(declaredFields).filter(field ->
|
|
|
|
while (clazz != null) {
|
|
|
|
|
|
|
|
Field[] fields = clazz.getDeclaredFields();
|
|
|
|
|
|
|
|
fieldSet.addAll(Arrays.asList(fields));
|
|
|
|
|
|
|
|
clazz = clazz.getSuperclass();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
fieldSet = fieldSet.stream().filter(field ->
|
|
|
|
field.isAnnotationPresent(EncryptField.class) && field.getType() == String.class)
|
|
|
|
field.isAnnotationPresent(EncryptField.class) && field.getType() == String.class)
|
|
|
|
.collect(Collectors.toSet());
|
|
|
|
.collect(Collectors.toSet());
|
|
|
|
for (Field field : fieldSet) {
|
|
|
|
for (Field field : fieldSet) {
|
|
|
|