All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.shoulder.crypto.negotiation.dto.SensitiveFieldWrapper Maven / Gradle / Ivy

Go to download

Shoulder 提供的 协商加密模块,用于非信任网络环境下的安全通信。基于 DH + ECC 实现先进的加密算法协商算法,比传统的 DH + DES 协商算法性能显著更高,更安全。

There is a newer version: 1.0.0-M2.2
Show newest version
package org.shoulder.crypto.negotiation.dto;

import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.collections4.CollectionUtils;

import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;

/**
 * 敏感字段包装器(为了支持字段嵌套与泛型)
 *
 * @author lym
 */
@Data
@NoArgsConstructor
public class SensitiveFieldWrapper {

    private Field field;

    private boolean sensitive = true;

    private List internalFields = new LinkedList<>();

    public SensitiveFieldWrapper(Field field) {
        this.field = field;
    }

    public void addInternalFields(SensitiveFieldWrapper field) {
        this.internalFields.add(field);
        sensitive = false;
    }

    public void addInternalFields(List fields) {
        this.internalFields.addAll(fields);
        sensitive = false;
    }

    /**
     * 整理,检查值,内存压缩
     */
    public void clearedUp() {
        if (CollectionUtils.isEmpty(internalFields)) {
            sensitive = true;
            internalFields = Collections.emptyList();
        } else {
            sensitive = false;
            internalFields = new ArrayList<>(internalFields);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy