parent
a9f1704389
commit
1ddccea891
|
@ -61,6 +61,8 @@ dispose.check-request-token=true
|
||||||
dispose.split_char=,
|
dispose.split_char=,
|
||||||
dispose.request-timeout-second=5
|
dispose.request-timeout-second=5
|
||||||
|
|
||||||
|
dispose.used-privacy-protect=true
|
||||||
|
|
||||||
# 迪普设备配置
|
# 迪普设备配置
|
||||||
# 发送超时时间(ms)
|
# 发送超时时间(ms)
|
||||||
dptech.soap-conn-timeout-second=60
|
dptech.soap-conn-timeout-second=60
|
||||||
|
|
|
@ -16,4 +16,6 @@ public class DisposeConfigValue {
|
||||||
* The constant REQUEST_TIMEOUT_MS.
|
* The constant REQUEST_TIMEOUT_MS.
|
||||||
*/
|
*/
|
||||||
public static volatile long REQUEST_TIMEOUT_MS = 5 * 1000;
|
public static volatile long REQUEST_TIMEOUT_MS = 5 * 1000;
|
||||||
|
|
||||||
|
public static volatile boolean USED_PRIVACY_PROTECT = false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,65 @@
|
||||||
|
package com.dispose.common;
|
||||||
|
|
||||||
|
import inet.ipaddr.IPAddress;
|
||||||
|
import inet.ipaddr.IPAddressSegment;
|
||||||
|
import inet.ipaddr.IPAddressString;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The type Privacy helper.
|
||||||
|
*
|
||||||
|
* @author <huangxin@cmhi.chinamoblie.com>
|
||||||
|
*/
|
||||||
|
public class PrivacyHelper {
|
||||||
|
/**
|
||||||
|
* Ip address privacy string.
|
||||||
|
*
|
||||||
|
* @param ipAddr the ip addr
|
||||||
|
* @return the string
|
||||||
|
*/
|
||||||
|
public static String ipAddressPrivacy(String ipAddr) {
|
||||||
|
if (ipAddr == null || ipAddr.length() == 0) {
|
||||||
|
return ipAddr;
|
||||||
|
}
|
||||||
|
|
||||||
|
IPAddressString addrString = new IPAddressString(ipAddr);
|
||||||
|
IPAddress addr = addrString.getAddress();
|
||||||
|
|
||||||
|
if (addr == null) {
|
||||||
|
return ipAddr;
|
||||||
|
}
|
||||||
|
|
||||||
|
IPAddressSegment[] segments = addr.getSegments();
|
||||||
|
|
||||||
|
if (addr.isIPv4()) {
|
||||||
|
return segments[0].toString() + ".***.***." + segments[3].toString();
|
||||||
|
} else {
|
||||||
|
StringBuilder privyAddr = new StringBuilder(segments[0].toString().replaceAll("0x", ""));
|
||||||
|
|
||||||
|
for (int i = 1; i < segments.length - 1; i++) {
|
||||||
|
privyAddr.append(":***");
|
||||||
|
}
|
||||||
|
|
||||||
|
privyAddr.append(":").append(segments[segments.length - 1].toString().replaceAll("0x", ""));
|
||||||
|
|
||||||
|
return privyAddr.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Username privacy string.
|
||||||
|
*
|
||||||
|
* @param username the username
|
||||||
|
* @return the string
|
||||||
|
*/
|
||||||
|
public static String usernamePrivacy(String username) {
|
||||||
|
if (username == null || username.length() == 0) {
|
||||||
|
return username;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(username.length() < 8) {
|
||||||
|
return username.substring(0, username.length() / 2) + "****";
|
||||||
|
} else {
|
||||||
|
return username.substring(0, 7) + "****";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -32,4 +32,9 @@ public class DisposeConfigure {
|
||||||
* The Request timeout second.
|
* The Request timeout second.
|
||||||
*/
|
*/
|
||||||
private String requestTimeoutSecond;
|
private String requestTimeoutSecond;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Used privacy protect.
|
||||||
|
*/
|
||||||
|
private String usedPrivacyProtect;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,11 +2,13 @@ package com.dispose.controller;
|
||||||
|
|
||||||
import com.dispose.common.CommonEnumHandler;
|
import com.dispose.common.CommonEnumHandler;
|
||||||
import com.dispose.common.DisposeCapacityType;
|
import com.dispose.common.DisposeCapacityType;
|
||||||
|
import com.dispose.common.DisposeConfigValue;
|
||||||
import com.dispose.common.DisposeDeviceType;
|
import com.dispose.common.DisposeDeviceType;
|
||||||
import com.dispose.common.DisposeObjectType;
|
import com.dispose.common.DisposeObjectType;
|
||||||
import com.dispose.common.ErrorCode;
|
import com.dispose.common.ErrorCode;
|
||||||
import com.dispose.common.HttpType;
|
import com.dispose.common.HttpType;
|
||||||
import com.dispose.common.IpAddrType;
|
import com.dispose.common.IpAddrType;
|
||||||
|
import com.dispose.common.PrivacyHelper;
|
||||||
import com.dispose.pojo.dto.protocol.base.BaseRespStatus;
|
import com.dispose.pojo.dto.protocol.base.BaseRespStatus;
|
||||||
import com.dispose.pojo.dto.protocol.base.IdArraysReq;
|
import com.dispose.pojo.dto.protocol.base.IdArraysReq;
|
||||||
import com.dispose.pojo.dto.protocol.base.ProtocolReqDTO;
|
import com.dispose.pojo.dto.protocol.base.ProtocolReqDTO;
|
||||||
|
@ -61,6 +63,12 @@ public class DisposeDeviceManagerController {
|
||||||
@Resource
|
@Resource
|
||||||
private DisposeDeviceManagerService disposeDeviceManagerService;
|
private DisposeDeviceManagerService disposeDeviceManagerService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Request to device list list.
|
||||||
|
*
|
||||||
|
* @param req the req
|
||||||
|
* @return the list
|
||||||
|
*/
|
||||||
private List<DisposeDevice> requestToDeviceList(AddDeviceReq req) {
|
private List<DisposeDevice> requestToDeviceList(AddDeviceReq req) {
|
||||||
List<DisposeDevice> devs = new ArrayList<>();
|
List<DisposeDevice> devs = new ArrayList<>();
|
||||||
|
|
||||||
|
@ -185,6 +193,12 @@ public class DisposeDeviceManagerController {
|
||||||
return ProtocolRespDTO.result(ErrorCode.ERR_OK, rspInfo);
|
return ProtocolRespDTO.result(ErrorCode.ERR_OK, rspInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Upgrade dispose device protocol resp dto.
|
||||||
|
*
|
||||||
|
* @param mr the mr
|
||||||
|
* @return the protocol resp dto
|
||||||
|
*/
|
||||||
@PostMapping("/upgrade")
|
@PostMapping("/upgrade")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
@ApiOperation("更新处置能力节点")
|
@ApiOperation("更新处置能力节点")
|
||||||
|
@ -214,6 +228,12 @@ public class DisposeDeviceManagerController {
|
||||||
return ProtocolRespDTO.result(ErrorCode.ERR_OK, rspInfo);
|
return ProtocolRespDTO.result(ErrorCode.ERR_OK, rspInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets all dispose device.
|
||||||
|
*
|
||||||
|
* @param mr the mr
|
||||||
|
* @return the all dispose device
|
||||||
|
*/
|
||||||
@PostMapping("/device_list")
|
@PostMapping("/device_list")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
@ApiOperation("删除处置能力节点")
|
@ApiOperation("删除处置能力节点")
|
||||||
|
@ -237,7 +257,8 @@ public class DisposeDeviceManagerController {
|
||||||
ret.getSecondParam().forEach(v -> {
|
ret.getSecondParam().forEach(v -> {
|
||||||
GetDeviceDetail devInfo = new GetDeviceDetail();
|
GetDeviceDetail devInfo = new GetDeviceDetail();
|
||||||
devInfo.setId(v.getId().toString());
|
devInfo.setId(v.getId().toString());
|
||||||
devInfo.setIpAddr(v.getIpAddr());
|
devInfo.setIpAddr(DisposeConfigValue.USED_PRIVACY_PROTECT ?
|
||||||
|
PrivacyHelper.ipAddressPrivacy(v.getIpAddr()) : v.getIpAddr());
|
||||||
devInfo.setIpPort(v.getIpPort());
|
devInfo.setIpPort(v.getIpPort());
|
||||||
devInfo.setDeviceType(v.getDeviceType().getValue());
|
devInfo.setDeviceType(v.getDeviceType().getValue());
|
||||||
devInfo.setAreaCode(v.getAreaCode());
|
devInfo.setAreaCode(v.getAreaCode());
|
||||||
|
@ -245,6 +266,8 @@ public class DisposeDeviceManagerController {
|
||||||
devInfo.setManufacturer(v.getManufacturer());
|
devInfo.setManufacturer(v.getManufacturer());
|
||||||
devInfo.setModel(v.getModel());
|
devInfo.setModel(v.getModel());
|
||||||
devInfo.setVersion(v.getVersion());
|
devInfo.setVersion(v.getVersion());
|
||||||
|
devInfo.setUserName(DisposeConfigValue.USED_PRIVACY_PROTECT ?
|
||||||
|
PrivacyHelper.usernamePrivacy(v.getUserName()) : v.getUserName());
|
||||||
devInfo.setUrlType(v.getUrlType().getValue());
|
devInfo.setUrlType(v.getUrlType().getValue());
|
||||||
devInfo.setReadme(v.getReadme());
|
devInfo.setReadme(v.getReadme());
|
||||||
devInfo.setDevStatus(v.getStatus().getValue());
|
devInfo.setDevStatus(v.getStatus().getValue());
|
||||||
|
|
|
@ -75,6 +75,12 @@ public class SystemInitial implements CommandLineRunner {
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
log.error("load CHECK_PROTO_REQUEST_TIMEOUT configure error: {}", ex.getMessage());
|
log.error("load CHECK_PROTO_REQUEST_TIMEOUT configure error: {}", ex.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
DisposeConfigValue.USED_PRIVACY_PROTECT = Boolean.parseBoolean(disposeConfigure.getUsedPrivacyProtect());
|
||||||
|
} catch (Exception ex) {
|
||||||
|
log.error("load USED_PRIVACY_PROTECT configure error: {}", ex.getMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -3,6 +3,7 @@ package com.dispose.test.debug;
|
||||||
import com.dispose.common.DisposeDeviceType;
|
import com.dispose.common.DisposeDeviceType;
|
||||||
import com.dispose.common.HttpType;
|
import com.dispose.common.HttpType;
|
||||||
import com.dispose.common.ObjectStatus;
|
import com.dispose.common.ObjectStatus;
|
||||||
|
import com.dispose.common.PrivacyHelper;
|
||||||
import com.dispose.pojo.entity.DisposeDevice;
|
import com.dispose.pojo.entity.DisposeDevice;
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
@ -129,4 +130,11 @@ public class demo {
|
||||||
.writerWithDefaultPrettyPrinter()
|
.writerWithDefaultPrettyPrinter()
|
||||||
.writeValueAsString(upgradeDisposeDeviceProperties(dev, dev2)));
|
.writeValueAsString(upgradeDisposeDeviceProperties(dev, dev2)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void privacyHelper() {
|
||||||
|
log.info(PrivacyHelper.ipAddressPrivacy("192.168.0.123"));
|
||||||
|
log.info(PrivacyHelper.ipAddressPrivacy("2001:0000:4136:e378:8000:63bf:3fff:fdd2"));
|
||||||
|
log.info(PrivacyHelper.ipAddressPrivacy("3fde::fde2"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue