REM:
1. 添加标准JavaDoc注释内容
This commit is contained in:
huangxin 2020-04-21 15:28:38 +08:00
parent 4c06518a86
commit 5e26f421c1
61 changed files with 1222 additions and 56 deletions

View File

@ -7,7 +7,17 @@ import javax.security.auth.callback.CallbackHandler;
import javax.security.auth.callback.UnsupportedCallbackException;
import org.apache.wss4j.common.ext.WSPasswordCallback;
/**
* The type Soap password callback handler.
*/
public class SoapPasswordCallbackHandler implements CallbackHandler {
/**
* Handle.
*
* @param callbacks the callbacks
* @throws IOException the io exception
* @throws UnsupportedCallbackException the unsupported callback exception
*/
@Override
public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
WSPasswordCallback pc = (WSPasswordCallback) callbacks[0];

View File

@ -10,10 +10,7 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
import tk.mybatis.spring.annotation.MapperScan;
/**
* 系统启动入口
*
* @author phoenix
* @date 2020年2月4日
* The type Phoenix boot application.
*/
@SpringBootApplication
@EnableAsync
@ -24,6 +21,11 @@ import tk.mybatis.spring.annotation.MapperScan;
@Slf4j
public class PhoenixBootApplication {
/**
* The entry point of application.
*
* @param args the input arguments
*/
public static void main(String[] args) {
SpringApplication.run(PhoenixBootApplication.class, args);
log.info("\n----------------------------------------------------------\n\t"

View File

@ -1,58 +1,91 @@
package com.dispose.common;
/**
* The type Const value.
*/
public class ConstValue {
public class GlobalConfigure {
/**
* The type Global configure.
*/
public static class GlobalConfigure {
/**
* The constant TOKEN_TIMEOUT_MS.
*/
public static final int TOKEN_TIMEOUT_MS = 30 * 60 * 1000;
/**
* The constant ALLOW_PWD_ERR_TIMES.
*/
public static final int ALLOW_PWD_ERR_TIMES = 5;
/**
* The constant IS_SKIP_TIMEOUT_CHECK.
*/
public static final boolean IS_SKIP_TIMEOUT_CHECK = true;
/**
* The constant IS_VERIFY_TOKEN.
*/
public static final boolean IS_VERIFY_TOKEN = false;
/**
* The constant TOKEN_EXPIRED_TIME_MS.
*/
public static final long TOKEN_EXPIRED_TIME_MS = 1000 * 60 * 60;
}
public class SOAPWrapperConst {
/**
* The type Soap wrapper const.
*/
public static class SOAPWrapperConst {
/**
* The constant NAMESPACE_URI.
*/
public static final String NAMESPACE_URI = "http://%s/UMC/service/AbnormalFlowCleaningService";
/**
* The constant USER_NAME.
*/
//public static final String SERVICE_ADDRESS = "http://10.88.77.15/UMC/service/AbnormalFlowCleaningService?wsdl";
public static final String USER_NAME = "admin";
/**
* The constant PASSWORD.
*/
public static final String PASSWORD = "UMCAdministrator";
}
public class Protocol {
/**
* The type Protocol.
*/
public static class Protocol {
/**
* The constant RESP_CMD_BASE.
*/
public static final int RESP_CMD_BASE = 10000;
/**
* The constant VERSION.
*/
public static final int VERSION = 2;
/**
* The constant CRYPTO_NONE.
*/
public static final int CRYPTO_NONE = 0;
/**
* The constant CRYPTO_BASE64.
*/
public static final int CRYPTO_BASE64 = 1;
/**
* The constant CRYPTO_AES256.
*/
public static final int CRYPTO_AES256 = 2;
}
public class ProtocolCmdId {
public static final int AUTH_LOGIN = 10;
public static final int AUTH_LOGOUT = 11;
public static final int ADD_DISPOSE_POINT = 100;
public static final int MOD_DISPOSE_POINT = 101;
public static final int DEL_DISPOSE_POINT = 102;
public static final int GET_DISPOSE_POINT_VERSION = 200;
public static final int GET_DISPOSE_POINT_DEV_INFO = 201;
public static final int GET_DISPOSE_POINT_LINK_STATUS = 202;
public static final int GET_DISPOSE_POINT_CATACITY = 203;
public static final int GET_DISPOSE_POINT_PROTECT_IP = 204;
public static final int GET_DISPOSE_POINT_LIST = 209;
public static final int GET_DISPOSE_POINT_DETAILS = 210;
public static final int START_DISPOSE_CMD = 400;
public static final int STOP_DISPOSE_CMD_BY_TASKID = 401;
public static final int STOP_DISPOSE_CMD_BY_IP = 402;
public static final int STOP_DISPOSE_CMD_BY_POINT = 403;
public static final int STOP_DISPOSE_CMD_ALL = 404;
public static final int GET_DISPOSE_TASK_LIST = 405;
public static final int GET_DISPOSE_TASK_DETAIL = 406;
}
/**
* The enum Dispose device type.
*/
public enum DisposeDeviceType {
/**
* Dptech umc dispose device type.
*/
DPTECH_UMC(0, "迪普UMC管理平台"),
/**
* Haohan platform dispose device type.
*/
HAOHAN_PLATFORM(1, "浩瀚处置设备");
private final int code;
@ -63,24 +96,58 @@ public class ConstValue {
this.readme = readme;
}
/**
* Gets code.
*
* @return the code
*/
public int getCode() {
return this.code;
}
/**
* Gets readme.
*
* @return the readme
*/
public String getReadme() {
return this.readme;
}
}
/**
* The type User account status.
*/
public class UserAccountStatus {
/**
* The constant NORMAL.
*/
public static final int NORMAL = 0;
/**
* The constant LOCKED.
*/
public static final int LOCKED = 1;
}
/**
* The enum Device capacity.
*/
public enum DeviceCapacity {
/**
* Cleanup device capacity.
*/
CLEANUP(0, "清洗能力"),
/**
* Hidepend device capacity.
*/
HIDEPEND(1, "高防能力"),
/**
* Blackhool device capacity.
*/
BLACKHOOL(2, "黑洞能力"),
/**
* Detecive device capacity.
*/
DETECIVE(3, "检测能力");
private final int code;
@ -91,18 +158,44 @@ public class ConstValue {
this.readme = readme;
}
/**
* Gets code.
*
* @return the code
*/
public int getCode() {
return this.code;
}
/**
* Gets readme.
*
* @return the readme
*/
public String getReadme() {
return this.readme;
}
}
/**
* The enum Ip addr type.
*/
public enum IPAddrType {
IPV4_TYPE, IPV6_TYPE;
/**
* Ipv 4 type ip addr type.
*/
IPV4_TYPE,
/**
* Ipv 6 type ip addr type.
*/
IPV6_TYPE;
/**
* Gets ip addr type.
*
* @param ipAddr the ip addr
* @return the ip addr type
*/
public static IPAddrType getIpAddrType(String ipAddr) {
if (ipAddr.contains(":")) {
return IPV6_TYPE;

View File

@ -1,33 +1,108 @@
package com.dispose.common;
/**
* 错误码常量定义
* The enum Error code.
*/
public enum ErrorCode {
/**
* Err ok error code.
*/
ERR_OK(0, "成功"),
/**
* Err password error code.
*/
ERR_PASSWORD(1, "密码错误"),
/**
* Err usernotfound error code.
*/
ERR_USERNOTFOUND(2, "用户不存在"),
/**
* Err passwordmore error code.
*/
ERR_PASSWORDMORE(3, "连续密码错误达上限,再次输入错误将锁定用户"),
/**
* Err userlock error code.
*/
ERR_USERLOCK(4, "密码错误达上限,用户被锁定"),
/**
* Err account error code.
*/
ERR_ACCOUNT(5, "用户账户异常"),
/**
* Err userexist error code.
*/
ERR_USEREXIST(6, "该用户已经存在"),
/**
* Err passwordsimple error code.
*/
ERR_PASSWORDSIMPLE(7, "用户密码强度不符合要求"),
/**
* Err inputformat error code.
*/
ERR_INPUTFORMAT(8, "输入信息格式有误"),
/**
* Err inputmiss error code.
*/
ERR_INPUTMISS(9, "缺少必要输入信息"),
/**
* Err permission error code.
*/
ERR_PERMISSION(10, "操作员权限不足"),
/**
* Err reqtimeout error code.
*/
ERR_REQTIMEOUT(11, "请求超时"),
/**
* Err params error code.
*/
ERR_PARAMS(12, "参数错误"),
/**
* Err systemexception error code.
*/
ERR_SYSTEMEXCEPTION(13, "系统异常"),
/**
* Err unknowncmd error code.
*/
ERR_UNKNOWNCMD(14, "未知命令"),
/**
* Err logout error code.
*/
ERR_LOGOUT(15, "用户未登录"),
/**
* Err tokentimeout error code.
*/
ERR_TOKENTIMEOUT(16, "Token超时"),
/**
* Err tokennotfound error code.
*/
ERR_TOKENNOTFOUND(17, "非法Token"),
/**
* Err missauthhead error code.
*/
ERR_MISSAUTHHEAD(18, "Http 请求缺少认证头部"),
/**
* Err nosuchdevice error code.
*/
ERR_NOSUCHDEVICE(19, "没有这个设备"),
/**
* Err deviceexists error code.
*/
ERR_DEVICEEXISTS(20, "设备已经存在"),
/**
* Err paramexception error code.
*/
ERR_PARAMEXCEPTION(21, "参数异常"),
/**
* Err version error code.
*/
ERR_VERSION(23, "协议版本不兼容,请升级系统"),
/**
* Err nosuchtype error code.
*/
ERR_NOSUCHTYPE(24, "没有这个类型的处置设备"),
/**
* Err removemore error code.
*/
ERR_REMOVEMORE(25, "禁止同时删除多个设备"),
;
@ -39,10 +114,20 @@ public enum ErrorCode {
this.errMsg = msg;
}
/**
* Gets code.
*
* @return the code
*/
public int getCode() {
return errno;
}
/**
* Gets http code.
*
* @return the http code
*/
public int getHttpCode() {
if (this.errno == 0) {
return 200;
@ -51,6 +136,11 @@ public enum ErrorCode {
}
}
/**
* Gets msg.
*
* @return the msg
*/
public String getMsg() {
return errMsg;
}

View File

@ -1,13 +1,18 @@
package com.dispose.common;
/**
* @author: chiwei
* @date: 2020年4月7日 下午4:36:39
* The type Global var.
*/
public class GlobalVar {
/**
* The constant MAX_THREAT_INFO_VERSION.
*/
public static volatile int MAX_THREAT_INFO_VERSION = -1;
/**
* The constant THREAT_INFO_TYPE.
*/
public static volatile String THREAT_INFO_TYPE = "1";
}

View File

@ -5,6 +5,9 @@ import lombok.Setter;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
/**
* The type Dispose configure.
*/
@Getter
@Setter
@Component

View File

@ -5,8 +5,16 @@ import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.filter.CharacterEncodingFilter;
/**
* The type Encoding filter config.
*/
@Configuration
public class EncodingFilterConfig {
/**
* Filter registration bean filter registration bean.
*
* @return the filter registration bean
*/
@Bean
public FilterRegistrationBean filterRegistrationBean() {
FilterRegistrationBean registrationBean = new FilterRegistrationBean();

View File

@ -6,6 +6,9 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;
/**
* The type Setup init.
*/
@Component
@Slf4j
public class SetupInit implements CommandLineRunner {
@ -13,6 +16,11 @@ public class SetupInit implements CommandLineRunner {
private DisposeNodeManager disposeNodeManager;
/**
* Run.
*
* @param args the args
*/
@Override
public void run(String... args) {
// TODO Auto-generated method stub

View File

@ -26,6 +26,9 @@ import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
/**
* The type Auth controller.
*/
@Controller
@RequestMapping(value = "/auth")
@Slf4j
@ -38,6 +41,14 @@ public class AuthController {
@Resource
private UserAccountService userAccountService;
/**
* User login protocol resp dto.
*
* @param mr the mr
* @return the protocol resp dto
* @throws JsonProcessingException the json processing exception
* @throws NoSuchAlgorithmException the no such algorithm exception
*/
@PostMapping("/login")
@ResponseBody
@ApiOperation("登录")
@ -69,6 +80,14 @@ public class AuthController {
return ProtocolRespDTO.result(ErrorCode.ERR_OK, rspInfo);
}
/**
* User logout protocol resp dto.
*
* @param mr the mr
* @param headers the headers
* @return the protocol resp dto
* @throws JsonProcessingException the json processing exception
*/
@PostMapping("/logout")
@ResponseBody
@ApiOperation("注销")

View File

@ -34,6 +34,9 @@ import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
/**
* The type Dispose node info controller.
*/
@Controller
@RequestMapping(value = "/information")
@Slf4j
@ -49,6 +52,14 @@ public class DisposeNodeInfoController {
//@Resource
//private DisposeDeviceMapper disposeDeviceMapper;
/**
* Gets link status.
*
* @param mr the mr
* @param headers the headers
* @return the link status
* @throws JsonProcessingException the json processing exception
*/
@PostMapping("/linkstatus")
@ResponseBody
@ApiOperation("链接状态")
@ -101,6 +112,14 @@ public class DisposeNodeInfoController {
return ProtocolRespDTO.result(ErrorCode.ERR_OK, rspInfo);
}
/**
* Gets version.
*
* @param mr the mr
* @param headers the headers
* @return the version
* @throws JsonProcessingException the json processing exception
*/
@PostMapping("/version")
@ResponseBody
@ApiOperation("处置设备版本")
@ -156,6 +175,14 @@ public class DisposeNodeInfoController {
return ProtocolRespDTO.result(ErrorCode.ERR_OK, rspInfo);
}
/**
* Gets device info.
*
* @param mr the mr
* @param headers the headers
* @return the device info
* @throws JsonProcessingException the json processing exception
*/
@PostMapping("/deviceinfo")
@ResponseBody
@ApiOperation("处置设备信息")
@ -223,6 +250,14 @@ public class DisposeNodeInfoController {
return ProtocolRespDTO.result(ErrorCode.ERR_OK, rspInfo);
}
/**
* Gets capacity.
*
* @param mr the mr
* @param headers the headers
* @return the capacity
* @throws JsonProcessingException the json processing exception
*/
@PostMapping("/capacity")
@ResponseBody
@ApiOperation("处置设备处置能力")
@ -278,6 +313,14 @@ public class DisposeNodeInfoController {
return ProtocolRespDTO.result(ErrorCode.ERR_OK, rspMessage, ConstValue.Protocol.CRYPTO_NONE);
}
/**
* Gets protected ip.
*
* @param mr the mr
* @param headers the headers
* @return the protected ip
* @throws JsonProcessingException the json processing exception
*/
@PostMapping("/protected_ip")
@ResponseBody
@ApiOperation("处置设备防护IP")
@ -333,6 +376,14 @@ public class DisposeNodeInfoController {
return ProtocolRespDTO.result(ErrorCode.ERR_OK, rspMessage, ConstValue.Protocol.CRYPTO_NONE);
}
/**
* Gets dispose node list.
*
* @param mr the mr
* @param headers the headers
* @return the dispose node list
* @throws JsonProcessingException the json processing exception
*/
@PostMapping("/node_list")
@ResponseBody
@ApiOperation("处置设备列表")
@ -394,6 +445,14 @@ public class DisposeNodeInfoController {
return ProtocolRespDTO.result(ErrorCode.ERR_OK, rspInfo);
}
/**
* Gets dispose node details.
*
* @param mr the mr
* @param headers the headers
* @return the dispose node details
* @throws JsonProcessingException the json processing exception
*/
@PostMapping("/node_details")
@ResponseBody
@ApiOperation("处置节点详细信息")

View File

@ -30,6 +30,9 @@ import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
/**
* The type Dispose node manager controller.
*/
@Controller
@RequestMapping(value = "/manager")
@Slf4j
@ -42,6 +45,14 @@ public class DisposeNodeManagerController {
@Resource
private UserAccountCacheManager userAccountCacheManager;
/**
* Add dispose node protocol resp dto.
*
* @param mr the mr
* @param headers the headers
* @return the protocol resp dto
* @throws JsonProcessingException the json processing exception
*/
@PutMapping("/device")
@ResponseBody
@ApiOperation("添加处置能力节点")
@ -95,6 +106,14 @@ public class DisposeNodeManagerController {
return ProtocolRespDTO.result(ErrorCode.ERR_OK, rspInfo);
}
/**
* Remove dispose node protocol resp dto.
*
* @param mr the mr
* @param headers the headers
* @return the protocol resp dto
* @throws JsonProcessingException the json processing exception
*/
@DeleteMapping("/device")
@ResponseBody
@ApiOperation("删除处置能力节点")

View File

@ -3,8 +3,19 @@ package com.dispose.dispose;
import com.dispose.common.ConstValue;
import com.dispose.dispose.impl.DPTechImpl;
/**
* The type Device router.
*/
public class DeviceRouter {
/**
* Device router factory dispose entry manager.
*
* @param devType the dev type
* @param ipAddr the ip addr
* @param ipType the ip type
* @return the dispose entry manager
*/
public static DisposeEntryManager deviceRouterFactory(int devType, String ipAddr, ConstValue.IPAddrType ipType) {
if (devType == ConstValue.DisposeDeviceType.DPTECH_UMC.getCode()) {
return new DPTechImpl(ipAddr);
@ -13,6 +24,13 @@ public class DeviceRouter {
return null;
}
/**
* Device router factory dispose entry manager.
*
* @param devType the dev type
* @param ipAddr the ip addr
* @return the dispose entry manager
*/
public static DisposeEntryManager deviceRouterFactory(int devType, String ipAddr) {
return deviceRouterFactory(devType, ipAddr, ConstValue.IPAddrType.IPV4_TYPE);
}

View File

@ -5,23 +5,74 @@ import com.dispose.dispose.po.DeviceInfo;
import com.dispose.pojo.po.DisposeDeviceCapacity;
import java.util.List;
/**
* The interface Dispose entry manager.
*/
public interface DisposeEntryManager {
/**
* Run dispose int.
*
* @param ip the ip
* @return the int
*/
int runDispose(String ip);
/**
* Gets all detection object.
*
* @param <T> the type parameter
* @return the all detection object
*/
<T> T getAllDetectionObject();
/**
* Gets all protection object.
*
* @param <T> the type parameter
* @return the all protection object
*/
<T> T getAllProtectionObject();
/**
* Gets device capacity.
*
* @return the device capacity
*/
List<DisposeDeviceCapacity> getDeviceCapacity();
/**
* Gets detection devices.
*
* @return the detection devices
*/
String getDetectionDevices();
/**
* Gets protect devices.
*
* @return the protect devices
*/
String getProtectDevices();
/**
* Gets device link status.
*
* @return the device link status
*/
boolean getDeviceLinkStatus();
/**
* Gets version.
*
* @return the version
*/
String getVersion();
/**
* Gets device info.
*
* @return the device info
*/
DeviceInfo getDeviceInfo();
//public NtcRequestResultInfo stopAbnormalTask(String abnormalIp, int attackType, int direction);

View File

@ -20,12 +20,25 @@ import org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor;
import org.apache.wss4j.dom.WSConstants;
import org.apache.wss4j.dom.handler.WSHandlerConstants;
/**
* The type Dp tech.
*/
public class DPTechImpl implements DisposeEntryManager {
/**
* Gets version.
*
* @return the version
*/
@Override
public String getVersion() {
return "Not Support";
}
/**
* Gets device info.
*
* @return the device info
*/
@Override
public DeviceInfo getDeviceInfo() {
return DeviceInfo.builder()
@ -41,6 +54,11 @@ public class DPTechImpl implements DisposeEntryManager {
.build();
}
/**
* Gets device capacity.
*
* @return the device capacity
*/
@Override
public List<DisposeDeviceCapacity> getDeviceCapacity() {
List<DisposeDeviceCapacity> capList = new ArrayList<>();
@ -83,6 +101,11 @@ public class DPTechImpl implements DisposeEntryManager {
return capList;
}
/**
* Gets device link status.
*
* @return the device link status
*/
@Override
public boolean getDeviceLinkStatus() {
List<ArrayOfProtectionObjectDataForService> objs = getAllProtectionObject();
@ -90,23 +113,47 @@ public class DPTechImpl implements DisposeEntryManager {
return objs != null;
}
/**
* Run dispose int.
*
* @param ip the ip
* @return the int
*/
@Override
public int runDispose(String ip) {
return 0;
}
/**
* Gets all detection object.
*
* @param <T> the type parameter
* @return the all detection object
*/
@Override
@SuppressWarnings("unchecked")
public <T> T getAllDetectionObject() {
return (T) cleanTypePort.getAllDetectionObjectFromUMC().getDetectionObjectDataForService();
}
/**
* Gets all protection object.
*
* @param <T> the type parameter
* @return the all protection object
*/
@Override
@SuppressWarnings("unchecked")
public <T> T getAllProtectionObject() {
return (T) cleanTypePort.getAllProtectionObjectFromUMC().getProtectionObjectDataForService();
}
/**
* Gets detection object device json.
*
* @return the detection object device json
* @throws JsonProcessingException the json processing exception
*/
public String getDetectionObjectDeviceJson() throws JsonProcessingException {
ArrayOfDetectionObjectDataForService typePort = cleanTypePort.getAllDetectionObjectFromUMC();
@ -114,18 +161,36 @@ public class DPTechImpl implements DisposeEntryManager {
return mapper.writerWithDefaultPrettyPrinter().writeValueAsString(typePort);
}
/**
* Gets protect devices.
*
* @return the protect devices
*/
@Override
public String getProtectDevices() {
return cleanTypePort.getAllProtectDevices();
}
/**
* Gets detection devices.
*
* @return the detection devices
*/
@Override
public String getDetectionDevices() {
return cleanTypePort.getAllDetectDevices();
}
/**
* The Clean type port.
*/
AbnormalFlowCleaningServicePortType cleanTypePort;
/**
* Instantiates a new Dp tech.
*
* @param ipAddr the ip addr
*/
public DPTechImpl(String ipAddr) {
JaxWsProxyFactoryBean jaxWsProxyFactoryBean = new JaxWsProxyFactoryBean();
jaxWsProxyFactoryBean.setServiceClass(AbnormalFlowCleaningServicePortType.class);
@ -144,6 +209,12 @@ public class DPTechImpl implements DisposeEntryManager {
this.cleanTypePort = (AbnormalFlowCleaningServicePortType) jaxWsProxyFactoryBean.create();
}
/**
* Instantiates a new Dp tech.
*
* @param ipAddr the ip addr
* @param type the type
*/
public DPTechImpl(String ipAddr, ConstValue.IPAddrType type) {
JaxWsProxyFactoryBean jaxWsProxyFactoryBean = new JaxWsProxyFactoryBean();
jaxWsProxyFactoryBean.setServiceClass(AbnormalFlowCleaningServicePortType.class);

View File

@ -4,6 +4,9 @@ import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* The type Device info.
*/
@Data
@Builder
@NoArgsConstructor
@ -18,6 +21,19 @@ public class DeviceInfo {
private int freeMemory;
private int cpuUsed;
/**
* Instantiates a new Device info.
*
* @param vendor the vendor
* @param model the model
* @param firmware the firmware
* @param os the os
* @param kernel the kernel
* @param arch the arch
* @param memory the memory
* @param freeMemory the free memory
* @param cpuUsed the cpu used
*/
public DeviceInfo(String vendor,
String model,
String firmware,

View File

@ -11,16 +11,19 @@ import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
/**
* 全局异常处理
*
* @author phoenix
* @date 2020年2月5日
* The type Global exception handler.
*/
@ControllerAdvice
@Slf4j
public class GlobalExceptionHandler {
/**
* Handle exception protocol resp dto.
*
* @param request the request
* @param e the e
* @return the protocol resp dto
*/
@ExceptionHandler(Throwable.class)
@ResponseBody
public ProtocolRespDTO handleException(HttpServletRequest request, Throwable e) {
@ -37,6 +40,13 @@ public class GlobalExceptionHandler {
return resp;
}
/**
* Param exception protocol resp dto.
*
* @param request the request
* @param e the e
* @return the protocol resp dto
*/
@ExceptionHandler(Exception.class)
@ResponseBody
public ProtocolRespDTO paramException(HttpServletRequest request, Exception e) {

View File

@ -6,6 +6,9 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;
/**
* The type Git information.
*/
@Getter
@Setter
@Component

View File

@ -4,22 +4,80 @@ import com.dispose.common.ErrorCode;
import com.fasterxml.jackson.core.JsonProcessingException;
import java.security.NoSuchAlgorithmException;
/**
* The interface User account cache manager.
*/
public interface UserAccountCacheManager {
/**
* Gets user token.
*
* @param username the username
* @return the user token
* @throws NoSuchAlgorithmException the no such algorithm exception
*/
String getUserToken(String username) throws NoSuchAlgorithmException;
/**
* Gets usr pwd err times.
*
* @param username the username
* @return the usr pwd err times
*/
int getUsrPwdErrTimes(String username);
/**
* Sets user pwd err times.
*
* @param username the username
* @param errTimes the err times
*/
void setUserPwdErrTimes(String username, Integer errTimes);
/**
* Clean user token.
*
* @param username the username
*/
void cleanUserToken(String username);
/**
* Verify user login error code.
*
* @param username the username
* @param token the token
* @return the error code
*/
ErrorCode verifyUserLogin(String username, String token);
/**
* Verify token error code.
*
* @param token the token
* @return the error code
*/
ErrorCode verifyToken(String token);
/**
* Gets username by token.
*
* @param token the token
* @return the username by token
*/
String getUsernameByToken(String token);
/**
* Verify permission error code.
*
* @param token the token
* @return the error code
*/
ErrorCode verifyPermission(String token);
/**
* Gets cache user.
*
* @return the cache user
* @throws JsonProcessingException the json processing exception
*/
String getCacheUser() throws JsonProcessingException;
}

View File

@ -18,6 +18,9 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.commons.codec.binary.Hex;
import org.springframework.stereotype.Component;
/**
* The type User account cache manager.
*/
@Component
@Slf4j
public class UserAccountCacheManagerImpl implements UserAccountCacheManager {
@ -29,6 +32,12 @@ public class UserAccountCacheManagerImpl implements UserAccountCacheManager {
private final ConcurrentHashMap<String, UserAccountCache> userAccountCache = new ConcurrentHashMap<>();
/**
* Verify permission error code.
*
* @param token the token
* @return the error code
*/
@Override
public ErrorCode verifyPermission(String token) {
if (disposeConfigure.getCheckAdminPermission().equals("false")) {
@ -46,6 +55,12 @@ public class UserAccountCacheManagerImpl implements UserAccountCacheManager {
return ErrorCode.ERR_PERMISSION;
}
/**
* Gets username by token.
*
* @param token the token
* @return the username by token
*/
@Override
public String getUsernameByToken(String token) {
if (userAccountCache.containsKey(token)) {
@ -55,6 +70,12 @@ public class UserAccountCacheManagerImpl implements UserAccountCacheManager {
return null;
}
/**
* Verify token error code.
*
* @param token the token
* @return the error code
*/
@Override
public ErrorCode verifyToken(String token) {
//userAccountMap
@ -73,6 +94,13 @@ public class UserAccountCacheManagerImpl implements UserAccountCacheManager {
}
}
/**
* Verify user login error code.
*
* @param username the username
* @param token the token
* @return the error code
*/
@Override
public ErrorCode verifyUserLogin(String username, String token) {
Optional<UserAccountCache> findRet = userAccountCache.values().stream()
@ -101,11 +129,22 @@ public class UserAccountCacheManagerImpl implements UserAccountCacheManager {
return ErrorCode.ERR_OK;
}
/**
* Gets cache user.
*
* @return the cache user
* @throws JsonProcessingException the json processing exception
*/
@Override
public String getCacheUser() throws JsonProcessingException {
return objectMapper.writeValueAsString(userAccountCache);
}
/**
* Clean user token.
*
* @param username the username
*/
@Override
public void cleanUserToken(String username) {
Optional<UserAccountCache> findRet = userAccountCache.values().stream()
@ -118,6 +157,12 @@ public class UserAccountCacheManagerImpl implements UserAccountCacheManager {
}
}
/**
* Gets usr pwd err times.
*
* @param username the username
* @return the usr pwd err times
*/
@Override
public int getUsrPwdErrTimes(String username) {
Optional<UserAccountCache> findRet = userAccountCache.values().stream()
@ -140,6 +185,12 @@ public class UserAccountCacheManagerImpl implements UserAccountCacheManager {
}
}
/**
* Sets user pwd err times.
*
* @param username the username
* @param errTimes the err times
*/
@Override
public void setUserPwdErrTimes(String username, Integer errTimes) {
Optional<UserAccountCache> findRet = userAccountCache.values().stream()
@ -152,6 +203,13 @@ public class UserAccountCacheManagerImpl implements UserAccountCacheManager {
}
}
/**
* Gets user token.
*
* @param username the username
* @return the user token
* @throws NoSuchAlgorithmException the no such algorithm exception
*/
@Override
public String getUserToken(String username) throws NoSuchAlgorithmException {

View File

@ -5,19 +5,61 @@ import tk.mybatis.mapper.common.IdsMapper;
import tk.mybatis.mapper.common.Mapper;
import tk.mybatis.mapper.common.MySqlMapper;
/**
* The interface Dispose device mapper.
*/
public interface DisposeDeviceMapper extends Mapper<DisposeDevice>,
IdsMapper<DisposeDevice>, MySqlMapper<DisposeDevice> {
/**
* Add new dispose device.
*
* @param dev the dev
*/
void addNewDisposeDevice(DisposeDevice dev);
/**
* Is device exists by ip int.
*
* @param ipAddr the ip addr
* @return the int
*/
int isDeviceExistsByIp(String ipAddr);
/**
* Is device exists by id int.
*
* @param id the id
* @return the int
*/
int isDeviceExistsById(Long id);
/**
* Gets device by ip.
*
* @param ipAddr the ip addr
* @return the device by ip
*/
DisposeDevice getDeviceByIp(String ipAddr);
/**
* Gets device by id.
*
* @param id the id
* @return the device by id
*/
DisposeDevice getDeviceById(Long id);
/**
* Del dispose device by ip.
*
* @param ipAddr the ip addr
*/
void delDisposeDeviceByIp(String ipAddr);
/**
* Del dispose device by ip.
*
* @param id the id
*/
void delDisposeDeviceByIp(Long id);
}

View File

@ -3,12 +3,36 @@ package com.dispose.mapper;
import com.dispose.pojo.entity.UserAccount;
import org.apache.ibatis.annotations.Param;
/**
* The interface User account mapper.
*/
public interface UserAccountMapper {
/**
* Gets user by name.
*
* @param username the username
* @return the user by name
*/
UserAccount getUserByName(String username);
/**
* Lock user account.
*
* @param username the username
*/
void lockUserAccount(@Param("username") String username);
/**
* Unlock user account.
*
* @param username the username
*/
void unlockUserAccount(@Param("username") String username);
/**
* Refresh login time.
*
* @param username the username
*/
void refreshLoginTime(@Param("username") String username);
}

View File

@ -9,6 +9,9 @@ import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* The type Protocol dto.
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@ -35,6 +38,11 @@ public abstract class ProtocolDTO {
example = "{}")
private String msgContent;
/**
* Is request timeout boolean.
*
* @return the boolean
*/
@JsonIgnore
public Boolean isRequestTimeout() {

View File

@ -11,6 +11,9 @@ import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.springframework.http.HttpHeaders;
/**
* The type Protocol req dto.
*/
@EqualsAndHashCode(callSuper = true)
@Data
@NoArgsConstructor
@ -20,16 +23,35 @@ public class ProtocolReqDTO extends ProtocolDTO {
private static String token;
/**
* Gets request object.
*
* @param <T> the type parameter
* @param objType the obj type
* @return the request object
* @throws JsonProcessingException the json processing exception
*/
public <T> T getRequestObject(Class<T> objType) throws JsonProcessingException {
return objMapper.readValue(this.getMsgContent(), objType);
}
/**
* Gets auth token.
*
* @return the auth token
*/
@JsonIgnore
public String getAuthToken() {
return ProtocolReqDTO.token;
}
/**
* Verify request error code.
*
* @param headers the headers
* @return the error code
*/
public ErrorCode verifyRequest(HttpHeaders headers) {
if (headers == null) {
@ -55,6 +77,11 @@ public class ProtocolReqDTO extends ProtocolDTO {
return ErrorCode.ERR_OK;
}
/**
* Verify request error code.
*
* @return the error code
*/
public ErrorCode verifyRequest() {
if (this.getVer() < ConstValue.Protocol.VERSION) {

View File

@ -13,6 +13,9 @@ import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
/**
* The type Protocol resp dto.
*/
@EqualsAndHashCode(callSuper = true)
@Data
@Builder
@ -31,6 +34,13 @@ public class ProtocolRespDTO extends ProtocolDTO {
return objectMapper.writeValueAsString(obj);
}
/**
* Result protocol resp dto.
*
* @param err the err
* @return the protocol resp dto
* @throws JsonProcessingException the json processing exception
*/
public static ProtocolRespDTO result(ErrorCode err) throws JsonProcessingException {
ProtocolRespDTO resp = new ProtocolRespDTO();
@ -43,14 +53,37 @@ public class ProtocolRespDTO extends ProtocolDTO {
return resp;
}
/**
* Result protocol resp dto.
*
* @param err the err
* @param respMsg the resp msg
* @return the protocol resp dto
*/
public static ProtocolRespDTO result(ErrorCode err, String respMsg) {
return result(err, respMsg, ConstValue.Protocol.CRYPTO_NONE);
}
/**
* Result protocol resp dto.
*
* @param err the err
* @param obj the obj
* @return the protocol resp dto
* @throws JsonProcessingException the json processing exception
*/
public static ProtocolRespDTO result(ErrorCode err, Object obj) throws JsonProcessingException {
return result(err, getObjectJson(obj), ConstValue.Protocol.CRYPTO_NONE);
}
/**
* Result protocol resp dto.
*
* @param err the err
* @param respMsg the resp msg
* @param crypto the crypto
* @return the protocol resp dto
*/
public static ProtocolRespDTO result(ErrorCode err, String respMsg, Integer crypto) {
ProtocolRespDTO resp = new ProtocolRespDTO();

View File

@ -17,6 +17,9 @@ import lombok.ToString;
import tk.mybatis.mapper.annotation.NameStyle;
import tk.mybatis.mapper.code.Style;
/**
* The type Dispose device.
*/
@Getter
@Setter
@ToString

View File

@ -13,6 +13,9 @@ import tk.mybatis.mapper.annotation.KeySql;
import tk.mybatis.mapper.annotation.NameStyle;
import tk.mybatis.mapper.code.Style;
/**
* The type User account.
*/
@Getter
@Setter
@ToString

View File

@ -7,6 +7,9 @@ import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
/**
* The type Dispose device capacity.
*/
@Getter
@Setter
@ToString

View File

@ -3,12 +3,24 @@ package com.dispose.pojo.po;
import lombok.Builder;
import lombok.Getter;
/**
* The type M return type.
*
* @param <A> the type parameter
* @param <B> the type parameter
*/
@Getter
@Builder
public class MReturnType<A, B> {
private final A firstParam;
private final B secondParam;
/**
* Instantiates a new M return type.
*
* @param a the a
* @param b the b
*/
public MReturnType(A a, B b) {
this.firstParam = a;
this.secondParam = b;

View File

@ -7,6 +7,9 @@ import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.lang.Nullable;
/**
* The type New node info.
*/
@Data
@Builder
@NoArgsConstructor

View File

@ -4,6 +4,9 @@ import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* The type Return status.
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@ -11,6 +14,11 @@ public class ReturnStatus {
private int status;
private String message;
/**
* To string string.
*
* @return the string
*/
@Override
public String toString() {
return "{\"status\":" + status + ", \"message\":\"" + message + "\"}";

View File

@ -3,6 +3,9 @@ package com.dispose.pojo.po;
import lombok.Builder;
import lombok.Data;
/**
* The type User account cache.
*/
@Data
@Builder
public class UserAccountCache {

View File

@ -7,6 +7,9 @@ import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* The type Login req.
*/
@Data
@Builder
@NoArgsConstructor

View File

@ -9,6 +9,9 @@ import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
/**
* The type Login rsp.
*/
@EqualsAndHashCode(callSuper = true)
@Data
@Builder

View File

@ -8,6 +8,9 @@ import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
/**
* The type Logout rsp.
*/
@EqualsAndHashCode(callSuper = true)
@Data
@Builder

View File

@ -7,14 +7,28 @@ import lombok.Builder;
import lombok.NoArgsConstructor;
import lombok.Setter;
/**
* The type Dispose capacity.
*/
@Setter
@Builder
@NoArgsConstructor
@AllArgsConstructor
@JsonInclude(JsonInclude.Include.NON_NULL)
public class DisposeCapacity {
/**
* The interface Base view.
*/
public interface BaseView {}
/**
* The interface Capacity view.
*/
public interface CapacityView extends BaseView {}
/**
* The interface Depend ip view.
*/
public interface DependIpView extends BaseView {}
@JsonView(BaseView.class)

View File

@ -5,6 +5,9 @@ import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* The type Id array req.
*/
@Data
@Builder
@NoArgsConstructor

View File

@ -8,6 +8,9 @@ import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
/**
* The type Id return status.
*/
@EqualsAndHashCode(callSuper = true)
@Data
@NoArgsConstructor

View File

@ -8,6 +8,9 @@ import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* The type Add node req.
*/
@Data
@Builder
@NoArgsConstructor

View File

@ -8,6 +8,9 @@ import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
/**
* The type Add node ret data.
*/
@EqualsAndHashCode(callSuper = true)
@Data
@NoArgsConstructor

View File

@ -8,13 +8,22 @@ import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
/**
* The type Add node rsp.
*/
@Data
@AllArgsConstructor
@Builder
@JsonInclude(JsonInclude.Include.NON_NULL)
public class AddNodeRsp {
/**
* The Result.
*/
List<AddNodeRetData> result;
/**
* Instantiates a new Add node rsp.
*/
public AddNodeRsp() {
this.result = new ArrayList<>();
}

View File

@ -12,14 +12,25 @@ import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
/**
* The type Device capacity data.
*/
@EqualsAndHashCode(callSuper = true)
@Data
@NoArgsConstructor
@JsonPropertyOrder({"id", "capacity", "status", "message"})
@JsonInclude(JsonInclude.Include.NON_NULL)
public class DeviceCapacityData extends IDReturnStatus {
/**
* The Capacity.
*/
List<DisposeCapacity> capacity;
/**
* Instantiates a new Device capacity data.
*
* @param cpList the cp list
*/
public DeviceCapacityData(List<DisposeDeviceCapacity> cpList) {
this.capacity = new ArrayList<>();

View File

@ -6,6 +6,9 @@ import java.util.List;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* The type Device capacity rsp.
*/
@Data
@NoArgsConstructor
@JsonPropertyOrder({"id", "capacity", "status", "message"})

View File

@ -8,6 +8,9 @@ import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
/**
* The type Device info data.
*/
@EqualsAndHashCode(callSuper = true)
@Data
@NoArgsConstructor
@ -18,6 +21,21 @@ public class DeviceInfoData extends DeviceInfo {
private int status;
private String message;
/**
* Instantiates a new Device info data.
*
* @param id the id
* @param vendor the vendor
* @param model the model
* @param firmware the firmware
* @param os the os
* @param kernel the kernel
* @param arch the arch
* @param memory the memory
* @param freeMemory the free memory
* @param cpuUsed the cpu used
* @param err the err
*/
public DeviceInfoData(String id,
String vendor,
String model,
@ -35,6 +53,12 @@ public class DeviceInfoData extends DeviceInfo {
this.message = err.getMsg();
}
/**
* Instantiates a new Device info data.
*
* @param id the id
* @param err the err
*/
public DeviceInfoData(String id,
ErrorCode err) {
this.id = id;

View File

@ -3,7 +3,13 @@ package com.dispose.pojo.vo.information;
import java.util.List;
import lombok.Data;
/**
* The type Device info rsp.
*/
@Data
public class DeviceInfoRsp {
/**
* The Items.
*/
List<DeviceInfoData> items;
}

View File

@ -10,6 +10,9 @@ import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
/**
* The type Dispose node data.
*/
@EqualsAndHashCode(callSuper = true)
@Data
@Builder
@ -27,6 +30,19 @@ public class DisposeNodeData extends DeviceCapacityData {
private String version;
private String readme;
/**
* Instantiates a new Dispose node data.
*
* @param type the type
* @param name the name
* @param ip the ip
* @param areaCode the area code
* @param manufacturer the manufacturer
* @param model the model
* @param version the version
* @param readme the readme
* @param capacity the capacity
*/
public DisposeNodeData(int type, String name, String ip, Integer areaCode,
String manufacturer, String model, String version,
String readme,

View File

@ -4,6 +4,9 @@ import java.util.List;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* The type Dispose node list rsp.
*/
@Data
@NoArgsConstructor
public class DisposeNodeListRsp {

View File

@ -8,6 +8,9 @@ import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
/**
* The type Link status rsp.
*/
@EqualsAndHashCode(callSuper = true)
@Data
@Builder

View File

@ -8,6 +8,9 @@ import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
/**
* The type Version rsp.
*/
@EqualsAndHashCode(callSuper = true)
@Data
@Builder

View File

@ -5,18 +5,59 @@ import com.dispose.pojo.entity.DisposeDevice;
import com.dispose.pojo.po.MReturnType;
import java.util.List;
/**
* The interface Dispose node manager.
*/
public interface DisposeNodeManager {
/**
* Add new dispose device m return type.
*
* @param dev the dev
* @return the m return type
*/
MReturnType<ErrorCode, String> addNewDisposeDevice(DisposeDevice dev);
/**
* Del dispose device by ip error code.
*
* @param ipAddr the ip addr
* @return the error code
*/
ErrorCode delDisposeDeviceByIp(String ipAddr);
/**
* Del dispose device by id error code.
*
* @param id the id
* @return the error code
*/
ErrorCode delDisposeDeviceById(Long id);
/**
* Gets all dispose device.
*
* @return the all dispose device
*/
List<DisposeDevice> getAllDisposeDevice();
/**
* Gets dispose device by ip.
*
* @param ipAddr the ip addr
* @return the dispose device by ip
*/
DisposeDevice getDisposeDeviceByIp(String ipAddr);
/**
* Gets dispose device by id.
*
* @param id the id
* @return the dispose device by id
*/
DisposeDevice getDisposeDeviceById(Long id);
/**
* Load dispose node from db.
*/
void loadDisposeNodeFromDB();
}

View File

@ -5,12 +5,42 @@ import com.dispose.pojo.entity.UserAccount;
import com.dispose.pojo.po.MReturnType;
import java.security.NoSuchAlgorithmException;
/**
* The interface User account service.
*/
public interface UserAccountService {
/**
* Login service m return type.
*
* @param username the username
* @param password the password
* @return the m return type
* @throws NoSuchAlgorithmException the no such algorithm exception
*/
MReturnType<ErrorCode, String> loginService(String username, String password) throws NoSuchAlgorithmException;
/**
* Logout service error code.
*
* @param username the username
* @param token the token
* @return the error code
*/
ErrorCode logoutService(String username, String token);
/**
* Auth token check error code.
*
* @param token the token
* @return the error code
*/
ErrorCode authTokenCheck(String token);
/**
* Gets user by token.
*
* @param token the token
* @return the user by token
*/
UserAccount getUserByToken(String token);
}

View File

@ -16,6 +16,9 @@ import java.util.concurrent.ConcurrentHashMap;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
/**
* The type Dispose node manager.
*/
@Service
public class DisposeNodeManagerImpl implements DisposeNodeManager {
@Resource
@ -26,6 +29,9 @@ public class DisposeNodeManagerImpl implements DisposeNodeManager {
private final ConcurrentHashMap<String, DisposeDevice> disposeDevMap = new ConcurrentHashMap<>();
/**
* Load dispose node from db.
*/
@Override
public void loadDisposeNodeFromDB() {
List<DisposeDevice> devList = disposeDeviceMapper.selectAll();
@ -49,6 +55,12 @@ public class DisposeNodeManagerImpl implements DisposeNodeManager {
});
}
/**
* Del dispose device by id error code.
*
* @param id the id
* @return the error code
*/
@Override
public ErrorCode delDisposeDeviceById(Long id) {
DisposeEntryManager dp;
@ -61,6 +73,12 @@ public class DisposeNodeManagerImpl implements DisposeNodeManager {
return delDisposeDeviceByIp(dev.getIpAddr());
}
/**
* Del dispose device by ip error code.
*
* @param ipAddr the ip addr
* @return the error code
*/
@Override
public ErrorCode delDisposeDeviceByIp(String ipAddr) {
DisposeEntryManager dp;
@ -88,6 +106,12 @@ public class DisposeNodeManagerImpl implements DisposeNodeManager {
return ErrorCode.ERR_OK;
}
/**
* Add new dispose device m return type.
*
* @param dev the dev
* @return the m return type
*/
@Override
public MReturnType<ErrorCode, String> addNewDisposeDevice(DisposeDevice dev) {
DisposeEntryManager dp;
@ -125,16 +149,33 @@ public class DisposeNodeManagerImpl implements DisposeNodeManager {
return new MReturnType<>(ErrorCode.ERR_OK, dev.getIpAddr());
}
/**
* Gets all dispose device.
*
* @return the all dispose device
*/
@Override
public List<DisposeDevice> getAllDisposeDevice() {
return new ArrayList<>(disposeDevMap.values());
}
/**
* Gets dispose device by ip.
*
* @param ipAddr the ip addr
* @return the dispose device by ip
*/
@Override
public DisposeDevice getDisposeDeviceByIp(String ipAddr) {
return disposeDevMap.get(ipAddr);
}
/**
* Gets dispose device by id.
*
* @param id the id
* @return the dispose device by id
*/
@Override
public DisposeDevice getDisposeDeviceById(Long id) {
Optional<DisposeDevice> findRet = disposeDevMap.values().stream()

View File

@ -12,6 +12,9 @@ import javax.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
/**
* The type User account service.
*/
@Service
@Slf4j
public class UserAccountServiceImpl implements UserAccountService {
@ -22,6 +25,12 @@ public class UserAccountServiceImpl implements UserAccountService {
@Resource
private UserAccountMapper userAccountMapper;
/**
* Auth token check error code.
*
* @param token the token
* @return the error code
*/
@Override
public ErrorCode authTokenCheck(String token) {
@ -32,6 +41,14 @@ public class UserAccountServiceImpl implements UserAccountService {
return ErrorCode.ERR_OK;
}
/**
* Login service m return type.
*
* @param username the username
* @param password the password
* @return the m return type
* @throws NoSuchAlgorithmException the no such algorithm exception
*/
@Override
public MReturnType<ErrorCode, String> loginService(String username, String password) throws NoSuchAlgorithmException {
userAccountMapper.refreshLoginTime(username);
@ -80,6 +97,13 @@ public class UserAccountServiceImpl implements UserAccountService {
.build();
}
/**
* Logout service error code.
*
* @param username the username
* @param token the token
* @return the error code
*/
@Override
public ErrorCode logoutService(String username, String token) {
UserAccount loginUser = userAccountMapper.getUserByName(username);
@ -97,6 +121,12 @@ public class UserAccountServiceImpl implements UserAccountService {
return err;
}
/**
* Gets user by token.
*
* @param token the token
* @return the user by token
*/
@Override
public UserAccount getUserByToken(String token) {

View File

@ -12,6 +12,9 @@ import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
/**
* The type Device manager task.
*/
@Component
@Slf4j
public class DeviceManagerTask {
@ -19,7 +22,7 @@ public class DeviceManagerTask {
private DisposeNodeManager disposeNodeManager;
/**
* Corn 小时 日期 月份 星期 每10秒执行
* Thread pool task.
*/
@Async("bizExecutor")
@Scheduled(cron = "0/30 * * * * ?")

View File

@ -1,20 +1,20 @@
#Generated by Git-Commit-Id-Plugin
#Mon Apr 20 15:47:47 CST 2020
git.branch=v2_dev
#Tue Apr 21 15:12:20 CST 2020
git.branch=master
git.build.host=DESKTOP-GJUT8MA
git.build.time=2020-04-20T15\:47\:47+0800
git.build.time=2020-04-21T15\:12\:20+0800
git.build.user.email=huangxin@\u0096cmhi.chinamobile.com
git.build.user.name=HuangXin
git.build.version=1.0.0
git.closest.tag.commit.count=
git.closest.tag.name=
git.commit.id=edff379c6495dcfd4488cab48dd1d30167f3e06a
git.commit.id.abbrev=edff379
git.commit.id.describe=edff379-dirty
git.commit.id.describe-short=edff379-dirty
git.commit.message.full=OCT\nREM\:\n1. \u589E\u52A0\u542F\u52A8\u65F6\u81EA\u52A8\u52A0\u8F7D\u6240\u6709\u5904\u7F6E\u8BBE\u5907\u529F\u80FD\n2. \u589E\u52A0\u8C03\u8BD5\u76F8\u5173\u914D\u7F6E\u9879\u5F00\u5173\u529F\u80FD\n3. \u589E\u52A0\u5904\u7F6E\u8282\u70B9\u4FE1\u606F\u83B7\u53D6\u63A5\u53E3\n4. \u589E\u52A0\u8282\u70B9\u7BA1\u7406\u6743\u9650\u9A8C\u8BC1\u529F\u80FD\n5. \u589E\u52A0\u8282\u70B9\u4FE1\u606F\u81EA\u52A8\u66F4\u65B0\u529F\u80FD\n6. \u589E\u52A0\u5BF9\u5E94\u63A5\u53E3\uFF0C\u529F\u80FD\u5355\u5143\u6D4B\u8BD5\u7528\u4F8B
git.commit.message.short=OCT REM\: 1. \u589E\u52A0\u542F\u52A8\u65F6\u81EA\u52A8\u52A0\u8F7D\u6240\u6709\u5904\u7F6E\u8BBE\u5907\u529F\u80FD 2. \u589E\u52A0\u8C03\u8BD5\u76F8\u5173\u914D\u7F6E\u9879\u5F00\u5173\u529F\u80FD 3. \u589E\u52A0\u5904\u7F6E\u8282\u70B9\u4FE1\u606F\u83B7\u53D6\u63A5\u53E3 4. \u589E\u52A0\u8282\u70B9\u7BA1\u7406\u6743\u9650\u9A8C\u8BC1\u529F\u80FD 5. \u589E\u52A0\u8282\u70B9\u4FE1\u606F\u81EA\u52A8\u66F4\u65B0\u529F\u80FD 6. \u589E\u52A0\u5BF9\u5E94\u63A5\u53E3\uFF0C\u529F\u80FD\u5355\u5143\u6D4B\u8BD5\u7528\u4F8B
git.commit.time=2020-04-17T20\:38\:41+0800
git.commit.id=4c06518a8623bb94f3da53fa27e43cd5c60625e0
git.commit.id.abbrev=4c06518
git.commit.id.describe=4c06518-dirty
git.commit.id.describe-short=4c06518-dirty
git.commit.message.full=OCT\nREM\:\n1. \u6DFB\u52A0idea\u5DE5\u7A0B\u914D\u7F6E\u6587\u4EF6\u8FC7\u6EE4\u89C4\u5219
git.commit.message.short=OCT REM\: 1. \u6DFB\u52A0idea\u5DE5\u7A0B\u914D\u7F6E\u6587\u4EF6\u8FC7\u6EE4\u89C4\u5219
git.commit.time=2020-04-21T15\:06\:48+0800
git.commit.user.email=huangxin@cmhi.chinamobile.com
git.commit.user.name=huangxin
git.dirty=true
@ -22,4 +22,4 @@ git.local.branch.ahead=0
git.local.branch.behind=0
git.remote.origin.url=git@git.komect.net\:DDOSAQ/phoenix_ddos_handle.git
git.tags=
git.total.commit.count=43
git.total.commit.count=47

View File

@ -10,6 +10,9 @@ import com.dispose.mapper.UserAccountMapperTest;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
/**
* The type All dispose platform test.
*/
@RunWith(Suite.class)
@Suite.SuiteClasses({
DPTechInterfaceTestCase.class,

View File

@ -23,6 +23,9 @@ import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.
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.
*/
@AutoConfigureMockMvc
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@ -37,6 +40,11 @@ public class AuthControllerTest {
static private String logToken = "";
/**
* Login 1.
*
* @throws Exception the exception
*/
@Test
public void login1() throws Exception {
LoginReq logReq = LoginReq.builder()
@ -67,6 +75,11 @@ public class AuthControllerTest {
log.info("Login Token:" + logToken);
}
/**
* Logout 2.
*
* @throws Exception the exception
*/
@Test
public void logout2() throws Exception {
LoginReq logReq = LoginReq.builder()

View File

@ -24,6 +24,9 @@ import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
/**
* The type Device node info controller test.
*/
@AutoConfigureMockMvc
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@ -51,6 +54,11 @@ public class DeviceNodeInfoControllerTest {
return -1L;
}
/**
* T 1 get version.
*
* @throws Exception the exception
*/
@Test
public void t1_getVersion() throws Exception {
IDArrayReq reqData = IDArrayReq.builder()
@ -77,6 +85,11 @@ public class DeviceNodeInfoControllerTest {
.getContentAsString();
}
/**
* T 2 get device info.
*
* @throws Exception the exception
*/
@Test
public void t2_getDeviceInfo() throws Exception {
IDArrayReq reqData = IDArrayReq.builder()
@ -103,6 +116,11 @@ public class DeviceNodeInfoControllerTest {
.getContentAsString();
}
/**
* T 3 get device capacity.
*
* @throws Exception the exception
*/
@Test
public void t3_getDeviceCapacity() throws Exception {
IDArrayReq reqData = IDArrayReq.builder()
@ -129,6 +147,11 @@ public class DeviceNodeInfoControllerTest {
.getContentAsString();
}
/**
* T 3 get device protected ip.
*
* @throws Exception the exception
*/
@Test
public void t3_getDeviceProtectedIp() throws Exception {
IDArrayReq reqData = IDArrayReq.builder()
@ -155,6 +178,11 @@ public class DeviceNodeInfoControllerTest {
.getContentAsString();
}
/**
* T 3 get dispose node list.
*
* @throws Exception the exception
*/
@Test
public void t3_getDisposeNodeList() throws Exception {
IDArrayReq reqData = IDArrayReq.builder()
@ -181,6 +209,11 @@ public class DeviceNodeInfoControllerTest {
.getContentAsString();
}
/**
* T 3 get dispose node details.
*
* @throws Exception the exception
*/
@Test
public void t3_getDisposeNodeDetails() throws Exception {
IDArrayReq reqData = IDArrayReq.builder()

View File

@ -25,6 +25,9 @@ import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
/**
* The type Device node manager controller test.
*/
@AutoConfigureMockMvc
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@ -37,6 +40,11 @@ public class DeviceNodeManagerControllerTest {
@Resource
private ObjectMapper objectMapper;
/**
* T 1 add device.
*
* @throws Exception the exception
*/
@Test
public void t1_addDevice() throws Exception {
AddNodeReq addReq = AddNodeReq.builder()
@ -85,6 +93,11 @@ public class DeviceNodeManagerControllerTest {
.getContentAsString();
}
/**
* T 2 del device.
*
* @throws Exception the exception
*/
@Test
public void t2_delDevice() throws Exception {
IDArrayReq reqData = IDArrayReq.builder()

View File

@ -18,6 +18,9 @@ import org.springframework.test.context.junit4.SpringRunner;
import javax.annotation.Resource;
import java.util.List;
/**
* The type Dp tech interface test case.
*/
@RunWith(SpringRunner.class)
@SpringBootTest
@Slf4j
@ -25,6 +28,9 @@ public class DPTechInterfaceTestCase {
@Resource
private ObjectMapper objMapper;
/**
* Get all detection object from umc.
*/
@Test
public void getAllDetectionObjectFromUMC(){
@ -40,6 +46,9 @@ public class DPTechInterfaceTestCase {
}
}
/**
* Get all protect devices.
*/
@Test
public void getAllProtectDevices(){
@ -55,6 +64,9 @@ public class DPTechInterfaceTestCase {
}
}
/**
* Get all protect objects.
*/
@Test
public void getAllProtectObjects(){
@ -70,6 +82,9 @@ public class DPTechInterfaceTestCase {
}
}
/**
* Get link status.
*/
@Test
public void getLinkStatus(){
@ -79,6 +94,11 @@ public class DPTechInterfaceTestCase {
Assert.assertTrue(dp.getDeviceLinkStatus());
}
/**
* Gets device capacity.
*
* @throws JsonProcessingException the json processing exception
*/
@Test
public void getDeviceCapacity() throws JsonProcessingException {

View File

@ -19,6 +19,9 @@ import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
/**
* The type Dispose device mapper test.
*/
@RunWith(SpringRunner.class)
@SpringBootTest
@Slf4j
@ -33,6 +36,11 @@ public class DisposeDeviceMapperTest {
@Resource
private DisposeNodeManager disposeNodeManager;
/**
* T 1 add new dispose device.
*
* @throws JsonProcessingException the json processing exception
*/
@Test
public void t1_addNewDisposeDevice() throws JsonProcessingException {
Long devId = -1L;
@ -59,6 +67,11 @@ public class DisposeDeviceMapperTest {
log.info(objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(dp));
}
/**
* T 2 is device exists by ip.
*
* @throws JsonProcessingException the json processing exception
*/
@Test
public void t2_isDeviceExistsByIp() throws JsonProcessingException {
List<DisposeDevice> dp = disposeDeviceMapper.selectAll();
@ -69,6 +82,11 @@ public class DisposeDeviceMapperTest {
});
}
/**
* T 3 is device exists by id.
*
* @throws JsonProcessingException the json processing exception
*/
@Test
public void t3_isDeviceExistsById() throws JsonProcessingException {
List<DisposeDevice> dp = disposeDeviceMapper.selectAll();
@ -79,6 +97,11 @@ public class DisposeDeviceMapperTest {
});
}
/**
* T 4 get device exists by ip.
*
* @throws JsonProcessingException the json processing exception
*/
@Test
public void t4_getDeviceExistsByIp() throws JsonProcessingException {
List<DisposeDevice> dp = disposeDeviceMapper.selectAll();
@ -91,6 +114,11 @@ public class DisposeDeviceMapperTest {
});
}
/**
* T 5 get device exists by id.
*
* @throws JsonProcessingException the json processing exception
*/
@Test
public void t5_getDeviceExistsById() throws JsonProcessingException {
List<DisposeDevice> dp = disposeDeviceMapper.selectAll();
@ -103,6 +131,11 @@ public class DisposeDeviceMapperTest {
});
}
/**
* T 100 del dispose device by ip.
*
* @throws JsonProcessingException the json processing exception
*/
@Test
public void t100_delDisposeDeviceByIp() throws JsonProcessingException {
String ipAddr = "10.88.77.15";

View File

@ -16,6 +16,9 @@ import org.springframework.test.context.junit4.SpringRunner;
import javax.annotation.Resource;
/**
* The type User account mapper test.
*/
@RunWith(SpringRunner.class)
@SpringBootTest
@Slf4j
@ -27,6 +30,11 @@ public class UserAccountMapperTest {
@Resource
private UserAccountMapper userAccountMapper;
/**
* T 1 get user by name.
*
* @throws JsonProcessingException the json processing exception
*/
@Test
public void t1_getUserByName() throws JsonProcessingException {
UserAccount user = userAccountMapper.getUserByName("admin");
@ -36,6 +44,11 @@ public class UserAccountMapperTest {
Assert.assertNotNull(user);
}
/**
* T 2 lock user.
*
* @throws JsonProcessingException the json processing exception
*/
@Test
public void t2_lockUser() throws JsonProcessingException {
userAccountMapper.lockUserAccount("admin");
@ -46,6 +59,11 @@ public class UserAccountMapperTest {
}
/**
* T 3 refresh login time.
*
* @throws JsonProcessingException the json processing exception
*/
@Test
public void t3_refreshLoginTime() throws JsonProcessingException {
userAccountMapper.refreshLoginTime("admin");
@ -55,6 +73,11 @@ public class UserAccountMapperTest {
log.info(objMapper.writerWithDefaultPrettyPrinter().writeValueAsString(user));
}
/**
* T 4 unlock user.
*
* @throws JsonProcessingException the json processing exception
*/
@Test
public void t4_unlockUser() throws JsonProcessingException {
userAccountMapper.unlockUserAccount("admin");