Merge remote-tracking branch 'origin/v2.0.9_dev'
# Conflicts: # config/application-dispose.properties # config/application-local.properties # pom.xml # src/main/java/com/cmhi/dispose/protocol/CmhiDisposeInterface.java # src/main/java/com/dispose/ability/impl/CmhiAbilityImpl.java # src/main/java/com/dispose/service/impl/DeviceTaskManagerServiceImpl.java # src/test/java/com/dispose/test/dev/debug/demo.java
This commit is contained in:
commit
7456a9947e
|
@ -15,25 +15,21 @@ dispose.call-error-retry-times=3
|
||||||
dispose.max-split-page-size=100
|
dispose.max-split-page-size=100
|
||||||
# 最小每页数据条数
|
# 最小每页数据条数
|
||||||
dispose.min-split-page-size=10
|
dispose.min-split-page-size=10
|
||||||
|
|
||||||
# 迪普设备配置
|
# 迪普设备配置
|
||||||
# 发送超时时间(s)
|
# 发送超时时间(s)
|
||||||
dptech.soap-conn-timeout-second=60
|
dptech.soap-conn-timeout-second=60
|
||||||
# 接收超时时间(s)
|
# 接收超时时间(s)
|
||||||
dptech.soap-recv-timeout-second=60
|
dptech.soap-recv-timeout-second=60
|
||||||
|
|
||||||
# 用户权限配置
|
# 用户权限配置
|
||||||
# 是否对设备管理进行用户验证
|
# 是否对设备管理进行用户验证
|
||||||
permission.admin-check=true
|
permission.admin-check=true
|
||||||
# 运行管理设备的操作员用户名
|
# 运行管理设备的操作员用户名
|
||||||
permission.admin-users=admin
|
permission.admin-users=admin
|
||||||
|
|
||||||
# 认证配置
|
# 认证配置
|
||||||
# 是否对接口访问进行认证
|
# 是否对接口访问进行认证
|
||||||
auth.verify-request-token=true
|
auth.verify-request-token=true
|
||||||
# token访问超时时间
|
# token访问超时时间
|
||||||
auth.token-timeout-minute=30
|
auth.token-timeout-minute=30
|
||||||
|
|
||||||
# 安全配置
|
# 安全配置
|
||||||
#加密类型: 0 不加密
|
#加密类型: 0 不加密
|
||||||
# 1 Base64编码
|
# 1 Base64编码
|
||||||
|
@ -43,7 +39,20 @@ crypto.security-protocol-type=0
|
||||||
crypto.aes-key=hkoUV5ZWh0q1jSxMnpjovVn19Qg99HY6DD40
|
crypto.aes-key=hkoUV5ZWh0q1jSxMnpjovVn19Qg99HY6DD40
|
||||||
# 3DES秘钥
|
# 3DES秘钥
|
||||||
crypto.des-key=P3mq9iSIvQcvfyfdWR8sAnfAadO
|
crypto.des-key=P3mq9iSIvQcvfyfdWR8sAnfAadO
|
||||||
|
# Kafka 服务器配置
|
||||||
|
#重试次数
|
||||||
|
kafka.producer.retries=3
|
||||||
|
#批量大小
|
||||||
|
kafka.producer.batch.size=16384
|
||||||
|
#延时
|
||||||
|
kafka.producer.linger=1
|
||||||
|
#生产端缓冲区大小
|
||||||
|
kafka.producer.buffer.memory=33554432
|
||||||
|
kafka.producer.servers=172.21.44.189:9092,172.21.44.9:9092,172.21.44.244:9092,172.21.44.236:9092,172.21.44.80:9092
|
||||||
|
kafka.dispose.topic=ddos-vip-customer-ck
|
||||||
|
#sonar配置信息
|
||||||
|
sonar.host.url=http://172.21.48.126:9000
|
||||||
|
sonar.login=8a66da73ef5943a8bc6e7daf9afbc25ce495febc
|
||||||
#信任主机配置
|
#信任主机配置
|
||||||
# 白名单开关
|
# 白名单开关
|
||||||
trust.auth-white-list-check=true
|
trust.auth-white-list-check=true
|
||||||
|
|
|
@ -18,7 +18,6 @@ spring.datasource.url=jdbc:mysql://172.21.48.75:3306/ci_dispose_v1?serverTimezon
|
||||||
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
|
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
|
||||||
spring.datasource.username=root
|
spring.datasource.username=root
|
||||||
spring.datasource.password=BCcf6Dd7&8
|
spring.datasource.password=BCcf6Dd7&8
|
||||||
|
|
||||||
# 配置连接池
|
# 配置连接池
|
||||||
spring.datasource.schema=classpath:test_db/unit_test.sql
|
spring.datasource.schema=classpath:test_db/unit_test.sql
|
||||||
spring.datasource.initialization-mode=always
|
spring.datasource.initialization-mode=always
|
||||||
|
|
15
pom.xml
15
pom.xml
|
@ -12,12 +12,12 @@
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-parent</artifactId>
|
<artifactId>spring-boot-starter-parent</artifactId>
|
||||||
<version>2.3.9.RELEASE</version>
|
<version>2.3.12.RELEASE</version>
|
||||||
<relativePath/>
|
<relativePath/>
|
||||||
</parent>
|
</parent>
|
||||||
<groupId>com.dispose</groupId>
|
<groupId>com.dispose</groupId>
|
||||||
<artifactId>dispose_platform</artifactId>
|
<artifactId>dispose_platform</artifactId>
|
||||||
<version>2.0.8.11</version>
|
<version>2.0.9</version>
|
||||||
<name>dispose_platform</name>
|
<name>dispose_platform</name>
|
||||||
<description>Dispose Platform</description>
|
<description>Dispose Platform</description>
|
||||||
|
|
||||||
|
@ -102,7 +102,11 @@
|
||||||
<version>2.4</version>
|
<version>2.4</version>
|
||||||
<classifier>jdk15</classifier>
|
<classifier>jdk15</classifier>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.kafka</groupId>
|
||||||
|
<artifactId>spring-kafka</artifactId>
|
||||||
|
<version>2.7.2</version>
|
||||||
|
</dependency>
|
||||||
<!--mysql -->
|
<!--mysql -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>mysql</groupId>
|
<groupId>mysql</groupId>
|
||||||
|
@ -349,6 +353,11 @@
|
||||||
</generateGitPropertiesFilename>
|
</generateGitPropertiesFilename>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.sonarsource.scanner.maven</groupId>
|
||||||
|
<artifactId>sonar-maven-plugin</artifactId>
|
||||||
|
<version>3.9.0.2155</version>
|
||||||
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package com.pengxin.dispose.common;
|
package com.cmhi.dispose.common;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
@ -15,7 +15,7 @@ import lombok.NoArgsConstructor;
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
public class PengXinDisposeAbilityInfo {
|
public class CmhiDisposeAbilityInfo {
|
||||||
/**
|
/**
|
||||||
* The Type.
|
* The Type.
|
||||||
*/
|
*/
|
|
@ -1,4 +1,4 @@
|
||||||
package com.pengxin.dispose.common;
|
package com.cmhi.dispose.common;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
|
@ -18,7 +18,7 @@ import java.util.List;
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
public class PengXinDisposeAbilityRsp extends PengXinBaseResp {
|
public class CmhiDisposeAbilityRsp extends CmhiDisposeBaseResp {
|
||||||
/**
|
/**
|
||||||
* The Device name.
|
* The Device name.
|
||||||
*/
|
*/
|
||||||
|
@ -27,5 +27,5 @@ public class PengXinDisposeAbilityRsp extends PengXinBaseResp {
|
||||||
/**
|
/**
|
||||||
* The Capacity.
|
* The Capacity.
|
||||||
*/
|
*/
|
||||||
List<PengXinDisposeAbilityInfo> capacity;
|
List<CmhiDisposeAbilityInfo> capacity;
|
||||||
}
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package com.pengxin.dispose.common;
|
package com.cmhi.dispose.common;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
@ -12,7 +12,7 @@ import lombok.NoArgsConstructor;
|
||||||
@Data
|
@Data
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
public class PengXinBaseResp {
|
public class CmhiDisposeBaseResp {
|
||||||
/**
|
/**
|
||||||
* The Status.
|
* The Status.
|
||||||
*/
|
*/
|
|
@ -1,4 +1,4 @@
|
||||||
package com.pengxin.dispose.common;
|
package com.cmhi.dispose.common;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Builder;
|
import lombok.Builder;
|
||||||
|
@ -14,7 +14,7 @@ import lombok.NoArgsConstructor;
|
||||||
@Builder
|
@Builder
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class PengXinLoginReq {
|
public class CmhiDisposeLoginReq {
|
||||||
/**
|
/**
|
||||||
* The User name.
|
* The User name.
|
||||||
*/
|
*/
|
|
@ -1,4 +1,4 @@
|
||||||
package com.pengxin.dispose.common;
|
package com.cmhi.dispose.common;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
|
@ -16,7 +16,7 @@ import lombok.NoArgsConstructor;
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
public class PengXinLoginRsp extends PengXinBaseResp {
|
public class CmhiDisposeLoginRsp extends CmhiDisposeBaseResp {
|
||||||
/**
|
/**
|
||||||
* The User name.
|
* The User name.
|
||||||
*/
|
*/
|
|
@ -1,4 +1,4 @@
|
||||||
package com.pengxin.dispose.common;
|
package com.cmhi.dispose.common;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Builder;
|
import lombok.Builder;
|
||||||
|
@ -14,7 +14,7 @@ import lombok.NoArgsConstructor;
|
||||||
@Builder
|
@Builder
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class PengXinStartTaskItem {
|
public class CmhiDisposeStartTaskItem {
|
||||||
/**
|
/**
|
||||||
* The Task req id.
|
* The Task req id.
|
||||||
*/
|
*/
|
|
@ -1,4 +1,4 @@
|
||||||
package com.pengxin.dispose.common;
|
package com.cmhi.dispose.common;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Builder;
|
import lombok.Builder;
|
||||||
|
@ -16,9 +16,9 @@ import java.util.List;
|
||||||
@Builder
|
@Builder
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class PengXinStartTaskReq {
|
public class CmhiDisposeStartTaskReq {
|
||||||
/**
|
/**
|
||||||
* The Items.
|
* The Items.
|
||||||
*/
|
*/
|
||||||
List<PengXinStartTaskItem> items;
|
List<CmhiDisposeStartTaskItem> items;
|
||||||
}
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package com.pengxin.dispose.common;
|
package com.cmhi.dispose.common;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
|
@ -16,7 +16,7 @@ import java.util.List;
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
public class PengXinStartTaskRsp {
|
public class CmhiDisposeStartTaskRsp {
|
||||||
/**
|
/**
|
||||||
* The Device name.
|
* The Device name.
|
||||||
*/
|
*/
|
||||||
|
@ -25,5 +25,5 @@ public class PengXinStartTaskRsp {
|
||||||
/**
|
/**
|
||||||
* The Items.
|
* The Items.
|
||||||
*/
|
*/
|
||||||
List<PengXinStartedItem> items;
|
List<CmhiDisposeStartedItem> items;
|
||||||
}
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package com.pengxin.dispose.common;
|
package com.cmhi.dispose.common;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
|
@ -16,7 +16,7 @@ import lombok.NoArgsConstructor;
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
public class PengXinStartedItem extends PengXinBaseResp {
|
public class CmhiDisposeStartedItem extends CmhiDisposeBaseResp {
|
||||||
/**
|
/**
|
||||||
* The Task req id.
|
* The Task req id.
|
||||||
*/
|
*/
|
|
@ -1,4 +1,4 @@
|
||||||
package com.pengxin.dispose.common;
|
package com.cmhi.dispose.common;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Builder;
|
import lombok.Builder;
|
||||||
|
@ -14,7 +14,7 @@ import lombok.NoArgsConstructor;
|
||||||
@Builder
|
@Builder
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class PengXinStopTaskReq {
|
public class CmhiDisposeStopTaskReq {
|
||||||
/**
|
/**
|
||||||
* The Task id.
|
* The Task id.
|
||||||
*/
|
*/
|
|
@ -1,4 +1,4 @@
|
||||||
package com.pengxin.dispose.common;
|
package com.cmhi.dispose.common;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
|
@ -16,7 +16,7 @@ import java.util.List;
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
public class PengXinStopTaskRsp {
|
public class CmhiDisposeStopTaskRsp {
|
||||||
/**
|
/**
|
||||||
* The Device name.
|
* The Device name.
|
||||||
*/
|
*/
|
||||||
|
@ -24,5 +24,5 @@ public class PengXinStopTaskRsp {
|
||||||
/**
|
/**
|
||||||
* The Items.
|
* The Items.
|
||||||
*/
|
*/
|
||||||
private List<PengXinStoppedItem> items;
|
private List<CmhiDisposeStoppedItem> items;
|
||||||
}
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package com.pengxin.dispose.common;
|
package com.cmhi.dispose.common;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
|
@ -16,7 +16,7 @@ import lombok.NoArgsConstructor;
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
public class PengXinStoppedItem extends PengXinBaseResp {
|
public class CmhiDisposeStoppedItem extends CmhiDisposeBaseResp {
|
||||||
/**
|
/**
|
||||||
* The Task id.
|
* The Task id.
|
||||||
*/
|
*/
|
|
@ -1,4 +1,4 @@
|
||||||
package com.pengxin.dispose.common;
|
package com.cmhi.dispose.common;
|
||||||
|
|
||||||
import com.dispose.common.BaseEnum;
|
import com.dispose.common.BaseEnum;
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ import com.dispose.common.BaseEnum;
|
||||||
*
|
*
|
||||||
* @author <huangxin@cmhi.chinamoblie.com>
|
* @author <huangxin@cmhi.chinamoblie.com>
|
||||||
*/
|
*/
|
||||||
public enum PengXinTaskStatus implements BaseEnum {
|
public enum CmhiDisposeTaskStatus implements BaseEnum {
|
||||||
/**
|
/**
|
||||||
* The Task starting.
|
* The Task starting.
|
||||||
*/
|
*/
|
||||||
|
@ -69,7 +69,7 @@ public enum PengXinTaskStatus implements BaseEnum {
|
||||||
* @param code the code
|
* @param code the code
|
||||||
* @param readme the readme
|
* @param readme the readme
|
||||||
*/
|
*/
|
||||||
PengXinTaskStatus(int code, String readme) {
|
CmhiDisposeTaskStatus(int code, String readme) {
|
||||||
this.code = code;
|
this.code = code;
|
||||||
this.readme = readme;
|
this.readme = readme;
|
||||||
}
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package com.pengxin.dispose.common;
|
package com.cmhi.dispose.common;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
|
@ -16,7 +16,7 @@ import lombok.NoArgsConstructor;
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
public class PengXinTaskStatusItem extends PengXinBaseResp {
|
public class CmhiDisposeTaskStatusItem extends CmhiDisposeBaseResp {
|
||||||
/**
|
/**
|
||||||
* The Task id.
|
* The Task id.
|
||||||
*/
|
*/
|
|
@ -1,4 +1,4 @@
|
||||||
package com.pengxin.dispose.common;
|
package com.cmhi.dispose.common;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
|
@ -16,7 +16,7 @@ import java.util.List;
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
public class PengXinTaskStatusRsp {
|
public class CmhiDisposeTaskStatusRsp {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Device name.
|
* The Device name.
|
||||||
|
@ -26,5 +26,5 @@ public class PengXinTaskStatusRsp {
|
||||||
/**
|
/**
|
||||||
* The Items.
|
* The Items.
|
||||||
*/
|
*/
|
||||||
private List<PengXinTaskStatusItem> items;
|
private List<CmhiDisposeTaskStatusItem> items;
|
||||||
}
|
}
|
|
@ -1,20 +1,19 @@
|
||||||
package com.pengxin.dispose.protocol;
|
package com.cmhi.dispose.protocol;
|
||||||
|
|
||||||
import com.dispose.common.CommonEnumHandler;
|
import com.cmhi.dispose.common.CmhiDisposeAbilityRsp;
|
||||||
|
import com.cmhi.dispose.common.CmhiDisposeBaseResp;
|
||||||
|
import com.cmhi.dispose.common.CmhiDisposeLoginReq;
|
||||||
|
import com.cmhi.dispose.common.CmhiDisposeLoginRsp;
|
||||||
|
import com.cmhi.dispose.common.CmhiDisposeStartTaskItem;
|
||||||
|
import com.cmhi.dispose.common.CmhiDisposeStartTaskReq;
|
||||||
|
import com.cmhi.dispose.common.CmhiDisposeStartTaskRsp;
|
||||||
|
import com.cmhi.dispose.common.CmhiDisposeStopTaskReq;
|
||||||
|
import com.cmhi.dispose.common.CmhiDisposeStopTaskRsp;
|
||||||
|
import com.cmhi.dispose.common.CmhiDisposeTaskStatusRsp;
|
||||||
import com.dispose.common.ErrorCode;
|
import com.dispose.common.ErrorCode;
|
||||||
import com.dispose.pojo.dto.protocol.base.BaseProtocolDTO;
|
import com.dispose.pojo.dto.protocol.base.BaseProtocolDTO;
|
||||||
import com.dispose.pojo.dto.protocol.base.ProtocolRespDTO;
|
import com.dispose.pojo.dto.protocol.base.ProtocolRespDTO;
|
||||||
import com.dispose.restful.RestfulInterface;
|
import com.dispose.restful.RestfulInterface;
|
||||||
import com.pengxin.dispose.common.PengXinBaseResp;
|
|
||||||
import com.pengxin.dispose.common.PengXinDisposeAbilityRsp;
|
|
||||||
import com.pengxin.dispose.common.PengXinLoginReq;
|
|
||||||
import com.pengxin.dispose.common.PengXinLoginRsp;
|
|
||||||
import com.pengxin.dispose.common.PengXinStartTaskItem;
|
|
||||||
import com.pengxin.dispose.common.PengXinStartTaskReq;
|
|
||||||
import com.pengxin.dispose.common.PengXinStartTaskRsp;
|
|
||||||
import com.pengxin.dispose.common.PengXinStopTaskReq;
|
|
||||||
import com.pengxin.dispose.common.PengXinStopTaskRsp;
|
|
||||||
import com.pengxin.dispose.common.PengXinTaskStatusRsp;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
@ -25,7 +24,7 @@ import java.util.List;
|
||||||
*
|
*
|
||||||
* @author <huangxin@cmhi.chinamoblie.com>
|
* @author <huangxin@cmhi.chinamoblie.com>
|
||||||
*/
|
*/
|
||||||
public class PengXinInterface {
|
public class CmhiDisposeInterface {
|
||||||
/**
|
/**
|
||||||
* The Ver.
|
* The Ver.
|
||||||
*/
|
*/
|
||||||
|
@ -54,11 +53,11 @@ public class PengXinInterface {
|
||||||
* @param password the password
|
* @param password the password
|
||||||
* @return the protocol resp dto
|
* @return the protocol resp dto
|
||||||
*/
|
*/
|
||||||
public ProtocolRespDTO<PengXinLoginRsp> login(String baseUrlPath, String username, String password) {
|
public ProtocolRespDTO<CmhiDisposeLoginRsp> login(String baseUrlPath, String username, String password) {
|
||||||
|
|
||||||
BaseProtocolDTO<PengXinLoginReq> reqInfo = new BaseProtocolDTO<>();
|
BaseProtocolDTO<CmhiDisposeLoginReq> reqInfo = new BaseProtocolDTO<>();
|
||||||
|
|
||||||
reqInfo.setMsgContent(PengXinLoginReq.builder()
|
reqInfo.setMsgContent(CmhiDisposeLoginReq.builder()
|
||||||
.userName(username)
|
.userName(username)
|
||||||
.password(password)
|
.password(password)
|
||||||
.build());
|
.build());
|
||||||
|
@ -70,7 +69,7 @@ public class PengXinInterface {
|
||||||
return RestfulInterface.baseProRun(baseUrlPath,
|
return RestfulInterface.baseProRun(baseUrlPath,
|
||||||
null,
|
null,
|
||||||
reqInfo,
|
reqInfo,
|
||||||
PengXinLoginRsp.class,
|
CmhiDisposeLoginRsp.class,
|
||||||
RequestMethod.POST);
|
RequestMethod.POST);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,12 +81,12 @@ public class PengXinInterface {
|
||||||
* @return the link status
|
* @return the link status
|
||||||
*/
|
*/
|
||||||
public ErrorCode getLinkStatus(String baseUrlPath, String token) {
|
public ErrorCode getLinkStatus(String baseUrlPath, String token) {
|
||||||
ProtocolRespDTO<PengXinBaseResp> rspInfo = RestfulInterface.baseProRun(baseUrlPath,
|
ProtocolRespDTO<CmhiDisposeBaseResp> rspInfo = RestfulInterface.baseProRun(baseUrlPath,
|
||||||
token,
|
token,
|
||||||
null,
|
null,
|
||||||
PengXinBaseResp.class,
|
CmhiDisposeBaseResp.class,
|
||||||
RequestMethod.GET);
|
RequestMethod.GET);
|
||||||
if (rspInfo != null) {
|
if (rspInfo != null && rspInfo.getMsgContent() != null) {
|
||||||
if (rspInfo.getCode() == HttpServletResponse.SC_UNAUTHORIZED) {
|
if (rspInfo.getCode() == HttpServletResponse.SC_UNAUTHORIZED) {
|
||||||
return ErrorCode.ERR_LOGOUT;
|
return ErrorCode.ERR_LOGOUT;
|
||||||
}
|
}
|
||||||
|
@ -124,10 +123,10 @@ public class PengXinInterface {
|
||||||
* @param items the items
|
* @param items the items
|
||||||
* @return the protocol resp dto
|
* @return the protocol resp dto
|
||||||
*/
|
*/
|
||||||
public ProtocolRespDTO<PengXinStartTaskRsp> startDisposeTask(String baseUrlPath, String token,
|
public ProtocolRespDTO<CmhiDisposeStartTaskRsp> startDisposeTask(String baseUrlPath, String token,
|
||||||
List<PengXinStartTaskItem> items) {
|
List<CmhiDisposeStartTaskItem> items) {
|
||||||
BaseProtocolDTO<PengXinStartTaskReq> reqInfo = new BaseProtocolDTO<>();
|
BaseProtocolDTO<CmhiDisposeStartTaskReq> reqInfo = new BaseProtocolDTO<>();
|
||||||
reqInfo.setMsgContent(new PengXinStartTaskReq());
|
reqInfo.setMsgContent(new CmhiDisposeStartTaskReq());
|
||||||
|
|
||||||
reqInfo.getMsgContent().setItems(items);
|
reqInfo.getMsgContent().setItems(items);
|
||||||
reqInfo.setCryptoType(this.cryptoType);
|
reqInfo.setCryptoType(this.cryptoType);
|
||||||
|
@ -137,7 +136,7 @@ public class PengXinInterface {
|
||||||
return RestfulInterface.baseProRun(baseUrlPath,
|
return RestfulInterface.baseProRun(baseUrlPath,
|
||||||
token,
|
token,
|
||||||
reqInfo,
|
reqInfo,
|
||||||
PengXinStartTaskRsp.class,
|
CmhiDisposeStartTaskRsp.class,
|
||||||
RequestMethod.POST);
|
RequestMethod.POST);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -149,10 +148,10 @@ public class PengXinInterface {
|
||||||
* @param taskId the task id
|
* @param taskId the task id
|
||||||
* @return the protocol resp dto
|
* @return the protocol resp dto
|
||||||
*/
|
*/
|
||||||
public ProtocolRespDTO<PengXinStopTaskRsp> stopDisposeTask(String baseUrlPath, String token, String[] taskId) {
|
public ProtocolRespDTO<CmhiDisposeStopTaskRsp> stopDisposeTask(String baseUrlPath, String token, String[] taskId) {
|
||||||
BaseProtocolDTO<PengXinStopTaskReq> reqInfo = new BaseProtocolDTO<>();
|
BaseProtocolDTO<CmhiDisposeStopTaskReq> reqInfo = new BaseProtocolDTO<>();
|
||||||
|
|
||||||
reqInfo.setMsgContent(new PengXinStopTaskReq());
|
reqInfo.setMsgContent(new CmhiDisposeStopTaskReq());
|
||||||
|
|
||||||
reqInfo.getMsgContent().setTaskId(taskId);
|
reqInfo.getMsgContent().setTaskId(taskId);
|
||||||
reqInfo.setCryptoType(this.cryptoType);
|
reqInfo.setCryptoType(this.cryptoType);
|
||||||
|
@ -162,7 +161,7 @@ public class PengXinInterface {
|
||||||
return RestfulInterface.baseProRun(baseUrlPath,
|
return RestfulInterface.baseProRun(baseUrlPath,
|
||||||
token,
|
token,
|
||||||
reqInfo,
|
reqInfo,
|
||||||
PengXinStopTaskRsp.class,
|
CmhiDisposeStopTaskRsp.class,
|
||||||
RequestMethod.POST);
|
RequestMethod.POST);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -173,11 +172,11 @@ public class PengXinInterface {
|
||||||
* @param token the token
|
* @param token the token
|
||||||
* @return the device dispose ability
|
* @return the device dispose ability
|
||||||
*/
|
*/
|
||||||
public ProtocolRespDTO<PengXinDisposeAbilityRsp> getDeviceDisposeAbility(String baseUrlPath, String token) {
|
public ProtocolRespDTO<CmhiDisposeAbilityRsp> getDeviceDisposeAbility(String baseUrlPath, String token) {
|
||||||
return RestfulInterface.baseProRun(baseUrlPath,
|
return RestfulInterface.baseProRun(baseUrlPath,
|
||||||
token,
|
token,
|
||||||
null,
|
null,
|
||||||
PengXinDisposeAbilityRsp.class,
|
CmhiDisposeAbilityRsp.class,
|
||||||
RequestMethod.GET);
|
RequestMethod.GET);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -189,10 +188,10 @@ public class PengXinInterface {
|
||||||
* @param taskId the task id
|
* @param taskId the task id
|
||||||
* @return the device task status
|
* @return the device task status
|
||||||
*/
|
*/
|
||||||
public ProtocolRespDTO<PengXinTaskStatusRsp> getDeviceTaskStatus(String baseUrlPath, String token, String[] taskId) {
|
public ProtocolRespDTO<CmhiDisposeTaskStatusRsp> getDeviceTaskStatus(String baseUrlPath, String token, String[] taskId) {
|
||||||
BaseProtocolDTO<PengXinStopTaskReq> reqInfo = new BaseProtocolDTO<>();
|
BaseProtocolDTO<CmhiDisposeStopTaskReq> reqInfo = new BaseProtocolDTO<>();
|
||||||
|
|
||||||
reqInfo.setMsgContent(new PengXinStopTaskReq());
|
reqInfo.setMsgContent(new CmhiDisposeStopTaskReq());
|
||||||
|
|
||||||
reqInfo.getMsgContent().setTaskId(taskId);
|
reqInfo.getMsgContent().setTaskId(taskId);
|
||||||
reqInfo.setCryptoType(this.cryptoType);
|
reqInfo.setCryptoType(this.cryptoType);
|
||||||
|
@ -202,7 +201,7 @@ public class PengXinInterface {
|
||||||
return RestfulInterface.baseProRun(baseUrlPath,
|
return RestfulInterface.baseProRun(baseUrlPath,
|
||||||
token,
|
token,
|
||||||
reqInfo,
|
reqInfo,
|
||||||
PengXinTaskStatusRsp.class,
|
CmhiDisposeTaskStatusRsp.class,
|
||||||
RequestMethod.POST);
|
RequestMethod.POST);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -5,6 +5,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||||
import org.mybatis.spring.annotation.MapperScan;
|
import org.mybatis.spring.annotation.MapperScan;
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
import org.springframework.boot.autoconfigure.kafka.KafkaAutoConfiguration;
|
||||||
import org.springframework.boot.web.servlet.ServletComponentScan;
|
import org.springframework.boot.web.servlet.ServletComponentScan;
|
||||||
import org.springframework.context.annotation.EnableAspectJAutoProxy;
|
import org.springframework.context.annotation.EnableAspectJAutoProxy;
|
||||||
import org.springframework.scheduling.annotation.EnableAsync;
|
import org.springframework.scheduling.annotation.EnableAsync;
|
||||||
|
@ -16,7 +17,7 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||||
*
|
*
|
||||||
* @author <huangxin@cmhi.chinamoblie.com>
|
* @author <huangxin@cmhi.chinamoblie.com>
|
||||||
*/
|
*/
|
||||||
@SpringBootApplication
|
@SpringBootApplication(exclude = {KafkaAutoConfiguration.class})
|
||||||
@EnableAsync
|
@EnableAsync
|
||||||
@EnableScheduling
|
@EnableScheduling
|
||||||
@EnableAspectJAutoProxy
|
@EnableAspectJAutoProxy
|
||||||
|
|
|
@ -1,23 +1,26 @@
|
||||||
package com.dispose.ability.impl;
|
package com.dispose.ability.impl;
|
||||||
|
|
||||||
|
import com.cmhi.dispose.common.CmhiDisposeAbilityRsp;
|
||||||
|
import com.cmhi.dispose.common.CmhiDisposeLoginRsp;
|
||||||
|
import com.cmhi.dispose.common.CmhiDisposeStartTaskItem;
|
||||||
|
import com.cmhi.dispose.common.CmhiDisposeStartTaskRsp;
|
||||||
|
import com.cmhi.dispose.common.CmhiDisposeStopTaskRsp;
|
||||||
|
import com.cmhi.dispose.common.CmhiDisposeTaskStatusRsp;
|
||||||
|
import com.cmhi.dispose.protocol.CmhiDisposeInterface;
|
||||||
import com.dispose.ability.DisposeAbility;
|
import com.dispose.ability.DisposeAbility;
|
||||||
import com.dispose.common.CommonEnumHandler;
|
|
||||||
import com.dispose.common.DisposeCapacityType;
|
import com.dispose.common.DisposeCapacityType;
|
||||||
import com.dispose.common.DisposeConfigValue;
|
import com.dispose.common.DisposeConfigValue;
|
||||||
import com.dispose.common.DisposeObjectType;
|
import com.dispose.common.DisposeObjectType;
|
||||||
import com.dispose.common.ErrorCode;
|
import com.dispose.common.ErrorCode;
|
||||||
|
import com.dispose.common.Helper;
|
||||||
|
import com.dispose.common.IpAddrType;
|
||||||
import com.dispose.common.NetflowDirection;
|
import com.dispose.common.NetflowDirection;
|
||||||
import com.dispose.pojo.dto.protocol.base.ProtocolRespDTO;
|
import com.dispose.pojo.dto.protocol.base.ProtocolRespDTO;
|
||||||
import com.dispose.pojo.entity.ServiceInfo;
|
import com.dispose.pojo.entity.ServiceInfo;
|
||||||
import com.dispose.pojo.po.MulReturnType;
|
import com.dispose.pojo.po.MulReturnType;
|
||||||
import com.dispose.pojo.vo.DeviceFirewareInfo;
|
import com.dispose.pojo.vo.DeviceFirewareInfo;
|
||||||
import com.dispose.security.arithmetic.CryptoHelper;
|
import inet.ipaddr.IPAddress;
|
||||||
import com.pengxin.dispose.common.PengXinLoginRsp;
|
import inet.ipaddr.IPAddressString;
|
||||||
import com.pengxin.dispose.common.PengXinStartTaskItem;
|
|
||||||
import com.pengxin.dispose.common.PengXinStartTaskRsp;
|
|
||||||
import com.pengxin.dispose.common.PengXinStopTaskRsp;
|
|
||||||
import com.pengxin.dispose.common.PengXinTaskStatusRsp;
|
|
||||||
import com.pengxin.dispose.protocol.PengXinInterface;
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
@ -25,27 +28,28 @@ import lombok.extern.slf4j.Slf4j;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The type Peng xin ability.
|
* The type Peng xin ability.
|
||||||
* @author xajhu
|
*
|
||||||
|
* @author <huangxin@cmhi.chinamoblie.com>
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class PengXinAbilityImpl implements DisposeAbility {
|
public class CmhiAbilityImpl implements DisposeAbility {
|
||||||
/*
|
/**
|
||||||
The Protect ip v 4.
|
* The Protect ip v 4.
|
||||||
*/
|
*/
|
||||||
//private final List<String> protectIpV4 = new ArrayList<>();
|
private final List<String> protectIpV4 = new ArrayList<>();
|
||||||
/*
|
/**
|
||||||
The Protect ip v 6.
|
* The Protect ip v 6.
|
||||||
*/
|
*/
|
||||||
//private final List<String> protectIpV6 = new ArrayList<>();
|
private final List<String> protectIpV6 = new ArrayList<>();
|
||||||
/**
|
/**
|
||||||
* The Restful interface.
|
* The Restful interface.
|
||||||
*/
|
*/
|
||||||
private final PengXinInterface restfulInterface = new PengXinInterface();
|
private final CmhiDisposeInterface restfulInterface = new CmhiDisposeInterface();
|
||||||
/**
|
/**
|
||||||
* The Peng xin dispose type.
|
* The Peng xin dispose type.
|
||||||
*/
|
*/
|
||||||
|
@ -124,7 +128,7 @@ public class PengXinAbilityImpl implements DisposeAbility {
|
||||||
public void initDeviceEnv(String urlPath, String username, String password) {
|
public void initDeviceEnv(String urlPath, String username, String password) {
|
||||||
this.urlRootPath = urlPath;
|
this.urlRootPath = urlPath;
|
||||||
this.username = username;
|
this.username = username;
|
||||||
this.password = new String(CryptoHelper.base64Decryption(password));
|
this.password = password;
|
||||||
restfulInterface.setParams(1, 0);
|
restfulInterface.setParams(1, 0);
|
||||||
|
|
||||||
upgradeToken();
|
upgradeToken();
|
||||||
|
@ -147,31 +151,28 @@ public class PengXinAbilityImpl implements DisposeAbility {
|
||||||
@Nullable NetflowDirection nfDirection,
|
@Nullable NetflowDirection nfDirection,
|
||||||
@Nullable Integer attackType,
|
@Nullable Integer attackType,
|
||||||
@Nullable Long duration) {
|
@Nullable Long duration) {
|
||||||
List<PengXinStartTaskItem> reqItems = new ArrayList<>();
|
List<CmhiDisposeStartTaskItem> reqItems = new ArrayList<>();
|
||||||
|
|
||||||
String url = urlRootPath + "dispose_device/task/start";
|
String url = urlRootPath + "dispose_device/task/start";
|
||||||
|
|
||||||
if (token == null || token.length() == 0) {
|
if (token == null || token.length() == 0) {
|
||||||
upgradeToken();
|
|
||||||
return new MulReturnType<>(ErrorCode.ERR_LOGOUT, "");
|
return new MulReturnType<>(ErrorCode.ERR_LOGOUT, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
log.info("++++Begging PengXin Start Cleanup Task: {}", disposeObject);
|
log.info("++++Begging PengXin Start Cleanup Task: {}", disposeObject);
|
||||||
|
|
||||||
|
if (capType != DisposeCapacityType.BLACKHOOL) {
|
||||||
// 集团一键处置线上环境,移除对处置能力检测操作
|
log.error("----Error PengXin don't support dispose capacity type: {}", capType);
|
||||||
// if (capType != DisposeCapacityType.BLACKHOOL) {
|
return new MulReturnType<>(ErrorCode.ERR_UNSUPPORT, null);
|
||||||
// log.error("----Error PengXin don't support dispose capacity type: {}", capType);
|
}
|
||||||
// return new MulReturnType<>(ErrorCode.ERR_UNSUPPORT, null);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// 适配处置时间参数, -1为不限制处置时间
|
// 适配处置时间参数, -1为不限制处置时间
|
||||||
if (duration == null || duration < 0) {
|
if (duration == null || duration < 0) {
|
||||||
duration = -1L;
|
duration = -1L;
|
||||||
}
|
}
|
||||||
|
|
||||||
reqItems.add(PengXinStartTaskItem.builder()
|
reqItems.add(CmhiDisposeStartTaskItem.builder()
|
||||||
.type(getPengXinTaskType(capType))
|
.type(getPengXinTaskType(capType))
|
||||||
.disposeObject(disposeObject)
|
.disposeObject(disposeObject)
|
||||||
.objectType(getPengXinObjectType(objectType))
|
.objectType(getPengXinObjectType(objectType))
|
||||||
|
@ -179,22 +180,16 @@ public class PengXinAbilityImpl implements DisposeAbility {
|
||||||
.taskReqId(String.valueOf(taskReqId++))
|
.taskReqId(String.valueOf(taskReqId++))
|
||||||
.build());
|
.build());
|
||||||
|
|
||||||
ProtocolRespDTO<PengXinStartTaskRsp> rspInfo = restfulInterface.startDisposeTask(url, token, reqItems);
|
ProtocolRespDTO<CmhiDisposeStartTaskRsp> rspInfo = restfulInterface.startDisposeTask(url, token, reqItems);
|
||||||
|
|
||||||
ErrorCode err = verifyInterfaceResp(rspInfo);
|
// 判断是否token过期
|
||||||
|
if (rspInfo != null && reLogin(rspInfo, rspInfo.getMsgContent().getItems().get(0).getStatus())) {
|
||||||
if (err != ErrorCode.ERR_OK) {
|
rspInfo = restfulInterface.startDisposeTask(url, token, reqItems);
|
||||||
log.error("----Error PengXin start clean {} server return {}", disposeObject, err.getMsg());
|
|
||||||
return new MulReturnType<>(err, disposeObject);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
err = verifyRespStatus(rspInfo.getMsgContent().getItems().get(0).getStatus());
|
if (rspInfo == null || rspInfo.getCode() != ErrorCode.ERR_OK.getHttpCode()) {
|
||||||
|
log.error("----Error PengXin start clean {} server return error", disposeObject);
|
||||||
if (err != ErrorCode.ERR_OK) {
|
return new MulReturnType<>(ErrorCode.ERR_PENGXIN_ERROR, null);
|
||||||
log.error("----Error PengXin start clean {} server return {}({})", disposeObject,
|
|
||||||
rspInfo.getMsgContent().getItems().get(0).getStatus(),
|
|
||||||
rspInfo.getMsgContent().getItems().get(0).getMessage());
|
|
||||||
return new MulReturnType<>(err, disposeObject);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rspInfo.getMsgContent().getItems().size() == 0) {
|
if (rspInfo.getMsgContent().getItems().size() == 0) {
|
||||||
|
@ -208,7 +203,7 @@ public class PengXinAbilityImpl implements DisposeAbility {
|
||||||
return new MulReturnType<>(ErrorCode.ERR_PENGXIN_ERROR, null);
|
return new MulReturnType<>(ErrorCode.ERR_PENGXIN_ERROR, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
log.info("----Finish PengXin Start Cleanup Task: {}", disposeObject);
|
log.debug("----Finish PengXin Start Cleanup Task: {}", disposeObject);
|
||||||
return new MulReturnType<>(ErrorCode.ERR_OK, rspInfo.getMsgContent().getItems().get(0).getTaskId());
|
return new MulReturnType<>(ErrorCode.ERR_OK, rspInfo.getMsgContent().getItems().get(0).getTaskId());
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
|
@ -235,7 +230,6 @@ public class PengXinAbilityImpl implements DisposeAbility {
|
||||||
String url = urlRootPath + "dispose_device/task/stop";
|
String url = urlRootPath + "dispose_device/task/stop";
|
||||||
|
|
||||||
if (token == null || token.length() == 0) {
|
if (token == null || token.length() == 0) {
|
||||||
upgradeToken();
|
|
||||||
return new MulReturnType<>(ErrorCode.ERR_LOGOUT, null);
|
return new MulReturnType<>(ErrorCode.ERR_LOGOUT, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -251,21 +245,17 @@ public class PengXinAbilityImpl implements DisposeAbility {
|
||||||
return new MulReturnType<>(ErrorCode.ERR_PARAMS, null);
|
return new MulReturnType<>(ErrorCode.ERR_PARAMS, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
ProtocolRespDTO<PengXinStopTaskRsp> rspInfo = restfulInterface.stopDisposeTask(url, token,
|
ProtocolRespDTO<CmhiDisposeStopTaskRsp> rspInfo = restfulInterface.stopDisposeTask(url, token,
|
||||||
new String[]{taskId});
|
new String[]{taskId});
|
||||||
|
|
||||||
ErrorCode err = verifyInterfaceResp(rspInfo);
|
// 判断是否token过期
|
||||||
|
if (rspInfo != null && reLogin(rspInfo, rspInfo.getMsgContent().getItems().get(0).getStatus())) {
|
||||||
if (err != ErrorCode.ERR_OK) {
|
rspInfo = restfulInterface.stopDisposeTask(url, token, new String[]{taskId});
|
||||||
log.error("----Error PengXin start clean {} server return {}", taskId, err.getMsg());
|
|
||||||
return new MulReturnType<>(err, null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
err = verifyRespStatus(rspInfo.getMsgContent().getItems().get(0).getStatus());
|
if (rspInfo == null || rspInfo.getCode() != ErrorCode.ERR_OK.getHttpCode()) {
|
||||||
|
log.error("----Error PengXin stop task{} server return error", taskId);
|
||||||
if (err != ErrorCode.ERR_OK) {
|
return new MulReturnType<>(ErrorCode.ERR_CALLDEVICE, null);
|
||||||
log.error("----Error PengXin start clean {} server return {}", taskId, err.getMsg());
|
|
||||||
return new MulReturnType<>(err, null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rspInfo.getMsgContent().getItems().size() == 0) {
|
if (rspInfo.getMsgContent().getItems().size() == 0) {
|
||||||
|
@ -279,7 +269,7 @@ public class PengXinAbilityImpl implements DisposeAbility {
|
||||||
return new MulReturnType<>(ErrorCode.ERR_PENGXIN_ERROR, null);
|
return new MulReturnType<>(ErrorCode.ERR_PENGXIN_ERROR, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
log.info("----Finish PengXin Stop Cleanup Task: {}", taskId);
|
log.debug("----Finish PengXin Stop Cleanup Task: {}", taskId);
|
||||||
return new MulReturnType<>(ErrorCode.ERR_OK, null);
|
return new MulReturnType<>(ErrorCode.ERR_OK, null);
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
|
@ -335,9 +325,8 @@ public class PengXinAbilityImpl implements DisposeAbility {
|
||||||
* Dev get link status.
|
* Dev get link status.
|
||||||
*/
|
*/
|
||||||
private void devGetLinkStatus() {
|
private void devGetLinkStatus() {
|
||||||
String url = urlRootPath + "dispose_device/information/linkstatus";
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
String url = urlRootPath + "dispose_device/information/linkstatus";
|
||||||
|
|
||||||
if (token == null || token.length() == 0) {
|
if (token == null || token.length() == 0) {
|
||||||
deviceLinkStatus = false;
|
deviceLinkStatus = false;
|
||||||
|
@ -358,7 +347,7 @@ public class PengXinAbilityImpl implements DisposeAbility {
|
||||||
|
|
||||||
return;
|
return;
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
log.error("Exception: {}, {}", url, ex.getMessage());
|
log.error(ex.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
deviceLinkStatus = false;
|
deviceLinkStatus = false;
|
||||||
|
@ -369,59 +358,54 @@ public class PengXinAbilityImpl implements DisposeAbility {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void getDisposeDeviceProtectObject() {
|
public void getDisposeDeviceProtectObject() {
|
||||||
// 集团一键处置线上环境,移除从设备获取能力信息相关接口调用
|
|
||||||
// if (token == null || token.length() == 0) {
|
if (token == null || token.length() == 0) {
|
||||||
// return;
|
return;
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// String url = urlRootPath + "dispose_device/information/capacity";
|
try {
|
||||||
//
|
String url = urlRootPath + "dispose_device/information/capacity";
|
||||||
// try {
|
|
||||||
// ProtocolRespDTO<PengXinDisposeAbilityRsp> rspInfo = restfulInterface.getDeviceDisposeAbility(url, token);
|
ProtocolRespDTO<CmhiDisposeAbilityRsp> rspInfo = restfulInterface.getDeviceDisposeAbility(url, token);
|
||||||
//
|
|
||||||
// ErrorCode err = verifyInterfaceResp(rspInfo);
|
// 判断是否token过期
|
||||||
//
|
if (rspInfo != null && reLogin(rspInfo, rspInfo.getMsgContent().getStatus())) {
|
||||||
// if (err != ErrorCode.ERR_OK) {
|
rspInfo = restfulInterface.getDeviceDisposeAbility(url, token);
|
||||||
// log.error("----Error PengXin get dispose device protect object server {} return {}", url, token);
|
}
|
||||||
// return;
|
|
||||||
// }
|
if (rspInfo != null && rspInfo.getCode() == ErrorCode.ERR_OK.getHttpCode()
|
||||||
//
|
&& rspInfo.getMsgContent().getStatus() == ErrorCode.ERR_OK.getCode()) {
|
||||||
// err = verifyRespStatus(rspInfo.getMsgContent().getStatus());
|
|
||||||
//
|
rspInfo.getMsgContent().getCapacity().forEach(v -> {
|
||||||
// if (err != ErrorCode.ERR_OK) {
|
if (v.getObjectType().equals(DisposeObjectType.DOMAIN.getValue())) {
|
||||||
// log.error("---Error PengXin get dispose device protect object server {} return {}", url, err.getMsg());
|
log.error("Unsupported: {}", v.getObjectType());
|
||||||
// return;
|
} else if (v.getObjectType().equals(DisposeObjectType.URL.getValue())) {
|
||||||
// }
|
log.error("Unsupported: {}", v.getObjectType());
|
||||||
//
|
} else {
|
||||||
// rspInfo.getMsgContent().getCapacity().forEach(v -> {
|
synchronized (this) {
|
||||||
// if (v.getObjectType().equals(DisposeObjectType.DOMAIN.getValue())) {
|
|
||||||
// log.error("Unsupported: {}", v.getObjectType());
|
protectIpV4.clear();
|
||||||
// } else if (v.getObjectType().equals(DisposeObjectType.URL.getValue())) {
|
protectIpV6.clear();
|
||||||
// log.error("Unsupported: {}", v.getObjectType());
|
|
||||||
// } else {
|
if (v.getIpType() == null || v.getIpType().equals(IpAddrType.IPV4_IPV6.getValue())) {
|
||||||
// synchronized (this) {
|
String [] allIpAddr = {null, "0.0.0.0", "0.0.0.0,::"};
|
||||||
//
|
|
||||||
// protectIpV4.clear();
|
if(Arrays.asList(allIpAddr).contains(v.getDisposeIp())) {
|
||||||
// protectIpV6.clear();
|
protectIpV4.add("");
|
||||||
//
|
protectIpV6.add("");
|
||||||
// if (v.getIpType() == null || v.getIpType().equals(IpAddrType.IPV4_IPV6.getValue())) {
|
}
|
||||||
// String [] allIpAddr = {null, "0.0.0.0", "0.0.0.0,::"};
|
} else if (v.getIpType().equals(IpAddrType.IPV4.getValue())) {
|
||||||
//
|
protectIpV4.add("");
|
||||||
// if(Arrays.asList(allIpAddr).contains(v.getDisposeIp())) {
|
} else if (v.getIpType().equals(IpAddrType.IPV6.getValue())) {
|
||||||
// protectIpV4.add("");
|
protectIpV6.add("");
|
||||||
// protectIpV6.add("");
|
}
|
||||||
// }
|
}
|
||||||
// } else if (v.getIpType().equals(IpAddrType.IPV4.getValue())) {
|
}
|
||||||
// protectIpV4.add("");
|
});
|
||||||
// } else if (v.getIpType().equals(IpAddrType.IPV6.getValue())) {
|
|
||||||
// protectIpV6.add("");
|
}
|
||||||
// }
|
} catch (Exception ignored) {
|
||||||
// }
|
}
|
||||||
// }
|
|
||||||
// });
|
|
||||||
// } catch (Exception ex) {
|
|
||||||
// log.error("server {}({}) exception: {}", url, token, ex);
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -432,36 +416,34 @@ public class PengXinAbilityImpl implements DisposeAbility {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean isCarryProtectIp(String ipAddr) {
|
public boolean isCarryProtectIp(String ipAddr) {
|
||||||
// 集团一键处置线上环境,默认支持所有IP地址
|
boolean ret = false;
|
||||||
return true;
|
IPAddress addr = new IPAddressString(ipAddr).getAddress();
|
||||||
// boolean ret = false;
|
synchronized (this) {
|
||||||
// IPAddress addr = new IPAddressString(ipAddr).getAddress();
|
if (addr.isIPv4()) {
|
||||||
// synchronized (this) {
|
ret = protectIpV4.stream().anyMatch(v -> Helper.ipInRange(v, ipAddr));
|
||||||
// if (addr.isIPv4()) {
|
}
|
||||||
// ret = protectIpV4.stream().anyMatch(v -> Helper.ipInRange(v, ipAddr));
|
|
||||||
// }
|
if (addr.isIPv6()) {
|
||||||
//
|
ret = protectIpV6.stream().anyMatch(v -> Helper.ipInRange(v, ipAddr));
|
||||||
// if (addr.isIPv6()) {
|
}
|
||||||
// ret = protectIpV6.stream().anyMatch(v -> Helper.ipInRange(v, ipAddr));
|
}
|
||||||
// }
|
|
||||||
// }
|
if (!ret) {
|
||||||
//
|
// 更新设备防护IP
|
||||||
// if (!ret) {
|
getDisposeDeviceProtectObject();
|
||||||
// // 更新设备防护IP
|
|
||||||
// getDisposeDeviceProtectObject();
|
synchronized (this) {
|
||||||
//
|
if (addr.isIPv4()) {
|
||||||
// synchronized (this) {
|
ret = protectIpV4.stream().anyMatch(v -> Helper.ipInRange(v, ipAddr));
|
||||||
// if (addr.isIPv4()) {
|
}
|
||||||
// ret = protectIpV4.stream().anyMatch(v -> Helper.ipInRange(v, ipAddr));
|
|
||||||
// }
|
if (addr.isIPv6()) {
|
||||||
//
|
ret = protectIpV6.stream().anyMatch(v -> Helper.ipInRange(v, ipAddr));
|
||||||
// if (addr.isIPv6()) {
|
}
|
||||||
// ret = protectIpV6.stream().anyMatch(v -> Helper.ipInRange(v, ipAddr));
|
}
|
||||||
// }
|
}
|
||||||
// }
|
|
||||||
// }
|
return ret;
|
||||||
//
|
|
||||||
// return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -473,35 +455,32 @@ public class PengXinAbilityImpl implements DisposeAbility {
|
||||||
@Override
|
@Override
|
||||||
public MulReturnType<ErrorCode, Long> taskStatus(String taskId) {
|
public MulReturnType<ErrorCode, Long> taskStatus(String taskId) {
|
||||||
if (token == null || token.length() == 0) {
|
if (token == null || token.length() == 0) {
|
||||||
upgradeToken();
|
|
||||||
return new MulReturnType<>(ErrorCode.ERR_LOGOUT, -1L);
|
return new MulReturnType<>(ErrorCode.ERR_LOGOUT, -1L);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
String url = urlRootPath + "dispose_device/task/get";
|
String url = urlRootPath + "dispose_device/task/get";
|
||||||
|
|
||||||
ProtocolRespDTO<PengXinTaskStatusRsp> rspInfo = restfulInterface.getDeviceTaskStatus(url, token,
|
ProtocolRespDTO<CmhiDisposeTaskStatusRsp> rspInfo = restfulInterface.getDeviceTaskStatus(url, token,
|
||||||
new String[]{taskId});
|
new String[]{taskId});
|
||||||
|
|
||||||
ErrorCode err = verifyInterfaceResp(rspInfo);
|
// 判断是否token过期
|
||||||
|
if (rspInfo != null && reLogin(rspInfo, rspInfo.getMsgContent().getItems().get(0).getStatus())) {
|
||||||
if (err != ErrorCode.ERR_OK) {
|
rspInfo = restfulInterface.getDeviceTaskStatus(url, token, new String[]{taskId});
|
||||||
log.error("----Error PengXin start clean {} server return {}", taskId, err.getMsg());
|
|
||||||
return new MulReturnType<>(err, -1L);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
err = verifyRespStatus(rspInfo.getMsgContent().getItems().get(0).getStatus());
|
if (rspInfo != null && rspInfo.getCode() == ErrorCode.ERR_OK.getHttpCode()) {
|
||||||
|
|
||||||
if (err != ErrorCode.ERR_OK) {
|
int errCode = rspInfo.getMsgContent().getItems().get(0).getStatus();
|
||||||
log.error("----Error PengXin start clean {} server return {}", taskId, err.getMsg());
|
if (rspInfo.getMsgContent().getItems().size() == 0 || errCode != ErrorCode.ERR_OK.getCode()) {
|
||||||
return new MulReturnType<>(err, -1L);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (rspInfo.getMsgContent().getItems().size() == 0) {
|
|
||||||
return new MulReturnType<>(ErrorCode.ERR_NOSUCHTASK, -1L);
|
return new MulReturnType<>(ErrorCode.ERR_NOSUCHTASK, -1L);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new MulReturnType<>(ErrorCode.ERR_OK, rspInfo.getMsgContent().getItems().get(0).getTaskStatus());
|
return new MulReturnType<>(ErrorCode.ERR_OK,
|
||||||
|
rspInfo.getMsgContent().getItems().get(0).getTaskStatus());
|
||||||
|
} else {
|
||||||
|
return new MulReturnType<>(ErrorCode.ERR_CALLDEVICE, -1L);
|
||||||
|
}
|
||||||
} catch (Exception ignored) {
|
} catch (Exception ignored) {
|
||||||
return new MulReturnType<>(ErrorCode.ERR_SYSTEMEXCEPTION, -1L);
|
return new MulReturnType<>(ErrorCode.ERR_SYSTEMEXCEPTION, -1L);
|
||||||
}
|
}
|
||||||
|
@ -511,72 +490,42 @@ public class PengXinAbilityImpl implements DisposeAbility {
|
||||||
* Upgrade token.
|
* Upgrade token.
|
||||||
*/
|
*/
|
||||||
private void upgradeToken() {
|
private void upgradeToken() {
|
||||||
String url = urlRootPath + "dispose_device/auth/login";
|
|
||||||
try {
|
try {
|
||||||
ProtocolRespDTO<PengXinLoginRsp> logInfo = restfulInterface.login(url, username, password);
|
String url = urlRootPath + "dispose_device/auth/login";
|
||||||
|
ProtocolRespDTO<CmhiDisposeLoginRsp> logInfo = restfulInterface.login(url, username, password);
|
||||||
|
|
||||||
if (logInfo != null && logInfo.getMsgContent().getStatus() == ErrorCode.ERR_OK.getCode()) {
|
if (logInfo != null && logInfo.getMsgContent().getStatus() == ErrorCode.ERR_OK.getCode()) {
|
||||||
this.token = logInfo.getMsgContent().getToken();
|
this.token = logInfo.getMsgContent().getToken();
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
|
||||||
log.error("Exception: {}, {}", url, ex.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Verify interface resp error code.
|
|
||||||
*
|
|
||||||
* @param <T> the type parameter
|
|
||||||
* @param rspInfo the rsp info
|
|
||||||
* @return the error code
|
|
||||||
*/
|
|
||||||
private <T> ErrorCode verifyInterfaceResp(ProtocolRespDTO<T> rspInfo) {
|
|
||||||
if (rspInfo == null) {
|
|
||||||
return ErrorCode.ERR_PENGXIN_ERROR;
|
|
||||||
} else if (rspInfo.getCode() == HttpServletResponse.SC_UNAUTHORIZED) {
|
|
||||||
upgradeToken();
|
|
||||||
return ErrorCode.ERR_TOKENTIMEOUT;
|
|
||||||
} else if (rspInfo.getCode() != HttpServletResponse.SC_OK) {
|
|
||||||
return ErrorCode.ERR_PENGXIN_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (rspInfo.getMsgContent() == null) {
|
|
||||||
return ErrorCode.ERR_PARAMS;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ErrorCode.ERR_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Verify resp status error code.
|
|
||||||
*
|
|
||||||
* @param status the status
|
|
||||||
* @return the error code
|
|
||||||
*/
|
|
||||||
private ErrorCode verifyRespStatus(int status) {
|
|
||||||
if (status == ErrorCode.ERR_LOGOUT.getCode()
|
|
||||||
|| status == ErrorCode.ERR_TOKENTIMEOUT.getCode()
|
|
||||||
|| status == ErrorCode.ERR_TOKENNOTFOUND.getCode()) {
|
|
||||||
upgradeToken();
|
|
||||||
return ErrorCode.ERR_TOKENTIMEOUT;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
ErrorCode err = CommonEnumHandler.codeOf(ErrorCode.class, status);
|
|
||||||
|
|
||||||
if (err == null) {
|
|
||||||
return ErrorCode.ERR_CALLDEVICE;
|
|
||||||
} else {
|
|
||||||
return err;
|
|
||||||
}
|
|
||||||
} catch (Exception ignored) {
|
} catch (Exception ignored) {
|
||||||
if (status == ErrorCode.ERR_OK.getCode()) {
|
|
||||||
return ErrorCode.ERR_OK;
|
|
||||||
} else {
|
|
||||||
return ErrorCode.ERR_CALLDEVICE;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* reLogin.
|
||||||
|
*/
|
||||||
|
private <T> boolean reLogin(ProtocolRespDTO<T> rspInfo, int status) {
|
||||||
|
try {
|
||||||
|
// 判断是否token过期
|
||||||
|
if (rspInfo.getCode() == HttpServletResponse.SC_UNAUTHORIZED) {
|
||||||
|
// 重新登录获取 token
|
||||||
|
upgradeToken();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rspInfo.getCode() == HttpServletResponse.SC_OK) {
|
||||||
|
if (status == ErrorCode.ERR_LOGOUT.getCode() ||
|
||||||
|
status == ErrorCode.ERR_TOKENTIMEOUT.getCode() ||
|
||||||
|
status == ErrorCode.ERR_TOKENNOTFOUND.getCode()) {
|
||||||
|
upgradeToken();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
} catch (Exception ignored) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -584,14 +533,17 @@ public class PengXinAbilityImpl implements DisposeAbility {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void periodTaskRuntime() {
|
public void periodTaskRuntime() {
|
||||||
// 集团一键处置线上环境,不再定时获取设备能力信息
|
log.debug("++++PengXin Period Task Running");
|
||||||
|
|
||||||
// 更新防护对象
|
// 更新防护对象
|
||||||
//getDisposeDeviceProtectObject();
|
getDisposeDeviceProtectObject();
|
||||||
|
|
||||||
// 更新心跳状态
|
// 更新心跳状态
|
||||||
if (timerCnt++ % DisposeConfigValue.HEART_PERIOD_OF_SECOND == 0) {
|
if (timerCnt++ % DisposeConfigValue.HEART_PERIOD_OF_SECOND == 0) {
|
||||||
devGetLinkStatus();
|
devGetLinkStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log.debug("----PengXin Period Task Running");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
|
@ -14,7 +14,6 @@ import com.dispose.common.NetflowDirection;
|
||||||
import com.dispose.pojo.entity.ServiceInfo;
|
import com.dispose.pojo.entity.ServiceInfo;
|
||||||
import com.dispose.pojo.po.MulReturnType;
|
import com.dispose.pojo.po.MulReturnType;
|
||||||
import com.dispose.pojo.vo.DeviceFirewareInfo;
|
import com.dispose.pojo.vo.DeviceFirewareInfo;
|
||||||
import com.dispose.security.arithmetic.CryptoHelper;
|
|
||||||
import com.dptech.dispose.AbnormalFlowCleaningServicePortType;
|
import com.dptech.dispose.AbnormalFlowCleaningServicePortType;
|
||||||
import com.dptech.dispose.ArrayOfProtectionObjectDataForService;
|
import com.dptech.dispose.ArrayOfProtectionObjectDataForService;
|
||||||
import com.dptech.dispose.NtcRequestResultInfo;
|
import com.dptech.dispose.NtcRequestResultInfo;
|
||||||
|
@ -102,7 +101,7 @@ public class DpTechAbilityImpl implements DisposeAbility {
|
||||||
this.cleanTypePort = (AbnormalFlowCleaningServicePortType) jaxWsProxyFactoryBean.create();
|
this.cleanTypePort = (AbnormalFlowCleaningServicePortType) jaxWsProxyFactoryBean.create();
|
||||||
|
|
||||||
Map<String, Object> ctx = ((BindingProvider) this.cleanTypePort).getRequestContext();
|
Map<String, Object> ctx = ((BindingProvider) this.cleanTypePort).getRequestContext();
|
||||||
ctx.put("password", new String(CryptoHelper.base64Decryption(password)));
|
ctx.put("password", password);
|
||||||
ctx.put("username", username);
|
ctx.put("username", username);
|
||||||
|
|
||||||
// 配置连接,访问超时时间
|
// 配置连接,访问超时时间
|
||||||
|
|
|
@ -10,7 +10,6 @@ import com.dispose.common.NetflowDirection;
|
||||||
import com.dispose.pojo.entity.ServiceInfo;
|
import com.dispose.pojo.entity.ServiceInfo;
|
||||||
import com.dispose.pojo.po.MulReturnType;
|
import com.dispose.pojo.po.MulReturnType;
|
||||||
import com.dispose.pojo.vo.DeviceFirewareInfo;
|
import com.dispose.pojo.vo.DeviceFirewareInfo;
|
||||||
import com.dispose.security.arithmetic.CryptoHelper;
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import com.huawei.dispose.common.HuaWeiLoginResp;
|
import com.huawei.dispose.common.HuaWeiLoginResp;
|
||||||
import com.huawei.dispose.protocol.HuaWeiInterface;
|
import com.huawei.dispose.protocol.HuaWeiInterface;
|
||||||
|
@ -86,7 +85,7 @@ public class HuaWeiAbilityImpl implements DisposeAbility {
|
||||||
public void initDeviceEnv(String urlPath, String username, String password) {
|
public void initDeviceEnv(String urlPath, String username, String password) {
|
||||||
this.urlRootPath = urlPath;
|
this.urlRootPath = urlPath;
|
||||||
this.username = username;
|
this.username = username;
|
||||||
this.password = new String(CryptoHelper.base64Decryption(password));
|
this.password = password;
|
||||||
|
|
||||||
upgradeToken();
|
upgradeToken();
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,7 +85,7 @@ public class HuaWeiFireWallAbilityImpl implements DisposeAbility {
|
||||||
public void initDeviceEnv(String urlPath, String username, String password) {
|
public void initDeviceEnv(String urlPath, String username, String password) {
|
||||||
this.urlRootPath = urlPath;
|
this.urlRootPath = urlPath;
|
||||||
this.username = username;
|
this.username = username;
|
||||||
this.password = new String(CryptoHelper.base64Decryption(password));
|
this.password = password;
|
||||||
|
|
||||||
upgradeToken();
|
upgradeToken();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,10 @@
|
||||||
package com.dispose.ability.impl;
|
package com.dispose.ability.impl;
|
||||||
|
|
||||||
|
import com.cmhi.dispose.common.CmhiDisposeStartTaskItem;
|
||||||
|
import com.cmhi.dispose.common.CmhiDisposeStartTaskRsp;
|
||||||
|
import com.cmhi.dispose.common.CmhiDisposeStopTaskRsp;
|
||||||
|
import com.cmhi.dispose.common.CmhiDisposeTaskStatusRsp;
|
||||||
|
import com.cmhi.dispose.protocol.CmhiDisposeInterface;
|
||||||
import com.dispose.common.DisposeCapacityType;
|
import com.dispose.common.DisposeCapacityType;
|
||||||
import com.dispose.common.DisposeObjectType;
|
import com.dispose.common.DisposeObjectType;
|
||||||
import com.dispose.common.ErrorCode;
|
import com.dispose.common.ErrorCode;
|
||||||
|
@ -8,12 +13,6 @@ import com.dispose.pojo.dto.protocol.base.ProtocolRespDTO;
|
||||||
import com.dispose.pojo.entity.ServiceInfo;
|
import com.dispose.pojo.entity.ServiceInfo;
|
||||||
import com.dispose.pojo.po.MulReturnType;
|
import com.dispose.pojo.po.MulReturnType;
|
||||||
import com.dispose.pojo.vo.DeviceFirewareInfo;
|
import com.dispose.pojo.vo.DeviceFirewareInfo;
|
||||||
import com.dispose.security.arithmetic.CryptoHelper;
|
|
||||||
import com.pengxin.dispose.common.PengXinStartTaskItem;
|
|
||||||
import com.pengxin.dispose.common.PengXinStartTaskRsp;
|
|
||||||
import com.pengxin.dispose.common.PengXinStopTaskRsp;
|
|
||||||
import com.pengxin.dispose.common.PengXinTaskStatusRsp;
|
|
||||||
import com.pengxin.dispose.protocol.PengXinInterface;
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
@ -29,11 +28,11 @@ import java.util.List;
|
||||||
* @author Nicole
|
* @author Nicole
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class UpfAbilityImpl extends PengXinAbilityImpl {
|
public class UpfAbilityImpl extends CmhiAbilityImpl {
|
||||||
/**
|
/**
|
||||||
* The Restful interface.
|
* The Restful interface.
|
||||||
*/
|
*/
|
||||||
private final PengXinInterface restfulInterface = new PengXinInterface();
|
private final CmhiDisposeInterface restfulInterface = new CmhiDisposeInterface();
|
||||||
/**
|
/**
|
||||||
* The upf dispose type.
|
* The upf dispose type.
|
||||||
*/
|
*/
|
||||||
|
@ -103,7 +102,7 @@ public class UpfAbilityImpl extends PengXinAbilityImpl {
|
||||||
public void initDeviceEnv(String urlPath, String username, String password) {
|
public void initDeviceEnv(String urlPath, String username, String password) {
|
||||||
this.urlRootPath = urlPath;
|
this.urlRootPath = urlPath;
|
||||||
this.username = username;
|
this.username = username;
|
||||||
this.password = new String(CryptoHelper.base64Decryption(password));
|
this.password = password;
|
||||||
restfulInterface.setParams(1, 0);
|
restfulInterface.setParams(1, 0);
|
||||||
//获取token值
|
//获取token值
|
||||||
upgradeToken();
|
upgradeToken();
|
||||||
|
@ -126,7 +125,7 @@ public class UpfAbilityImpl extends PengXinAbilityImpl {
|
||||||
@Nullable NetflowDirection nfDirection,
|
@Nullable NetflowDirection nfDirection,
|
||||||
@Nullable Integer attackType,
|
@Nullable Integer attackType,
|
||||||
@Nullable Long duration) {
|
@Nullable Long duration) {
|
||||||
List<PengXinStartTaskItem> reqItems = new ArrayList<>();
|
List<CmhiDisposeStartTaskItem> reqItems = new ArrayList<>();
|
||||||
String url = urlRootPath + "dispose_device/task/start";
|
String url = urlRootPath + "dispose_device/task/start";
|
||||||
//1.调用upf设备登录接口,生成token值;2.upf不提供登录接口,随机生成token值,保证有token值
|
//1.调用upf设备登录接口,生成token值;2.upf不提供登录接口,随机生成token值,保证有token值
|
||||||
if (token == null || token.length() == 0) {
|
if (token == null || token.length() == 0) {
|
||||||
|
@ -143,7 +142,7 @@ public class UpfAbilityImpl extends PengXinAbilityImpl {
|
||||||
// 适配处置时间参数, -1为不限制处置时间
|
// 适配处置时间参数, -1为不限制处置时间
|
||||||
duration = -1L;
|
duration = -1L;
|
||||||
|
|
||||||
reqItems.add(PengXinStartTaskItem.builder()
|
reqItems.add(CmhiDisposeStartTaskItem.builder()
|
||||||
.type(getUpfTaskType(capType))
|
.type(getUpfTaskType(capType))
|
||||||
.disposeObject(disposeObject)
|
.disposeObject(disposeObject)
|
||||||
.objectType(getUpfObjectType(objectType))
|
.objectType(getUpfObjectType(objectType))
|
||||||
|
@ -151,7 +150,7 @@ public class UpfAbilityImpl extends PengXinAbilityImpl {
|
||||||
.taskReqId(String.valueOf(taskReqId++))
|
.taskReqId(String.valueOf(taskReqId++))
|
||||||
.build());
|
.build());
|
||||||
|
|
||||||
ProtocolRespDTO<PengXinStartTaskRsp> rspInfo = restfulInterface.startDisposeTask(url, token, reqItems);
|
ProtocolRespDTO<CmhiDisposeStartTaskRsp> rspInfo = restfulInterface.startDisposeTask(url, token, reqItems);
|
||||||
|
|
||||||
// upf设备不判断header认证消息中的token值
|
// upf设备不判断header认证消息中的token值
|
||||||
if (rspInfo == null || rspInfo.getCode() != ErrorCode.ERR_OK.getHttpCode()) {
|
if (rspInfo == null || rspInfo.getCode() != ErrorCode.ERR_OK.getHttpCode()) {
|
||||||
|
@ -210,7 +209,7 @@ public class UpfAbilityImpl extends PengXinAbilityImpl {
|
||||||
return new MulReturnType<>(ErrorCode.ERR_PARAMS, null);
|
return new MulReturnType<>(ErrorCode.ERR_PARAMS, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
ProtocolRespDTO<PengXinStopTaskRsp> rspInfo = restfulInterface.stopDisposeTask(url, token,
|
ProtocolRespDTO<CmhiDisposeStopTaskRsp> rspInfo = restfulInterface.stopDisposeTask(url, token,
|
||||||
new String[]{taskId});
|
new String[]{taskId});
|
||||||
|
|
||||||
if (rspInfo == null || rspInfo.getCode() != ErrorCode.ERR_OK.getHttpCode()) {
|
if (rspInfo == null || rspInfo.getCode() != ErrorCode.ERR_OK.getHttpCode()) {
|
||||||
|
@ -316,7 +315,7 @@ public class UpfAbilityImpl extends PengXinAbilityImpl {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
String url = urlRootPath + "dispose_device/task/get";
|
String url = urlRootPath + "dispose_device/task/get";
|
||||||
ProtocolRespDTO<PengXinTaskStatusRsp> rspInfo = restfulInterface.getDeviceTaskStatus(url, token,
|
ProtocolRespDTO<CmhiDisposeTaskStatusRsp> rspInfo = restfulInterface.getDeviceTaskStatus(url, token,
|
||||||
new String[]{taskId});
|
new String[]{taskId});
|
||||||
|
|
||||||
if (rspInfo != null && rspInfo.getCode() == ErrorCode.ERR_OK.getHttpCode()) {
|
if (rspInfo != null && rspInfo.getCode() == ErrorCode.ERR_OK.getHttpCode()) {
|
||||||
|
|
|
@ -0,0 +1,112 @@
|
||||||
|
package com.dispose.common;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The emos constants.
|
||||||
|
*
|
||||||
|
* @author <chenling@cmhi.chinamoblie.com>
|
||||||
|
*/
|
||||||
|
public class Constants {
|
||||||
|
/**
|
||||||
|
* DDoS具体攻击类型
|
||||||
|
*/
|
||||||
|
public static final Map<String, String> ATTACK_TYPE;
|
||||||
|
|
||||||
|
static {
|
||||||
|
Map<String, String> attTypeMap = new HashMap<>();
|
||||||
|
attTypeMap.put("hosttotaltraffic", "Host total traffic|1|2");
|
||||||
|
|
||||||
|
attTypeMap.put("RSTFlood", "RST Flood|3|4");
|
||||||
|
attTypeMap.put("SYNFlood", "SYN Flood|5|6");
|
||||||
|
attTypeMap.put("ACKFlood", "ACK Flood|7|8");
|
||||||
|
attTypeMap.put("TCPnullFlood", "TCP null|9|10");
|
||||||
|
attTypeMap.put("SYNACKAmplification", "SYN/ACK Amplification|11|12");
|
||||||
|
attTypeMap.put("tcpmisuse", "TCP Misuse|13|14");
|
||||||
|
attTypeMap.put("FINFlood", "FIN Flood|15|16");
|
||||||
|
attTypeMap.put("TCPFragment", "TCP Fragment|17|18");
|
||||||
|
attTypeMap.put("HTTPFlood", "HTTP Flood|19|20");
|
||||||
|
attTypeMap.put("HTTPSFlood", "HTTPS Flood|21|22");
|
||||||
|
|
||||||
|
attTypeMap.put("SIPFlood", "SIP Flood|23|24");
|
||||||
|
attTypeMap.put("DNS", "DNS|25|26");
|
||||||
|
|
||||||
|
attTypeMap.put("UDPFragment", "UDP Fragment|27|28");
|
||||||
|
attTypeMap.put("chargenAmplification", "chargen Amplification|29|30");
|
||||||
|
attTypeMap.put("L2TPAmplification", "L2TP Amplification|31|32");
|
||||||
|
attTypeMap.put("mDNSAmplification", "mDNS Amplification|33|34");
|
||||||
|
attTypeMap.put("MSSQLRSAmplification", "MS SQL RS Amplification|35|36");
|
||||||
|
attTypeMap.put("NetBIOSAmplification", "NetBIOS Amplification|37|38");
|
||||||
|
attTypeMap.put("NTPAmplification", "NTP Amplification|39|40");
|
||||||
|
attTypeMap.put("RIPv1Amplification", "RIPv1 Amplification|41|42");
|
||||||
|
attTypeMap.put("rpcbindAmplification", "rpcbind Amplification|43|44");
|
||||||
|
attTypeMap.put("SNMPAmplification", "SNMP Amplification|45|46");
|
||||||
|
attTypeMap.put("SSDPAmplification", "SSDP Amplification|47|48");
|
||||||
|
attTypeMap.put("DNSAmplification", "DNS Amplification|49|50");
|
||||||
|
attTypeMap.put("QOTDAmplification", "QOTD Amplification|51|52");
|
||||||
|
attTypeMap.put("Quake3Amplification", "Quake3 Amplification|53|54");
|
||||||
|
attTypeMap.put("SteamAmplification", "Steam Amplification|55|56");
|
||||||
|
attTypeMap.put("CLADPAmplification", "CLADP Amplification|57|58");
|
||||||
|
attTypeMap.put("MemcacheAmplification", "Memcache Amplification|59|60");
|
||||||
|
attTypeMap.put("UDPFlood", "UDP Flood|61|62");
|
||||||
|
|
||||||
|
attTypeMap.put("smurf", "Smurf|63|64");
|
||||||
|
attTypeMap.put("icmpfrgment", "ICMP Fragment|65|66");
|
||||||
|
attTypeMap.put("ICMPFlood", "ICMP Flood|67|68");
|
||||||
|
|
||||||
|
attTypeMap.put("IPv4Protocol0", "IPv4 Protocol 0|69|70");
|
||||||
|
attTypeMap.put("IPPrivate", "IP Private|71|72");
|
||||||
|
attTypeMap.put("landflood", "Land flood|73|74");
|
||||||
|
attTypeMap.put("IGMPFlood", "IGMP Flood|75|76");
|
||||||
|
ATTACK_TYPE = Collections.unmodifiableMap(attTypeMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 各省份城市
|
||||||
|
*/
|
||||||
|
public static final String REGION_BEIJING = "北京";
|
||||||
|
public static final String REGION_SHANGHAI = "上海";
|
||||||
|
public static final String REGION_TIANJIN = "天津";
|
||||||
|
public static final String REGION_CHONGQING = "重庆";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 处置类型(1:清洗,2:黑洞,3:高防)
|
||||||
|
*/
|
||||||
|
public static final int CLEANUP = 1;
|
||||||
|
public static final int BLACKHOOL = 2;
|
||||||
|
public static final int HIDEPEND = 3;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 派单eoms模板
|
||||||
|
*/
|
||||||
|
public static final String DISPATCH_TEMPLATE = "<AlarmStart>\nMsgSerial:{0}\nSDN:{1}\nNeName:{2}\nEquipmentClass:99236\n" +
|
||||||
|
"AlarmUniqueId:{3}\nAlarmUniqueClearId:{4}\nLocateNeName:{5}\nLocateNeType:99236\nLocateNeSDN:{6}\nLocateInfo:{7}\n" +
|
||||||
|
"EventTime:{8}\nCancelTime:{9}\nVendorAlarmType:{10}\nVendorSeverity:{11}\nVendorAlarmId:{12}\nAlarmTitle:{13}\n" +
|
||||||
|
"ProbableCauseTxt:{14}\nRLocateSDN: \nRLocateNeName: \nRLocateNeType: \nRate: \nAlarmLocation: \nAlarmCheck: \n" +
|
||||||
|
"HolderType: \nAlarmStatus:{15}\nCorrelateAlarmFlag: \nAlarmActCount: \nNeIp:\nEmsId: \nVendor:99083\nAlarmText:{16}\n" +
|
||||||
|
"NeAlias: \nVersion: \nRemoteNe: \nAlarmProvince:{17}\nAlarmRegion:{18}\nAlarmCounty: \nSite: \nSiteType: \nSiteProperty: \n" +
|
||||||
|
"MachineroomIDofZGTT: \nBusinessSystem:{19}\nCircuitNo: \nMac: \nSpecialty:9\nNetworkType:903\nNeSubType: \nEffectCircuitNum: \n" +
|
||||||
|
"CircuitLevel: \nAlarmSeverity:3\nNmsAlarmId:0903-083-056-10-900001\nStandardAlarmName:{20}\nAlarmLogicClass:{21}\n" +
|
||||||
|
"AlarmLogicSubClass:{22}\nEffectOnEquipment:5\nEffectOnBusiness:4\nNmsAlarmType:1\nSendGroupFlag: \nStandardFlag:2\n" +
|
||||||
|
"AlarmExplanation:{23}\nBusinessType: \nBusinessInfo:{24}\nIsRelatedRemote: \nLocateNeStatus:1300\nProjectNo: \n" +
|
||||||
|
"ProjectName: \nProjectStartTime: \nProjectEndTime: \nGroupCustomer: \nCustomerLevel: \nServiceType: \nServiceLevel: \n" +
|
||||||
|
"ServiceName: \nServiceCrossDomainType: \nInterruptCircuitState: \nCircuitLocateInfo: \nHomeClientNum: \nHomeCellNum: \n" +
|
||||||
|
"LinkOnuNum: \n<AlarmEnd>";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 0:网元自动清除 --收到从采集源发送的清除告警
|
||||||
|
*/
|
||||||
|
public static final int NE_AUTO_CLEARED_STATUS = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 1:活动告警---告警当前为活动状态
|
||||||
|
*/
|
||||||
|
public static final int ACTIVE_ALARM_STATUS = 1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 2:同步清除---已采集活动告警,但采集平台从告警源同步时,发现已经没有对应的活动告警,由采集平台产生的清除告警
|
||||||
|
*/
|
||||||
|
public static final int SYNCHRONIZATION_CLEAR_STATUS = 2;
|
||||||
|
}
|
|
@ -17,7 +17,7 @@ public enum DisposeDeviceType implements BaseEnum {
|
||||||
/**
|
/**
|
||||||
* The Pengxin platform.
|
* The Pengxin platform.
|
||||||
*/
|
*/
|
||||||
PENGXIN_PLATFORM(2, "鹏信处置设备"),
|
CMHI_PLATFORM(2, "集团一键处置设备"),
|
||||||
/**
|
/**
|
||||||
* The Huawei platform.
|
* The Huawei platform.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -293,6 +293,10 @@ public enum ErrorCode implements BaseEnum {
|
||||||
* The Err huawei firewall error.
|
* The Err huawei firewall error.
|
||||||
*/
|
*/
|
||||||
ERR_HUAWEIFIREWALL_ERROR(305, "华为防火墙返回错误"),
|
ERR_HUAWEIFIREWALL_ERROR(305, "华为防火墙返回错误"),
|
||||||
|
/**
|
||||||
|
* The Err emos create message error.
|
||||||
|
*/
|
||||||
|
EMOS_CREATEMESSAGE_ERROR(306, "EMOS发送信息错误"),
|
||||||
;
|
;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -0,0 +1,111 @@
|
||||||
|
package com.dispose.config;
|
||||||
|
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.kafka.clients.producer.ProducerConfig;
|
||||||
|
import org.apache.kafka.common.serialization.StringSerializer;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.kafka.annotation.EnableKafka;
|
||||||
|
import org.springframework.kafka.core.DefaultKafkaProducerFactory;
|
||||||
|
import org.springframework.kafka.core.KafkaTemplate;
|
||||||
|
import org.springframework.kafka.core.ProducerFactory;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The type Kafka configuration.
|
||||||
|
*
|
||||||
|
* @author <huangxin@cmhi.chinamoblie.com>
|
||||||
|
*/
|
||||||
|
@EnableKafka
|
||||||
|
@ConfigurationProperties(prefix = "kafka")
|
||||||
|
@Configuration
|
||||||
|
@Component
|
||||||
|
@Slf4j
|
||||||
|
public class KafkaConfiguration {
|
||||||
|
/**
|
||||||
|
* The Producer servers.
|
||||||
|
*/
|
||||||
|
@Value("${kafka.producer.servers}")
|
||||||
|
private String producerServers;
|
||||||
|
/**
|
||||||
|
* The Producer retries.
|
||||||
|
*/
|
||||||
|
@Value("${kafka.producer.retries}")
|
||||||
|
private Integer producerRetries;
|
||||||
|
/**
|
||||||
|
* The Producer batch size.
|
||||||
|
*/
|
||||||
|
@Value("${kafka.producer.batch.size}")
|
||||||
|
private Integer producerBatchSize;
|
||||||
|
/**
|
||||||
|
* The Producer linger.
|
||||||
|
*/
|
||||||
|
@Value("${kafka.producer.linger}")
|
||||||
|
private Integer producerLinger;
|
||||||
|
/**
|
||||||
|
* The Buffer memory.
|
||||||
|
*/
|
||||||
|
@Value("${kafka.producer.buffer.memory}")
|
||||||
|
private Integer bufferMemory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Kafka topic.
|
||||||
|
*/
|
||||||
|
@Value("${kafka.dispose.topic}")
|
||||||
|
private String kafkaTopic;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Producer configs map.
|
||||||
|
*
|
||||||
|
* @return the map
|
||||||
|
*/
|
||||||
|
public Map<String, Object> producerConfigs() {
|
||||||
|
Map<String, Object> props = new HashMap<>(1);
|
||||||
|
log.info("-----------------servers---------: {}", producerServers);
|
||||||
|
props.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, producerServers);
|
||||||
|
props.put(ProducerConfig.RETRIES_CONFIG, producerRetries);
|
||||||
|
props.put(ProducerConfig.BATCH_SIZE_CONFIG, producerBatchSize);
|
||||||
|
props.put(ProducerConfig.LINGER_MS_CONFIG, producerLinger);
|
||||||
|
props.put(ProducerConfig.BUFFER_MEMORY_CONFIG, bufferMemory);
|
||||||
|
props.put(ProducerConfig.RECONNECT_BACKOFF_MS_CONFIG, 5000);
|
||||||
|
props.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, StringSerializer.class);
|
||||||
|
props.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, StringSerializer.class);
|
||||||
|
return props;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets kafka topic.
|
||||||
|
*
|
||||||
|
* @return the kafka topic
|
||||||
|
*/
|
||||||
|
public String getKafkaTopic() {
|
||||||
|
return kafkaTopic;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Producer factory producer factory.
|
||||||
|
*
|
||||||
|
* @return the producer factory
|
||||||
|
*/
|
||||||
|
public ProducerFactory<String, String> producerFactory() {
|
||||||
|
return new DefaultKafkaProducerFactory<>(producerConfigs());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Kafka template kafka template.
|
||||||
|
*
|
||||||
|
* @return the kafka template
|
||||||
|
*/
|
||||||
|
@Bean
|
||||||
|
public KafkaTemplate<String, String> kafkaTemplate() {
|
||||||
|
KafkaTemplate<String, String> kafkaTemplate = new KafkaTemplate<>(producerFactory());
|
||||||
|
kafkaTemplate.setDefaultTopic(kafkaTopic);
|
||||||
|
|
||||||
|
return kafkaTemplate;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,30 @@
|
||||||
|
package com.dispose.config;
|
||||||
|
|
||||||
|
import io.undertow.server.DefaultByteBufferPool;
|
||||||
|
import io.undertow.websockets.jsr.WebSocketDeploymentInfo;
|
||||||
|
import org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFactory;
|
||||||
|
import org.springframework.boot.web.server.WebServerFactoryCustomizer;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The type Undertow pool customizer.
|
||||||
|
*
|
||||||
|
* @author <huangxin@cmhi.chinamoblie.com>
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
public class UndertowPoolCustomizer implements WebServerFactoryCustomizer<UndertowServletWebServerFactory> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Customize.
|
||||||
|
*
|
||||||
|
* @param factory the factory
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void customize(UndertowServletWebServerFactory factory) {
|
||||||
|
factory.addDeploymentInfoCustomizers(deploymentInfo -> {
|
||||||
|
WebSocketDeploymentInfo webSocketDeploymentInfo = new WebSocketDeploymentInfo();
|
||||||
|
webSocketDeploymentInfo.setBuffers(new DefaultByteBufferPool(false, 1024));
|
||||||
|
deploymentInfo.addServletContextAttribute("io.undertow.websockets.jsr.WebSocketDeploymentInfo", webSocketDeploymentInfo);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,252 @@
|
||||||
|
package com.dispose.controller;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.dispose.common.Constants;
|
||||||
|
import com.dispose.common.ErrorCode;
|
||||||
|
import com.dispose.config.KafkaConfiguration;
|
||||||
|
import com.dispose.manager.AlarmInfoManager;
|
||||||
|
import com.dispose.pojo.dto.protocol.base.BaseRespStatus;
|
||||||
|
import com.dispose.pojo.dto.protocol.base.ProtocolReqDTO;
|
||||||
|
import com.dispose.pojo.dto.protocol.base.ProtocolRespDTO;
|
||||||
|
import com.dispose.pojo.dto.protocol.kafka.AlarmInfoReq;
|
||||||
|
import com.dispose.pojo.dto.protocol.kafka.EmosAlarmInfo;
|
||||||
|
import com.dispose.pojo.entity.AlarmInformation;
|
||||||
|
import com.dispose.pojo.po.MulReturnType;
|
||||||
|
import com.dispose.security.annotation.Decryption;
|
||||||
|
import com.dispose.security.annotation.Encryption;
|
||||||
|
import com.dispose.service.MsgSerialService;
|
||||||
|
import com.dispose.validation.group.ValidGroups;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.lang.exception.ExceptionUtils;
|
||||||
|
import org.springframework.kafka.support.SendResult;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.util.concurrent.ListenableFuture;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.text.MessageFormat;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The type Auth controller.
|
||||||
|
*
|
||||||
|
* @author <chenling@cmhi.chinamoblie.com>
|
||||||
|
*/
|
||||||
|
@Controller
|
||||||
|
@RequestMapping(value = "/kafka")
|
||||||
|
@Slf4j
|
||||||
|
@Api(value = "处置平台发送消息接口", tags = "处置平台发送消息接口")
|
||||||
|
@Component
|
||||||
|
@Validated
|
||||||
|
@Encryption
|
||||||
|
@Decryption
|
||||||
|
public class KafkaController {
|
||||||
|
/**
|
||||||
|
* The Kafka configuration.
|
||||||
|
*/
|
||||||
|
@Resource
|
||||||
|
private KafkaConfiguration kafkaConfiguration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The message serial service.
|
||||||
|
*/
|
||||||
|
@Resource
|
||||||
|
private MsgSerialService msgSerialService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The alarm information manager.
|
||||||
|
*/
|
||||||
|
@Resource
|
||||||
|
private AlarmInfoManager alarmInfoManager;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dispatch command sent to kafka.
|
||||||
|
*
|
||||||
|
* @param mr the mr
|
||||||
|
* @return the protocol resp dto
|
||||||
|
*/
|
||||||
|
@PostMapping("/dispatchCommand")
|
||||||
|
@ResponseBody
|
||||||
|
@ApiOperation("发送消息")
|
||||||
|
public ProtocolRespDTO<BaseRespStatus> dispatchCommand(
|
||||||
|
@Validated(ValidGroups.ProtocolCommonValid.class)
|
||||||
|
@RequestBody ProtocolReqDTO<AlarmInfoReq> mr) {
|
||||||
|
//获取入参信息
|
||||||
|
BaseRespStatus rspInfo = new BaseRespStatus();
|
||||||
|
log.info("emos alarm is:{}", mr.getMsgContent().getAlarmInfo());
|
||||||
|
EmosAlarmInfo alarmInfo = JSONObject.parseObject(mr.getMsgContent().getAlarmInfo(), EmosAlarmInfo.class);
|
||||||
|
|
||||||
|
//拼接emos据格式
|
||||||
|
String content = createSendContent(alarmInfo);
|
||||||
|
if (content == null) {
|
||||||
|
rspInfo.setStatus(ErrorCode.EMOS_CREATEMESSAGE_ERROR.getCode());
|
||||||
|
rspInfo.setMessage(new String[]{ErrorCode.EMOS_CREATEMESSAGE_ERROR.getMsg()});
|
||||||
|
return ProtocolRespDTO.result(ErrorCode.EMOS_CREATEMESSAGE_ERROR, rspInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
//保存数据格式到数据库
|
||||||
|
log.info("send alarm :{}", content);
|
||||||
|
AlarmInformation alarmInformation = AlarmInformation.builder().alarmInfo(content).build();
|
||||||
|
alarmInfoManager.addAlarmInfo(alarmInformation);
|
||||||
|
|
||||||
|
//推动数据格式到kafka
|
||||||
|
ListenableFuture<SendResult<String, String>> sendResult = kafkaConfiguration
|
||||||
|
.kafkaTemplate()
|
||||||
|
.sendDefault(0, System.currentTimeMillis(), "dispose", content);
|
||||||
|
|
||||||
|
sendResult.addCallback(v -> log.info("Kafka send {} to {} at {}", content,
|
||||||
|
Objects.requireNonNull(v)
|
||||||
|
.getRecordMetadata()
|
||||||
|
.topic(), v.getRecordMetadata().partition()),
|
||||||
|
ex -> log.error("Kafka send error: {}", ex.getMessage()));
|
||||||
|
|
||||||
|
rspInfo.setStatus(ErrorCode.ERR_OK.getCode());
|
||||||
|
rspInfo.setMessage(new String[]{ErrorCode.ERR_OK.getMsg()});
|
||||||
|
return ProtocolRespDTO.result(ErrorCode.ERR_OK, rspInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param alarmInfo emos告警信息
|
||||||
|
* @return 发送的消息
|
||||||
|
*/
|
||||||
|
private String createSendContent(EmosAlarmInfo alarmInfo) {
|
||||||
|
try {
|
||||||
|
long dbIncrement = msgSerialService.getMaxMessageSerial();
|
||||||
|
long increment = dbIncrement + 1;
|
||||||
|
MulReturnType<ErrorCode, Long> returnType = msgSerialService.updateMessageSerial(increment);
|
||||||
|
if (returnType.getFirstParam() == ErrorCode.ERR_OK) {
|
||||||
|
increment = returnType.getSecondParam();
|
||||||
|
} else {
|
||||||
|
increment = dbIncrement;
|
||||||
|
}
|
||||||
|
|
||||||
|
String dstIp = alarmInfo.getDstIp();
|
||||||
|
String alarmId = alarmInfo.getAlarmId();
|
||||||
|
//LocateInfo: 192.168.11.6 ddos attack alarm,Memcache , 2019-08-01 12:31, 2.1Gbps, 1.01Mpps
|
||||||
|
String locateInfo = getAlarmEvent(alarmInfo);
|
||||||
|
String eventTime = alarmInfo.getStartTime();
|
||||||
|
String cancelTime = alarmInfo.getEndTime();
|
||||||
|
|
||||||
|
//告警类型vendorAlarmType、告警级别vendorSeverity、告警号vendorAlarmId、告警标题AlarmTitle、告警可能原因ProbableCauseTxt
|
||||||
|
String type = Constants.ATTACK_TYPE.get(alarmInfo.getAttackType());
|
||||||
|
String vendorSeverity = characterEncode("一级");
|
||||||
|
String vendorAlarmType;
|
||||||
|
String vendorAlarmId;
|
||||||
|
if (type != null) {
|
||||||
|
String[] arr = type.split("\\|");
|
||||||
|
String bps = "bps";
|
||||||
|
vendorAlarmType = arr[0];
|
||||||
|
if (bps.equals(alarmInfo.getBpspps())) {
|
||||||
|
vendorAlarmId = arr[1];
|
||||||
|
} else {
|
||||||
|
vendorAlarmId = arr[2];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
vendorAlarmType = alarmInfo.getAttackType();
|
||||||
|
vendorAlarmId = "0";
|
||||||
|
log.info("unKnown attack type:" + vendorAlarmType);
|
||||||
|
}
|
||||||
|
String alarmStatus = String.valueOf(Constants.ACTIVE_ALARM_STATUS);
|
||||||
|
String alarmText = characterEncode(getAlarmText(alarmInfo));
|
||||||
|
String alarmExplanation = characterEncode(getAlarmExplanation(alarmInfo));
|
||||||
|
|
||||||
|
return MessageFormat.format(Constants.DISPATCH_TEMPLATE, increment, dstIp,
|
||||||
|
dstIp, alarmId, alarmId, dstIp, dstIp, locateInfo, eventTime, cancelTime,
|
||||||
|
vendorAlarmType, vendorSeverity, vendorAlarmId, characterEncode("重保攻击事件告警"),
|
||||||
|
characterEncode("DDos攻击事件"), alarmStatus, alarmText,
|
||||||
|
characterEncode(alarmInfo.getDstProvince()), characterEncode(alarmInfo.getDstCity()),
|
||||||
|
characterEncode("网络部集中抗D系统"), characterEncode("DDOS攻击事件告警"),
|
||||||
|
characterEncode("安全告警"), characterEncode("DDOS告警"),
|
||||||
|
alarmExplanation, characterEncode("集中抗D"));
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("createSendContent告警消息异常,详细信息:{}", ExceptionUtils.getStackTrace(e));
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取告警事件AlarmEvent
|
||||||
|
*/
|
||||||
|
private String getAlarmEvent(EmosAlarmInfo a) {
|
||||||
|
return a.getDstIp() + " ddos attack alarm, " + a.getAttackType() + ", " + a.getStartTime() +
|
||||||
|
", " + a.getMaxBps() + ", " + a.getMaxPps();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据编码都采用GBK编码方式
|
||||||
|
*/
|
||||||
|
private String characterEncode(String character) {
|
||||||
|
try {
|
||||||
|
return new String(character.getBytes("GBK"), "GBK");
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.info("character encoding failed:" + e.getMessage());
|
||||||
|
return character;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取告警区域
|
||||||
|
*/
|
||||||
|
private String getAreaDes(String province, String city) {
|
||||||
|
String areaDes;
|
||||||
|
if (Constants.REGION_BEIJING.equals(province)) {
|
||||||
|
areaDes = "北京市";
|
||||||
|
} else if (Constants.REGION_SHANGHAI.equals(province)) {
|
||||||
|
areaDes = "上海市";
|
||||||
|
} else if (Constants.REGION_TIANJIN.equals(province)) {
|
||||||
|
areaDes = "天津市";
|
||||||
|
} else if (Constants.REGION_CHONGQING.equals(province)) {
|
||||||
|
areaDes = "重庆市";
|
||||||
|
} else {
|
||||||
|
areaDes = province + "省" + city + "市";
|
||||||
|
}
|
||||||
|
|
||||||
|
return areaDes;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取处置类型(1:清洗,2:黑洞,3:高防)
|
||||||
|
*/
|
||||||
|
private String getOperateType(Integer disposeType) {
|
||||||
|
String operateType = null;
|
||||||
|
if (Constants.CLEANUP == disposeType) {
|
||||||
|
operateType = "清洗";
|
||||||
|
} else if (Constants.BLACKHOOL == disposeType) {
|
||||||
|
operateType = "流控";
|
||||||
|
} else if (Constants.HIDEPEND == disposeType) {
|
||||||
|
operateType = "黑洞";
|
||||||
|
}
|
||||||
|
return operateType;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取告警正文AlarmText
|
||||||
|
*/
|
||||||
|
private String getAlarmText(EmosAlarmInfo a) {
|
||||||
|
String area = getAreaDes(a.getDstProvince(), a.getDstCity());
|
||||||
|
String operateType = getOperateType(a.getDisposeType());
|
||||||
|
return "攻击目的IP:" + a.getDstIp() + "," + area + "," + "处置操作:" + operateType + "," + "处置时长:" + a.getDisposeTime() + "分钟";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取告警解释AlarmExplanation
|
||||||
|
*/
|
||||||
|
private String getAlarmExplanation(EmosAlarmInfo a) {
|
||||||
|
String operateType = getOperateType(a.getDisposeType());
|
||||||
|
StringBuilder srcIp = new StringBuilder();
|
||||||
|
for (String ip : a.getSrcIpLs()) {
|
||||||
|
srcIp.append(ip).append(",");
|
||||||
|
}
|
||||||
|
if (srcIp.length() > 0) {
|
||||||
|
srcIp = new StringBuilder(srcIp.substring(0, srcIp.length() - 1));
|
||||||
|
}
|
||||||
|
return "攻击目的IP:" + a.getDstIp() + "," + "攻击源地址:(" + srcIp + ")," + "处置操作:" + operateType + "," + "处置时长:" + a.getDisposeTime() + "分钟";
|
||||||
|
}
|
||||||
|
}
|
|
@ -69,8 +69,7 @@ public class GlobalExceptionHandler {
|
||||||
log.error("Interface [{}] request <{}> from {}, token = <{}>\n" +
|
log.error("Interface [{}] request <{}> from {}, token = <{}>\n" +
|
||||||
"+++ Request: {}\n" +
|
"+++ Request: {}\n" +
|
||||||
"--- Verify params failed: {}",
|
"--- Verify params failed: {}",
|
||||||
reqType, reqPath, reqIp, reqToken, Helper.inputStream2String(req.getInputStream()),
|
reqType, reqPath, reqIp, reqToken, Helper.inputStream2String(req.getInputStream()), sb);
|
||||||
sb.toString());
|
|
||||||
} catch (Exception ignored) {
|
} catch (Exception ignored) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package com.dispose.config;
|
package com.dispose.interceptor;
|
||||||
|
|
||||||
import com.dispose.common.AuthConfigValue;
|
import com.dispose.common.AuthConfigValue;
|
||||||
import com.dispose.interceptor.TokenInterceptor;
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
@ -24,7 +23,7 @@ import java.util.Optional;
|
||||||
@Component
|
@Component
|
||||||
@ConfigurationProperties(prefix = "auth")
|
@ConfigurationProperties(prefix = "auth")
|
||||||
@Configuration
|
@Configuration
|
||||||
public class AuthConfigure implements WebMvcConfigurer {
|
public class AuthConfigureFilter implements WebMvcConfigurer {
|
||||||
/**
|
/**
|
||||||
* The Token timeout minute.
|
* The Token timeout minute.
|
||||||
*/
|
*/
|
|
@ -0,0 +1,17 @@
|
||||||
|
package com.dispose.manager;
|
||||||
|
|
||||||
|
import com.dispose.pojo.entity.AlarmInformation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The interface alarm information manager.
|
||||||
|
*
|
||||||
|
* @author <chenlinghy@cmhi.chinamoblie.com>
|
||||||
|
*/
|
||||||
|
public interface AlarmInfoManager {
|
||||||
|
/**
|
||||||
|
* Add alarm information.
|
||||||
|
*
|
||||||
|
* @param alarmInformation the alarm information
|
||||||
|
*/
|
||||||
|
void addAlarmInfo(AlarmInformation alarmInformation);
|
||||||
|
}
|
|
@ -0,0 +1,25 @@
|
||||||
|
package com.dispose.manager;
|
||||||
|
|
||||||
|
import com.dispose.common.ErrorCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The interface Msg serial manager.
|
||||||
|
*
|
||||||
|
* @author <huangxin@cmhi.chinamoblie.com>
|
||||||
|
*/
|
||||||
|
public interface MsgSerialManager {
|
||||||
|
/**
|
||||||
|
* Update msg serial number error code.
|
||||||
|
*
|
||||||
|
* @param msgSerial the msg serial
|
||||||
|
* @return the error code
|
||||||
|
*/
|
||||||
|
ErrorCode updateMsgSerialNumber(Long msgSerial);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets max msg serial.
|
||||||
|
*
|
||||||
|
* @return the max msg serial
|
||||||
|
*/
|
||||||
|
Long getMaxMsgSerial();
|
||||||
|
}
|
|
@ -0,0 +1,34 @@
|
||||||
|
package com.dispose.manager.impl;
|
||||||
|
|
||||||
|
import com.dispose.manager.AlarmInfoManager;
|
||||||
|
import com.dispose.mapper.AlarmInformationMapper;
|
||||||
|
import com.dispose.pojo.entity.AlarmInformation;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The interface alarm information manager.
|
||||||
|
*
|
||||||
|
* @author <chenlinghy@cmhi.chinamoblie.com>
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
@Slf4j
|
||||||
|
public class AlarmInfoManagerImpl implements AlarmInfoManager {
|
||||||
|
/**
|
||||||
|
* The alarm information mapper.
|
||||||
|
*/
|
||||||
|
@Resource
|
||||||
|
private AlarmInformationMapper alarmInformationMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add alarm information.
|
||||||
|
*
|
||||||
|
* @param alarmInformation the alarm information
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void addAlarmInfo(AlarmInformation alarmInformation) {
|
||||||
|
alarmInformationMapper.addAlarmInfo(alarmInformation);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,50 @@
|
||||||
|
package com.dispose.manager.impl;
|
||||||
|
|
||||||
|
import com.dispose.common.ErrorCode;
|
||||||
|
import com.dispose.manager.MsgSerialManager;
|
||||||
|
import com.dispose.mapper.MsgSerialMapper;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The interface message serial manager.
|
||||||
|
*
|
||||||
|
* @author <chenlinghy@cmhi.chinamoblie.com>
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
@Slf4j
|
||||||
|
public class MsgSerialManagerImpl implements MsgSerialManager {
|
||||||
|
/**
|
||||||
|
* The message serial mapper.
|
||||||
|
*/
|
||||||
|
@Resource
|
||||||
|
private MsgSerialMapper msgSerialMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add user business error code.
|
||||||
|
*
|
||||||
|
* @param msgSerial the message serial
|
||||||
|
* @return the error code
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public ErrorCode updateMsgSerialNumber(Long msgSerial) {
|
||||||
|
if (msgSerialMapper.updateMsgSerial(msgSerial) == 1) {
|
||||||
|
return ErrorCode.ERR_OK;
|
||||||
|
} else {
|
||||||
|
return ErrorCode.ERR_DATABASE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get new max message serial.
|
||||||
|
*
|
||||||
|
* @return the long
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Long getMaxMsgSerial() {
|
||||||
|
return msgSerialMapper.getMaxMsgSerial();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
package com.dispose.mapper;
|
||||||
|
|
||||||
|
import com.dispose.pojo.entity.AlarmInformation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The interface alarm information mapper.
|
||||||
|
*
|
||||||
|
* @author <chenlinghy@cmhi.chinamoblie.com>
|
||||||
|
*/
|
||||||
|
public interface AlarmInformationMapper {
|
||||||
|
/**
|
||||||
|
* Add alarm information.
|
||||||
|
*
|
||||||
|
* @param alarmInformation the alarm information
|
||||||
|
* @return the int
|
||||||
|
*/
|
||||||
|
int addAlarmInfo(AlarmInformation alarmInformation);
|
||||||
|
}
|
|
@ -0,0 +1,24 @@
|
||||||
|
package com.dispose.mapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The interface message serial mapper.
|
||||||
|
*
|
||||||
|
* @author <chenlinghy@cmhi.chinamoblie.com>
|
||||||
|
*/
|
||||||
|
public interface MsgSerialMapper {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update new task int.
|
||||||
|
*
|
||||||
|
* @param msgSerial the msgSerial number
|
||||||
|
* @return the int
|
||||||
|
*/
|
||||||
|
int updateMsgSerial(Long msgSerial);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get new max message serial.
|
||||||
|
*
|
||||||
|
* @return the long
|
||||||
|
*/
|
||||||
|
long getMaxMsgSerial();
|
||||||
|
}
|
|
@ -0,0 +1,29 @@
|
||||||
|
package com.dispose.pojo.dto.protocol.kafka;
|
||||||
|
|
||||||
|
import com.dispose.validation.group.ValidGroups;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotBlank;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The type Login req.
|
||||||
|
*
|
||||||
|
* @author <huangxin@cmhi.chinamoblie.com>
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
|
public class AlarmInfoReq {
|
||||||
|
/**
|
||||||
|
* 告警信息.
|
||||||
|
*/
|
||||||
|
@NotBlank(message = "alarmInfo 告警信息不能为空", groups = ValidGroups.ProtocolCommonValid.class)
|
||||||
|
private String alarmInfo;
|
||||||
|
}
|
|
@ -0,0 +1,89 @@
|
||||||
|
package com.dispose.pojo.dto.protocol.kafka;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The type Emos alarm info.
|
||||||
|
*
|
||||||
|
* @author <huangxin@cmhi.chinamoblie.com>
|
||||||
|
*/
|
||||||
|
@EqualsAndHashCode()
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@AllArgsConstructor
|
||||||
|
@JsonPropertyOrder({"alarmId", "dstIp", "attackType", "bpspps", "dstProvince", "dstCity", "srcIpLs", "startTime",
|
||||||
|
"endTime", "disposeType", "disposeTime", "maxBps", "maxPps"})
|
||||||
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
|
public class EmosAlarmInfo {
|
||||||
|
/**
|
||||||
|
* The Alarm id.
|
||||||
|
*/
|
||||||
|
private String alarmId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Dst ip.
|
||||||
|
*/
|
||||||
|
private String dstIp;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Attack type.
|
||||||
|
*/
|
||||||
|
private String attackType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Bpspps.
|
||||||
|
*/
|
||||||
|
private String bpspps;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Dst province.
|
||||||
|
*/
|
||||||
|
private String dstProvince;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Dst city.
|
||||||
|
*/
|
||||||
|
private String dstCity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Src ip ls.
|
||||||
|
*/
|
||||||
|
private List<String> srcIpLs;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Start time.
|
||||||
|
*/
|
||||||
|
private String startTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The End time.
|
||||||
|
*/
|
||||||
|
private String endTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Dispose type.
|
||||||
|
*/
|
||||||
|
private Integer disposeType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Dispose time.
|
||||||
|
*/
|
||||||
|
private Integer disposeTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Max bps.
|
||||||
|
*/
|
||||||
|
private String maxBps;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Max pps.
|
||||||
|
*/
|
||||||
|
private String maxPps;
|
||||||
|
}
|
|
@ -0,0 +1,51 @@
|
||||||
|
package com.dispose.pojo.entity;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import tk.mybatis.mapper.annotation.KeySql;
|
||||||
|
import tk.mybatis.mapper.annotation.NameStyle;
|
||||||
|
import tk.mybatis.mapper.code.Style;
|
||||||
|
|
||||||
|
import javax.persistence.Id;
|
||||||
|
import javax.persistence.Table;
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The emos alarm information.
|
||||||
|
*
|
||||||
|
* @author <chenlinghy@cmhi.chinamoblie.com>
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Builder
|
||||||
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
|
@Table(name = "alarm_information")
|
||||||
|
@NameStyle(Style.normal)
|
||||||
|
public class AlarmInformation implements Serializable {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The constant serialVersionUID.
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The id.
|
||||||
|
*/
|
||||||
|
@Id
|
||||||
|
@KeySql(useGeneratedKeys = true)
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The alarm information.
|
||||||
|
*/
|
||||||
|
private String alarmInfo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The creating time.
|
||||||
|
*/
|
||||||
|
private String createTime;
|
||||||
|
}
|
|
@ -0,0 +1,46 @@
|
||||||
|
package com.dispose.pojo.entity;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import tk.mybatis.mapper.annotation.KeySql;
|
||||||
|
import tk.mybatis.mapper.annotation.NameStyle;
|
||||||
|
import tk.mybatis.mapper.code.Style;
|
||||||
|
|
||||||
|
import javax.persistence.Id;
|
||||||
|
import javax.persistence.Table;
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The message serial.
|
||||||
|
*
|
||||||
|
* @author <chenlinghy@cmhi.chinamoblie.com>
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Builder
|
||||||
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
|
@Table(name = "msg_serial")
|
||||||
|
@NameStyle(Style.normal)
|
||||||
|
public class MsgSerial implements Serializable {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The constant serialVersionUID.
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The id.
|
||||||
|
*/
|
||||||
|
@Id
|
||||||
|
@KeySql(useGeneratedKeys = true)
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The message serial.
|
||||||
|
*/
|
||||||
|
private Long msgSerial;
|
||||||
|
}
|
|
@ -0,0 +1,27 @@
|
||||||
|
package com.dispose.service;
|
||||||
|
|
||||||
|
import com.dispose.common.ErrorCode;
|
||||||
|
import com.dispose.pojo.po.MulReturnType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The interface Msg serial service.
|
||||||
|
*
|
||||||
|
* @author <huangxin@cmhi.chinamoblie.com>
|
||||||
|
*/
|
||||||
|
public interface MsgSerialService {
|
||||||
|
/**
|
||||||
|
* Update message serial mul return type.
|
||||||
|
*
|
||||||
|
* @param msgSerial the msg serial
|
||||||
|
* @return the mul return type
|
||||||
|
*/
|
||||||
|
MulReturnType<ErrorCode, Long> updateMessageSerial(Long msgSerial);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets max message serial.
|
||||||
|
*
|
||||||
|
* @return the max message serial
|
||||||
|
*/
|
||||||
|
Long getMaxMessageSerial();
|
||||||
|
|
||||||
|
}
|
|
@ -1,5 +1,6 @@
|
||||||
package com.dispose.service.impl;
|
package com.dispose.service.impl;
|
||||||
|
|
||||||
|
import com.cmhi.dispose.common.CmhiDisposeTaskStatus;
|
||||||
import com.dispose.common.DisposeConfigValue;
|
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;
|
||||||
|
@ -18,7 +19,6 @@ import com.dispose.pojo.po.AbilityInfo;
|
||||||
import com.dispose.pojo.po.MulReturnType;
|
import com.dispose.pojo.po.MulReturnType;
|
||||||
import com.dispose.service.DeviceTaskManagerService;
|
import com.dispose.service.DeviceTaskManagerService;
|
||||||
import com.dispose.service.DisposeAbilityRouterService;
|
import com.dispose.service.DisposeAbilityRouterService;
|
||||||
import com.pengxin.dispose.common.PengXinTaskStatus;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.scheduling.annotation.Async;
|
import org.springframework.scheduling.annotation.Async;
|
||||||
import org.springframework.scheduling.annotation.Scheduled;
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
|
@ -429,7 +429,7 @@ public class DeviceTaskManagerServiceImpl implements DeviceTaskManagerService {
|
||||||
|
|
||||||
//任务出错,设备任务状态为启动处置任务失败
|
//任务出错,设备任务状态为启动处置任务失败
|
||||||
deviceTaskManager.changeDisposeDeviceTaskInfoDevStatus(deviceTask.getId(),
|
deviceTaskManager.changeDisposeDeviceTaskInfoDevStatus(deviceTask.getId(),
|
||||||
(long) PengXinTaskStatus.TASK_STARTED_FAILED.getValue());
|
(long) CmhiDisposeTaskStatus.TASK_STARTED_FAILED.getValue());
|
||||||
|
|
||||||
// 记录任务出错重试次数
|
// 记录任务出错重试次数
|
||||||
deviceTaskManager.setTaskErrRetryTimes(deviceTask.getId(), 0);
|
deviceTaskManager.setTaskErrRetryTimes(deviceTask.getId(), 0);
|
||||||
|
@ -596,8 +596,8 @@ public class DeviceTaskManagerServiceImpl implements DeviceTaskManagerService {
|
||||||
virtualDeviceTaskRun(ai, v, task);
|
virtualDeviceTaskRun(ai, v, task);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PENGXIN_PLATFORM:
|
case CMHI_PLATFORM:
|
||||||
restfulDeviceTaskRun(ai, v, task, DisposeDeviceType.PENGXIN_PLATFORM);
|
restfulDeviceTaskRun(ai, v, task, DisposeDeviceType.CMHI_PLATFORM);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case HUAWEI_PLATFORM:
|
case HUAWEI_PLATFORM:
|
||||||
|
@ -681,8 +681,8 @@ public class DeviceTaskManagerServiceImpl implements DeviceTaskManagerService {
|
||||||
virtualDeviceTaskStop(ai, v, task);
|
virtualDeviceTaskStop(ai, v, task);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PENGXIN_PLATFORM:
|
case CMHI_PLATFORM:
|
||||||
restfulDeviceTaskStop(ai, v, task, DisposeDeviceType.PENGXIN_PLATFORM);
|
restfulDeviceTaskStop(ai, v, task, DisposeDeviceType.CMHI_PLATFORM);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case HUAWEI_PLATFORM:
|
case HUAWEI_PLATFORM:
|
||||||
|
|
|
@ -6,7 +6,7 @@ import com.dispose.ability.impl.DpTechBypassAbilityImpl;
|
||||||
import com.dispose.ability.impl.HaoHanAbilityImpl;
|
import com.dispose.ability.impl.HaoHanAbilityImpl;
|
||||||
import com.dispose.ability.impl.HuaWeiAbilityImpl;
|
import com.dispose.ability.impl.HuaWeiAbilityImpl;
|
||||||
import com.dispose.ability.impl.HuaWeiFireWallAbilityImpl;
|
import com.dispose.ability.impl.HuaWeiFireWallAbilityImpl;
|
||||||
import com.dispose.ability.impl.PengXinAbilityImpl;
|
import com.dispose.ability.impl.CmhiAbilityImpl;
|
||||||
import com.dispose.ability.impl.UpfAbilityImpl;
|
import com.dispose.ability.impl.UpfAbilityImpl;
|
||||||
import com.dispose.ability.impl.VirtualAbilityImpl;
|
import com.dispose.ability.impl.VirtualAbilityImpl;
|
||||||
import com.dispose.common.DisposeCapacityType;
|
import com.dispose.common.DisposeCapacityType;
|
||||||
|
@ -17,6 +17,7 @@ import com.dispose.manager.DisposeDeviceManager;
|
||||||
import com.dispose.mapper.ServiceGroupMapper;
|
import com.dispose.mapper.ServiceGroupMapper;
|
||||||
import com.dispose.pojo.entity.DisposeDevice;
|
import com.dispose.pojo.entity.DisposeDevice;
|
||||||
import com.dispose.pojo.po.AbilityInfo;
|
import com.dispose.pojo.po.AbilityInfo;
|
||||||
|
import com.dispose.security.arithmetic.CryptoHelper;
|
||||||
import com.dispose.service.DisposeAbilityRouterService;
|
import com.dispose.service.DisposeAbilityRouterService;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.scheduling.annotation.Async;
|
import org.springframework.scheduling.annotation.Async;
|
||||||
|
@ -165,8 +166,8 @@ public class DisposeAbilityRouterServiceImpl implements DisposeAbilityRouterServ
|
||||||
case HAOHAN_PLATFORM:
|
case HAOHAN_PLATFORM:
|
||||||
db = new HaoHanAbilityImpl();
|
db = new HaoHanAbilityImpl();
|
||||||
break;
|
break;
|
||||||
case PENGXIN_PLATFORM:
|
case CMHI_PLATFORM:
|
||||||
db = new PengXinAbilityImpl();
|
db = new CmhiAbilityImpl();
|
||||||
break;
|
break;
|
||||||
case HUAWEI_PLATFORM:
|
case HUAWEI_PLATFORM:
|
||||||
db = new HuaWeiAbilityImpl();
|
db = new HuaWeiAbilityImpl();
|
||||||
|
@ -190,6 +191,7 @@ public class DisposeAbilityRouterServiceImpl implements DisposeAbilityRouterServ
|
||||||
}
|
}
|
||||||
|
|
||||||
// 初始化设备
|
// 初始化设备
|
||||||
|
dev.setPassword(new String(CryptoHelper.base64Decryption(dev.getPassword())));
|
||||||
db.initDeviceEnv(url, dev.getUserName(), dev.getPassword());
|
db.initDeviceEnv(url, dev.getUserName(), dev.getPassword());
|
||||||
db.getDisposeDeviceProtectObject();
|
db.getDisposeDeviceProtectObject();
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,56 @@
|
||||||
|
package com.dispose.service.impl;
|
||||||
|
|
||||||
|
import com.dispose.common.ErrorCode;
|
||||||
|
import com.dispose.manager.MsgSerialManager;
|
||||||
|
import com.dispose.pojo.po.MulReturnType;
|
||||||
|
import com.dispose.service.MsgSerialService;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The type Msg serial service.
|
||||||
|
*
|
||||||
|
* @author <huangxin@cmhi.chinamoblie.com>
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class MsgSerialServiceImpl implements MsgSerialService {
|
||||||
|
/**
|
||||||
|
* The Msg serial manager.
|
||||||
|
*/
|
||||||
|
@Resource
|
||||||
|
private MsgSerialManager msgSerialManager;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update message serial mul return type.
|
||||||
|
*
|
||||||
|
* @param msgSerial the msg serial
|
||||||
|
* @return the mul return type
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public MulReturnType<ErrorCode, Long> updateMessageSerial(Long msgSerial) {
|
||||||
|
//告警序号的最大值2^32-1
|
||||||
|
long indexEnd = 4294967295L;
|
||||||
|
long indexStart = 1L;
|
||||||
|
//编号从1开始,以实时消息发布通道为单位进行编号。如果编号超过最大正整数(2^32-1),重新从1开始编号。
|
||||||
|
if (msgSerial > indexEnd) {
|
||||||
|
msgSerial = indexStart;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (msgSerialManager.updateMsgSerialNumber(msgSerial) == ErrorCode.ERR_OK) {
|
||||||
|
return new MulReturnType<>(ErrorCode.ERR_OK, msgSerial);
|
||||||
|
} else {
|
||||||
|
return new MulReturnType<>(ErrorCode.ERR_DATABASE, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets max message serial.
|
||||||
|
*
|
||||||
|
* @return the max message serial
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Long getMaxMessageSerial() {
|
||||||
|
return msgSerialManager.getMaxMsgSerial();
|
||||||
|
}
|
||||||
|
}
|
|
@ -81,7 +81,7 @@ public class ValidAddCapacityInfoImpl implements ConstraintValidator<ValidAddCap
|
||||||
|
|
||||||
if (Arrays.stream(IpAddrType.values()).noneMatch(v -> v.getValue().equals(addCapacityInfo.getIpType()))) {
|
if (Arrays.stream(IpAddrType.values()).noneMatch(v -> v.getValue().equals(addCapacityInfo.getIpType()))) {
|
||||||
List<Integer> val = Arrays.stream(IpAddrType.values()).map(IpAddrType::getValue).collect(Collectors.toList());
|
List<Integer> val = Arrays.stream(IpAddrType.values()).map(IpAddrType::getValue).collect(Collectors.toList());
|
||||||
errMsg.add("字段 ipType 值 {}, 错误, 合理取值范围为:" + val.toString());
|
errMsg.add("字段 ipType 值 {}, 错误, 合理取值范围为:" + val);
|
||||||
ret = false;
|
ret = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,7 +106,7 @@ public class ValidAddCapacityInfoImpl implements ConstraintValidator<ValidAddCap
|
||||||
|
|
||||||
// 重新设置消息
|
// 重新设置消息
|
||||||
ctx.disableDefaultConstraintViolation();
|
ctx.disableDefaultConstraintViolation();
|
||||||
ctx.buildConstraintViolationWithTemplate(this.message + " " + errMsg.toString()).addConstraintViolation();
|
ctx.buildConstraintViolationWithTemplate(this.message + " " + errMsg).addConstraintViolation();
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,7 +58,7 @@ public class ValidBaseEnumArrayImpl implements ConstraintValidator<ValidBaseEnum
|
||||||
String errMsg = this.message + " 字段 " +
|
String errMsg = this.message + " 字段 " +
|
||||||
((ConstraintValidatorContextImpl) ctx).getConstraintViolationCreationContexts()
|
((ConstraintValidatorContextImpl) ctx).getConstraintViolationCreationContexts()
|
||||||
.get(0).getPath().getLeafNode().getName()
|
.get(0).getPath().getLeafNode().getName()
|
||||||
+ " 值 {" + Arrays.toString(integers) + "} 错误, 字段取值范围:" + enumValues.toString();
|
+ " 值 {" + Arrays.toString(integers) + "} 错误, 字段取值范围:" + enumValues;
|
||||||
|
|
||||||
// 重新设置消息
|
// 重新设置消息
|
||||||
ctx.disableDefaultConstraintViolation();
|
ctx.disableDefaultConstraintViolation();
|
||||||
|
|
|
@ -61,7 +61,7 @@ public class ValidBaseEnumImpl implements ConstraintValidator<ValidBaseEnum, Int
|
||||||
String errMsg = this.message + " 字段 " +
|
String errMsg = this.message + " 字段 " +
|
||||||
((ConstraintValidatorContextImpl) ctx).getConstraintViolationCreationContexts()
|
((ConstraintValidatorContextImpl) ctx).getConstraintViolationCreationContexts()
|
||||||
.get(0).getPath().getLeafNode().getName()
|
.get(0).getPath().getLeafNode().getName()
|
||||||
+ " 值 {" + integer + "} 错误, 字段取值范围:" + enumValues.toString();
|
+ " 值 {" + integer + "} 错误, 字段取值范围:" + enumValues;
|
||||||
|
|
||||||
// 重新设置消息
|
// 重新设置消息
|
||||||
ctx.disableDefaultConstraintViolation();
|
ctx.disableDefaultConstraintViolation();
|
||||||
|
|
|
@ -63,7 +63,7 @@ public class ValidDisposeObjectImpl implements ConstraintValidator<ValidDisposeO
|
||||||
|
|
||||||
// 重新设置消息
|
// 重新设置消息
|
||||||
ctx.disableDefaultConstraintViolation();
|
ctx.disableDefaultConstraintViolation();
|
||||||
ctx.buildConstraintViolationWithTemplate(this.message + " " + errMsg.toString()).addConstraintViolation();
|
ctx.buildConstraintViolationWithTemplate(this.message + " " + errMsg).addConstraintViolation();
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,7 +55,7 @@ public class ValidSplitPageSizeImpl implements ConstraintValidator<ValidSplitPag
|
||||||
String errMsg = this.message + " 字段 " +
|
String errMsg = this.message + " 字段 " +
|
||||||
((ConstraintValidatorContextImpl) ctx).getConstraintViolationCreationContexts()
|
((ConstraintValidatorContextImpl) ctx).getConstraintViolationCreationContexts()
|
||||||
.get(0).getPath().getLeafNode().getName() +
|
.get(0).getPath().getLeafNode().getName() +
|
||||||
" 值 {" + integer + "} 错误, 字段取值范围:" + rang.toString();
|
" 值 {" + integer + "} 错误, 字段取值范围:" + rang;
|
||||||
|
|
||||||
// 重新设置消息
|
// 重新设置消息
|
||||||
ctx.disableDefaultConstraintViolation();
|
ctx.disableDefaultConstraintViolation();
|
||||||
|
|
|
@ -9,3 +9,11 @@ INSERT INTO `user_account`
|
||||||
VALUES (1, 'admin', 'c3855e6b6bb120450f160ba91134522868f89d36062f2061ebeefd80817e1d58', '2020-11-13 09:25:19', '',
|
VALUES (1, 'admin', 'c3855e6b6bb120450f160ba91134522868f89d36062f2061ebeefd80817e1d58', '2020-11-13 09:25:19', '',
|
||||||
'2021-01-20 10:18:56', '1db9ddc47de514eb16b7ec07d7f7f96f7a714ae00e1209755bab30d543a0a2c3',
|
'2021-01-20 10:18:56', '1db9ddc47de514eb16b7ec07d7f7f96f7a714ae00e1209755bab30d543a0a2c3',
|
||||||
'2021-01-20 10:20:57', '1970-01-02 00:00:00', 0, 0);
|
'2021-01-20 10:20:57', '1970-01-02 00:00:00', 0, 0);
|
||||||
|
|
||||||
|
-- ----------------------------
|
||||||
|
-- Records of msg_serial
|
||||||
|
-- ----------------------------
|
||||||
|
INSERT INTO `msg_serial` VALUES ('1', '1');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,8 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
SET NAMES utf8mb4;
|
SET NAMES utf8mb4;
|
||||||
SET FOREIGN_KEY_CHECKS = 0;
|
SET
|
||||||
|
FOREIGN_KEY_CHECKS = 0;
|
||||||
|
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
-- Table structure for device_task
|
-- Table structure for device_task
|
||||||
|
@ -171,4 +172,30 @@ CREATE TABLE `user_account`
|
||||||
COLLATE = utf8_general_ci
|
COLLATE = utf8_general_ci
|
||||||
ROW_FORMAT = DYNAMIC;
|
ROW_FORMAT = DYNAMIC;
|
||||||
|
|
||||||
SET FOREIGN_KEY_CHECKS = 1;
|
SET
|
||||||
|
FOREIGN_KEY_CHECKS = 1;
|
||||||
|
|
||||||
|
-- ----------------------------
|
||||||
|
-- Table structure for msg_serial
|
||||||
|
-- ----------------------------
|
||||||
|
DROP TABLE IF EXISTS `msg_serial`;
|
||||||
|
CREATE TABLE `msg_serial`
|
||||||
|
(
|
||||||
|
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||||
|
`msgSerial` bigint(20) NOT NULL DEFAULT '1' COMMENT '连续消息序号',
|
||||||
|
PRIMARY KEY (`id`)
|
||||||
|
) ENGINE=InnoDB AUTO_INCREMENT=50 DEFAULT CHARSET=utf8;
|
||||||
|
|
||||||
|
|
||||||
|
-- ----------------------------
|
||||||
|
-- Table structure for alarm_information
|
||||||
|
-- ----------------------------
|
||||||
|
DROP TABLE IF EXISTS `alarm_information`;
|
||||||
|
CREATE TABLE `alarm_information`
|
||||||
|
(
|
||||||
|
`id` bigint(11) NOT NULL AUTO_INCREMENT,
|
||||||
|
`alarmInfo` varchar(255) NOT NULL COMMENT 'emos告警内容',
|
||||||
|
`createTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||||
|
PRIMARY KEY (`id`)
|
||||||
|
) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8;
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.dispose.mapper.AlarmInformationMapper">
|
||||||
|
<resultMap id="msg_serial" type="com.dispose.pojo.entity.AlarmInformation">
|
||||||
|
<id column="id" property="id"/>
|
||||||
|
<result column="alarmInfo" property="alarmInfo"/>
|
||||||
|
<result column="createTime" property="createTime"/>
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
<insert id="addAlarmInfo" useGeneratedKeys="true" keyProperty="id"
|
||||||
|
parameterType="com.dispose.pojo.entity.AlarmInformation">
|
||||||
|
INSERT
|
||||||
|
IGNORE INTO alarm_information(alarmInfo)
|
||||||
|
VALUES (
|
||||||
|
#{alarmInfo}
|
||||||
|
)
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
</mapper>
|
|
@ -150,9 +150,9 @@
|
||||||
SELECT dt.*, dd.*
|
SELECT dt.*, dd.*
|
||||||
FROM device_task dt
|
FROM device_task dt
|
||||||
LEFT JOIN dispose_device dd ON dt.deviceId = dd.id
|
LEFT JOIN dispose_device dd ON dt.deviceId = dd.id
|
||||||
WHERE dd.deviceType = ${@com.dispose.common.DisposeDeviceType@PENGXIN_PLATFORM.getValue()}
|
WHERE dd.deviceType = ${@com.dispose.common.DisposeDeviceType@CMHI_PLATFORM.getValue()}
|
||||||
AND dt.devStatus != ${@com.pengxin.dispose.common.PengXinTaskStatus@TASK_FINISHED_USER.getValue()}
|
AND dt.devStatus != ${@com.cmhi.dispose.common.CmhiDisposeTaskStatus@TASK_FINISHED_USER.getValue()}
|
||||||
AND dt.devStatus != ${@com.pengxin.dispose.common.PengXinTaskStatus@TASK_FINISHED_TIME.getValue()}
|
AND dt.devStatus != ${@com.cmhi.dispose.common.CmhiDisposeTaskStatus@TASK_FINISHED_TIME.getValue()}
|
||||||
AND dt.devStatus != ${@com.pengxin.dispose.common.PengXinTaskStatus@TASK_REVIEWED_FAILED.getValue()}
|
AND dt.devStatus != ${@com.cmhi.dispose.common.CmhiDisposeTaskStatus@TASK_REVIEWED_FAILED.getValue()}
|
||||||
</select>
|
</select>
|
||||||
</mapper>
|
</mapper>
|
|
@ -0,0 +1,21 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.dispose.mapper.MsgSerialMapper">
|
||||||
|
<resultMap id="msg_serial" type="com.dispose.pojo.entity.MsgSerial">
|
||||||
|
<id column="id" property="id"/>
|
||||||
|
<result column="msgSerial" property="msgSerial"/>
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
<update id="updateMsgSerial">
|
||||||
|
UPDATE
|
||||||
|
msg_serial
|
||||||
|
SET msgSerial = #{msgSerial}
|
||||||
|
WHERE id = 1;
|
||||||
|
</update>
|
||||||
|
|
||||||
|
<select id="getMaxMsgSerial" resultType="java.lang.Long">
|
||||||
|
SELECT msgSerial
|
||||||
|
FROM msg_serial
|
||||||
|
ORDER BY ID DESC LIMIT 1
|
||||||
|
</select>
|
||||||
|
</mapper>
|
|
@ -0,0 +1,126 @@
|
||||||
|
package com.dispose.test.dev.controller;
|
||||||
|
|
||||||
|
import cn.hutool.json.JSONObject;
|
||||||
|
import com.dispose.common.ConstValue;
|
||||||
|
import com.dispose.common.ErrorCode;
|
||||||
|
import com.dispose.common.ProtoCryptoType;
|
||||||
|
import com.dispose.pojo.dto.protocol.base.BaseRespStatus;
|
||||||
|
import com.dispose.pojo.dto.protocol.base.ProtocolReqDTO;
|
||||||
|
import com.dispose.pojo.dto.protocol.base.ProtocolRespDTO;
|
||||||
|
import com.dispose.pojo.dto.protocol.kafka.AlarmInfoReq;
|
||||||
|
import com.dispose.test.dev.Global.InitTestEnvironment;
|
||||||
|
import com.fasterxml.jackson.core.type.TypeReference;
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import jodd.net.HttpStatus;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.junit.Assert;
|
||||||
|
import org.junit.FixMethodOrder;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.junit.runners.MethodSorters;
|
||||||
|
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
|
||||||
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
import org.springframework.http.MediaType;
|
||||||
|
import org.springframework.test.annotation.DirtiesContext;
|
||||||
|
import org.springframework.test.annotation.Rollback;
|
||||||
|
import org.springframework.test.context.junit4.SpringRunner;
|
||||||
|
import org.springframework.test.web.servlet.MockMvc;
|
||||||
|
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;
|
||||||
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
|
||||||
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The type Auth controller test.
|
||||||
|
*
|
||||||
|
* @author <huangxin@cmhi.chinamoblie.com>
|
||||||
|
*/
|
||||||
|
@AutoConfigureMockMvc
|
||||||
|
@RunWith(SpringRunner.class)
|
||||||
|
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
|
||||||
|
@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS)
|
||||||
|
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
|
||||||
|
@Transactional
|
||||||
|
@Rollback
|
||||||
|
@Slf4j
|
||||||
|
public class KafkaControllerTest extends InitTestEnvironment {
|
||||||
|
/**
|
||||||
|
* The Mock mvc.
|
||||||
|
*/
|
||||||
|
@Resource
|
||||||
|
private MockMvc mockMvc;
|
||||||
|
/**
|
||||||
|
* The Object mapper.
|
||||||
|
*/
|
||||||
|
@Resource
|
||||||
|
private ObjectMapper objectMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A 1 login.
|
||||||
|
*
|
||||||
|
* @throws Exception the exception
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void a1_dispatchCommand() throws Exception {
|
||||||
|
JSONObject disposeParam = new JSONObject();
|
||||||
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||||
|
disposeParam.set("alarmId", "1");
|
||||||
|
disposeParam.set("dstIp", "192.168.1.1");
|
||||||
|
disposeParam.set("attackType", "RSTFlood");
|
||||||
|
disposeParam.set("bpspps", "bps");
|
||||||
|
disposeParam.set("dstProvince", "浙江");
|
||||||
|
disposeParam.set("dstCity", "杭州");
|
||||||
|
disposeParam.set("startTime", sdf.format(new Date()));
|
||||||
|
// 1清洗,2流控,3黑洞
|
||||||
|
disposeParam.set("disposeType", 1);
|
||||||
|
disposeParam.set("disposeTime", 30);
|
||||||
|
disposeParam.set("endTime", sdf.format(new Date()));
|
||||||
|
List<String> srcIp = new ArrayList<>();
|
||||||
|
srcIp.add("192.168.10.1");
|
||||||
|
srcIp.add("192.168.10.2");
|
||||||
|
disposeParam.set("srcIpLs", srcIp);
|
||||||
|
disposeParam.set("maxBps", "20bps");
|
||||||
|
disposeParam.set("maxPps", "20pps");
|
||||||
|
String jsonAlarmInfo = disposeParam.toString();
|
||||||
|
log.info("============ jsonAlarmInfo :{}", jsonAlarmInfo);
|
||||||
|
|
||||||
|
AlarmInfoReq alarmInfoReq = AlarmInfoReq.builder()
|
||||||
|
.alarmInfo(jsonAlarmInfo).build();
|
||||||
|
|
||||||
|
ProtocolReqDTO<AlarmInfoReq> reqInfo = new ProtocolReqDTO<>();
|
||||||
|
|
||||||
|
reqInfo.setVer(ConstValue.Protocol.VERSION);
|
||||||
|
reqInfo.setCryptoType(ProtoCryptoType.CRYPTO_NONE.getCode());
|
||||||
|
reqInfo.setTimeStamp(System.currentTimeMillis());
|
||||||
|
reqInfo.setMsgContent(alarmInfoReq);
|
||||||
|
|
||||||
|
String ret = mockMvc.perform(MockMvcRequestBuilders
|
||||||
|
.post("/kafka/dispatchCommand")
|
||||||
|
.contentType(MediaType.APPLICATION_JSON)
|
||||||
|
.header("Authorization", ConstValue.STRING_HTTP_AUTH_HEAD + getLoginToken())
|
||||||
|
.content(objectMapper.writeValueAsString(reqInfo)))
|
||||||
|
.andDo(print()).andExpect(status().isOk())
|
||||||
|
.andExpect(jsonPath("$.code").value(HttpStatus.ok().status()))
|
||||||
|
.andReturn()
|
||||||
|
.getResponse()
|
||||||
|
.getContentAsString();
|
||||||
|
|
||||||
|
ProtocolRespDTO<BaseRespStatus> rspInfo = objectMapper.readValue(ret,
|
||||||
|
new TypeReference<ProtocolRespDTO<BaseRespStatus>>() {
|
||||||
|
});
|
||||||
|
|
||||||
|
verifyRespProtocol(rspInfo);
|
||||||
|
|
||||||
|
log.debug(objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(rspInfo));
|
||||||
|
Assert.assertEquals(ErrorCode.ERR_OK.getCode(), (long) rspInfo.getMsgContent().getStatus());
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,6 +1,10 @@
|
||||||
package com.dispose.test.dev.debug;
|
package com.dispose.test.dev.debug;
|
||||||
|
|
||||||
|
<<<<<<< HEAD
|
||||||
import com.fasterxml.jackson.core.type.TypeReference;
|
import com.fasterxml.jackson.core.type.TypeReference;
|
||||||
|
=======
|
||||||
|
import cn.hutool.json.JSONObject;
|
||||||
|
>>>>>>> origin/v2.0.9_dev
|
||||||
import com.dispose.common.ConstValue;
|
import com.dispose.common.ConstValue;
|
||||||
import com.dispose.common.DDoSAttackType;
|
import com.dispose.common.DDoSAttackType;
|
||||||
import com.dispose.common.DisposeConfigValue;
|
import com.dispose.common.DisposeConfigValue;
|
||||||
|
@ -32,8 +36,10 @@ import java.lang.reflect.Type;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.security.InvalidKeyException;
|
import java.security.InvalidKeyException;
|
||||||
import java.security.NoSuchAlgorithmException;
|
import java.security.NoSuchAlgorithmException;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.Hashtable;
|
import java.util.Hashtable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -719,4 +725,30 @@ public class demo {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void alarmInfoTest() {
|
||||||
|
JSONObject disposeParam = new JSONObject();
|
||||||
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||||
|
|
||||||
|
disposeParam.set("alarmId", "1");
|
||||||
|
disposeParam.set("dstIp", "192.168.1.1");
|
||||||
|
disposeParam.set("attackType", "1");
|
||||||
|
disposeParam.set("bpspps", "bps");
|
||||||
|
disposeParam.set("dstProvince", "ZHEJIANG");
|
||||||
|
disposeParam.set("dstCity", "HANGZHOU");
|
||||||
|
disposeParam.set("startTime", sdf.format(new Date()));
|
||||||
|
// 1清洗,2流控,3黑洞
|
||||||
|
disposeParam.set("disposeType", 1);
|
||||||
|
disposeParam.set("disposeTime", 30);
|
||||||
|
disposeParam.set("endTime", "");
|
||||||
|
List<String> srcIp = new ArrayList<>();
|
||||||
|
srcIp.add("192.168.10.1");
|
||||||
|
srcIp.add("192.168.10.2");
|
||||||
|
disposeParam.set("srcIpLs", srcIp);
|
||||||
|
disposeParam.set("maxBps", "20bps");
|
||||||
|
disposeParam.set("maxPps", "20pps");
|
||||||
|
String jsonAlarmInfo = disposeParam.toString();
|
||||||
|
log.info("============ jsonAlarmInfo :{}", jsonAlarmInfo);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,53 @@
|
||||||
|
package com.dispose.test.dev.mapper;
|
||||||
|
|
||||||
|
import com.dispose.mapper.MsgSerialMapper;
|
||||||
|
import com.dispose.test.dev.Global.InitTestEnvironment;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.junit.Assert;
|
||||||
|
import org.junit.FixMethodOrder;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.junit.runners.MethodSorters;
|
||||||
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
import org.springframework.test.context.junit4.SpringRunner;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The message serial test.
|
||||||
|
*/
|
||||||
|
@RunWith(SpringRunner.class)
|
||||||
|
@SpringBootTest
|
||||||
|
@Slf4j
|
||||||
|
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
|
||||||
|
@Transactional
|
||||||
|
public class MsgSerialMapperTest extends InitTestEnvironment {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The message serial mapper.
|
||||||
|
*/
|
||||||
|
@Resource
|
||||||
|
MsgSerialMapper msgSerialMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A 1 add new message serial.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void a1_addMsgSerial() {
|
||||||
|
for (long msgSerial = 1L; msgSerial <= 10L; msgSerial++) {
|
||||||
|
log.info("++++++++++++++++++MsgSerial {}", msgSerial);
|
||||||
|
msgSerialMapper.updateMsgSerial(msgSerial);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void a2_getMaxMsgSerial() {
|
||||||
|
for (long msgSerial = 1L; msgSerial <= 16L; msgSerial++) {
|
||||||
|
msgSerialMapper.updateMsgSerial(msgSerial);
|
||||||
|
}
|
||||||
|
long maxMsgSerial = msgSerialMapper.getMaxMsgSerial();
|
||||||
|
log.info("+++++++++++++++++++ max MsgSerial {}", maxMsgSerial);
|
||||||
|
Assert.assertEquals(maxMsgSerial, 16);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue