REM:
1. 重新格式化代码
This commit is contained in:
HuangXin 2020-09-15 15:31:48 +08:00
parent 8cbaecd3ba
commit cd46e50469
38 changed files with 312 additions and 316 deletions

View File

@ -118,22 +118,22 @@ public class DpTechAbilityImpl implements DisposeAbility {
log.debug("++++Begging DPTech Start Cleanup Task: {}, {}, {} ", ip, attackType, nfDirection);
NtcRequestResultInfo ret = cleanTypePort.startAbnormalTaskForUMC(ip, attackType,
nfDirection.getValue());
nfDirection.getValue());
if (ret.getResultRetVal() != 0) {
err = ErrorCode.ERR_CALLDEVICE;
log.error("----Error DPTech Start Cleanup Task: {}, {}, {}, {}", ip, nfDirection,
CommonEnumHandler.codeOf(DpTechAttackType.class, attackType),
ret.getResultInfo().getValue());
CommonEnumHandler.codeOf(DpTechAttackType.class, attackType),
ret.getResultInfo().getValue());
} else {
log.debug("----Finish DPTech Start Cleanup Task: {}, {}, {}, {}", ip, nfDirection,
CommonEnumHandler.codeOf(DpTechAttackType.class, attackType),
ret.getResultInfo().getValue());
CommonEnumHandler.codeOf(DpTechAttackType.class, attackType),
ret.getResultInfo().getValue());
}
} catch (Exception ex) {
err = ErrorCode.ERR_SYSTEMEXCEPTION;
log.error("----Exception DPTech Start Cleanup Task: {}, {}, {}", ip, nfDirection,
CommonEnumHandler.codeOf(DpTechAttackType.class, attackType));
CommonEnumHandler.codeOf(DpTechAttackType.class, attackType));
}
return new MulReturnType<>(err, null);
@ -161,22 +161,22 @@ public class DpTechAbilityImpl implements DisposeAbility {
log.info("++++Begging DPTech Stop Cleanup Task: {}, {}, {} ", ip, attackType, nfDirection);
NtcRequestResultInfo ret = cleanTypePort.stopAbnormalTaskForUMC(ip, attackType,
nfDirection.getValue());
nfDirection.getValue());
if (ret.getResultRetVal() != 0) {
err = ErrorCode.ERR_CALLDEVICE;
log.error("----Error DPTech Stop Cleanup Task: {}, {}, {}, {}", ip, nfDirection,
CommonEnumHandler.codeOf(DpTechAttackType.class, attackType),
ret.getResultInfo().getValue());
CommonEnumHandler.codeOf(DpTechAttackType.class, attackType),
ret.getResultInfo().getValue());
} else {
log.info("----Finish DPTech Stop Cleanup Task: {}, {}, {}, {}", ip, nfDirection,
CommonEnumHandler.codeOf(DpTechAttackType.class, attackType),
ret.getResultInfo().getValue());
CommonEnumHandler.codeOf(DpTechAttackType.class, attackType),
ret.getResultInfo().getValue());
}
} catch (Exception ex) {
err = ErrorCode.ERR_SYSTEMEXCEPTION;
log.error("----Exception DPTech Stop Cleanup Task: {}, {}, {}", ip, nfDirection,
CommonEnumHandler.codeOf(DpTechAttackType.class, attackType));
CommonEnumHandler.codeOf(DpTechAttackType.class, attackType));
}
return new MulReturnType<>(err, null);
@ -208,18 +208,18 @@ public class DpTechAbilityImpl implements DisposeAbility {
@Override
public MulReturnType<ErrorCode, DeviceFirewareInfo> getAbilityDeviceFireware() {
return new MulReturnType<>(ErrorCode.ERR_OK,
DeviceFirewareInfo.builder()
.vendor("DpTech")
.model("UMC")
.firmware("Unknown")
.os("Windows Server")
.kernel("Windows")
.arch("x86_64")
.version("5.7.31")
.memory(-1)
.freeMemory(-1)
.cpuUsed(-1)
.build());
DeviceFirewareInfo.builder()
.vendor("DpTech")
.model("UMC")
.firmware("Unknown")
.os("Windows Server")
.kernel("Windows")
.arch("x86_64")
.version("5.7.31")
.memory(-1)
.freeMemory(-1)
.cpuUsed(-1)
.build());
}
/**

View File

@ -70,8 +70,8 @@ public class HaoHanAbilityImpl implements DisposeAbility {
duration = -1L;
}
HaoHanStartCleanResp resp = restfulInterface.startClean(this.urlRootPath, ip, Math.max(duration.intValue(), 0),
DISPOSE_PLATFORM_NAME);
HaoHanStartCleanResp resp = restfulInterface.startClean(this.urlRootPath, ip, Math.max(duration.intValue(), 0),
DISPOSE_PLATFORM_NAME);
if (resp == null) {
log.error("----Error Haohan start clean {} server return error", ip);
@ -109,7 +109,7 @@ public class HaoHanAbilityImpl implements DisposeAbility {
}
HaoHanStopCleanResp resp = restfulInterface.stopClean(this.urlRootPath, taskId.intValue(),
DISPOSE_PLATFORM_NAME);
DISPOSE_PLATFORM_NAME);
if (resp == null) {
log.error("----Error Haohan stop task{} server return error", taskId);
@ -139,18 +139,18 @@ public class HaoHanAbilityImpl implements DisposeAbility {
@Override
public MulReturnType<ErrorCode, DeviceFirewareInfo> getAbilityDeviceFireware() {
return new MulReturnType<>(ErrorCode.ERR_OK,
DeviceFirewareInfo.builder()
.vendor("HaoHan")
.model("Unknown")
.firmware("Unknown")
.os("Linux Server")
.kernel("Linux")
.arch("x86_64")
.version("Unknown")
.memory(-1)
.freeMemory(-1)
.cpuUsed(-1)
.build());
DeviceFirewareInfo.builder()
.vendor("HaoHan")
.model("Unknown")
.firmware("Unknown")
.os("Linux Server")
.kernel("Linux")
.arch("x86_64")
.version("Unknown")
.memory(-1)
.freeMemory(-1)
.cpuUsed(-1)
.build());
}
/**

View File

@ -31,7 +31,7 @@ public class VirtualAbilityImpl implements DisposeAbility {
public void initDeviceEnv(String urlPath, String username, String password) {
final String offlineTarget = "0";
if(offlineTarget.equals(username)) {
if (offlineTarget.equals(username)) {
isOnline = false;
}
}
@ -78,18 +78,18 @@ public class VirtualAbilityImpl implements DisposeAbility {
@Override
public MulReturnType<ErrorCode, DeviceFirewareInfo> getAbilityDeviceFireware() {
return new MulReturnType<>(ErrorCode.ERR_OK,
DeviceFirewareInfo.builder()
.vendor("Virtual")
.model("Dispose_1000")
.firmware("Unknown")
.os("Unknown")
.kernel("Linux")
.arch("x86_64")
.version("Virtual_Device_2.0")
.memory(-1)
.freeMemory(-1)
.cpuUsed(-1)
.build());
DeviceFirewareInfo.builder()
.vendor("Virtual")
.model("Dispose_1000")
.firmware("Unknown")
.os("Unknown")
.kernel("Linux")
.arch("x86_64")
.version("Virtual_Device_2.0")
.memory(-1)
.freeMemory(-1)
.cpuUsed(-1)
.build());
}
/**

View File

@ -8,42 +8,35 @@ import java.util.HashMap;
* @author <huangxin@cmhi.chinamoblie.com>
*/
public class AuthConfigValue {
/**
* The constant VERIFY_REQUEST_TOKEN.
*/
public static volatile boolean VERIFY_REQUEST_TOKEN = true;
/**
* The constant ALLOW_PWD_ERR_TIMES.
*/
public static final int ALLOW_PWD_ERR_TIMES = 5;
/**
* The constant TOKEN_EXPIRED_TIME_MS.
*/
public static volatile long TOKEN_EXPIRED_TIME_MS = 30 * 60 * 1000;
/**
* The constant MYSQL_REGEX.
*/
public static final String MYSQL_REGEX = "^((?!(and|exec|insert|select|drop|grant|alter" +
"|delete|update|count|chr|mid|master|truncate|char|declare|or|--|\\s|\\*|%|\\+|'|;])).)*$";
"|delete|update|count|chr|mid|master|truncate|char|declare|or|--|\\s|\\*|%|\\+|'|;])).)*$";
/**
* The constant MYSQL_REGEX_CHARS.
*/
public static final String MYSQL_REGEX_CHARS = "^((?!(--|\\s|\\*|%|\\+|'|;])).)*$";
/**
* The constant TRUST_TOKEN_CACHE.
*/
public static final HashMap<String, Long> TRUST_TOKEN_CACHE = new HashMap<>();
/**
* The constant TRUST_HOST_CACHE.
*/
public static final HashMap<String, Long> TRUST_HOST_CACHE = new HashMap<>();
/**
* The constant VERIFY_REQUEST_TOKEN.
*/
public static volatile boolean VERIFY_REQUEST_TOKEN = true;
/**
* The constant TOKEN_EXPIRED_TIME_MS.
*/
public static volatile long TOKEN_EXPIRED_TIME_MS = 30 * 60 * 1000;
/**
* The constant AUTH_WHITE_LIST_CHECK.
*/

View File

@ -40,6 +40,26 @@ public final class CommonEnumHandler<E extends BaseEnum> extends BaseTypeHandler
this.enums = Arrays.asList(type.getEnumConstants());
}
/**
* Code of e.
*
* @param <E> the type parameter
* @param enumClass the enum class
* @param code the code
* @return the e
*/
public static <E extends Enum<?> & BaseEnum> E codeOf(Class<E> enumClass, int code) {
E[] enumCodes = enumClass.getEnumConstants();
for (E e : enumCodes) {
if (e.getValue() == code) {
return e;
}
}
return null;
}
/**
* Sets non null parameter.
*
@ -122,24 +142,4 @@ public final class CommonEnumHandler<E extends BaseEnum> extends BaseTypeHandler
}
throw new IllegalArgumentException(enumType.getName() + " unknown enumerated type index:" + index);
}
/**
* Code of e.
*
* @param <E> the type parameter
* @param enumClass the enum class
* @param code the code
* @return the e
*/
public static <E extends Enum<?> & BaseEnum> E codeOf(Class<E> enumClass, int code) {
E[] enumCodes = enumClass.getEnumConstants();
for(E e : enumCodes) {
if(e.getValue() == code) {
return e;
}
}
return null;
}
}

View File

@ -70,12 +70,14 @@ public class ConstValue {
"|(([\\da-fA-F]{1,4}:){2}((:[\\da-fA-F]{1,4}){1,4}|:)(\\/([1-9]?\\d|(1([0-1]\\d|2[0-8]))))?)|(([\\da-fA-F]{1," +
"4}:){3}((:[\\da-fA-F]{1,4}){1,3}|:)(\\/([1-9]?\\d|(1([0-1]\\d|2[0-8]))))?)|(([\\da-fA-F]{1,4}:){4}(" +
"(:[\\da-fA-F]{1,4}){1,2}|:)(\\/([1-9]?\\d|(1([0-1]\\d|2[0-8]))))?)|(([\\da-fA-F]{1,4}:){5}:([\\da-fA-F]{1," +
"4})?(\\/([1-9]?\\d|(1([0-1]\\d|2[0-8]))))?)|(([\\da-fA-F]{1,4}:){6}:(\\/([1-9]?\\d|(1([0-1]\\d|2[0-8]))))?)))$";
"4})?(\\/([1-9]?\\d|(1([0-1]\\d|2[0-8]))))?)|(([\\da-fA-F]{1,4}:){6}:(\\/([1-9]?\\d|(1([0-1]\\d|2[0-8]))))?))" +
")$";
/**
* The constant IP_PORT_REG.
*/
public static final String IP_PORT_REG="^[1-9]$|(^[1-9][0-9]$)|(^[1-9][0-9][0-9]$)|(^[1-9][0-9][0-9][0-9]$)|(^[1-6][0-5][0-5][0-3][0-5]$)";
public static final String IP_PORT_REG = "^[1-9]$|(^[1-9][0-9]$)|(^[1-9][0-9][0-9]$)|(^[1-9][0-9][0-9][0-9]$)|" +
"(^[1-6][0-5][0-5][0-3][0-5]$)";
/**
* The type Protocol.

View File

@ -90,7 +90,7 @@ public enum DpTechAttackType implements BaseEnum {
long mask = 0L;
for (DpTechAttackType type : types) {
mask |= (long)1 << type.getValue();
mask |= (long) 1 << type.getValue();
}
return mask;
@ -104,9 +104,9 @@ public enum DpTechAttackType implements BaseEnum {
*/
public static Long formDdosAttackTypeMaks(Long ddosAttackMask) {
return getTypeMaskFromAttackType(DDoSAttackType.maskToDdosAttackType(ddosAttackMask)
.stream()
.flatMap(DpTechAttackType::fromDdosAttackTypeValue)
.distinct().toArray(DpTechAttackType[]::new));
.stream()
.flatMap(DpTechAttackType::fromDdosAttackTypeValue)
.distinct().toArray(DpTechAttackType[]::new));
}
/**
@ -118,8 +118,8 @@ public enum DpTechAttackType implements BaseEnum {
public static List<DpTechAttackType> maskToDdosAttackType(Long attackTypeMask) {
List<DpTechAttackType> attackTypes = new ArrayList<>();
for(DpTechAttackType t : DpTechAttackType.values()) {
if((((long)1 << t.getValue()) & attackTypeMask) != 0) {
for (DpTechAttackType t : DpTechAttackType.values()) {
if ((((long) 1 << t.getValue()) & attackTypeMask) != 0) {
attackTypes.add(t);
}
}
@ -248,6 +248,6 @@ public enum DpTechAttackType implements BaseEnum {
* @return the attack type mask
*/
public Long getAttackTypeMask() {
return (long)1 << this.code;
return (long) 1 << this.code;
}
}

View File

@ -242,7 +242,7 @@ public enum ErrorCode {
* @return the http code
*/
public int getHttpCode() {
switch(this) {
switch (this) {
case ERR_OK:
return HttpServletResponse.SC_OK;
case ERR_SYSTEMEXCEPTION:

View File

@ -134,7 +134,7 @@ public class Helper {
}
// 处理CIDR格式
if(rangeIp.contains(cidrSplit)) {
if (rangeIp.contains(cidrSplit)) {
IPAddressString network = new IPAddressString(rangeIp);
IPAddressString ip = new IPAddressString(ipAddr);
return network.prefixContains(ip);

View File

@ -36,6 +36,22 @@ public enum HttpType implements BaseEnum {
this.readme = readme;
}
/**
* Gets default port.
*
* @param type the type
* @return the default port
*/
public static String getDefaultPort(HttpType type) {
if (type == HTTP) {
return "80";
} else if (type == HTTPS) {
return "443";
} else {
return "";
}
}
/**
* Gets value.
*
@ -55,20 +71,4 @@ public enum HttpType implements BaseEnum {
public String getDescription() {
return this.readme;
}
/**
* Gets default port.
*
* @param type the type
* @return the default port
*/
public static String getDefaultPort(HttpType type) {
if(type == HTTP) {
return "80";
} else if(type == HTTPS) {
return "443";
} else {
return "";
}
}
}

View File

@ -44,6 +44,16 @@ public enum ProtoCryptoType {
this.readme = readme;
}
/**
* Verify crypto valuable boolean.
*
* @param code the code
* @return the boolean
*/
public static boolean verifyCryptoValuable(int code) {
return code >= CRYPTO_NONE.getCode() && code <= CRYPTO_DES.getCode();
}
/**
* Gets code.
*
@ -61,14 +71,4 @@ public enum ProtoCryptoType {
public String getReadme() {
return this.readme;
}
/**
* Verify crypto valuable boolean.
*
* @param code the code
* @return the boolean
*/
public static boolean verifyCryptoValuable(int code) {
return code >= CRYPTO_NONE.getCode() && code <= CRYPTO_DES.getCode();
}
}

View File

@ -51,7 +51,7 @@ public class AuthConfigure implements WebMvcConfigurer {
* @return the token interceptor
*/
@Bean
public TokenInterceptor initAuthInterceptor(){
public TokenInterceptor initAuthInterceptor() {
return new TokenInterceptor();
}

View File

@ -59,12 +59,12 @@ public class AuthController {
@ResponseBody
@ApiOperation("登录")
public ProtocolRespDTO<? extends BaseRespStatus> userLogin(
@Validated(ValidGroups.LoginReqValid.class)
@RequestBody ProtocolReqDTO<LoginReq> mr)
throws NoSuchAlgorithmException {
@Validated(ValidGroups.LoginReqValid.class)
@RequestBody ProtocolReqDTO<LoginReq> mr)
throws NoSuchAlgorithmException {
// 登录
MulReturnType<ErrorCode, String> ret = userAccountService.loginService(mr.getMsgContent().getUserName(),
mr.getMsgContent().getPassword());
mr.getMsgContent().getPassword());
// 登录错误
if (ret.getFirstParam() != ErrorCode.ERR_OK) {
@ -76,11 +76,11 @@ public class AuthController {
long expTime = AuthConfigValue.TOKEN_EXPIRED_TIME_MS / 1000 / 60;
LoginRsp rspInfo = LoginRsp.builder()
.userName(mr.getMsgContent().getUserName())
.token(ret.getSecondParam())
.logTime(System.currentTimeMillis())
.expireTime(expTime)
.build();
.userName(mr.getMsgContent().getUserName())
.token(ret.getSecondParam())
.logTime(System.currentTimeMillis())
.expireTime(expTime)
.build();
rspInfo.setStatus(ErrorCode.ERR_OK.getCode());
rspInfo.setMessage(new String[]{ErrorCode.ERR_OK.getMsg()});
@ -103,7 +103,7 @@ public class AuthController {
@RequestBody ProtocolReqDTO<LoginReq> mr,
@RequestHeader HttpHeaders headers) { // 注销用户登录
ErrorCode err = userAccountService.logoutService(mr.getMsgContent().getUserName(),
mr.getAuthToken(headers));
mr.getAuthToken(headers));
// 注销失败
if (err != ErrorCode.ERR_OK) {
@ -113,8 +113,8 @@ public class AuthController {
// 创建返回消息
LoginRsp rspInfo = LoginRsp.builder()
.userName(mr.getMsgContent().getUserName())
.build();
.userName(mr.getMsgContent().getUserName())
.build();
rspInfo.setStatus(err.getCode());
rspInfo.setMessage(new String[]{err.getMsg()});

View File

@ -93,30 +93,30 @@ public class DisposeTaskController {
// 构造处置任务参数
DisposeTask task = DisposeTask.builder()
.deviceId(Long.parseLong(Optional.ofNullable(req.getId()).orElse("-1")))
.accountId(userAccountService.getUserIdByAuthHead(Objects.requireNonNull(headers.get("Authorization"))
.get(0)))
.disposeCapacity(CommonEnumHandler.codeOf(DisposeCapacityType.class,
req.getType()))
.disposeIp(Helper.ipAddressNormalize(req.getDisposeIp()))
.planEndTime(String.valueOf(req.getDisposeTime()))
.flowDirection(CommonEnumHandler.codeOf(NetflowDirection.class,
Optional.ofNullable(req.getFlowDirection())
.orElse(2)))
.attackType(DDoSAttackType.getTypeMaskFromAttackType(
Optional.ofNullable(req.getAttackType())
.orElse(new Integer[]{DDoSAttackType.ALL_ATTACKS.getValue()})))
.flowBandWidth(Optional.ofNullable(req.getFlowBandwidth())
.orElse(DisposeConfigValue.DEFAULT_DISPOSE_BANDWIDTH))
.build();
.deviceId(Long.parseLong(Optional.ofNullable(req.getId()).orElse("-1")))
.accountId(userAccountService.getUserIdByAuthHead(Objects.requireNonNull(headers.get("Authorization"))
.get(0)))
.disposeCapacity(CommonEnumHandler.codeOf(DisposeCapacityType.class,
req.getType()))
.disposeIp(Helper.ipAddressNormalize(req.getDisposeIp()))
.planEndTime(String.valueOf(req.getDisposeTime()))
.flowDirection(CommonEnumHandler.codeOf(NetflowDirection.class,
Optional.ofNullable(req.getFlowDirection())
.orElse(2)))
.attackType(DDoSAttackType.getTypeMaskFromAttackType(
Optional.ofNullable(req.getAttackType())
.orElse(new Integer[]{DDoSAttackType.ALL_ATTACKS.getValue()})))
.flowBandWidth(Optional.ofNullable(req.getFlowBandwidth())
.orElse(DisposeConfigValue.DEFAULT_DISPOSE_BANDWIDTH))
.build();
// 创建处置任务
MulReturnType<ErrorCode, DisposeTask> ret = disposeTaskService.createTask(task);
// 设置返回消息
TaskStartRsp rspInfo = TaskStartRsp.builder()
.disposeIp(task.getDisposeIp())
.build();
.disposeIp(task.getDisposeIp())
.build();
rspInfo.setStatus(ret.getFirstParam().getCode());
rspInfo.setMessage(new String[]{ret.getFirstParam().getMsg()});
@ -156,34 +156,34 @@ public class DisposeTaskController {
NetflowDirection netDir = CommonEnumHandler.codeOf(NetflowDirection.class,
Optional.ofNullable(req.getFlowDirection()).orElse(2));
Long attackType = DDoSAttackType.getTypeMaskFromAttackType(Optional.ofNullable(req.getAttackType())
.orElse(new Integer[]{DDoSAttackType.ALL_ATTACKS.getValue()}));
.orElse(new Integer[]{DDoSAttackType.ALL_ATTACKS.getValue()}));
Integer flowBand = Optional.ofNullable(req.getFlowBandwidth())
.orElse(DisposeConfigValue.DEFAULT_DISPOSE_BANDWIDTH);
.orElse(DisposeConfigValue.DEFAULT_DISPOSE_BANDWIDTH);
TaskStartMulRsp mulRsp = TaskStartMulRsp.builder()
.items(new ArrayList<>())
.build();
.items(new ArrayList<>())
.build();
for (String ip : req.getMulDisposeIp()) {
// 构造处置任务参数
DisposeTask task = DisposeTask.builder()
.deviceId(devId)
.accountId(aId)
.disposeCapacity(capType)
.disposeIp(Helper.ipAddressNormalize(ip))
.planEndTime(endTime)
.flowDirection(netDir)
.attackType(attackType)
.flowBandWidth(flowBand)
.build();
.deviceId(devId)
.accountId(aId)
.disposeCapacity(capType)
.disposeIp(Helper.ipAddressNormalize(ip))
.planEndTime(endTime)
.flowDirection(netDir)
.attackType(attackType)
.flowBandWidth(flowBand)
.build();
// 创建处置任务
MulReturnType<ErrorCode, DisposeTask> ret = disposeTaskService.createTask(task);
// 设置返回消息
TaskStartRsp rspInfo = TaskStartRsp.builder()
.disposeIp(ip)
.build();
.disposeIp(ip)
.build();
// 启动任务成功
if (ret.getFirstParam() == ErrorCode.ERR_OK ||
@ -211,7 +211,7 @@ public class DisposeTaskController {
@ResponseBody
@ApiOperation("停止处置任务")
public ProtocolRespDTO<TaskStopRsp> stopTask(@Validated(ValidGroups.TaskStopReqValid.class)
@RequestBody ProtocolReqDTO<IdArraysReq> mr) {
@RequestBody ProtocolReqDTO<IdArraysReq> mr) {
// 记录多个任务停止信息
TaskStopRsp rspList = new TaskStopRsp();
@ -228,9 +228,9 @@ public class DisposeTaskController {
// 停止成功
if (ret.getFirstParam() == ErrorCode.ERR_OK) {
rspInfo.setDisposeDevice(ret.getSecondParam().getDeviceTask().stream()
.map(DeviceTask::getDeviceId)
.map(String::valueOf)
.toArray(String[]::new));
.map(DeviceTask::getDeviceId)
.map(String::valueOf)
.toArray(String[]::new));
rspInfo.setType(ret.getSecondParam().getDisposeCapacity().getValue());
rspInfo.setDisposeIp(ret.getSecondParam().getDisposeIp());
rspInfo.setLeftTime(String.valueOf(Math.abs(
@ -278,26 +278,26 @@ public class DisposeTaskController {
ret.getSecondParam().forEach(v -> {
GetTaskDetail taskDetail = GetTaskDetail.builder()
.taskId(String.valueOf(v.getId()))
.accountId(String.valueOf(v.getAccountId()))
.disposeCapacity(v.getDisposeCapacity().getValue())
.disposeIp(v.getDisposeIp())
.createTime(v.getCreateTime())
.planEndTime(v.getPlanEndTime())
.endTime(v.getEndTime())
.flowDirection(v.getFlowDirection().getValue())
.attackType(v.getAttackType().toString())
.flowBandWidth(v.getFlowBandWidth())
.currentStatus(v.getCurrentStatus().getValue())
.deviceTask(new ArrayList<>())
.build();
.taskId(String.valueOf(v.getId()))
.accountId(String.valueOf(v.getAccountId()))
.disposeCapacity(v.getDisposeCapacity().getValue())
.disposeIp(v.getDisposeIp())
.createTime(v.getCreateTime())
.planEndTime(v.getPlanEndTime())
.endTime(v.getEndTime())
.flowDirection(v.getFlowDirection().getValue())
.attackType(v.getAttackType().toString())
.flowBandWidth(v.getFlowBandWidth())
.currentStatus(v.getCurrentStatus().getValue())
.deviceTask(new ArrayList<>())
.build();
v.getDeviceTask().forEach(k -> {
GetDeviceTaskDetail deviceTaskDetail = GetDeviceTaskDetail.builder()
.devTaskId(String.valueOf(k.getId()))
.devId(String.valueOf(k.getDeviceId()))
.externId(String.valueOf(k.getExternId()))
.status(k.getStatus())
.build();
.devTaskId(String.valueOf(k.getId()))
.devId(String.valueOf(k.getDeviceId()))
.externId(String.valueOf(k.getExternId()))
.status(k.getStatus())
.build();
taskDetail.getDeviceTask().add(deviceTaskDetail);
});

View File

@ -41,10 +41,10 @@ public class DeviceTaskManagerImpl implements DeviceTaskManager {
}
return deviceTaskMapper.addNewTaskInfo(DeviceTask.builder()
.taskId(taskId)
.deviceId(deviceId)
.taskAttackType(attackTypeMask)
.build()) == 1;
.taskId(taskId)
.deviceId(deviceId)
.taskAttackType(attackTypeMask)
.build()) == 1;
}
/**
@ -112,7 +112,7 @@ public class DeviceTaskManagerImpl implements DeviceTaskManager {
@Override
public void execAttackTypeCleanBit(Long id, NetflowDirection nf, Integer bit) {
Long execAttackTypeMask;
long bitMask = (long)1 << bit;
long bitMask = (long) 1 << bit;
DeviceTask devTask = deviceTaskMapper.getTaskInfoById(id);
@ -143,7 +143,7 @@ public class DeviceTaskManagerImpl implements DeviceTaskManager {
@Override
public void execAttackTypeSetBit(Long id, NetflowDirection nf, Integer bit) {
Long execAttackTypeMask;
long bitMask = (long)1 << bit;
long bitMask = (long) 1 << bit;
DeviceTask devTask = deviceTaskMapper.getTaskInfoById(id);
@ -197,7 +197,7 @@ public class DeviceTaskManagerImpl implements DeviceTaskManager {
@Override
public void attackTypeStatusCleanBit(Long id, NetflowDirection nf, Integer bit) {
Long attackTypeStatusMask;
long bitMask = (long)1 << bit;
long bitMask = (long) 1 << bit;
DeviceTask devTask = deviceTaskMapper.getTaskInfoById(id);
@ -228,7 +228,7 @@ public class DeviceTaskManagerImpl implements DeviceTaskManager {
@Override
public void attackTypeStatusSetBit(Long id, NetflowDirection nf, Integer bit) {
Long attackTypeStatusMask;
long bitMask = (long)1 << bit;
long bitMask = (long) 1 << bit;
DeviceTask devTask = deviceTaskMapper.getTaskInfoById(id);

View File

@ -77,7 +77,7 @@ public class DisposeDeviceManagerImpl implements DisposeDeviceManager {
// 添加设备能力信息
if (err == ErrorCode.ERR_OK) {
dev.getDevCapacity().forEach(v-> v.setDeviceId(dev.getId()));
dev.getDevCapacity().forEach(v -> v.setDeviceId(dev.getId()));
disposeCapacityMapper.addNewDisposeCapacity(dev.getDevCapacity());
}
@ -109,7 +109,7 @@ public class DisposeDeviceManagerImpl implements DisposeDeviceManager {
fdDest.setAccessible(true);
if (!obj.equals(fdDest.get(destDev))) {
log.debug("Upgrade field [{}] value form [{}] to [{}]",
fdSrc.getName(), fdDest.get(destDev), obj);
fdSrc.getName(), fdDest.get(destDev), obj);
fdDest.set(destDev, obj);
}
fdDest.setAccessible(false);
@ -137,11 +137,11 @@ public class DisposeDeviceManagerImpl implements DisposeDeviceManager {
// HTTP 默认端口
if (dev.getUrlType() == HttpType.HTTP) {
tDev = disposeDeviceMapper.getDeviceByAddress(dev.getIpAddr(),
HttpType.getDefaultPort(HttpType.HTTP));
HttpType.getDefaultPort(HttpType.HTTP));
} else if (dev.getUrlType() == HttpType.HTTPS) {
// HTTPS 默认端口
tDev = disposeDeviceMapper.getDeviceByAddress(dev.getIpAddr(),
HttpType.getDefaultPort(HttpType.HTTPS));
HttpType.getDefaultPort(HttpType.HTTPS));
}
}
}
@ -164,7 +164,7 @@ public class DisposeDeviceManagerImpl implements DisposeDeviceManager {
Long devId = tDev.getId();
if (tDev.getDevCapacity().size() != 0) {
tDev.getDevCapacity().forEach(v-> v.setDeviceId(devId));
tDev.getDevCapacity().forEach(v -> v.setDeviceId(devId));
disposeCapacityMapper.addNewDisposeCapacity(tDev.getDevCapacity());
}
@ -247,7 +247,7 @@ public class DisposeDeviceManagerImpl implements DisposeDeviceManager {
@Override
public List<DisposeDevice> getAllNormalDisposeDevices() {
return disposeDeviceMapper.selectAll().stream()
.filter(v -> v.getStatus() == ObjectStatus.NORMAL)
.collect(Collectors.toList());
.filter(v -> v.getStatus() == ObjectStatus.NORMAL)
.collect(Collectors.toList());
}
}

View File

@ -123,7 +123,7 @@ public class DisposeTaskManagerImpl implements DisposeTaskManager {
List<DisposeTask> taskList = disposeTaskMapper.selectAll();
if(taskList == null) {
if (taskList == null) {
taskList = new ArrayList<>();
}

View File

@ -68,8 +68,8 @@ public class UserAccountManagerImpl implements UserAccountManager {
public UserAccount getUserByName(String username) {
// 根据用户名在缓存中查找用户
Optional<UserAccount> findRet = userAccountCache.values().stream()
.filter(userAccountCache -> userAccountCache.getUsername().equals(username))
.findFirst();
.filter(userAccountCache -> userAccountCache.getUsername().equals(username))
.findFirst();
return findRet.orElseGet(() -> userAccountMapper.getUserByName(username));
}
@ -103,8 +103,8 @@ public class UserAccountManagerImpl implements UserAccountManager {
// 根据用户名在缓存中查找用户
Optional<UserAccount> findRet = userAccountCache.values().stream()
.filter(userAccountCache -> username.equals(userAccountCache.getUsername()))
.findFirst();
.filter(userAccountCache -> username.equals(userAccountCache.getUsername()))
.findFirst();
// 缓存中存在
if (findRet.isPresent()) {
@ -169,8 +169,8 @@ public class UserAccountManagerImpl implements UserAccountManager {
@Override
public int getUsrPwdErrTimes(String username) {
Optional<UserAccount> findRet = userAccountCache.values().stream()
.filter(userAccountCache -> username.equals(userAccountCache.getUsername()))
.findFirst();
.filter(userAccountCache -> username.equals(userAccountCache.getUsername()))
.findFirst();
if (findRet.isPresent()) {
return findRet.get().getPwdErrTimes();
@ -189,8 +189,8 @@ public class UserAccountManagerImpl implements UserAccountManager {
@Override
public void setUserPwdErrTimes(String username, Integer errTimes) {
Optional<UserAccount> findRet = userAccountCache.values().stream()
.filter(userAccountCache -> username.equals(userAccountCache.getUsername()))
.findFirst();
.filter(userAccountCache -> username.equals(userAccountCache.getUsername()))
.findFirst();
if (findRet.isPresent()) {
findRet.get().setPwdErrTimes(Math.abs(errTimes));
@ -211,8 +211,8 @@ public class UserAccountManagerImpl implements UserAccountManager {
// 根据用户名在缓存中查找用户
Optional<UserAccount> findRet = userAccountCache.values().stream()
.filter(userAccountCache -> username.equals(userAccountCache.getUsername()))
.findFirst();
.filter(userAccountCache -> username.equals(userAccountCache.getUsername()))
.findFirst();
// 缓存中存在
if (findRet.isPresent()) {
@ -296,8 +296,8 @@ public class UserAccountManagerImpl implements UserAccountManager {
MessageDigest messageDigest = MessageDigest.getInstance("SHA-256");
String tokenKey = username +
Convert.toStr(new Random(System.currentTimeMillis())) +
Convert.toStr(System.currentTimeMillis());
Convert.toStr(new Random(System.currentTimeMillis())) +
Convert.toStr(System.currentTimeMillis());
// 调用digest方法进行加密操作
byte[] cipherBytes = messageDigest.digest(tokenKey.getBytes());
@ -431,7 +431,7 @@ public class UserAccountManagerImpl implements UserAccountManager {
}
// 检测用户名是否匹配
if(!user.getUsername().equals(username)) {
if (!user.getUsername().equals(username)) {
return ErrorCode.ERR_USERNOTFOUND;
}
@ -452,7 +452,7 @@ public class UserAccountManagerImpl implements UserAccountManager {
private boolean tokenTimeout(String lastAccess) {
try {
return (System.currentTimeMillis() - Helper.getTimestampMilliSecond(lastAccess))
>= AuthConfigValue.TOKEN_EXPIRED_TIME_MS;
>= AuthConfigValue.TOKEN_EXPIRED_TIME_MS;
} catch (Exception ex) {
return true;
}

View File

@ -10,7 +10,7 @@ import java.util.List;
*
* @author <huangxin@cmhi.chinamoblie.com>
*/
public interface UserAccountMapper {
public interface UserAccountMapper {
/**
* Select all list.
@ -38,7 +38,7 @@ public interface UserAccountMapper {
* @param operators the operators
*/
void delUserAccount(@Param("username") String username,
@Param("operators") String operators);
@Param("operators") String operators);
/**
* Disable user account.
@ -47,7 +47,7 @@ public interface UserAccountMapper {
* @param operators the operators
*/
void disableUserAccount(@Param("username") String username,
@Param("operators") String operators);
@Param("operators") String operators);
/**
* Gets user by name.
@ -110,5 +110,5 @@ public interface UserAccountMapper {
* @return the pwd err times
*/
Integer setPwdErrTimes(@Param("username") String username,
@Param("pwdErrTimes") Integer pwdErrTimes);
@Param("pwdErrTimes") Integer pwdErrTimes);
}

View File

@ -28,9 +28,9 @@ public class LoginReq {
*/
@NotBlank(message = "userName 用户名不能为空", groups = ValidGroups.LogoutReqValid.class)
@Pattern(regexp = AuthConfigValue.MYSQL_REGEX_CHARS,
flags = Pattern.Flag.CASE_INSENSITIVE,
message = "userName 用户名存在非法字符串",
groups = ValidGroups.LogoutReqValid.class)
flags = Pattern.Flag.CASE_INSENSITIVE,
message = "userName 用户名存在非法字符串",
groups = ValidGroups.LogoutReqValid.class)
private String userName;
/**
@ -38,11 +38,11 @@ public class LoginReq {
*/
@NotBlank(message = "password 密码不能为空", groups = ValidGroups.LoginReqValid.class)
@Length(min = 64, max = 64,
message = "password 密码长度必须为SHA256编码后的长度",
groups = ValidGroups.LoginReqValid.class)
message = "password 密码长度必须为SHA256编码后的长度",
groups = ValidGroups.LoginReqValid.class)
@Pattern(regexp = AuthConfigValue.MYSQL_REGEX_CHARS,
flags = Pattern.Flag.CASE_INSENSITIVE,
message = "password 密码存在非法字符串",
groups = ValidGroups.LoginReqValid.class)
flags = Pattern.Flag.CASE_INSENSITIVE,
message = "password 密码存在非法字符串",
groups = ValidGroups.LoginReqValid.class)
private String password;
}

View File

@ -35,15 +35,15 @@ public class BaseProtocolDTO<T> {
* msgContent字段内容编码格式
*/
@ApiModelProperty(value = "msgContent字段内容编码格式\n" +
"0无编码格式普通字符串\n" +
"1base64编码格式\n" +
"2采用AES加密后的base64编码格式\n", required = true,
allowableValues = "0, 1, 2",
example = "0")
"0无编码格式普通字符串\n" +
"1base64编码格式\n" +
"2采用AES加密后的base64编码格式\n", required = true,
allowableValues = "0, 1, 2",
example = "0")
@NotNull(message = "cryptoType 字段不能为空", groups = ValidGroups.ProtocolCommonValid.class)
@Range(min = 0, max = 2,
message = "cryptoType 字段取值为 [0, 2]"
, groups = ValidGroups.ProtocolCommonValid.class)
message = "cryptoType 字段取值为 [0, 2]"
, groups = ValidGroups.ProtocolCommonValid.class)
private Integer cryptoType;
/**
@ -52,8 +52,8 @@ public class BaseProtocolDTO<T> {
@ApiModelProperty(value = "当前UTC时间戳", required = true, example = "1526625689000")
@NotNull(message = "timeStamp 字段不能为空", groups = ValidGroups.ProtocolCommonValid.class)
@DecimalMin(value = "1595494343000",
message = "timeStamp 字段值不能为过去时间"
, groups = ValidGroups.ProtocolCommonValid.class)
message = "timeStamp 字段值不能为过去时间"
, groups = ValidGroups.ProtocolCommonValid.class)
private Long timeStamp;
/**

View File

@ -19,7 +19,7 @@ import lombok.NoArgsConstructor;
@Builder
@NoArgsConstructor
@AllArgsConstructor
@JsonPropertyOrder({"id", "ipAddr", "ipPort", "version", "online" ,"status", "message"})
@JsonPropertyOrder({"id", "ipAddr", "ipPort", "version", "online", "status", "message"})
@JsonInclude(JsonInclude.Include.NON_NULL)
public class DeviceDetail extends BaseIdResp {
/**

View File

@ -15,7 +15,7 @@ import lombok.NoArgsConstructor;
@Data
@NoArgsConstructor
@JsonPropertyOrder({"id", "ipAddr", "ipPort", "deviceType", "areaCode", "deviceName", "manufacturer",
"model", "version", "userName", "password", "urlPath", "urlType", "readme", "devStatus", "capacity"})
"model", "version", "userName", "password", "urlPath", "urlType", "readme", "devStatus", "capacity"})
@JsonInclude(JsonInclude.Include.NON_NULL)
public class GetDeviceDetail extends AddDeviceInfo {
/**

View File

@ -29,7 +29,7 @@ import java.util.List;
@AllArgsConstructor
@Builder
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonPropertyOrder(alphabetic=true)
@JsonPropertyOrder(alphabetic = true)
@Table(name = "dispose_device")
@NameStyle(Style.normal)
public class DisposeDevice implements Serializable {

View File

@ -39,7 +39,7 @@ public interface ProtocolSecurityService {
* @return the string
*/
String encryptProtocolString(String plainText, int cryptoType);
/**
* Encrypt protocol protocol resp dto.
*

View File

@ -65,7 +65,7 @@ public class DeviceTaskManagerServiceImpl implements DeviceTaskManagerService {
deviceTaskManager.changeDisposeDeviceTaskInfoStatus(deviceTask.getId(), DisposeTaskStatus.TASK_STARTING);
// 设置启动任务攻击类型状态
deviceTaskManager.setExecAttackType(deviceTask.getId(), NetflowDirection.DIRECTION_BI,
deviceTask.getTaskAttackType());
deviceTask.getTaskAttackType());
// 调用设备执行处置任务
ret = ai.getDb().runDispose(disposeTask.getDisposeIp(), disposeTask.getDisposeCapacity(), null, null, null);
@ -73,15 +73,15 @@ public class DeviceTaskManagerServiceImpl implements DeviceTaskManagerService {
if (ret.getFirstParam() == ErrorCode.ERR_OK) {
// 设置攻击类型任务启动结果
deviceTaskManager.setAttackTypeStatus(deviceTask.getId(),
disposeTask.getFlowDirection(), deviceTask.getTaskAttackType());
disposeTask.getFlowDirection(), deviceTask.getTaskAttackType());
// 更改处置任务状态为处置中
deviceTaskManager.changeDisposeDeviceTaskInfoStatus(deviceTask.getId(),
DisposeTaskStatus.TASK_STARTED);
DisposeTaskStatus.TASK_STARTED);
log.info("VIRTUAL_DISPOSE setup task succeed: {}", deviceTask);
} else {
// 任务出错不在重试当做失败任务处理
deviceTaskManager.setAttackTypeStatus(deviceTask.getId(),
disposeTask.getFlowDirection(), 0L);
disposeTask.getFlowDirection(), 0L);
log.error("VIRTUAL_DISPOSE setup task error {}: {}", ret.getFirstParam(), deviceTask);
}
}
@ -129,15 +129,15 @@ public class DeviceTaskManagerServiceImpl implements DeviceTaskManagerService {
deviceTaskManager.changeDisposeDeviceTaskInfoStatus(deviceTask.getId(), DisposeTaskStatus.TASK_STARTING);
// 设置启动任务攻击类型状态
deviceTaskManager.setExecAttackType(deviceTask.getId(), NetflowDirection.DIRECTION_BI,
deviceTask.getTaskAttackType());
deviceTask.getTaskAttackType());
ret = ai.getDb().runDispose(disposeTask.getDisposeIp(), disposeTask.getDisposeCapacity(), null, null,
(long) -Helper.getTimestampDiffNow(disposeTask.getPlanEndTime()));
(long) -Helper.getTimestampDiffNow(disposeTask.getPlanEndTime()));
if (ret.getFirstParam() == ErrorCode.ERR_OK) {
// 设置攻击类型任务启动结果
deviceTaskManager.setAttackTypeStatus(deviceTask.getId(),
disposeTask.getFlowDirection(), deviceTask.getTaskAttackType());
disposeTask.getFlowDirection(), deviceTask.getTaskAttackType());
// 更改处置任务状态为处置中
deviceTaskManager.changeDisposeDeviceTaskInfoStatus(deviceTask.getId(), DisposeTaskStatus.TASK_STARTED);
@ -154,11 +154,11 @@ public class DeviceTaskManagerServiceImpl implements DeviceTaskManagerService {
// 记录任务出错重试次数
deviceTaskManager.setTaskErrRetryTimes(deviceTask.getId(), deviceTask.getErrRetry() + 1);
log.error("HAOHAN_PLATFORM setup task times {} error {}: {}", deviceTask.getErrRetry(),
ret.getSecondParam(), deviceTask);
ret.getSecondParam(), deviceTask);
} else {
// 任务出错不在重试当做失败任务处理
deviceTaskManager.setAttackTypeStatus(deviceTask.getId(),
disposeTask.getFlowDirection(), 0L);
disposeTask.getFlowDirection(), 0L);
log.error("HAOHAN_PLATFORM setup task error {}: {}", ret.getFirstParam(), deviceTask);
}
}
@ -175,7 +175,7 @@ public class DeviceTaskManagerServiceImpl implements DeviceTaskManagerService {
// 停止处置任务
ret = ai.getDb().stopDispose(disposeTask.getDisposeIp(), disposeTask.getDisposeCapacity(), null, null,
deviceTask.getExternId());
deviceTask.getExternId());
if (ret.getFirstParam() == ErrorCode.ERR_OK) {
log.info("HAOHAN_PLATFORM stop task succeed: {}, device taskId {}", deviceTask, ret.getSecondParam());
@ -186,7 +186,7 @@ public class DeviceTaskManagerServiceImpl implements DeviceTaskManagerService {
// 记录任务出错重试次数
deviceTaskManager.setTaskErrRetryTimes(deviceTask.getId(), deviceTask.getErrRetry() + 1);
log.error("HAOHAN_PLATFORM stop task times {} error {}: {}", deviceTask.getErrRetry(),
ret.getSecondParam(), deviceTask);
ret.getSecondParam(), deviceTask);
} else {
log.error("HAOHAN_PLATFORM stop task error {}: {}", ret.getFirstParam(), deviceTask);
}
@ -215,15 +215,15 @@ public class DeviceTaskManagerServiceImpl implements DeviceTaskManagerService {
}
// 设置启动任务攻击类型状态
deviceTaskManager.execAttackTypeSetBit(deviceTask.getId(), NetflowDirection.DIRECTION_OUT,
t.getValue());
t.getValue());
// 调用迪普设备启动处置任务
ret = ai.getDb().runDispose(disposeTask.getDisposeIp(), disposeTask.getDisposeCapacity(),
NetflowDirection.DIRECTION_OUT, t.getValue(), null);
NetflowDirection.DIRECTION_OUT, t.getValue(), null);
if (ret.getFirstParam() == ErrorCode.ERR_OK) {
// 标志启动成功
deviceTaskManager.attackTypeStatusSetBit(deviceTask.getId(), NetflowDirection.DIRECTION_OUT,
t.getValue());
t.getValue());
log.info("DPTECH_UMC setup task {}, {} succeed: {}", t, NetflowDirection.DIRECTION_OUT, deviceTask);
@ -235,12 +235,12 @@ public class DeviceTaskManagerServiceImpl implements DeviceTaskManagerService {
deviceTaskManager.setTaskErrRetryTimes(deviceTask.getId(), deviceTask.getErrRetry());
//清除任务攻击类型启动标志
deviceTaskManager.execAttackTypeCleanBit(deviceTask.getId(), NetflowDirection.DIRECTION_OUT,
t.getValue());
t.getValue());
log.error("DPTECH_UMC setup task {}, {} times {} error: {}", t,
NetflowDirection.DIRECTION_OUT, deviceTask.getErrRetry(), deviceTask);
NetflowDirection.DIRECTION_OUT, deviceTask.getErrRetry(), deviceTask);
} else {
log.error("DPTECH_UMC setup task {}, {} error {}: {}", t,
NetflowDirection.DIRECTION_OUT, ret.getFirstParam(), deviceTask);
NetflowDirection.DIRECTION_OUT, ret.getFirstParam(), deviceTask);
}
}
@ -252,15 +252,15 @@ public class DeviceTaskManagerServiceImpl implements DeviceTaskManagerService {
}
// 设置启动任务攻击类型状态
deviceTaskManager.execAttackTypeSetBit(deviceTask.getId(), NetflowDirection.DIRECTION_IN,
t.getValue());
t.getValue());
// 调用迪普设备启动处置任务
ret = ai.getDb().runDispose(disposeTask.getDisposeIp(), disposeTask.getDisposeCapacity(),
NetflowDirection.DIRECTION_IN, t.getValue(), null);
NetflowDirection.DIRECTION_IN, t.getValue(), null);
if (ret.getFirstParam() == ErrorCode.ERR_OK) {
// 标志启动成功
deviceTaskManager.attackTypeStatusSetBit(deviceTask.getId(), NetflowDirection.DIRECTION_IN,
t.getValue());
t.getValue());
log.info("DPTECH_UMC setup task {}, {} succeed: {}", t, NetflowDirection.DIRECTION_IN, deviceTask);
@ -272,12 +272,12 @@ public class DeviceTaskManagerServiceImpl implements DeviceTaskManagerService {
deviceTaskManager.setTaskErrRetryTimes(deviceTask.getId(), deviceTask.getErrRetry());
//清除任务攻击类型启动标志
deviceTaskManager.execAttackTypeCleanBit(deviceTask.getId(), NetflowDirection.DIRECTION_IN,
t.getValue());
t.getValue());
log.error("DPTECH_UMC setup task {}, {} times {} error: {}", t,
NetflowDirection.DIRECTION_IN, deviceTask.getErrRetry(), deviceTask);
NetflowDirection.DIRECTION_IN, deviceTask.getErrRetry(), deviceTask);
} else {
log.error("DPTECH_UMC setup task {}, {} error {}: {}", t,
NetflowDirection.DIRECTION_IN, ret.getFirstParam(), deviceTask);
NetflowDirection.DIRECTION_IN, ret.getFirstParam(), deviceTask);
}
}
}
@ -330,12 +330,12 @@ public class DeviceTaskManagerServiceImpl implements DeviceTaskManagerService {
if (disposeTask.getFlowDirection() != NetflowDirection.DIRECTION_IN) {
// 调用迪普设备停止处置任务
ret = ai.getDb().stopDispose(disposeTask.getDisposeIp(), disposeTask.getDisposeCapacity(),
NetflowDirection.DIRECTION_OUT, t.getValue(), null);
NetflowDirection.DIRECTION_OUT, t.getValue(), null);
if (ret.getFirstParam() == ErrorCode.ERR_OK) {
// 标志停止成功
deviceTaskManager.attackTypeStatusCleanBit(deviceTask.getId(), NetflowDirection.DIRECTION_OUT,
t.getValue());
t.getValue());
log.info("DPTECH_UMC stop task {}, {} succeed: {}", t, NetflowDirection.DIRECTION_OUT, deviceTask);
@ -345,10 +345,10 @@ public class DeviceTaskManagerServiceImpl implements DeviceTaskManagerService {
deviceTask.setErrRetry(deviceTask.getErrRetry() + 1);
deviceTaskManager.setTaskErrRetryTimes(deviceTask.getId(), deviceTask.getErrRetry());
log.error("DPTECH_UMC stop task {}, {} times {} error: {}", t,
NetflowDirection.DIRECTION_OUT, deviceTask.getErrRetry(), deviceTask);
NetflowDirection.DIRECTION_OUT, deviceTask.getErrRetry(), deviceTask);
} else {
log.info("DPTECH_UMC stop task {}, {} error {}: {}", t,
NetflowDirection.DIRECTION_OUT, ret.getFirstParam(), deviceTask);
NetflowDirection.DIRECTION_OUT, ret.getFirstParam(), deviceTask);
}
}
@ -356,15 +356,15 @@ public class DeviceTaskManagerServiceImpl implements DeviceTaskManagerService {
if (disposeTask.getFlowDirection() != NetflowDirection.DIRECTION_OUT) {
// 调用迪普设备启动处置任务
ret = ai.getDb().stopDispose(disposeTask.getDisposeIp(), disposeTask.getDisposeCapacity(),
NetflowDirection.DIRECTION_IN, t.getValue(), null);
NetflowDirection.DIRECTION_IN, t.getValue(), null);
if (ret.getFirstParam() == ErrorCode.ERR_OK) {
// 标志启动成功
deviceTaskManager.attackTypeStatusCleanBit(deviceTask.getId(), NetflowDirection.DIRECTION_IN,
t.getValue());
t.getValue());
log.info("DPTECH_UMC setup task {}, {} succeed: {}", t,
NetflowDirection.DIRECTION_IN, deviceTask);
NetflowDirection.DIRECTION_IN, deviceTask);
deviceTaskManager.setTaskErrRetryTimes(deviceTask.getId(), 0);
} else if (deviceTask.getErrRetry() < DisposeConfigValue.CALL_ERROR_RETRY_TIMES * 10) {
@ -372,10 +372,10 @@ public class DeviceTaskManagerServiceImpl implements DeviceTaskManagerService {
deviceTask.setErrRetry(deviceTask.getErrRetry() + 1);
deviceTaskManager.setTaskErrRetryTimes(deviceTask.getId(), deviceTask.getErrRetry());
log.error("DPTECH_UMC stop task {}, {} times {} error: {}", t,
NetflowDirection.DIRECTION_IN, deviceTask.getErrRetry(), deviceTask);
NetflowDirection.DIRECTION_IN, deviceTask.getErrRetry(), deviceTask);
} else {
log.info("DPTECH_UMC stop task {}, {} error {}: {}", t,
NetflowDirection.DIRECTION_IN, ret.getFirstParam(), deviceTask);
NetflowDirection.DIRECTION_IN, ret.getFirstParam(), deviceTask);
}
}
}
@ -419,7 +419,7 @@ public class DeviceTaskManagerServiceImpl implements DeviceTaskManagerService {
// 清理过期任务
for (DisposeTask v : disposeTaskManager.getExpiredTasks()) {
log.info("Task {} {} {} is expired, expect finished at {}",
v.getId(), v.getDisposeCapacity(), v.getDisposeIp(), v.getPlanEndTime());
v.getId(), v.getDisposeCapacity(), v.getDisposeIp(), v.getPlanEndTime());
// 设置任务状态过期任务不再为设备创建处置任务
disposeTaskManager.changeDisposeTaskStatus(v.getId(), DisposeTaskStatus.TASK_EXPIRED);
}
@ -441,7 +441,7 @@ public class DeviceTaskManagerServiceImpl implements DeviceTaskManagerService {
log.info("Add dispose task for device: {}", d.getDev());
if (!deviceTaskManager.addDisposeDeviceTaskInfo(v.getId(), d.getDev().getId(),
d.getDb().toDeviceAttackType(v.getAttackType()))) {
d.getDb().toDeviceAttackType(v.getAttackType()))) {
log.error("Add task {} to device {} error", v, d);
}
});

View File

@ -149,13 +149,13 @@ public class DisposeAbilityRouterServiceImpl implements DisposeAbilityRouterServ
return ErrorCode.ERR_NOSUCHDEVICE;
}
if(getAllAbilityDevices().stream()
if (getAllAbilityDevices().stream()
.noneMatch(c -> c.getDev().getDevCapacity().stream()
.anyMatch(m -> m.getCapacityType() == capacityType))) {
return ErrorCode.ERR_NOSUCHTYPE;
}
if(getAllAbilityDevices().stream()
if (getAllAbilityDevices().stream()
.noneMatch(c -> c.getDb().isCarryProtectIp(disposeIp))) {
return ErrorCode.ERR_IPNODEVICE;
}

View File

@ -89,7 +89,7 @@ public class DisposeDeviceManagerServiceImpl implements DisposeDeviceManagerServ
DisposeDevice dev = new DisposeDevice();
MulReturnType<ErrorCode, ObjectStatus> ret = disposeDeviceManager.changeDisposeDeviceStatus(v,
ObjectStatus.DELETED);
ObjectStatus.DELETED);
dev.setId(v);
dev.setStatus(ret.getSecondParam());
@ -122,7 +122,7 @@ public class DisposeDeviceManagerServiceImpl implements DisposeDeviceManagerServ
public List<DisposeDevice> getAllDisposeDevice() {
List<DisposeDevice> disposeDevices = disposeDeviceManager.getAllNormalDisposeDevices();
if(disposeDevices == null) {
if (disposeDevices == null) {
return new ArrayList<>();
} else {
return disposeDevices;

View File

@ -41,7 +41,7 @@ public class DisposeTaskServiceImpl implements DisposeTaskService {
@Override
public MulReturnType<ErrorCode, DisposeTask> createTask(DisposeTask task) {
DisposeTask exitTask = disposeTaskManager.getDisposeTask(task.getDeviceId(),
task.getDisposeIp(), task.getDisposeCapacity());
task.getDisposeIp(), task.getDisposeCapacity());
if (exitTask != null) {
return new MulReturnType<>(ErrorCode.ERR_TASKRUNNING, exitTask);
@ -51,12 +51,12 @@ public class DisposeTaskServiceImpl implements DisposeTaskService {
task.getDeviceId(), task.getDisposeIp(), task.getDisposeCapacity()
);
if(err != ErrorCode.ERR_OK) {
if (err != ErrorCode.ERR_OK) {
return new MulReturnType<>(err, task);
}
return new MulReturnType<>(disposeTaskManager.addDisposeTask(task),
disposeTaskManager.getDisposeTaskById(task.getId()));
disposeTaskManager.getDisposeTaskById(task.getId()));
}
/**

View File

@ -58,7 +58,8 @@ public class ProtocolSecurityServiceImpl implements ProtocolSecurityService {
// 反序列化为对象处理
ProtocolReqDTO<String> proReq = objectMapper
.readValue(ciphertext, new TypeReference<ProtocolReqDTO<String>>(){});
.readValue(ciphertext, new TypeReference<ProtocolReqDTO<String>>() {
});
// 首先对加密内容进行base64解码
byte[] base64Decode = CryptoHelper.base64Decryption(proReq.getMsgContent());
@ -134,7 +135,7 @@ public class ProtocolSecurityServiceImpl implements ProtocolSecurityService {
try {
byte[] encode = CryptoHelper.desEncryption(plainText.getBytes(StandardCharsets.UTF_8),
SecurityConfigValue.DES_KEY);
cipherText= CryptoHelper.base64Encryption(encode);
cipherText = CryptoHelper.base64Encryption(encode);
} catch (Exception e) {
log.error("DES encode message error: {}", plainText);
throw new SecurityProtocolException(ErrorCode.ERR_ENCRYPT_3DES);

View File

@ -34,9 +34,9 @@ public class DeviceManagerTask {
disposeAbilityRouterService.getAllAbilityDevices().forEach(v -> {
v.setLinkStatus(v.getDb().getDeviceLinkStatus());
log.debug("{}{} get link status {}", v.getDev().getIpAddr(),
((v.getDev().getIpPort() == null || v.getDev().getIpPort().length() == 0) ? "" :
":" + v.getDev().getIpPort()),
v.getLinkStatus());
((v.getDev().getIpPort() == null || v.getDev().getIpPort().length() == 0) ? "" :
":" + v.getDev().getIpPort()),
v.getLinkStatus());
});
}
@ -54,9 +54,9 @@ public class DeviceManagerTask {
}
log.debug("{}{} get fireware status {}", v.getDev().getIpAddr(),
((v.getDev().getIpPort() == null || v.getDev().getIpPort().length() == 0) ? "" :
":" + v.getDev().getIpPort()),
ret.getFirstParam());
((v.getDev().getIpPort() == null || v.getDev().getIpPort().length() == 0) ? "" :
":" + v.getDev().getIpPort()),
ret.getFirstParam());
// 更新设备保护对象
v.getDb().getDisposeDeviceProtectObject();

View File

@ -19,7 +19,7 @@ import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Constraint(validatedBy = {ValidArrayIpAddrImpl.class})
public @interface ValidArrayIpAddr {
public @interface ValidArrayIpAddr {
/**
* Message string.
*

View File

@ -53,11 +53,11 @@ public class ValidBaseEnumArrayImpl implements ConstraintValidator<ValidBaseEnum
}
List<Integer> enumValues = Arrays.stream(enumClass.getEnumConstants())
.map(BaseEnum::getValue).collect(Collectors.toList());
.map(BaseEnum::getValue).collect(Collectors.toList());
String errMsg = this.message + " 字段 " +
((ConstraintValidatorContextImpl) ctx).getConstraintViolationCreationContexts()
.get(0).getPath().getLeafNode().getName()
.get(0).getPath().getLeafNode().getName()
+ " 值 {" + Arrays.toString(integers) + "} 错误, 字段取值范围:" + enumValues.toString();
// 重新设置消息

View File

@ -56,11 +56,11 @@ public class ValidBaseEnumImpl implements ConstraintValidator<ValidBaseEnum, Int
}
List<Integer> enumValues = Arrays.stream(enumClass.getEnumConstants())
.map(BaseEnum::getValue).collect(Collectors.toList());
.map(BaseEnum::getValue).collect(Collectors.toList());
String errMsg = this.message + " 字段 " +
((ConstraintValidatorContextImpl) ctx).getConstraintViolationCreationContexts()
.get(0).getPath().getLeafNode().getName()
.get(0).getPath().getLeafNode().getName()
+ " 值 {" + integer + "} 错误, 字段取值范围:" + enumValues.toString();
// 重新设置消息

View File

@ -35,7 +35,7 @@ public class ValidIpAddrImpl implements ConstraintValidator<ValidIpAddr, String>
@Override
public boolean isValid(String s, ConstraintValidatorContext constraintValidatorContext) {
if(s == null || s.length() == 0) {
if (s == null || s.length() == 0) {
return true;
}

View File

@ -54,7 +54,7 @@ public class ValidSplitPageSizeImpl implements ConstraintValidator<ValidSplitPag
String errMsg = this.message + " 字段 " +
((ConstraintValidatorContextImpl) ctx).getConstraintViolationCreationContexts()
.get(0).getPath().getLeafNode().getName() +
.get(0).getPath().getLeafNode().getName() +
" 值 {" + integer + "} 错误, 字段取值范围:" + rang.toString();
// 重新设置消息

View File

@ -88,8 +88,8 @@ public class RestfulInterface {
*/
public HaoHanGetCleanTaskStatusResp getCleanTaskStatus(String baseUrlPath, Integer taskId) {
return protocolRun(baseUrlPath + "/getCleanTaskState",
HaoHanGetCleanTaskStatusReq.builder().cleanTaskId(taskId).build(),
HaoHanGetCleanTaskStatusResp.class);
HaoHanGetCleanTaskStatusReq.builder().cleanTaskId(taskId).build(),
HaoHanGetCleanTaskStatusResp.class);
}
/**
@ -103,8 +103,8 @@ public class RestfulInterface {
*/
public HaoHanStartCleanResp startClean(String baseUrlPath, String ipAddr, int times, String readme) {
HaoHanStartCleanResp svrResp = protocolRun(baseUrlPath + "/sendTow",
new HaoHanStartCleanReq(ipAddr, times, readme),
HaoHanStartCleanResp.class);
new HaoHanStartCleanReq(ipAddr, times, readme),
HaoHanStartCleanResp.class);
final String regexPattern = "\\{(.*?)}";
final String usedTag = "ip已存在清洗中";
@ -124,7 +124,7 @@ public class RestfulInterface {
List<String> ids = new ArrayList<>();
while (matcher.find()) {
ids.add(matcher.group(1).substring(matcher.group(1).lastIndexOf("=") + 1)
.replaceAll("\\D", ""));
.replaceAll("\\D", ""));
}
// 排序保留最后一次任务
@ -159,8 +159,8 @@ public class RestfulInterface {
*/
public HaoHanStopCleanResp stopClean(String baseUrlPath, Integer taskId, String readme) {
return protocolRun(baseUrlPath + "/delTow",
new HaoHanStopCleanReq(taskId, readme),
HaoHanStopCleanResp.class);
new HaoHanStopCleanReq(taskId, readme),
HaoHanStopCleanResp.class);
}
/**
@ -172,8 +172,8 @@ public class RestfulInterface {
*/
public HaoHanGetCleaningNetflowInfoResp getCleaningNetflow(String baseUrlPath, String readme) {
return protocolRun(baseUrlPath + "/allIpFlow",
new HaoHanGetCleaningNetflowInfoReq(readme),
HaoHanGetCleaningNetflowInfoResp.class);
new HaoHanGetCleaningNetflowInfoReq(readme),
HaoHanGetCleaningNetflowInfoResp.class);
}
/**
@ -185,8 +185,8 @@ public class RestfulInterface {
*/
public HaoHanGetCleanTaskNetflowInfoResp getCleanTaskNetflow(String baseUrlPath, Integer taskId) {
return protocolRun(baseUrlPath + "/cleanTaskFlow",
new HaoHanGetCleanTaskNetflowInfoReq(taskId),
HaoHanGetCleanTaskNetflowInfoResp.class
new HaoHanGetCleanTaskNetflowInfoReq(taskId),
HaoHanGetCleanTaskNetflowInfoResp.class
);
}
}

View File

@ -11,7 +11,7 @@ import lombok.Setter;
*/
@Getter
@Setter
public class SecurityProtocolException extends RuntimeException {
public class SecurityProtocolException extends RuntimeException {
/**
* The Err.
*/