com.ideaaedi.log4j2.defender.strategy.SimpleDefenderStrategy Maven / Gradle / Ivy
The newest version!
package com.ideaaedi.log4j2.defender.strategy;
/**
* 简单的脱敏策略
*
* @author JustryDeng
* @since 2021/7/21 1:14:54
*/
@SuppressWarnings("unused")
public enum SimpleDefenderStrategy implements DefenderStrategy {
/** 姓名类脱敏策略 */
NAME("name", 1, 1, '*'),
/** 账号类脱敏策略 */
ACCOUNT_NO("accountNo", 2, 2, '*'),
/** 邮箱类脱敏策略 */
EMAIL("email", 2, 7, '*'),
/** 身份证号类脱敏策略 */
ID_CARD("idCard", 6, 4, '*'),
/** 手机号码类脱敏策略 */
PHONE_NUMBER("phoneNumber", 3, 4, '*'),
/** 住址类脱敏策略 */
ADDRESS("address", 3, 4, '*');
private final String category;
private final int retainPrefixCount;
private final int retainSuffixCount;
private final char replaceChar;
SimpleDefenderStrategy(String category, int retainPrefixCount, int retainSuffixCount, char replaceChar) {
this.category = category;
this.retainPrefixCount = retainPrefixCount;
this.retainSuffixCount = retainSuffixCount;
this.replaceChar = replaceChar;
}
@Override
public String category() {
return this.category;
}
@Override
public int retainPrefixCount() {
return this.retainPrefixCount;
}
@Override
public int retainSuffixCount() {
return this.retainSuffixCount;
}
@Override
public char replaceChar() {
return this.replaceChar;
}
}