REM:
1. 修正IPv6添加旁路手动牵引策略名称过长导致接口调用失败问题
This commit is contained in:
HuangXin 2021-01-28 18:32:55 +08:00
parent e1648c1203
commit 5c8f3210ad
2 changed files with 31 additions and 1 deletions

View File

@ -18,6 +18,7 @@ import com.dispose.pojo.dto.protocol.device.ability.DpProtectionStrategyInfo;
import com.dispose.pojo.dto.protocol.device.ability.DpTractionStrategy;
import com.dispose.pojo.entity.ServiceInfo;
import com.dispose.pojo.po.MulReturnType;
import com.dispose.security.arithmetic.CryptoHelper;
import com.dptech.dispose.ArrayOfBypassManualTractionStrategyForService;
import com.dptech.dispose.ArrayOfProtectionObjectDataForService;
import com.dptech.dispose.ArrayOfProtectionTargetWithStrategyForService;
@ -25,6 +26,7 @@ import com.dptech.dispose.NtcRequestResultInfo;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
@ -42,6 +44,10 @@ import java.util.stream.Collectors;
@Slf4j
public class DpTechBypassAbilityImpl extends DpTechAbilityImpl {
/**
* The Traction strategy name.
*/
private Long tractionStrategyName = System.currentTimeMillis() / 1000;
/**
* The Dispose object cache.
*/
@ -638,7 +644,18 @@ public class DpTechBypassAbilityImpl extends DpTechAbilityImpl {
* @return the traction strategy name
*/
private String getTractionStrategyName(String disposeIp) {
return objectPrefix + "_" + disposeIp;
String tsName = objectPrefix + "_" + disposeIp;
if(tsName.length() >= 16) {
try {
tsName = objectPrefix + "_" + CryptoHelper.md5Encryption(disposeIp).substring(0, 14);
} catch (NoSuchAlgorithmException e) {
tsName = objectPrefix + "_" + tractionStrategyName++;
}
}
return tsName;
}
/**

View File

@ -73,6 +73,19 @@ public class CryptoHelper {
return messageDigest.digest();
}
/**
* Md 5 encryption string.
*
* @param plaintext the plaintext
* @return the string
* @throws NoSuchAlgorithmException the no such algorithm exception
*/
public static String md5Encryption(String plaintext) throws NoSuchAlgorithmException {
MessageDigest messageDigest = MessageDigest.getInstance("MD5");
messageDigest.update(plaintext.getBytes(StandardCharsets.UTF_8));
return new String(messageDigest.digest());
}
/**
* Aes 128 encryption byte [ ].
*