wang_xy пре 3 година
родитељ
комит
9ec2b7ab9c
46 измењених фајлова са 4220 додато и 6 уклоњено
  1. 7 0
      leiSP-admin/src/main/resources/static/zhnc/hls.min.js
  2. 18 0
      mybusiness/src/main/java/com/business/tools/CommonConfig.java
  3. 86 0
      mybusiness/src/main/java/com/business/zhnc/video/DhDomainResponseInfo.java
  4. 23 0
      mybusiness/src/main/java/com/business/zhnc/video/DhRealMonitorResponse.java
  5. 45 0
      mybusiness/src/main/java/com/business/zhnc/video/HlsVideoVo.java
  6. 79 0
      mybusiness/src/main/java/com/business/zhnc/video/MTSVideoDemo.java
  7. 40 0
      mybusiness/src/main/java/com/business/zhnc/video/RealTimeVideoVo.java
  8. 212 0
      mybusiness/src/main/java/com/business/zhnc/video/RealTimeVideoXo.java
  9. 91 0
      mybusiness/src/main/java/com/dahua/sdk/client/DHClientTool.java
  10. 762 0
      mybusiness/src/main/java/com/dahua/sdk/client/DahuaDomainService.java
  11. 36 0
      mybusiness/src/main/java/com/dahua/sdk/client/TestSignature.java
  12. 48 0
      mybusiness/src/main/java/com/dahua/sdk/client/bean/RSAPrivateBean.java
  13. 52 0
      mybusiness/src/main/java/com/dahua/sdk/client/bean/VersionInfoVo.java
  14. 125 0
      mybusiness/src/main/java/com/dahua/sdk/client/bean/alarm/AlarmMessage.java
  15. 38 0
      mybusiness/src/main/java/com/dahua/sdk/client/bean/alarm/AlarmMessageObj.java
  16. 95 0
      mybusiness/src/main/java/com/dahua/sdk/client/bean/hls/HLSBeanXo.java
  17. 30 0
      mybusiness/src/main/java/com/dahua/sdk/client/bean/hls/HLSXo.java
  18. 46 0
      mybusiness/src/main/java/com/dahua/sdk/client/bean/request/AuthorizePortInfo.java
  19. 109 0
      mybusiness/src/main/java/com/dahua/sdk/client/bean/request/AuthorizeRequest.java
  20. 74 0
      mybusiness/src/main/java/com/dahua/sdk/client/bean/request/MyRestTemplate.java
  21. 67 0
      mybusiness/src/main/java/com/dahua/sdk/client/bean/request/RequestData.java
  22. 115 0
      mybusiness/src/main/java/com/dahua/sdk/client/bean/request/RequestInfo.java
  23. 71 0
      mybusiness/src/main/java/com/dahua/sdk/client/bean/response/APIResponseInfo.java
  24. 59 0
      mybusiness/src/main/java/com/dahua/sdk/client/bean/response/AuthorizeFirstResponse.java
  25. 102 0
      mybusiness/src/main/java/com/dahua/sdk/client/bean/response/AuthorizeResponse.java
  26. 68 0
      mybusiness/src/main/java/com/dahua/sdk/client/bean/response/BaseResponse.java
  27. 83 0
      mybusiness/src/main/java/com/dahua/sdk/client/bean/response/DhDomainResponseInfo.java
  28. 50 0
      mybusiness/src/main/java/com/dahua/sdk/client/bean/response/MqAddressResponseInfo.java
  29. 79 0
      mybusiness/src/main/java/com/dahua/sdk/client/bean/response/ResponseInfo.java
  30. 169 0
      mybusiness/src/main/java/com/dahua/sdk/client/bean/response/SuccessResponse.java
  31. 135 0
      mybusiness/src/main/java/com/dahua/sdk/client/bean/xo/AuthorizeXo.java
  32. 34 0
      mybusiness/src/main/java/com/dahua/sdk/client/common/Constants.java
  33. 43 0
      mybusiness/src/main/java/com/dahua/sdk/client/common/DomainOfflineReasonEnum.java
  34. 40 0
      mybusiness/src/main/java/com/dahua/sdk/client/common/EncryptType.java
  35. 14 0
      mybusiness/src/main/java/com/dahua/sdk/client/common/SchemeEnum.java
  36. 8 0
      mybusiness/src/main/java/com/dahua/sdk/client/common/ServiceErrorCode.java
  37. 80 0
      mybusiness/src/main/java/com/dahua/sdk/client/convert/GsonUtils.java
  38. 54 0
      mybusiness/src/main/java/com/dahua/sdk/client/convert/JsonToObjectConvert.java
  39. 36 0
      mybusiness/src/main/java/com/dahua/sdk/client/convert/StringToObjectConvert.java
  40. 14 0
      mybusiness/src/main/java/com/dahua/sdk/client/main/Main.java
  41. 227 0
      mybusiness/src/main/java/com/dahua/sdk/client/util/EncryptionUtils.java
  42. 50 0
      mybusiness/src/main/java/com/dahua/sdk/client/util/HexUtil.java
  43. 135 0
      mybusiness/src/main/java/com/dahua/sdk/client/util/JsonParserUtils.java
  44. 406 0
      mybusiness/src/main/java/com/dahua/sdk/client/util/RsaUtil.java
  45. 65 0
      mybusiness/src/main/java/com/dahua/sdk/client/util/StringUtil.java
  46. 0 6
      mybusiness/src/main/resources/templates/ksh/ksh.html

Разлика између датотеке није приказан због своје велике величине
+ 7 - 0
leiSP-admin/src/main/resources/static/zhnc/hls.min.js


+ 18 - 0
mybusiness/src/main/java/com/business/tools/CommonConfig.java

@@ -0,0 +1,18 @@
+package com.business.tools;
+
+public class CommonConfig {
+//    public static String SERVER_IP = "10.38.108.92";
+    public static String SERVER_IP = "222.161.138.120";
+//    public static String SERVER_IP = "10.38.108.123";
+
+    public static int SERVER_PORT_HTTP = 80;
+
+    public static int SERVER_PORT_HTTPS = 4430;
+
+    public static String USERNAME = "system";
+
+    public static String PASSWORD = "system123";
+//    public static String PASSWORD = "admin123";
+
+    public static final String ftpPassword = "Admin@123";
+}

+ 86 - 0
mybusiness/src/main/java/com/business/zhnc/video/DhDomainResponseInfo.java

@@ -0,0 +1,86 @@
+package com.business.zhnc.video;
+
+
+import com.dahua.sdk.client.bean.response.ResponseInfo;
+
+public class DhDomainResponseInfo<T> {
+
+    private int code;
+
+    private String desc;
+
+    private T data;
+
+    public ResponseInfo getResponse() {
+        ResponseInfo responseInfo = new ResponseInfo();
+        responseInfo.setCode(code);
+        responseInfo.setDesc(desc);
+        responseInfo.setData(data);
+        return responseInfo;
+    }
+
+    public boolean isError() {
+        if (code == 1000) {
+            return false;
+        }
+        return true;
+    }
+
+    /**
+     * @return the code
+     */
+    public int getCode() {
+        return code;
+    }
+
+    /**
+     * @param code the code to set
+     */
+    public void setCode(int code) {
+        this.code = code;
+    }
+
+    /**
+     * @return the desc
+     */
+    public String getDesc() {
+        return desc;
+    }
+
+    /**
+     * @param desc the desc to set
+     */
+    public void setDesc(String desc) {
+        this.desc = desc;
+    }
+
+    /**
+     * @return the data
+     */
+    public T getData() {
+        return data;
+    }
+
+    /**
+     * @param data the data to set
+     */
+    public void setData(T data) {
+        this.data = data;
+    }
+
+    /* (non-Javadoc)
+     * @see java.lang.Object#toString()
+     */
+    @Override
+    public String toString() {
+        StringBuilder builder = new StringBuilder();
+        builder.append("DomainResponseInfo [code=");
+        builder.append(code);
+        builder.append("\n, data=");
+        builder.append(data);
+        builder.append("\n, desc=");
+        builder.append(desc);
+        builder.append("\n]");
+        return builder.toString();
+    }
+}

+ 23 - 0
mybusiness/src/main/java/com/business/zhnc/video/DhRealMonitorResponse.java

@@ -0,0 +1,23 @@
+package com.business.zhnc.video;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+
+/**
+ * 实时视频的参数
+ * @author 杨健
+ * @date 2018年5月7日
+ * @since 7.02
+ */
+@JsonIgnoreProperties(ignoreUnknown=true)
+public class DhRealMonitorResponse extends RealTimeVideoVo {
+
+    private static final long serialVersionUID = -2778870120660414370L;
+
+    /* (non-Jsdoc)
+     * @see java.lang.Object#toString()
+     */
+    @Override
+    public String toString() {
+        return super.toString();
+    }
+}

+ 45 - 0
mybusiness/src/main/java/com/business/zhnc/video/HlsVideoVo.java

@@ -0,0 +1,45 @@
+package com.business.zhnc.video;
+
+import java.io.Serializable;
+import java.lang.reflect.Array;
+
+/**
+ * @author wang_xy
+ * @description
+ * @Version 1.0
+ * @params
+ * @return
+ * @since 2022/7/15 14:23
+ */
+public class HlsVideoVo implements Serializable {
+
+    private String devicecode;//设备编号
+
+    private String chnSeq;//通道序号,如果ipc在nvr中,只需要输入对应的通道号就行
+
+    private String streamType;//码流类型 1-主码流,2-辅码流;3-三码流
+
+    public String getDevicecode() {
+        return devicecode;
+    }
+
+    public void setDevicecode(String devicecode) {
+        this.devicecode = devicecode;
+    }
+
+    public String getChnSeq() {
+        return chnSeq;
+    }
+
+    public void setChnSeq(String chnSeq) {
+        this.chnSeq = chnSeq;
+    }
+
+    public String getStreamType() {
+        return streamType;
+    }
+
+    public void setStreamType(String streamType) {
+        this.streamType = streamType;
+    }
+}

+ 79 - 0
mybusiness/src/main/java/com/business/zhnc/video/MTSVideoDemo.java

@@ -0,0 +1,79 @@
+package com.business.zhnc.video;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.business.tools.CommonConfig;
+import com.dahua.sdk.client.DHClientTool;
+import com.dahua.sdk.client.DahuaDomainService;
+import com.dahua.sdk.client.common.SchemeEnum;
+import com.google.gson.reflect.TypeToken;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+import org.springframework.stereotype.Service;
+import org.springframework.web.client.RestClientException;
+
+import java.util.HashMap;
+import java.util.Map;
+
+
+/**
+ * 实时预览 demo
+ */
+@Service
+public class MTSVideoDemo {
+
+    static DahuaDomainService service=DHClientTool.createService(SchemeEnum.HTTPS, CommonConfig.SERVER_IP, CommonConfig.SERVER_PORT_HTTPS, CommonConfig.USERNAME, CommonConfig.PASSWORD);
+
+    /**
+     * 获取实时预览流路径
+     * @param xo
+     * @return
+     */
+    public static Object startVideo(JSONObject xo) {
+
+        //TODO 是否已经连接到 平台
+        Map<String, JSONObject> request = new HashMap<String, JSONObject>();
+        request.put("data", xo);
+        System.out.println(xo.toString());
+
+        String responseStr = "";
+
+        try {
+            responseStr = service.postForObject("/admin/API/hls/getLiveUrl", request);
+//            responseStr = service.postForObject("/admin/API/DMS/Ptz/OperateDirect", request);
+        } catch(RestClientException e) {
+            System.out.println("realmonitor failed, error: "+e.getMessage());
+            return null;
+        } catch(Exception e) {
+            System.out.println("realmonitor failed, error: "+e.getMessage());
+            return null;
+        }
+        return responseStr;
+    }
+
+    /**
+     * 获取实时预览流路径
+     * @param xo
+     * @return
+     */
+    public static Object operateDirect(JSONObject xo) {
+
+        //TODO 是否已经连接到 平台
+        Map<String, JSONObject> request = new HashMap<String, JSONObject>();
+        request.put("data", xo);
+        System.out.println(xo.toString());
+
+        String responseStr = "";
+
+        try {
+            responseStr = service.postForObject("/admin/API/DMS/Ptz/OperateDirect", request);
+        } catch(RestClientException e) {
+            System.out.println("realmonitor failed, error: "+e.getMessage());
+            return null;
+        } catch(Exception e) {
+            System.out.println("realmonitor failed, error: "+e.getMessage());
+            return null;
+        }
+        return responseStr;
+    }
+}

+ 40 - 0
mybusiness/src/main/java/com/business/zhnc/video/RealTimeVideoVo.java

@@ -0,0 +1,40 @@
+package com.business.zhnc.video;
+
+import java.io.Serializable;
+
+/**
+ * 实时视频信息
+ * RealTimeVideoVo
+ * @author	张定红
+ * @date	2016-12-10
+ */
+public class RealTimeVideoVo implements Serializable {
+
+	/**
+	 * serialVersionUID
+	 */
+	private static final long serialVersionUID = -3317984892221838524L;
+
+	private String urls;		//视频流地址
+
+	public String getUrls() {
+		return urls;
+	}
+
+	public void setUrls(String urls) {
+		this.urls = urls;
+	}
+
+	/* (non-Javadoc)
+	 * @see java.lang.Object#toString()
+	 */
+	@Override
+	public String toString() {
+		StringBuilder builder = new StringBuilder();
+		builder.append("RealTimeVideoVo [urls=");
+		builder.append(urls);
+		builder.append("\n]");
+		return builder.toString();
+	}
+
+}

+ 212 - 0
mybusiness/src/main/java/com/business/zhnc/video/RealTimeVideoXo.java

@@ -0,0 +1,212 @@
+package com.business.zhnc.video;
+
+
+import com.dahua.sdk.client.bean.request.RequestData;
+
+/**
+ * 实时视频信息
+ * RealTimeVideoXo
+ * @author	张定红
+ * @date	2016-12-10
+ */
+public class RealTimeVideoXo extends RequestData {
+
+	/**
+	 * serialVersionUID
+	 */
+	private static final long serialVersionUID = -6809243182640561259L;
+
+	private String channelId;	//视频通道编码
+
+	private String dataType;	//视频类型:1=视频, 2=音频, 3=音视频
+
+	private String streamType;	//码流类型:1=主码流, 2=辅码流
+
+	private String extend;		//扩展数据
+
+	private String planId;		//录像计划ID
+
+	private String trackId;		//轨道ID
+
+	private String session;		//转发会话ID
+
+	private String operateType;	//操作类型:1=锁定, 2=解锁
+
+	private String keyCode;     //键盘码
+
+	private String enableRtsps; //是否启用RTSPS,空或0禁用,1启用
+
+	/**
+	 * @return the channelId
+	 */
+	public String getChannelId() {
+		return channelId;
+	}
+
+	/**
+	 * @param channelId the channelId to set
+	 */
+	public void setChannelId(String channelId) {
+		this.channelId = channelId;
+	}
+
+	/**
+	 * @return the dataType
+	 */
+	public String getDataType() {
+		return dataType;
+	}
+
+	/**
+	 * @param dataType the dataType to set
+	 */
+	public void setDataType(String dataType) {
+		this.dataType = dataType;
+	}
+
+	/**
+	 * @return the streamType
+	 */
+	public String getStreamType() {
+		return streamType;
+	}
+
+	/**
+	 * @param streamType the streamType to set
+	 */
+	public void setStreamType(String streamType) {
+		this.streamType = streamType;
+	}
+
+	/**
+	 * @return the extend
+	 */
+	public String getExtend() {
+		return extend;
+	}
+
+	/**
+	 * @param extend the extend to set
+	 */
+	public void setExtend(String extend) {
+		this.extend = extend;
+	}
+
+	/**
+	 * @return the planId
+	 */
+	public String getPlanId() {
+		return planId;
+	}
+
+	/**
+	 * @param planId the planId to set
+	 */
+	public void setPlanId(String planId) {
+		this.planId = planId;
+	}
+
+	/**
+	 * @return the trackId
+	 */
+	public String getTrackId() {
+		return trackId;
+	}
+
+	/**
+	 * @param trackId the trackId to set
+	 */
+	public void setTrackId(String trackId) {
+		this.trackId = trackId;
+	}
+
+	/**
+	 * @return the session
+	 */
+	@Override
+    public String getSession() {
+		return session;
+	}
+
+	/**
+	 * @param session the session to set
+	 */
+	@Override
+    public void setSession(String session) {
+		this.session = session;
+	}
+
+	/**
+	 * @return the operateType
+	 */
+	public String getOperateType() {
+		return operateType;
+	}
+
+	/**
+	 * @param operateType the operateType to set
+	 */
+	public void setOperateType(String operateType) {
+		this.operateType = operateType;
+	}
+
+	/**
+	 * @return the keyCode
+	 */
+	public String getKeyCode() {
+		return keyCode;
+	}
+
+	/**
+	 * @param keyCode the keyCode to set
+	 */
+	public void setKeyCode(String keyCode) {
+		this.keyCode = keyCode;
+	}
+
+	public String getEnableRtsps() {
+		return enableRtsps;
+	}
+
+	public void setEnableRtsps(String enableRtsps) {
+		this.enableRtsps = enableRtsps;
+	}
+
+	public RealTimeVideoXo setDefault(){
+		this.setKeyCode("");
+		this.setPlanId("");
+		this.setExtend("");
+		this.setTrackId("");
+		return this;
+	}
+	/* (non-Javadoc)
+	 * @see java.lang.Object#toString()
+	 */
+	@Override
+	public String toString() {
+		StringBuilder builder = new StringBuilder();
+		builder.append("RealTimeVideoXo [channelId=");
+		builder.append(channelId);
+		builder.append("\n, dataType=");
+		builder.append(dataType);
+		builder.append("\n, extend=");
+		builder.append(extend);
+		builder.append("\n, operateType=");
+		builder.append(operateType);
+		builder.append("\n, planId=");
+		builder.append(planId);
+		builder.append("\n, session=");
+		builder.append(session);
+		builder.append("\n, streamType=");
+		builder.append(streamType);
+		builder.append("\n, trackId=");
+		builder.append(trackId);
+		builder.append("\n, keyCode=");
+		builder.append(keyCode);
+		builder.append("\n, enableRtsps=");
+		builder.append(enableRtsps);
+		builder.append("]");
+		return builder.toString();
+	}
+
+}

+ 91 - 0
mybusiness/src/main/java/com/dahua/sdk/client/DHClientTool.java

@@ -0,0 +1,91 @@
+package com.dahua.sdk.client;
+
+import com.dahua.sdk.client.bean.response.ResponseInfo;
+import com.dahua.sdk.client.common.SchemeEnum;
+import com.dahua.sdk.client.common.ServiceErrorCode;
+import com.dahua.sdk.client.util.HexUtil;
+import org.springframework.stereotype.Component;
+
+import javax.crypto.Cipher;
+import javax.crypto.SecretKey;
+import javax.crypto.spec.SecretKeySpec;
+
+public class DHClientTool {
+    public static DahuaDomainService createService(SchemeEnum scheme,
+                                     String serverIp,
+                                     int serverPort,
+                                     String username,
+                                     String password){
+
+
+        DahuaDomainService service = new DahuaDomainService(scheme, serverIp, serverPort, username, password);
+
+        int ret = service.init();
+        if (ServiceErrorCode.SUCCESS != ret) {
+            return null;
+        }
+
+        service.start();
+
+        return service;
+    }
+
+//    public static void main(String[] args) {
+//        DahuaDomainService service = createService(SchemeEnum.HTTP, "10.35.183.104",
+//                80, "system", "admin1234567");
+//
+//        while(true) {
+//            try {
+//                Thread.sleep(3 * 1000);
+//            } catch (InterruptedException e) {
+//                e.printStackTrace();
+//            }
+//            ResponseInfo hls = service.getHls();
+//            System.out.println(hls);
+//        }
+//    }
+
+//    public static void main(String[] args) {
+//        String encPwd = "658334a990787d7794102d24f40a2668";
+//        String AES_KEY = "4rfvgy7UJMko0pqa";
+//        String mqPassword = decryptWithAES(encPwd, AES_KEY);
+//        System.out.println(mqPassword);
+//    }
+//
+//    public static String decryptWithAES(String content, String key) {
+//        try {
+//            SecretKey keySpec = new SecretKeySpec(key.getBytes("UTF-8"), EncryptType.AES.getType());
+//            Cipher cipher = Cipher.getInstance(EncryptType.AES_ECB_PKCS5.getType());
+//            cipher.init(Cipher.DECRYPT_MODE, keySpec);
+//            byte[] bytes = cipher.doFinal(HexUtil.hexStringToBytes(content.toUpperCase()));
+//            return new String(bytes, "UTF-8");
+//        } catch (RuntimeException e) {
+//            return content;
+//        } catch (Exception e) {
+//            return content;
+//        }
+//    }
+//
+//    enum EncryptType {
+//
+//        MD5("MD5"),
+//        SSL("SSL"),
+//        TLS("TLS"),
+//        SHA512("SHA-512"),
+//        SHA256("SHA-256"),
+//        AES("AES"),
+//        AES_ECB_PKCS5("AES/ECB/PKCS5Padding");
+//
+//        private String type;
+//
+//        private EncryptType(String type) {
+//            this.type = type;
+//        }
+//
+//        public String getType() {
+//            return type;
+//        }
+//
+//    }
+
+}

+ 762 - 0
mybusiness/src/main/java/com/dahua/sdk/client/DahuaDomainService.java

@@ -0,0 +1,762 @@
+package com.dahua.sdk.client;
+
+import com.dahua.sdk.client.bean.RSAPrivateBean;
+import com.dahua.sdk.client.bean.hls.HLSBeanXo;
+import com.dahua.sdk.client.bean.hls.HLSXo;
+import com.dahua.sdk.client.bean.request.AuthorizeRequest;
+import com.dahua.sdk.client.bean.request.MyRestTemplate;
+import com.dahua.sdk.client.bean.response.*;
+import com.dahua.sdk.client.bean.xo.AuthorizeXo;
+import com.dahua.sdk.client.common.Constants;
+import com.dahua.sdk.client.common.DomainOfflineReasonEnum;
+import com.dahua.sdk.client.common.SchemeEnum;
+import com.dahua.sdk.client.common.ServiceErrorCode;
+import com.dahua.sdk.client.convert.JsonToObjectConvert;
+import com.dahua.sdk.client.util.*;
+import com.google.gson.reflect.TypeToken;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.http.HttpEntity;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.MediaType;
+import org.springframework.http.client.SimpleClientHttpRequestFactory;
+import org.springframework.stereotype.Component;
+import org.springframework.stereotype.Service;
+import org.springframework.web.client.HttpClientErrorException;
+import org.springframework.web.client.RestClientException;
+import org.springframework.web.client.RestTemplate;
+
+import javax.net.ssl.*;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.security.SecureRandom;
+import java.security.cert.CertificateExpiredException;
+import java.security.cert.CertificateNotYetValidException;
+import java.security.cert.X509Certificate;
+import java.security.interfaces.RSAPrivateKey;
+import java.security.interfaces.RSAPublicKey;
+import java.util.*;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.TimeUnit;
+
+
+public class DahuaDomainService {
+//    protected static Logger logger = Logger.getLogger(DahuaDomainService.class);
+
+    protected SchemeEnum scheme;
+    protected String serverIp;
+
+    protected String clientIp;
+
+    protected int serverPort;
+
+    protected String username;
+
+    protected String password;
+
+    protected String passSalt;
+    protected String token;
+
+    protected String userId;
+
+    protected int KEEPALIVE_INTERVAL_TIME = 60;//保活间隔时间
+
+    protected int keepaliveFailedCount = 1;
+
+    protected Date tokenTime = new Date();
+
+    protected int tokenRate = 1800 - 300;  // 默认token更新频率30分钟,平台提早几分钟去更新
+
+    protected ExecutorService bossExecutor = null;
+
+    protected volatile boolean isOnline = false;
+
+    protected volatile boolean isFinished = false;
+
+    protected RestTemplate restTemplate;
+
+    protected HttpHeaders headers;
+
+    protected volatile boolean started =false;
+
+    //mq 相关配置信息
+    private String mqAddress;
+
+    private String mqUserName;
+
+    private String mqPassword;
+
+    protected JsonToObjectConvert jsonConvert = JsonToObjectConvert.getInstance();
+
+    public DahuaDomainService(SchemeEnum scheme, String serverIp, int serverPort, String username, String password) {
+        this.scheme = scheme;
+        this.serverIp = serverIp;
+        this.serverPort = serverPort;
+        this.username = username;
+        this.password = password;
+    }
+
+    public int init() {
+
+        //TODO 参数检查
+
+        //设置请求头
+        headers = new HttpHeaders();
+        headers.setContentType(MediaType.parseMediaType("application/json;charset=utf-8"));
+
+        //初始化 restTemplate
+        SimpleClientHttpRequestFactory requestFactory = new SimpleClientHttpRequestFactory();
+        requestFactory.setConnectTimeout(1 * 1000);
+        requestFactory.setReadTimeout(30 * 1000);
+        requestFactory.setOutputStreaming(false);
+        this.restTemplate = new MyRestTemplate(requestFactory);
+
+        //openHttps
+        try {
+            openHttps();
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return ServiceErrorCode.SUCCESS;
+    }
+
+    /**
+     * 解决java.security.cert.CertificateException: No subject alternative names present
+     * 系统刚起来打开一次即可,放在init中为了利用domain的ip和port
+     * @throws Exception
+     * @since 7.02
+     */
+    public void openHttps() throws Exception {
+        final String[] VERIFY_HOST_NAME_ARRAY = new String[] {};
+
+        HttpsURLConnection.setDefaultHostnameVerifier(new HostnameVerifier() {
+            @Override
+            public boolean verify(String hostname, SSLSession arg1) {
+                if (StringUtils.isEmpty(hostname)) {
+                    return false;
+                }
+                return !Arrays.asList(VERIFY_HOST_NAME_ARRAY).contains(hostname);
+            }
+        });
+        SSLContext sslContext = SSLContext.getInstance("TLSv1.2");
+        sslContext.init(null, trusTCerts, new SecureRandom());
+        HttpsURLConnection.setDefaultSSLSocketFactory(sslContext.getSocketFactory());
+        // 以下可以不需要
+        URL url = new URL(buildUrl("admin"));
+        HttpURLConnection connection = (HttpURLConnection) url.openConnection();
+        connection.setRequestMethod("GET");
+        connection.setConnectTimeout(150);
+        connection.setReadTimeout(50);
+    }
+
+    /**
+     * 启动登录和心跳
+     * @return
+     * @since 7.02
+     */
+    public int start() {
+        if (started) {
+//            logger.info("domain service already started"+commonLogInfo());
+            System.out.println("domain service already started"+commonLogInfo());
+            return ServiceErrorCode.SUCCESS;
+        }
+        // 初始化主线程,主要用于登录、重连和心跳
+        bossExecutor = Executors.newSingleThreadExecutor();
+        bossExecutor.submit(new Runnable() {
+            @Override
+            public void run() {
+                while (!Thread.interrupted()) {
+                    if (!isOnline) {
+                        int ret = ServiceErrorCode.SUCCESS;
+                        try {
+                            ret = authorize();
+                        } catch (Exception e) {
+                            System.out.println("authorize error: "+e.getMessage());
+                            ret = ServiceErrorCode.FAIL;
+                        }
+
+                        try {
+                            TimeUnit.SECONDS.sleep(ret == ServiceErrorCode.SUCCESS ? KEEPALIVE_INTERVAL_TIME : 10);
+                        } catch (InterruptedException e) {
+                            System.out.println("sleep interrupted");
+                            Thread.currentThread().interrupt();
+                        }
+                    } else {
+                        int ret;
+                        try {
+                            ret = keepalive();
+                            updateToken();
+                        } catch (Exception e) {
+                            System.out.println("keeplive error: "+e.getMessage());
+                            ret = ServiceErrorCode.FAIL;
+                        }
+
+                        if (ret != ServiceErrorCode.SUCCESS) {
+                            try {
+                                TimeUnit.SECONDS.sleep(10);
+                            } catch (InterruptedException e) {
+                                System.out.println("sleep interrupted");
+                                Thread.currentThread().interrupt();
+                            }
+                            continue;
+                        }
+                        try {
+                            TimeUnit.SECONDS.sleep(KEEPALIVE_INTERVAL_TIME);
+                        } catch (InterruptedException e) {
+                            System.out.println("sleep interrupted");
+                            Thread.currentThread().interrupt();
+                        }
+                    }
+                }
+            }
+        });
+        started = true;
+        return ServiceErrorCode.SUCCESS;
+    }
+
+    /**
+     * 登录
+     * @return 0-成功
+     * @since 7.02
+     */
+    public int authorize() {
+        AuthorizeRequest request = new AuthorizeRequest();
+        request.setUserName(username);
+        request.setClientType("WINPC_V1");
+        request.setIpAddress(serverIp);
+        AuthorizeFirstResponse firstResponse = null;
+        try {
+            restTemplate.postForObject(buildUrl("/admin/API/accounts/authorize"), request, String.class);
+        } catch(RestClientException e) {
+            // 防止登录一个失败的请求导致等待的过程中(连接超时设置10秒)新的域已经登录成功,超时候会将成功的域改成离线
+            if (!started) {
+                System.out.println(String.format("destroy when authorize%s", commonLogInfo()));
+                return ServiceErrorCode.FAIL;
+            }
+            if (e instanceof HttpClientErrorException) {
+                HttpClientErrorException response = (HttpClientErrorException) e;
+                if (401 == response.getStatusCode().value()) {
+                    String body = response.getResponseBodyAsString();
+                    firstResponse = (AuthorizeFirstResponse) jsonConvert.convert(body, AuthorizeFirstResponse.class);
+                } else {
+                    System.out.println("login domain failed, error: "+e.getMessage());
+                    return ServiceErrorCode.FAIL;
+                }
+            } else {
+                System.out.println("login domain failed, error: "+e.getMessage());
+                // 置为离线
+                return ServiceErrorCode.FAIL;
+            }
+        } catch (Exception e) {
+            System.out.println("login domain failed, error: "+e.getMessage());
+            // 置为离线
+            return ServiceErrorCode.FAIL;
+        }
+
+        if (null == firstResponse) {
+            System.out.println("login to domain failed, response is null");
+            // 置为离线
+            return ServiceErrorCode.FAIL;
+        }
+
+        String pass_temp = "";
+        try {
+            pass_temp = EncryptionUtils.encryptWithMD5(EncryptionUtils.encryptWithMD5(username + EncryptionUtils.encryptWithMD5(password)));
+        }catch (Exception e){
+            System.out.println(e);
+        }
+        String encrypted_passwd = EncryptionUtils.encryptWithMD5(String.format("%s:%s:%s", username, firstResponse.getRealm(), pass_temp));
+        String signature = EncryptionUtils.encryptWithMD5(String.format("%s:%s", encrypted_passwd, firstResponse.getRandomKey()));
+        passSalt = firstResponse.getRealm();
+        if (null == signature) {
+            System.out.println("encrypt password failed, password is null");
+            // 置为离线
+            return ServiceErrorCode.FAIL;
+        }
+
+        request.setEncryptType(firstResponse.getEncryptType());
+        request.setRandomKey(firstResponse.getRandomKey());
+        request.setSignature(signature);
+        RSAPublicKey rsaPublicKey = null;
+
+        try {
+            rsaPublicKey = RsaUtil.generateRandomKey();
+        } catch (Exception e) {
+            System.out.println("generate rsa public key error" + e);
+        }
+        RSAPrivateKey rsaPrivateKey = ((RSAPrivateBean) RsaUtil.getKeyPairMap().get(Base64.getEncoder().encodeToString(rsaPublicKey.getEncoded()))).getRsaPrivateKey();
+        request.setPublicKey(Base64.getEncoder().encodeToString(rsaPublicKey.getEncoded()));
+
+        AuthorizeResponse authResponse;
+        try {
+            authResponse = restTemplate.postForObject(buildUrl("/admin/API/accounts/authorize"), request, AuthorizeResponse.class);
+        } catch(RestClientException e) {
+            System.out.println("login domain failed, error: "+e.getMessage());
+            // 置为离线
+            return ServiceErrorCode.FAIL;
+        } catch(Exception e) {
+            System.out.println("login domain failed, error: "+e.getMessage());
+            // 置为离线
+            return ServiceErrorCode.FAIL;
+        }
+        if (null == authResponse) {
+            System.out.println("login to domain failed, response is null");
+            // 置为离线
+            return ServiceErrorCode.FAIL;
+        }
+        if (null != authResponse.getCode() && !"1000".equals(authResponse.getCode())) {
+            System.out.println(String.format("login to domain failed, code=%s, desc=%s%s", authResponse.getCode(), authResponse.getDesc()));
+            handleOffline(authResponse.getCode());
+            offlineHandle();
+            // 如果是用户名密码错误则无需再登录
+            if ("2001".equals(authResponse.getCode())) {
+                Thread.currentThread().interrupt();
+            }
+            return ServiceErrorCode.FAIL;
+        }
+        token = authResponse.getToken();
+        tokenTime = new Date();
+        userId = authResponse.getUserId();
+        String duration = authResponse.getDuration();
+        if (!StringUtil.isEmpty(duration) && StringUtil.isInteger(duration)) {
+            KEEPALIVE_INTERVAL_TIME = (int) Math.rint(Integer.parseInt(duration) * 3/4);
+        }
+        headers.remove("X-Subject-Token");
+        headers.add("X-Subject-Token", token);
+        keepaliveFailedCount = 1;
+        System.out.println("login to domain successfully");
+
+        // 登录成功之后立即做的事情
+        loginAfterSyncHandle();
+
+        String secretKey = authResponse.getSecretKey();
+        String secretVector = authResponse.getSecretVector();
+        try {
+            byte[] secretKeyBytes = Base64.getDecoder().decode(secretKey);
+            byte[] bytes = Base64.getDecoder().decode(secretVector);
+            secretKey = new String(RsaUtil.decryptByPrivateKey(secretKeyBytes, HexUtil.bytesToHexString(rsaPrivateKey.getEncoded())), Constants.ENCODING);
+            secretVector = new String(RsaUtil.decryptByPrivateKey(bytes, HexUtil.bytesToHexString(rsaPrivateKey.getEncoded())), Constants.ENCODING);
+        } catch (Exception e) {
+            System.out.println("get address failed, RSA decrypt error" + e);
+        }
+        authResponse.setSecretKey(secretKey);
+        authResponse.setSecretVector(secretVector);
+
+        isOnline = true;
+        // 置为在线
+
+        return ServiceErrorCode.SUCCESS;
+    }
+
+    /**
+     * 更新 token
+     */
+    protected void updateToken() {
+        long millis = System.currentTimeMillis() - tokenTime.getTime();
+        if (millis < (long)tokenRate * 1000) {
+            return;
+        }
+
+        Map<String, String> params = new HashMap<String, String>();
+
+        String encryptPass = EncryptionUtils.encryptWithMD5(username +":" + passSalt + ":" +
+                EncryptionUtils.encryptWithMD5( EncryptionUtils.encryptWithMD5(username +  EncryptionUtils.encryptWithMD5(password))));
+
+        params.put("signature", EncryptionUtils.encryptWithMD5(String.format("%s:%s", encryptPass, token)));
+        HttpEntity<Map<String, String>> request = new HttpEntity<Map<String, String>>(params, headers);
+        APIResponseInfo updateTokenResponse;
+        boolean updateTokenSuccess = false;
+        String newToken = null;
+        for (int i = 0; i < 3; i++) {
+            try {
+                updateTokenResponse = restTemplate.postForObject(buildUrl("/admin/API/accounts/updateToken"), request, APIResponseInfo.class);
+                updateTokenSuccess = true;
+                newToken = JsonParserUtils.getPrimitiveField(updateTokenResponse.getData().toString(), "token", String.class);
+                break;
+            } catch(Exception e) {
+                System.out.println("update token failed:" + e.getMessage());
+
+                try {
+                    TimeUnit.SECONDS.sleep(10);
+                } catch (InterruptedException e1) {
+                    System.out.println("sleep interrupted");
+                    Thread.currentThread().interrupt();
+                }
+
+                continue;
+            }
+        }
+
+        if (!updateTokenSuccess) {
+            offlineHandle();
+            System.out.println("updateToken failed");
+            return;
+        }
+
+        //logger.info("newtoken:" + newToken);
+        if (null != newToken) {
+            token = newToken;
+            tokenTime = new Date();
+            headers.remove("X-Subject-Token");
+            headers.add("X-Subject-Token", token);
+        }
+
+        return;
+    }
+
+    /**
+     * 心跳
+     * @return
+     * @since 7.02
+     */
+    protected int keepalive() {
+        Map<String, String> params = new HashMap<String, String>();
+        params.put("signature", "domain");
+        HttpEntity<Map<String, String>> request = new HttpEntity<Map<String, String>>(params, headers);
+        try {
+            //restTemplate.postForObject(buildUrl("/admin/API/accounts/keepalive"), request, String.class);
+            restTemplate.put(buildUrl("/admin/API/accounts/keepalive"), request, String.class);
+        } catch(RestClientException e) {
+            if (keepaliveFailedCount > 3) {
+                offlineHandle();
+                System.out.println("keepalive failed"+commonLogInfo()+", error: "+e.getMessage());
+                // 置为离线
+                return ServiceErrorCode.FAIL;
+            }
+            keepaliveFailedCount++;
+            return ServiceErrorCode.SUCCESS;
+        } catch(Exception e) {
+            if (keepaliveFailedCount > 3) {
+                offlineHandle();
+                System.out.println("keepalive failed"+commonLogInfo()+", error: "+e.getMessage());
+                // 置为离线
+                return ServiceErrorCode.FAIL;
+            }
+            keepaliveFailedCount++;
+            return ServiceErrorCode.SUCCESS;
+        }
+        keepaliveFailedCount = 1;
+        System.out.println("keepalive"+commonLogInfo());
+        return ServiceErrorCode.SUCCESS;
+    }
+
+    /**
+     * 登录成功之后同步处理的方法
+     *
+     * @since 7.02
+     */
+    public void loginAfterSyncHandle() {
+        //获取 mq 连接配置信息
+        getMqAddrInfo();
+    }
+
+    /**
+     * 获取MQ地址
+     *
+     * @since 7.02
+     */
+    @SuppressWarnings("unchecked")
+    public void getMqAddrInfo() {
+        Map<String, Object> params = new HashMap<String, Object>();
+//        params.put("data", null);
+        params.put("clientType", "WINPC_V1");
+        params.put("clientMac", "");
+        params.put("project", "PSDK");
+        params.put("method", "BRM.Config.GetMqConfig");
+        DhDomainResponseInfo<MqAddressResponseInfo> responseInfo = null;
+        DhDomainResponseInfo<SuccessResponse> aesResponseInfo = null;
+        RSAPublicKey rsaPublicKey = null;
+        try {
+            rsaPublicKey = RsaUtil.generateRandomKey();
+        } catch (Exception e) {
+            System.out.println("generate rsa public key error" + e);
+        }
+        if(StringUtil.isBlank(rsaPublicKey)){
+            System.out.println("generate rsa public key error");
+            return;
+        }
+        System.out.println("rsaPublicKey: "+ rsaPublicKey);
+        RSAPrivateKey rsaPrivateKey = ((RSAPrivateBean) RsaUtil.getKeyPairMap().get(Base64.getEncoder().encodeToString(rsaPublicKey.getEncoded()))).getRsaPrivateKey();
+        System.out.println("rsaPrivateKey: "+ rsaPrivateKey);
+        try {
+            String responseStr = restTemplate.postForObject(buildUrl(String.format("/admin/API/BRM/Config/GetMqConfig?token=%s", token)), params, String.class);
+            responseInfo = (DhDomainResponseInfo<MqAddressResponseInfo>) jsonConvert.convert(responseStr, new TypeToken<DhDomainResponseInfo<MqAddressResponseInfo>>(){}.getType());
+            AuthorizeXo authorizeXo = new AuthorizeXo();
+            authorizeXo.setPublicKey(Base64.getEncoder().encodeToString(rsaPublicKey.getEncoded()));
+            String aesResponseStr = restTemplate.postForObject(buildUrl(String.format("/admin/API/config/encrypt/key/generate?token=%s",token)),authorizeXo, String.class);
+            aesResponseInfo = (DhDomainResponseInfo<SuccessResponse>) jsonConvert.convert(aesResponseStr, new TypeToken<DhDomainResponseInfo<SuccessResponse>>(){}.getType());
+
+        } catch(RestClientException e) {
+            System.out.println("get mq address failed"+commonLogInfo()+", error: "+e.getMessage());
+            return;
+        } catch(Exception e) {
+            System.out.println("get mq address failed"+commonLogInfo()+", error: "+e.getMessage());
+            return;
+        }
+        if (1000 != responseInfo.getCode()) {
+            System.out.println(String.format("get mq address failed, code=%s, desc=%s%s", responseInfo.getCode(), responseInfo.getDesc(), commonLogInfo()));
+            return;
+        }
+        MqAddressResponseInfo mqAddressResponse = responseInfo.getData();
+        SuccessResponse aesResponse= aesResponseInfo.getData();
+        if (null == mqAddressResponse) {
+            System.out.println("get mq address failed, mqAddressResponse is null"+commonLogInfo());
+            return;
+        }
+        mqAddress = mqAddressResponse.getAddr();
+        mqUserName = mqAddressResponse.getUserName();
+
+        System.out.println("address: "+ mqAddress+ ";mqUserName: "+ mqUserName);
+        //获取aes秘钥和向量
+        String secretKey = aesResponse.getSecretKey();
+        String secretVector = aesResponse.getSecretVector();
+        System.out.println("secretKey:"+ secretKey+ ";secretVector: "+ secretVector);
+
+        System.out.println("$$$$ mqAddressResponse.getPassword() " + mqAddressResponse.getPassword());
+        try {
+            byte[] secretKeyBytes = Base64.getDecoder().decode(secretKey);
+            byte[] bytes = Base64.getDecoder().decode(secretVector);
+            secretKey = new String(RsaUtil.decryptByPrivateKey(secretKeyBytes,HexUtil.bytesToHexString(rsaPrivateKey.getEncoded())), Constants.ENCODING);
+            secretVector = new String(RsaUtil.decryptByPrivateKey(bytes, HexUtil.bytesToHexString(rsaPrivateKey.getEncoded())), Constants.ENCODING);
+        } catch (Exception e) {
+            System.out.println("get mq address failed, RSA decrypt error" + e);
+            e.printStackTrace();
+//            logger.error("get mq address failed, RSA decrypt error" + e);
+        }
+
+//        mqPassword = EncryptionUtils.decryptByAesCbc(mqAddressResponse.getPassword(), secretKey, secretVector);
+        mqPassword = EncryptionUtils.decryptByAesCbc(mqAddressResponse.getPassword(), secretKey, secretVector);
+        System.out.println(String.format("get mq address: %s", mqAddress));
+
+        System.out.println("$$$$ mq: " + mqAddress + " == " + mqUserName + " == " + mqPassword);
+    }
+
+    private void test1(){
+//        List<String> aesKeys = null;
+//        try {
+//            aesKeys = EncryptionUtils.getAesKey();
+//            String decryptPassWord = "";
+//            for (String aesKey : aesKeys) {
+//                decryptPassWord = EncryptionUtils.decryptByAesCbcGDPR(password, aesKey);
+//                if (StringUtils.isNotEmpty(decryptPassWord)) {
+//                    break;
+//                }
+//            }
+//            if (StringUtils.isNotEmpty(decryptPassWord)) {
+//                password = decryptPassWord;
+//            }
+//            logger.debug("mq用户名,gdpr解密成功:" + decryptPassWord);
+//        } catch (Exception e) {
+//            logger.error(e);
+//        }
+    }
+
+    private void handleOffline(String code) {
+        // 置为离线
+        int status;
+        if ("2001".equals(code)) {
+            status = DomainOfflineReasonEnum.USER_PASS_ERROR.getCode();
+        } else if ("2002".equals(code)) {
+            status = DomainOfflineReasonEnum.USER_LOCKED.getCode();
+        } else if ("2003".equals(code)) {
+            status = DomainOfflineReasonEnum.USER_DISABLED.getCode();
+        } else if ("2004".equals(code)) {
+            status = DomainOfflineReasonEnum.USER_LOGGED_IN.getCode();
+        } else if ("2005".equals(code)) {
+            status = DomainOfflineReasonEnum.USER_DATE_OVER.getCode();
+        } else if ("2006".equals(code)) {
+            status = DomainOfflineReasonEnum.USER_TIME_OVER.getCode();
+        } else if ("2155".equals(code)) {
+            status = DomainOfflineReasonEnum.USER_MAC_ERROR.getCode();
+        } else if ("2156".equals(code)) {
+            status = DomainOfflineReasonEnum.AD_LOGIN_CLOSE.getCode();
+        } else if ("2218".equals(code)) {
+            status = DomainOfflineReasonEnum.USER_LOCKED_SYS_UPGRADE.getCode();
+        } else {
+            status = DomainOfflineReasonEnum.CONNECT_EXCEPTION.getCode();
+        }
+        System.out.println("offline reason code: " + status);
+    }
+
+    /**
+     * 离线之后要做的事情
+     *
+     * @since 7.02
+     */
+    public void offlineHandle(){
+        isOnline = false;
+        isFinished = false;
+    }
+
+    protected String buildUrl(String url) {
+        StringBuilder str = new StringBuilder();
+        str.append(scheme.getScheme());
+        str.append(serverIp);
+        str.append(":");
+        str.append(serverPort);
+        str.append("/");
+        str.append(url);
+        return str.toString();
+    }
+
+    String buildUrlWithToken(String url) {
+        StringBuilder str = new StringBuilder();
+        str.append(scheme.getScheme());
+        str.append(serverIp);
+        str.append(":");
+        str.append(serverPort);
+        str.append("/");
+        str.append(url);
+        str.append("?token=" + token);
+        return str.toString();
+    }
+
+
+
+    /**
+     * 公共日志信息
+     * @return
+     * @since 7.02
+     */
+    protected String commonLogInfo() {
+        StringBuilder str = new StringBuilder();
+        str.append(", ip=");
+        str.append(serverIp);
+        str.append(":");
+        str.append(serverPort);
+        return str.toString();
+    }
+
+    public ResponseInfo getHls(){
+
+        /**
+         * {
+         *
+         * 		"hlsBeanXoList": [
+         *                        {
+         * 				"devicecode": "1000002",
+         * 				"unitSeq": "1",
+         * 				"chnSeq": "0",
+         * 				"recordSource": "2",
+         * 				"recordType": "1",
+         * 				"streamType": "1",
+         * 				"beginTime": "2020-06-19 00:00:00",
+         * 				"endTime": "2020-06-19 23:59:59"
+         *            }
+         * 		]
+         *
+         * }
+         */
+
+        Map<String, Object> params = new HashMap<>();
+        HLSXo hlsXo = new HLSXo();
+
+        HLSBeanXo hlsBeanXo = new HLSBeanXo();
+        hlsBeanXo.setDevicecode("1000000");
+        hlsBeanXo.setUnitSeq("1");
+        hlsBeanXo.setChnSeq("0");
+        hlsBeanXo.setRecordSource("2");
+        hlsBeanXo.setRecordType("1");
+        hlsBeanXo.setStreamType("1");
+        hlsBeanXo.setBeginTime("2020-07-01 00:00:00");
+        hlsBeanXo.setEndTime("2020-07-01 23:59:59");
+
+        List<HLSBeanXo> hlsBeanXoList = new ArrayList<>();
+        hlsBeanXoList.add(hlsBeanXo);
+
+        hlsXo.setHlsBeanXoList(hlsBeanXoList);
+
+        params.put("data", hlsXo);
+        HttpEntity<Map<String, Object>> request = new HttpEntity<>(params, headers);
+
+        ResponseInfo responseInfo = restTemplate.postForObject(buildUrlWithToken("/admin/API/hls/getLiveUrl"), request,
+                ResponseInfo.class);
+
+
+        return responseInfo;
+    }
+
+    /**
+     * HttpEntity 封装参数
+     * @param params
+     * @param <T>
+     * @return
+     */
+    public <T> HttpEntity<T>  getHttpEntity(T params){
+        HttpEntity<T> request = new HttpEntity<>(params, headers);
+        return request;
+    }
+
+    /**
+     *
+     * @param uri /admin/API/tree/devices
+     * @param request
+     * @return
+     */
+    public String postForObject(String uri, HttpEntity request){
+        String responseStr = restTemplate.postForObject(buildUrl(uri), // attach token
+                request,
+                String.class); //表示返回值类型
+        return responseStr;
+    }
+
+    public <T> String postForObject(String uri, Map<String, T> request){
+        String responseStr = restTemplate
+                .postForObject(buildUrlWithToken(uri), request, String.class);
+
+        return responseStr;
+    }
+
+    public JsonToObjectConvert getJsonConvert() {
+        return jsonConvert;
+    }
+
+    public String getMqUserName() {
+        return mqUserName;
+    }
+
+    public String getMqPassword() {
+        return mqPassword;
+    }
+
+    public String getMqAddress() {
+        return mqAddress;
+    }
+
+    /**
+     * 信任证书
+     */
+    static TrustManager[] trusTCerts = new TrustManager[] {
+            new X509TrustManager() {
+                @Override
+                public X509Certificate[] getAcceptedIssuers() {
+                    return new X509Certificate[]{};
+                }
+                @Override
+                public void checkServerTrusted(X509Certificate[] chain, String authType) {
+                    for (X509Certificate certificate : chain) {
+                        try {
+                            certificate.checkValidity();
+                        } catch (CertificateExpiredException e) {
+                            System.out.println("CertificateExpiredException " + e);
+                        } catch (CertificateNotYetValidException e) {
+                            System.out.println("CertificateNotYetValidException " + e);
+                        }
+                    }
+                }
+                @Override
+                public void checkClientTrusted(X509Certificate[] chain, String authType) {
+                    for (X509Certificate certificate : chain) {
+                        try {
+                            certificate.checkValidity();
+                        } catch (CertificateExpiredException e) {
+                            System.out.println("CertificateExpiredException " + e);
+                        } catch (CertificateNotYetValidException e) {
+                            System.out.println("CertificateNotYetValidException " + e);
+                        }
+                    }
+                }
+            }
+    };
+
+}

+ 36 - 0
mybusiness/src/main/java/com/dahua/sdk/client/TestSignature.java

@@ -0,0 +1,36 @@
+package com.dahua.sdk.client;
+
+import com.dahua.sdk.client.util.EncryptionUtils;
+
+/**
+ * 验证下签名
+ */
+public class TestSignature {
+
+    public static void main(String[] args) {
+        method1();
+    }
+
+    private static void method1(){
+        String realm = "f689ed8c43530d68bf7d6e95a62f7f87";
+        String randomKey = "b5069ea0c6834dfc";
+        String userName = "system";
+        String password = "Admin123";
+        String publicKey = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAg9CQU6Ar2kLNvZ2sF5fGKvdUAe/VnTzc8E1JNF0ZCHhYi4BFVv3sY2PpwoSRYtfCIGQl5UbuRcmsCaXXlVIqP2oj3F8sqIOkuaw3TQBrjnTOy3qoXLx6R5VOAZ7BT9uHWm1KfK2ivJOfBrMs2U4w4sSKJsqAWMNK6c187BuIByyBBGpkw5kvEbBz6hUx+oZXVPC+ypnajx5Fb37Q0+YRafyZ6R245dqcT34J1+2/TLChlP+O9d/46rFbtLTYEtOCQewHZ/b/ZA+ZSuUZNEQ6vpsArV0Jcd1FG2fB7BjnsDWKvbyLxW/6I38FtyNhWS6t3PDs0pQeYH7W1nucdUasCwIDAQAB";
+        //第一个tmp: e64b78fc3bc91bcbc7dc232ba8ec59e0
+        String tmp1 = EncryptionUtils.encryptWithMD5(password);
+        System.out.println("tmp1: "+ tmp1);
+        //第二个, 65bdebf33107fb50bacfd25960c3dc28
+        String tmp2 = EncryptionUtils.encryptWithMD5(userName+ tmp1);
+        System.out.println("tmp2: "+ tmp2);
+        //第三个, 929aade29b4fe40290e43148aca9dc4d
+        String tmp3 = EncryptionUtils.encryptWithMD5( tmp2);
+        System.out.println("tmp3: "+ tmp3);
+        //第四个,a168bfb677775befa9140b025216f5dc
+        String tmp4 = EncryptionUtils.encryptWithMD5( userName+":"+realm+":"+tmp3);
+        System.out.println("tmp4: "+ tmp4);
+        String signature = EncryptionUtils.encryptWithMD5(String.format("%s:%s", tmp4, randomKey));
+        //593dfa523846ebc8e5becc6cad981afe
+        System.out.println("signature: "+ signature);
+    }
+}

+ 48 - 0
mybusiness/src/main/java/com/dahua/sdk/client/bean/RSAPrivateBean.java

@@ -0,0 +1,48 @@
+/**
+ * *********************** 版权声明 ***********************************
+ * <p>
+ * 版权所有:浙江大华技术股份有限公司
+ * ©CopyRight DahuaTech 2018
+ * <p>
+ * *******************************************************************
+ */
+package com.dahua.sdk.client.bean;
+
+import java.security.interfaces.RSAPrivateKey;
+
+public class RSAPrivateBean {
+
+    private RSAPrivateKey rsaPrivateKey;
+
+    private Long timeStamp;
+
+    public RSAPrivateBean(RSAPrivateKey rsaPrivateKey, Long timeStamp) {
+        this.rsaPrivateKey = rsaPrivateKey;
+        this.timeStamp = timeStamp;
+    }
+
+    public RSAPrivateKey getRsaPrivateKey() {
+        return rsaPrivateKey;
+    }
+
+    public void setRsaPrivateKey(RSAPrivateKey rsaPrivateKey) {
+        this.rsaPrivateKey = rsaPrivateKey;
+    }
+
+    public Long getTimeStamp() {
+        return timeStamp;
+    }
+
+    public void setTimeStamp(Long timeStamp) {
+        this.timeStamp = timeStamp;
+    }
+
+    @Override
+    public String toString() {
+        final StringBuilder sb = new StringBuilder("RSAPrivateBean{");
+        sb.append("rsaPrivateKey=").append(rsaPrivateKey);
+        sb.append(", timeStamp=").append(timeStamp);
+        sb.append('}');
+        return sb.toString();
+    }
+}

+ 52 - 0
mybusiness/src/main/java/com/dahua/sdk/client/bean/VersionInfoVo.java

@@ -0,0 +1,52 @@
+/**
+ * *********************** 版权声明 ***********************************
+ * <p>
+ * 版权所有:浙江大华技术股份有限公司
+ * ©CopyRight DahuaTech 2017
+ * <p>
+ * *******************************************************************
+ */
+package com.dahua.sdk.client.bean;
+
+import java.io.Serializable;
+
+/**
+ * @author 26803
+ * @version Ver 7.0
+ * @since Ver 7.0
+ * @Date 2017/12/25
+ *
+ */
+public class VersionInfoVo implements Serializable {
+    
+    private static final long serialVersionUID = 6881581586473047763L;
+    
+    private String lastVersion;
+    
+    private String updateUrl;
+    
+    public String getLastVersion() {
+        return lastVersion;
+    }
+    
+    public void setLastVersion(String lastVersion) {
+        this.lastVersion = lastVersion;
+    }
+    
+    public String getUpdateUrl() {
+        return updateUrl;
+    }
+    
+    public void setUpdateUrl(String updateUrl) {
+        this.updateUrl = updateUrl;
+    }
+    
+    @Override
+    public String toString() {
+        final StringBuilder sb = new StringBuilder("VersionInfoVo{");
+        sb.append("lastVersion='").append(lastVersion).append('\'');
+        sb.append(", updateUrl='").append(updateUrl).append('\'');
+        sb.append('}');
+        return sb.toString();
+    }
+}

+ 125 - 0
mybusiness/src/main/java/com/dahua/sdk/client/bean/alarm/AlarmMessage.java

@@ -0,0 +1,125 @@
+package com.dahua.sdk.client.bean.alarm;
+
+public class AlarmMessage {
+
+    private String deviceCode;
+
+    private Integer channelSeq;
+
+    private Integer unitType;
+
+    private Integer unitSeq;
+
+    private String nodeType;
+
+    private String nodeCode;
+
+    private String alarmCode;
+
+    private String alarmType;
+
+    private String alarmPicture;
+
+    private String alarmSourceName;
+
+    private String gpsX;
+
+    private String gpsY;
+
+
+    public String getDeviceCode() {
+        return deviceCode;
+    }
+
+    public void setDeviceCode(String deviceCode) {
+        this.deviceCode = deviceCode;
+    }
+
+    public Integer getChannelSeq() {
+        return channelSeq;
+    }
+
+    public void setChannelSeq(Integer channelSeq) {
+        this.channelSeq = channelSeq;
+    }
+
+    public Integer getUnitType() {
+        return unitType;
+    }
+
+    public void setUnitType(Integer unitType) {
+        this.unitType = unitType;
+    }
+
+    public Integer getUnitSeq() {
+        return unitSeq;
+    }
+
+    public void setUnitSeq(Integer unitSeq) {
+        this.unitSeq = unitSeq;
+    }
+
+    public String getNodeType() {
+        return nodeType;
+    }
+
+    public void setNodeType(String nodeType) {
+        this.nodeType = nodeType;
+    }
+
+    public String getNodeCode() {
+        return nodeCode;
+    }
+
+    public void setNodeCode(String nodeCode) {
+        this.nodeCode = nodeCode;
+    }
+
+    public String getAlarmCode() {
+        return alarmCode;
+    }
+
+    public void setAlarmCode(String alarmCode) {
+        this.alarmCode = alarmCode;
+    }
+
+    public String getAlarmType() {
+        return alarmType;
+    }
+
+    public void setAlarmType(String alarmType) {
+        this.alarmType = alarmType;
+    }
+
+    public String getAlarmPicture() {
+        return alarmPicture;
+    }
+
+    public void setAlarmPicture(String alarmPicture) {
+        this.alarmPicture = alarmPicture;
+    }
+
+    public String getAlarmSourceName() {
+        return alarmSourceName;
+    }
+
+    public void setAlarmSourceName(String alarmSourceName) {
+        this.alarmSourceName = alarmSourceName;
+    }
+
+    public String getGpsX() {
+        return gpsX;
+    }
+
+    public void setGpsX(String gpsX) {
+        this.gpsX = gpsX;
+    }
+
+    public String getGpsY() {
+        return gpsY;
+    }
+
+    public void setGpsY(String gpsY) {
+        this.gpsY = gpsY;
+    }
+}

+ 38 - 0
mybusiness/src/main/java/com/dahua/sdk/client/bean/alarm/AlarmMessageObj.java

@@ -0,0 +1,38 @@
+package com.dahua.sdk.client.bean.alarm;
+
+/**
+ * 报警消息
+ */
+public class AlarmMessageObj {
+
+    private String method ;
+    /**
+     * 报警消息体, 比如秸秆
+     */
+    private AlarmMessage info;
+
+    public String getMethod() {
+        return method;
+    }
+
+    public void setMethod(String method) {
+        this.method = method;
+    }
+
+    public AlarmMessage getInfo() {
+        return info;
+    }
+
+    public void setInfo(AlarmMessage info) {
+        this.info = info;
+    }
+
+    @Override
+    public String toString() {
+        final StringBuffer sb = new StringBuffer("AlarmMessageObj{");
+        sb.append("method='").append(method).append('\'');
+        sb.append(", info=").append(info);
+        sb.append('}');
+        return sb.toString();
+    }
+}

+ 95 - 0
mybusiness/src/main/java/com/dahua/sdk/client/bean/hls/HLSBeanXo.java

@@ -0,0 +1,95 @@
+package com.dahua.sdk.client.bean.hls;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+
+import java.io.Serializable;
+
+@JsonIgnoreProperties(ignoreUnknown=true)
+public class HLSBeanXo implements Serializable{
+
+	private static final long serialVersionUID = 1L;
+    
+	private  String devicecode;
+	
+    private String unitSeq;
+	
+	private String chnSeq;
+	
+	private String streamType;//码流类型
+	
+	private String beginTime;
+	
+	private String endTime;
+	
+	private String recordSource;
+	
+	private String recordType;
+	
+	public String getRecordSource() {
+		return recordSource;
+	}
+
+	public void setRecordSource(String recordSource) {
+		this.recordSource = recordSource;
+	}
+
+	public String getRecordType() {
+		return recordType;
+	}
+
+	public void setRecordType(String recordType) {
+		this.recordType = recordType;
+	}
+	
+	public String getBeginTime() {
+		return beginTime;
+	}
+
+	public void setBeginTime(String beginTime) {
+		this.beginTime = beginTime;
+	}
+
+	public String getEndTime() {
+		return endTime;
+	}
+
+	public void setEndTime(String endTime) {
+		this.endTime = endTime;
+	}
+	
+	public String getDevicecode() {
+		return devicecode;
+	}
+
+	public void setDevicecode(String devicecode) {
+		this.devicecode = devicecode;
+	}
+
+	public String getUnitSeq() {
+		return unitSeq;
+	}
+
+	public void setUnitSeq(String unitSeq) {
+		this.unitSeq = unitSeq;
+	}
+
+	public String getChnSeq() {
+		return chnSeq;
+	}
+
+	public void setChnSeq(String chnSeq) {
+		this.chnSeq = chnSeq;
+	}
+
+	public String getStreamType() {
+		return streamType;
+	}
+
+	public void setStreamType(String streamType) {
+		this.streamType = streamType;
+	}
+
+	
+	
+	
+}

+ 30 - 0
mybusiness/src/main/java/com/dahua/sdk/client/bean/hls/HLSXo.java

@@ -0,0 +1,30 @@
+package com.dahua.sdk.client.bean.hls;
+
+import com.dahua.sdk.client.bean.request.RequestData;
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+
+import java.io.Serializable;
+import java.util.List;
+
+@JsonIgnoreProperties(ignoreUnknown=true)
+public class HLSXo extends RequestData implements Serializable{
+
+    private static final long serialVersionUID = 8200877999414014456L;
+
+    private List<HLSBeanXo> hlsBeanXoList ;
+
+    @Override
+    public String toString() {
+        return "HLSXo [hlsBeanXoList=" + hlsBeanXoList + "]";
+    }
+
+    public List<HLSBeanXo> getHlsBeanXoList() {
+        return hlsBeanXoList;
+    }
+
+    public void setHlsBeanXoList(List<HLSBeanXo> hlsBeanXoList) {
+        this.hlsBeanXoList = hlsBeanXoList;
+    }
+
+
+}

+ 46 - 0
mybusiness/src/main/java/com/dahua/sdk/client/bean/request/AuthorizePortInfo.java

@@ -0,0 +1,46 @@
+package com.dahua.sdk.client.bean.request;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+
+/**
+ * 认证响应的端口信息
+ */
+@JsonIgnoreProperties(ignoreUnknown=true)
+public class AuthorizePortInfo {
+
+    // HTTP端口
+    private String httpPort;
+    
+    // HTTPS端口
+    private String httpsPort;
+    
+    public String getHttpPort() {
+        return httpPort;
+    }
+
+    public void setHttpPort(String httpPort) {
+        this.httpPort = httpPort;
+    }
+
+    public String getHttpsPort() {
+        return httpsPort;
+    }
+
+    public void setHttpsPort(String httpsPort) {
+        this.httpsPort = httpsPort;
+    }
+
+    /* (non-Jsdoc)
+     * @see java.lang.Object#toString()
+     */
+    @Override
+    public String toString() {
+        StringBuilder builder = new StringBuilder();
+        builder.append("AuthorizePortInfo [httpPort=");
+        builder.append(httpPort);
+        builder.append(", httpsPort=");
+        builder.append(httpsPort);
+        builder.append("]");
+        return builder.toString();
+    }
+}

+ 109 - 0
mybusiness/src/main/java/com/dahua/sdk/client/bean/request/AuthorizeRequest.java

@@ -0,0 +1,109 @@
+package com.dahua.sdk.client.bean.request;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+
+/**
+ * 登录域的参数
+ */
+@JsonIgnoreProperties(ignoreUnknown=true)
+public class AuthorizeRequest {
+
+    // 用户名
+    private String userName;
+    
+    // 签名
+    private String signature;
+    
+    // 随机秘钥种子
+    private String randomKey;
+    
+    // 加密算法,MD5
+    private String encryptType;
+    
+    // 客户端类型,web
+    private String clientType;
+    
+    // 客户端IP
+    private String ipAddress;
+
+    //用于加密aes的秘钥向量
+    private String publicKey;
+
+    public String getPublicKey() {
+        return publicKey;
+    }
+
+    public void setPublicKey(String publicKey) {
+        this.publicKey = publicKey;
+    }
+
+    public String getUserName() {
+        return userName;
+    }
+
+    public void setUserName(String userName) {
+        this.userName = userName;
+    }
+
+    public String getSignature() {
+        return signature;
+    }
+
+    public void setSignature(String signature) {
+        this.signature = signature;
+    }
+
+    public String getRandomKey() {
+        return randomKey;
+    }
+
+    public void setRandomKey(String randomKey) {
+        this.randomKey = randomKey;
+    }
+
+    public String getEncryptType() {
+        return encryptType;
+    }
+
+    public void setEncryptType(String encryptType) {
+        this.encryptType = encryptType;
+    }
+
+    public String getClientType() {
+        return clientType;
+    }
+
+    public void setClientType(String clientType) {
+        this.clientType = clientType;
+    }
+
+    public String getIpAddress() {
+        return ipAddress;
+    }
+
+    public void setIpAddress(String ipAddress) {
+        this.ipAddress = ipAddress;
+    }
+
+    /* (non-Jsdoc)
+     * @see java.lang.Object#toString()
+     */
+    @Override
+    public String toString() {
+        StringBuilder builder = new StringBuilder();
+        builder.append("AuthorizeRequest [userName=");
+        builder.append(userName);
+        builder.append(", signature=");
+        builder.append(signature);
+        builder.append(", randomKey=");
+        builder.append(randomKey);
+        builder.append(", encryptType=");
+        builder.append(encryptType);
+        builder.append(", clientType=");
+        builder.append(clientType);
+        builder.append(", ipAddress=");
+        builder.append(ipAddress);
+        builder.append("]");
+        return builder.toString();
+    }
+}

+ 74 - 0
mybusiness/src/main/java/com/dahua/sdk/client/bean/request/MyRestTemplate.java

@@ -0,0 +1,74 @@
+package com.dahua.sdk.client.bean.request;
+
+import org.springframework.http.HttpMethod;
+import org.springframework.http.client.ClientHttpRequest;
+import org.springframework.http.client.ClientHttpRequestFactory;
+import org.springframework.http.client.ClientHttpResponse;
+import org.springframework.util.Assert;
+import org.springframework.web.client.*;
+
+import java.io.IOException;
+import java.net.SocketTimeoutException;
+import java.net.URI;
+
+/**
+ * 重写RestTemplate的doExecute方法,增加请求超时3次重试功能
+ */
+public class MyRestTemplate extends RestTemplate {
+
+    public MyRestTemplate() {
+        super();
+    }
+    
+    public MyRestTemplate(ClientHttpRequestFactory requestFactory) {
+        super(requestFactory);
+    }
+    
+    @Override
+    protected <T> T doExecute(URI url, HttpMethod method,
+            RequestCallback requestCallback,
+            ResponseExtractor<T> responseExtractor) throws RestClientException {
+        return doExecuteInner(url, method, requestCallback, responseExtractor, 1);
+    }
+    
+    private <T> T doExecuteInner(URI url, HttpMethod method,
+            RequestCallback requestCallback,
+            ResponseExtractor<T> responseExtractor, int tryCount) throws RestClientException {
+        Assert.notNull(url, "'url' must not be null");
+        Assert.notNull(method, "'method' must not be null");
+        ClientHttpResponse response = null;
+        try {
+            ClientHttpRequest request = createRequest(url, method);
+            if (requestCallback != null) {
+                requestCallback.doWithRequest(request);
+            }
+            response = request.execute();
+            if (!getErrorHandler().hasError(response)) {
+                //logResponseStatus(method, url, response);
+            }
+            else {
+                getErrorHandler().handleError(response);
+            }
+            if (responseExtractor != null) {
+                return responseExtractor.extractData(response);
+            }
+            else {
+                return null;
+            }
+        }
+        catch (IOException ex) {
+            if (ex instanceof SocketTimeoutException) {
+                if (tryCount < 3) {
+                    return doExecuteInner(url, method, requestCallback, responseExtractor, ++tryCount);
+                }
+            }
+            throw new ResourceAccessException("I/O error on " + method.name() +
+                    " request for \"" + url + "\":" + ex.getMessage(), ex);
+        }
+        finally {
+            if (response != null) {
+                response.close();
+            }
+        }
+    }
+}

+ 67 - 0
mybusiness/src/main/java/com/dahua/sdk/client/bean/request/RequestData.java

@@ -0,0 +1,67 @@
+package com.dahua.sdk.client.bean.request;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+
+import java.io.Serializable;
+
+/**
+ * 请求数据基类(所有接口的请求对象都必须继承该类)
+ */
+@JsonIgnoreProperties(ignoreUnknown=true)
+public class RequestData implements Serializable {
+	
+	private static final long serialVersionUID = -556564542030056996L;
+
+	protected String optional;
+	
+	protected String locale;	//语言环境
+	
+	protected String session;	//会话标识
+	
+	/**
+	 * @return the optional
+	 */
+	protected String getOptional() {
+		return optional;
+	}
+
+	/**
+	 * @param optional the optional to set
+	 */
+	protected void setOptional(String optional) {
+		this.optional = optional;
+	}
+
+	public String getLocale() {
+		return locale;
+	}
+
+	public void setLocale(String locale) {
+		this.locale = locale;
+	}
+
+	public String getSession() {
+		return session;
+	}
+
+	public void setSession(String session) {
+		this.session = session;
+	}
+
+	/* (non-Jsdoc)
+	 * @see java.lang.Object#toString()
+	 */
+	@Override
+	public String toString() {
+		StringBuilder builder = new StringBuilder();
+		builder.append("RequestData [optional=");
+		builder.append(optional);
+		builder.append(", locale=");
+		builder.append(locale);
+		builder.append(", session=");
+		builder.append(session);
+		builder.append("]");
+		return builder.toString();
+	}
+
+}

+ 115 - 0
mybusiness/src/main/java/com/dahua/sdk/client/bean/request/RequestInfo.java

@@ -0,0 +1,115 @@
+package com.dahua.sdk.client.bean.request;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+
+import java.io.Serializable;
+
+/**
+ * 接口请求对象(使用时必须指定泛型T的具体类型)
+ */
+@JsonIgnoreProperties(ignoreUnknown=true)
+public class RequestInfo<T> implements Serializable {
+
+	private static final long serialVersionUID = -3551447239704640657L;
+	
+	private String clientType;
+	
+	private String clientMac;
+	
+	private String clientPushId;
+	
+	private String project;
+	
+	private T data;
+
+	/**
+	 * @return the clientType
+	 */
+	public String getClientType() {
+		return clientType;
+	}
+
+	/**
+	 * @param clientType the clientType to set
+	 */
+	public void setClientType(String clientType) {
+		this.clientType = clientType;
+	}
+
+	/**
+	 * @return the clientMac
+	 */
+	public String getClientMac() {
+		return clientMac;
+	}
+
+	/**
+	 * @param clientMac the clientMac to set
+	 */
+	public void setClientMac(String clientMac) {
+		this.clientMac = clientMac;
+	}
+
+	/**
+	 * @return the clientPushId
+	 */
+	public String getClientPushId() {
+		return clientPushId;
+	}
+
+	/**
+	 * @param clientPushId the clientPushId to set
+	 */
+	public void setClientPushId(String clientPushId) {
+		this.clientPushId = clientPushId;
+	}
+
+	/**
+	 * @return the project
+	 */
+	public String getProject() {
+		return project;
+	}
+
+	/**
+	 * @param project the project to set
+	 */
+	public void setProject(String project) {
+		this.project = project;
+	}
+
+	/**
+	 * @return the data
+	 */
+	public T getData() {
+		return data;
+	}
+
+	/**
+	 * @param data the data to set
+	 */
+	public void setData(T data) {
+		this.data = data;
+	}
+
+	/* (non-Javadoc)
+	 * @see java.lang.Object#toString()
+	 */
+	@Override
+	public String toString() {
+		StringBuilder builder = new StringBuilder();
+		builder.append("RequestInfo [clientMac=");
+		builder.append(clientMac);
+		builder.append(", clientPushId=");
+		builder.append(clientPushId);
+		builder.append(", clientType=");
+		builder.append(clientType);
+		builder.append(", data=");
+		builder.append(data);
+		builder.append(", project=");
+		builder.append(project);
+		builder.append("]");
+		return builder.toString();
+	}
+
+}

+ 71 - 0
mybusiness/src/main/java/com/dahua/sdk/client/bean/response/APIResponseInfo.java

@@ -0,0 +1,71 @@
+package com.dahua.sdk.client.bean.response;
+
+/**
+ * 登录域的参数
+ */
+public class APIResponseInfo {
+
+	private int code;
+	
+	private String desc;
+
+	private Object data;
+
+	/**
+	 * @return the code
+	 */
+	public int getCode() {
+		return code;
+	}
+
+	/**
+	 * @param code the code to set
+	 */
+	public void setCode(int code) {
+		this.code = code;
+	}
+
+	/**
+	 * @return the desc
+	 */
+	public String getDesc() {
+		return desc;
+	}
+
+	/**
+	 * @param desc the desc to set
+	 */
+	public void setDesc(String desc) {
+		this.desc = desc;
+	}
+
+	/**
+	 * @return the data
+	 */
+	public Object getData() {
+		return data;
+	}
+
+	/**
+	 * @param data the data to set
+	 */
+	public void setData(Object data) {
+		this.data = data;
+	}
+
+	/* (non-Javadoc)
+	 * @see java.lang.Object#toString()
+	 */
+	@Override
+	public String toString() {
+		StringBuilder builder = new StringBuilder();
+		builder.append("ResponseInfo [code=");
+		builder.append(code);
+		builder.append(", data=");
+		builder.append(data);
+		builder.append(", desc=");
+		builder.append(desc);
+		builder.append("]");
+		return builder.toString();
+	}
+}

+ 59 - 0
mybusiness/src/main/java/com/dahua/sdk/client/bean/response/AuthorizeFirstResponse.java

@@ -0,0 +1,59 @@
+package com.dahua.sdk.client.bean.response;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+
+/**
+ * 登录域的参数
+ */
+@JsonIgnoreProperties(ignoreUnknown=true)
+public class AuthorizeFirstResponse {
+
+    // 域信息
+    private String realm;
+    
+    // 随机秘钥种子
+    private String randomKey;
+    
+    // 加密算法,MD5
+    private String encryptType;
+    
+    public String getRealm() {
+        return realm;
+    }
+
+    public void setRealm(String realm) {
+        this.realm = realm;
+    }
+
+    public String getRandomKey() {
+        return randomKey;
+    }
+
+    public void setRandomKey(String randomKey) {
+        this.randomKey = randomKey;
+    }
+
+    public String getEncryptType() {
+        return encryptType;
+    }
+
+    public void setEncryptType(String encryptType) {
+        this.encryptType = encryptType;
+    }
+
+    /* (non-Jsdoc)
+     * @see java.lang.Object#toString()
+     */
+    @Override
+    public String toString() {
+        StringBuilder builder = new StringBuilder();
+        builder.append("AuthorizeFirstResponse [realm=");
+        builder.append(realm);
+        builder.append(", randomKey=");
+        builder.append(randomKey);
+        builder.append(", encryptType=");
+        builder.append(encryptType);
+        builder.append("]");
+        return builder.toString();
+    }
+}

+ 102 - 0
mybusiness/src/main/java/com/dahua/sdk/client/bean/response/AuthorizeResponse.java

@@ -0,0 +1,102 @@
+package com.dahua.sdk.client.bean.response;
+
+import com.dahua.sdk.client.bean.request.AuthorizePortInfo;
+
+import java.util.List;
+
+/**
+ * 登录域的参数
+ */
+public class AuthorizeResponse extends BaseResponse {
+
+    // 有效时间,心跳间隔时间
+    private String duration;
+    
+    private String token;
+    
+    private String userId;
+    
+    private List<String> serviceAbilty;
+    
+    private AuthorizePortInfo portInfo;
+
+    private String secretKey;
+
+    private String secretVector;
+
+    public String getSecretKey() {
+        return secretKey;
+    }
+
+    public void setSecretKey(String secretKey) {
+        this.secretKey = secretKey;
+    }
+
+    public String getSecretVector() {
+        return secretVector;
+    }
+
+    public void setSecretVector(String secretVector) {
+        this.secretVector = secretVector;
+    }
+
+    public String getDuration() {
+        return duration;
+    }
+
+    public void setDuration(String duration) {
+        this.duration = duration;
+    }
+
+    public String getToken() {
+        return token;
+    }
+
+    public void setToken(String token) {
+        this.token = token;
+    }
+
+    public String getUserId() {
+        return userId;
+    }
+
+    public void setUserId(String userId) {
+        this.userId = userId;
+    }
+
+    public List<String> getServiceAbilty() {
+        return serviceAbilty;
+    }
+
+    public void setServiceAbilty(List<String> serviceAbilty) {
+        this.serviceAbilty = serviceAbilty;
+    }
+
+    public AuthorizePortInfo getPortInfo() {
+        return portInfo;
+    }
+
+    public void setPortInfo(AuthorizePortInfo portInfo) {
+        this.portInfo = portInfo;
+    }
+
+    /* (non-Jsdoc)
+     * @see java.lang.Object#toString()
+     */
+    @Override
+    public String toString() {
+        StringBuilder builder = new StringBuilder();
+        builder.append("AuthorizeResponse [duration=");
+        builder.append(duration);
+        builder.append(", token=");
+        builder.append(token);
+        builder.append(", userId=");
+        builder.append(userId);
+        builder.append(", serviceAbilty=");
+        builder.append(serviceAbilty);
+        builder.append(", portInfo=");
+        builder.append(portInfo);
+        builder.append("]");
+        return builder.toString();
+    }
+}

+ 68 - 0
mybusiness/src/main/java/com/dahua/sdk/client/bean/response/BaseResponse.java

@@ -0,0 +1,68 @@
+package com.dahua.sdk.client.bean.response;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+
+/**
+ * BaseResponse
+ */
+@JsonIgnoreProperties(ignoreUnknown=true)
+public class BaseResponse {
+
+    private String code;
+    
+    private String message;
+    
+    private String desc;
+    
+    private String randomKey;
+    
+    public String getCode() {
+        return code;
+    }
+
+    public void setCode(String code) {
+        this.code = code;
+    }
+
+    public String getMessage() {
+        return message;
+    }
+
+    public void setMessage(String message) {
+        this.message = message;
+    }
+
+    public String getDesc() {
+        return desc;
+    }
+
+    public void setDesc(String desc) {
+        this.desc = desc;
+    }
+
+    public String getRandomKey() {
+        return randomKey;
+    }
+
+    public void setRandomKey(String randomKey) {
+        this.randomKey = randomKey;
+    }
+
+    /* (non-Jsdoc)
+     * @see java.lang.Object#toString()
+     */
+    @Override
+    public String toString() {
+        StringBuilder builder = new StringBuilder();
+        builder.append("BaseResponse [code=");
+        builder.append(code);
+        builder.append(", message=");
+        builder.append(message);
+        builder.append(", desc=");
+        builder.append(desc);
+        builder.append(", randomKey=");
+        builder.append(randomKey);
+        builder.append("]");
+        return builder.toString();
+    }
+}

+ 83 - 0
mybusiness/src/main/java/com/dahua/sdk/client/bean/response/DhDomainResponseInfo.java

@@ -0,0 +1,83 @@
+package com.dahua.sdk.client.bean.response;
+
+public class DhDomainResponseInfo<T> {
+
+    private int code;
+    
+    private String desc;
+    
+    private T data;
+    
+    public ResponseInfo getResponse() {
+        ResponseInfo responseInfo = new ResponseInfo();
+        responseInfo.setCode(code);
+        responseInfo.setDesc(desc);
+        responseInfo.setData(data);
+        return responseInfo;
+    }
+    
+    public boolean isError() {
+        if (code == 1000) {
+            return false;
+        }
+        return true;
+    }
+
+    /**
+     * @return the code
+     */
+    public int getCode() {
+        return code;
+    }
+
+    /**
+     * @param code the code to set
+     */
+    public void setCode(int code) {
+        this.code = code;
+    }
+
+    /**
+     * @return the desc
+     */
+    public String getDesc() {
+        return desc;
+    }
+
+    /**
+     * @param desc the desc to set
+     */
+    public void setDesc(String desc) {
+        this.desc = desc;
+    }
+
+    /**
+     * @return the data
+     */
+    public T getData() {
+        return data;
+    }
+
+    /**
+     * @param data the data to set
+     */
+    public void setData(T data) {
+        this.data = data;
+    }
+
+    /* (non-Javadoc)
+     * @see java.lang.Object#toString()
+     */
+    @Override
+    public String toString() {
+        StringBuilder builder = new StringBuilder();
+        builder.append("DomainResponseInfo [code=");
+        builder.append(code);
+        builder.append(", data=");
+        builder.append(data);
+        builder.append(", desc=");
+        builder.append(desc);
+        builder.append("]");
+        return builder.toString();
+    }
+}

+ 50 - 0
mybusiness/src/main/java/com/dahua/sdk/client/bean/response/MqAddressResponseInfo.java

@@ -0,0 +1,50 @@
+package com.dahua.sdk.client.bean.response;
+
+public class MqAddressResponseInfo {
+
+    private String userName;
+    
+    private String password;
+    
+    private String addr;
+    
+    public String getUserName() {
+        return userName;
+    }
+
+    public void setUserName(String userName) {
+        this.userName = userName;
+    }
+
+    public String getPassword() {
+        return password;
+    }
+
+    public void setPassword(String password) {
+        this.password = password;
+    }
+
+    public String getAddr() {
+        return addr;
+    }
+
+    public void setAddr(String addr) {
+        this.addr = addr;
+    }
+
+    /* (non-Javadoc)
+     * @see java.lang.Object#toString()
+     */
+    @Override
+    public String toString() {
+        StringBuilder builder = new StringBuilder();
+        builder.append("MqAddressResponseInfo [userName=");
+        builder.append(userName);
+        builder.append(", password=");
+        builder.append(password);
+        builder.append(", addr=");
+        builder.append(addr);
+        builder.append("]");
+        return builder.toString();
+    }
+}

+ 79 - 0
mybusiness/src/main/java/com/dahua/sdk/client/bean/response/ResponseInfo.java

@@ -0,0 +1,79 @@
+package com.dahua.sdk.client.bean.response;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+
+import java.io.Serializable;
+
+/**
+ * 接口输出对象
+ */
+@JsonInclude(JsonInclude.Include.NON_NULL)
+public class ResponseInfo implements Serializable {
+
+	private static final long serialVersionUID = -8638593562772051758L;
+
+	private int code;
+	
+	private String desc;
+
+	private Object data;
+
+	/**
+	 * @return the code
+	 */
+	public int getCode() {
+		return code;
+	}
+
+	/**
+	 * @param code the code to set
+	 */
+	public void setCode(int code) {
+		this.code = code;
+	}
+
+	/**
+	 * @return the desc
+	 */
+	public String getDesc() {
+		return desc;
+	}
+
+	/**
+	 * @param desc the desc to set
+	 */
+	public void setDesc(String desc) {
+		this.desc = desc;
+	}
+
+	/**
+	 * @return the data
+	 */
+	public Object getData() {
+		return data;
+	}
+
+	/**
+	 * @param data the data to set
+	 */
+	public void setData(Object data) {
+		this.data = data;
+	}
+
+	/* (non-Javadoc)
+	 * @see java.lang.Object#toString()
+	 */
+	@Override
+	public String toString() {
+		StringBuilder builder = new StringBuilder();
+		builder.append("ResponseInfo [code=");
+		builder.append(code);
+		builder.append(", data=");
+		builder.append(data);
+		builder.append(", desc=");
+		builder.append(desc);
+		builder.append("]");
+		return builder.toString();
+	}
+	
+}

+ 169 - 0
mybusiness/src/main/java/com/dahua/sdk/client/bean/response/SuccessResponse.java

@@ -0,0 +1,169 @@
+/**
+ * *********************** 版权声明 ***********************************
+ *
+ * 版权所有:浙江大华技术股份有限公司
+ * CopyRight DahuaTech 2017   
+ *  
+ * *******************************************************************
+*/
+
+package com.dahua.sdk.client.bean.response;
+
+import com.dahua.sdk.client.bean.VersionInfoVo;
+
+import java.io.Serializable;
+import java.util.Arrays;
+
+/**
+ * TODO
+ *
+ * @author    范玉宪
+ * @version   Express Ver 1.0
+ * @since     Express Ver 1.0
+ * @Date      2017年9月13日
+ *
+ */
+public class SuccessResponse implements Serializable {
+
+	/**
+	 * 
+	 */
+	private static final long serialVersionUID = 5195126361045006378L;
+	
+	 private int duration  ;  // 300,	有效时间,由服务端指定,单位秒,建议3/4 duration时就进行会话更新
+	 
+	 private String token  ;     //	返回登陆令牌,令牌字符串由服务端发布
+	 
+	 private String userId;     // “用户id”,	用户Id
+	 
+	 private String [] serviceAbilty ;
+	
+	 private VersionInfoVo versionInfo ;     //客户端版本号、下载路径
+	
+	 private String emapUrl ;     //电子地图路径
+	 
+	 private String sipNum;		//呼叫号码
+	 
+	 private int tokenRate;  // token更新时间
+
+	 private String secretKey;
+
+	 private String secretVector;
+
+	 private String reused;
+
+	public String getReused() {
+		return reused;
+	}
+
+	public void setReused(String reused) {
+		this.reused = reused;
+	}
+
+	public String getSecretKey() {
+		return secretKey;
+	}
+
+	public void setSecretKey(String secretKey) {
+		this.secretKey = secretKey;
+	}
+
+	public String getSecretVector() {
+		return secretVector;
+	}
+
+	public void setSecretVector(String secretVector) {
+		this.secretVector = secretVector;
+	}
+
+	public int getDuration() {
+		return duration;
+	}
+
+	public void setDuration(int duration) {
+		this.duration = duration;
+	}
+
+	public String getToken() {
+		return token;
+	}
+
+	public void setToken(String token) {
+		this.token = token;
+	}
+
+	public String getUserId() {
+		return userId;
+	}
+
+	public void setUserId(String userId) {
+		this.userId = userId;
+	}
+
+	public String[] getServiceAbilty() {
+		return serviceAbilty;
+	}
+
+	public void setServiceAbilty(String[] serviceAbilty) {
+		this.serviceAbilty = serviceAbilty;
+	}
+	
+	public VersionInfoVo getVersionInfo() {
+		return versionInfo;
+	}
+	
+	public void setVersionInfo(VersionInfoVo versionInfo) {
+		this.versionInfo = versionInfo;
+	}
+	
+	public String getEmapUrl() {
+		return emapUrl;
+	}
+	
+	public void setEmapUrl(String emapUrl) {
+		this.emapUrl = emapUrl;
+	}
+	
+	
+	public String getSipNum() {
+		return sipNum;
+	}
+
+	public void setSipNum(String sipNum) {
+		this.sipNum = sipNum;
+	}
+
+	@Override
+	public String toString() {
+		StringBuilder builder = new StringBuilder();
+		builder.append("SuccessResponse [duration=");
+		builder.append(duration);
+		builder.append(", token=");
+		builder.append(token);
+		builder.append(", userId=");
+		builder.append(userId);
+		builder.append(", serviceAbilty=");
+		builder.append(Arrays.toString(serviceAbilty));
+		builder.append(", versionInfo=");
+		builder.append(versionInfo);
+		builder.append(", emapUrl=");
+		builder.append(emapUrl);
+		builder.append(", sipNum=");
+		builder.append(sipNum);
+		builder.append(", reused=");
+		builder.append(reused);
+		builder.append("]");
+		return  builder.toString();
+	}
+
+	public int getTokenRate() {
+		return tokenRate;
+	}
+
+	public void setTokenRate(int tokenRate) {
+		this.tokenRate = tokenRate;
+	}
+
+	
+}
+ 

+ 135 - 0
mybusiness/src/main/java/com/dahua/sdk/client/bean/xo/AuthorizeXo.java

@@ -0,0 +1,135 @@
+/**
+ * *********************** 版权声明 ***********************************
+ * <p>
+ * 版权所有:浙江大华技术股份有限公司
+ * ©CopyRight DahuaTech 2017
+ * <p>
+ * *******************************************************************
+ */
+package com.dahua.sdk.client.bean.xo;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+
+import java.io.Serializable;
+
+/**
+ * com.dahua.admin.restapi.xo
+ *
+ * @author 26803
+ * @version Ver 7.0
+ * @since Ver 7.0
+ * @Date 2017/12/25
+ *
+ */
+@JsonIgnoreProperties(ignoreUnknown=true)
+public class AuthorizeXo implements Serializable {
+    
+    private static final long serialVersionUID = 297561054494560506L;
+    
+    private String userName;
+    
+    private String signature;
+    
+    private String randomKey;
+    
+    private String encryptType;
+
+    /**
+     * "Android"||"IOS".
+     */
+    private String clientType;
+    
+    private String ipAddress;
+    
+    private String mac;
+
+    private String userType;
+
+    private String publicKey;
+
+    public String getPublicKey() {
+        return publicKey;
+    }
+
+    public void setPublicKey(String publicKey) {
+        this.publicKey = publicKey;
+    }
+
+    public String getUserName() {
+        return userName;
+    }
+    
+    public void setUserName(String userName) {
+        this.userName = userName;
+    }
+    
+    public String getSignature() {
+        return signature;
+    }
+    
+    public void setSignature(String signature) {
+        this.signature = signature;
+    }
+    
+    public String getRandomKey() {
+        return randomKey;
+    }
+    
+    public void setRandomKey(String randomKey) {
+        this.randomKey = randomKey;
+    }
+    
+    public String getEncryptType() {
+        return encryptType;
+    }
+    
+    public void setEncryptType(String encryptType) {
+        this.encryptType = encryptType;
+    }
+    
+    public String getClientType() {
+        return clientType;
+    }
+    
+    public void setClientType(String clientType) {
+        this.clientType = clientType;
+    }
+    
+    public String getIpAddress() {
+        return ipAddress;
+    }
+    
+    public void setIpAddress(String ipAddress) {
+        this.ipAddress = ipAddress;
+    }
+    
+    public String getMac() {
+        return mac;
+    }
+    
+    public void setMac(String mac) {
+        this.mac = mac;
+    }
+
+    public String getUserType() {
+        return userType;
+    }
+
+    public void setUserType(String userType) {
+        this.userType = userType;
+    }
+
+    @Override
+    public String toString() {
+        return "AuthorizeXo{" +
+                "userName='" + userName + '\'' +
+                ", signature='" + signature + '\'' +
+                ", randomKey='" + randomKey + '\'' +
+                ", encryptType='" + encryptType + '\'' +
+                ", clientType='" + clientType + '\'' +
+                ", ipAddress='" + ipAddress + '\'' +
+                ", mac='" + mac + '\'' +
+                ", userType='" + userType + '\'' +
+                '}';
+    }
+}

+ 34 - 0
mybusiness/src/main/java/com/dahua/sdk/client/common/Constants.java

@@ -0,0 +1,34 @@
+package com.dahua.sdk.client.common;
+
+/** 类描述 	: 系统全局静态变量类
+ *
+ * @author    maoxn
+ * @version   V 3.0
+ * @since     V 3.0
+ * @Date      2012-7-25  下午01:57:04
+ */
+
+public class Constants {
+    
+    /** 编码 */
+    public static String ENCODING = "UTF-8";
+
+	/**
+	 * 发送心跳包时间间隔,单位毫秒
+	 */
+	public static int SENT_HEARTBEAT_TIME = 30000;
+    
+    /** 数据字典,域服务,CMS*/
+    public static String DICT_DOMAIN_SERVICE_TYPE_CMS = "1";
+    
+    /** 数据字典,域服务,PCS*/
+    public static String DICT_DOMAIN_SERVICE_TYPE_PCS = "2";
+    
+    /** 数据字典,域服务,WEB*/
+    public static String DICT_DOMAIN_SERVICE_TYPE_WEB = "3";
+
+    public static final String PUBLIC_KEY = "RSAPublicKey";
+
+    public static final String PRIVATE_KEY = "RSAPrivateKey";
+
+}

+ 43 - 0
mybusiness/src/main/java/com/dahua/sdk/client/common/DomainOfflineReasonEnum.java

@@ -0,0 +1,43 @@
+package com.dahua.sdk.client.common;
+
+public enum DomainOfflineReasonEnum {
+    NORMAL(0, ""),
+    CONNECT_EXCEPTION(1, "error.domain.login.connect.exception"),
+    AD_LOGIN_CLOSE(2, "error.domain.login.domain.forbidden"),
+    USER_PASS_ERROR(3, "error.domain.login.user.pass.error"),
+    USER_LOCKED(4, "error.domain.login.user.locked"),
+    USER_LOCKED_SYS_UPGRADE(5, "error.domain.login.user.locked"),
+    USER_MAC_ERROR(6, "error.domain.login.user.mac.error"),
+    USER_DISABLED(7, "error.domain.login.user.disabled"),
+    USER_LOGGED_IN(8, "error.domain.login.user.loggedin"),
+    USER_DATE_OVER(9, "error.domain.login.user.date.over"),
+    USER_TIME_OVER(10, "error.domain.login.user.time.over");
+    
+    private DomainOfflineReasonEnum(int code, String i18nCode) {
+        this.code = code;
+        this.i18nCode = i18nCode;
+    }
+    
+    private int code;
+    
+    private String i18nCode;
+    
+    public static String getI18nCode(int code) {
+        DomainOfflineReasonEnum[] elements = DomainOfflineReasonEnum.values();
+        for (DomainOfflineReasonEnum offlineStatus : elements) {
+            if (offlineStatus.getCode() == code) {
+                return offlineStatus.getI18nCode();
+            }
+        }
+        return "";
+    }
+
+    public int getCode() {
+        return code;
+    }
+
+    public String getI18nCode() {
+        return i18nCode;
+    }
+
+}

+ 40 - 0
mybusiness/src/main/java/com/dahua/sdk/client/common/EncryptType.java

@@ -0,0 +1,40 @@
+/**
+ * *********************** 版权声明 ***********************************
+ *
+ * 版权所有:浙江大华技术股份有限公司
+ * ©CopyRight DahuaTech 2017   
+ *  
+ * *******************************************************************
+*/
+
+package com.dahua.sdk.client.common;
+
+/**
+ * @author    周海青
+ * @version   Ver 3.20
+ * @since     Ver 3.20
+ * @Date      2017年9月22日
+ *
+ */
+public enum EncryptType {
+    
+    MD5("MD5"),
+    SSL("SSL"),
+    TLS("TLS"),
+    SHA512("SHA-512"),
+    SHA256("SHA-256"),
+    AES("AES"),
+    AES_CBC_PKCS7("AES/CBC/PKCS7Padding");
+
+    private String type;
+
+    private EncryptType(String type) {
+        this.type = type;
+    }
+
+    public String getType() {
+        return type;
+    }
+
+}
+

+ 14 - 0
mybusiness/src/main/java/com/dahua/sdk/client/common/SchemeEnum.java

@@ -0,0 +1,14 @@
+package com.dahua.sdk.client.common;
+
+public enum SchemeEnum {
+    HTTP("http://"), HTTPS("https://");
+
+    String scheme;
+    SchemeEnum(String scheme) {
+        this.scheme = scheme;
+    }
+
+    public String getScheme() {
+        return scheme;
+    }
+}

+ 8 - 0
mybusiness/src/main/java/com/dahua/sdk/client/common/ServiceErrorCode.java

@@ -0,0 +1,8 @@
+package com.dahua.sdk.client.common;
+
+public class ServiceErrorCode {
+
+    public static int SUCCESS = 0;
+    
+    public static int FAIL = -1;
+}

+ 80 - 0
mybusiness/src/main/java/com/dahua/sdk/client/convert/GsonUtils.java

@@ -0,0 +1,80 @@
+/**
+ * *********************** 版权声明 ***********************************
+ *
+ * 版权所有:浙江大华技术股份有限公司
+ * ©CopyRight DahuaTech 2012   
+ *  
+ * *******************************************************************
+*/
+
+package com.dahua.sdk.client.convert;
+
+import com.google.gson.ExclusionStrategy;
+import com.google.gson.FieldAttributes;
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+
+/**
+ * 用于生成 Gson对象,从而可以进行 对象 和 json字符串之间的转化
+ */
+public class GsonUtils {
+    
+    private static Gson exposeFieldsGson;
+    private static Gson allFieldsGson;
+    private static Gson multipleGson;
+    
+    public static Gson getGson() {
+        if (exposeFieldsGson == null) {
+            GsonBuilder gsonBuilder = new GsonBuilder();
+            gsonBuilder.excludeFieldsWithoutExposeAnnotation();
+            exposeFieldsGson = gsonBuilder.create();
+        }
+        return exposeFieldsGson;
+    }
+    
+    public static Gson getAllFieldsGson(){
+        if (allFieldsGson == null) {
+            GsonBuilder gsonBuilder = new GsonBuilder();
+            allFieldsGson = gsonBuilder.create();
+        }
+        return allFieldsGson;
+    }
+    
+    public static Gson getGson(boolean multipleParam){
+        if (multipleGson == null) {
+            GsonBuilder gsonBuilder = new GsonBuilder();
+            // 支持null
+           // gsonBuilder.serializeNulls();
+            // 支持转义字符
+            gsonBuilder.disableHtmlEscaping();
+            multipleGson = gsonBuilder.create();
+        }
+        return multipleGson;
+    }
+    
+    public static Gson getSkipFiledsGson(final String... filedNames) {
+        ExclusionStrategy myExclusionStrategy = new ExclusionStrategy() {
+
+            @Override
+            public boolean shouldSkipField(FieldAttributes filed) {
+                for (String filedName : filedNames) {
+                    if (filed.getName().equals(filedName)) {
+                        return true;
+                    }
+                }
+                return false;
+            }
+
+            // 先不做操作
+            @Override
+            public boolean shouldSkipClass(Class<?> arg0) {
+                return false;
+            }
+        };
+
+        GsonBuilder gsonBuilder = new GsonBuilder();
+        gsonBuilder.setExclusionStrategies(myExclusionStrategy);
+        return gsonBuilder.create();
+    }
+}
+

+ 54 - 0
mybusiness/src/main/java/com/dahua/sdk/client/convert/JsonToObjectConvert.java

@@ -0,0 +1,54 @@
+/**
+ * *********************** 版权声明 ***********************************
+ *
+ * 版权所有:浙江大华技术股份有限公司
+ * ©CopyRight DahuaTech 2016   
+ *  
+ * *******************************************************************
+*/
+
+package com.dahua.sdk.client.convert;
+
+import com.google.gson.Gson;
+
+import java.lang.reflect.Type;
+
+/**
+ * Json和对象之间进行转换
+ *
+ */
+public class JsonToObjectConvert implements StringToObjectConvert {
+
+    private static JsonToObjectConvert instance = new JsonToObjectConvert();
+    
+    private JsonToObjectConvert() {
+        
+    }
+    
+    public static JsonToObjectConvert getInstance() {
+        return instance;
+    }
+    
+	@Override
+	public Object convert(String body, Class<?> clazz) {
+		return new Gson().fromJson(body, clazz);
+	}
+	
+	public Object convert(String body, Type type) {
+		return new Gson().fromJson(body, type);
+	}
+
+	@Override
+	public String convert(Object object) {
+		return new Gson().toJson(object);
+	}
+	
+	public String convert(Object object, Type type) {
+		return new Gson().toJson(object, type);
+	}
+	
+	public String convert(Object object, boolean multipleParam) {
+	    Gson gson = GsonUtils.getGson(multipleParam); 
+        return gson.toJson(object);
+    }
+}

+ 36 - 0
mybusiness/src/main/java/com/dahua/sdk/client/convert/StringToObjectConvert.java

@@ -0,0 +1,36 @@
+/**
+ * *********************** 版权声明 ***********************************
+ *
+ * 版权所有:浙江大华技术股份有限公司
+ * ©CopyRight DahuaTech 2016   
+ *  
+ * *******************************************************************
+*/
+
+package com.dahua.sdk.client.convert;
+
+/**
+ * 字符串和对象转换器
+ *
+ */
+public interface StringToObjectConvert {
+	
+	/**
+	 * 把指定的字符串转换成对象
+	 *
+	 * @param body
+	 * @param clazz
+	 * @return      
+	 * @since  Ver 6.07
+	 */
+	Object convert(String body, Class<?> clazz);
+	
+	/**
+	 * 把指定对象转换成字符串
+	 *
+	 * @param object
+	 * @return      
+	 * @since  Ver 6.07
+	 */
+	String convert(Object object);
+}

+ 14 - 0
mybusiness/src/main/java/com/dahua/sdk/client/main/Main.java

@@ -0,0 +1,14 @@
+package com.dahua.sdk.client.main;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class Main {
+    public static void main(String[] args) {
+
+        List<String> list = new ArrayList<>();
+        list.add("11");
+        list.add("22");
+        System.out.println(list);
+    }
+}

+ 227 - 0
mybusiness/src/main/java/com/dahua/sdk/client/util/EncryptionUtils.java

@@ -0,0 +1,227 @@
+package com.dahua.sdk.client.util;
+
+
+import com.dahua.sdk.client.common.Constants;
+import com.dahua.sdk.client.common.EncryptType;
+import org.apache.log4j.Logger;
+import org.bouncycastle.jce.provider.BouncyCastleProvider;
+import org.springframework.util.StringUtils;
+
+import javax.crypto.BadPaddingException;
+import javax.crypto.Cipher;
+import javax.crypto.IllegalBlockSizeException;
+import javax.crypto.NoSuchPaddingException;
+import javax.crypto.spec.IvParameterSpec;
+import javax.crypto.spec.SecretKeySpec;
+import java.io.File;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.nio.charset.StandardCharsets;
+import java.security.*;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * 加密
+ */
+public class EncryptionUtils {
+
+    protected static Logger logger = Logger.getLogger(EncryptionUtils.class);
+
+    public  static String AES_CBC_IV = null;
+
+    public static String encryptWithMD5(String text) {
+        return encrypt(text, "MD5");
+    }
+
+
+    private static String encrypt(String text, String algorithm) {
+        String password = null;
+        try {
+            MessageDigest md = MessageDigest.getInstance( algorithm );
+            try {
+                md.update(text.getBytes("utf-8"));
+            } catch (UnsupportedEncodingException e) {
+                e.printStackTrace();
+            }
+            byte b[] = md.digest();
+            StringBuilder sb = new StringBuilder();
+            for (int offset = 0; offset < b.length; offset++) {
+                int i = b[offset];
+                if (i < 0) {
+                    i += 256;
+                }
+                if (i < 16) {
+                    sb.append("0");
+                }
+                sb.append(Integer.toHexString(i));
+            }
+            password = sb.toString();
+        } catch (NoSuchAlgorithmException e) {
+            e.printStackTrace();
+        }
+        return password;
+    }
+
+
+    /**
+     * 普通AES-CBC模式解密
+     * @param encryPassword
+     * @param aesKey
+     * @return
+     */
+    public static String decryptByAesCbc(String encryPassword, String aesKey,String ivKey) {
+        Security.addProvider(new BouncyCastleProvider());
+        if (StringUtils.isEmpty(encryPassword)) {
+//            logger.info("the encryPassword is null,will return null");
+            System.out.println("the encryPassword is null,will return null");
+            return null;
+        }
+        if (StringUtils.isEmpty(aesKey)) {
+            System.out.println("decrypt pass error by AES-CBC: aesKey is null ");
+            return null;
+        }
+        try {
+            byte[] raw = aesKey.getBytes(Constants.ENCODING);
+            SecretKeySpec skeySpec = new SecretKeySpec(raw, EncryptType.AES.getType());
+            Cipher cipher = Cipher.getInstance(EncryptType.AES_CBC_PKCS7.getType());
+            //Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
+            //IvParameterSpec iv = new IvParameterSpec(AES_CBC_IV.getBytes(Constants.ENCODING));
+            IvParameterSpec iv = new IvParameterSpec(ivKey.getBytes(Constants.ENCODING));
+            cipher.init(Cipher.DECRYPT_MODE, skeySpec, iv);
+            byte[] encrypted = parseHexStr2Byte(encryPassword);
+            byte[] originalPassByte = cipher.doFinal(encrypted);
+            return new String(originalPassByte, Constants.ENCODING);
+        } catch (UnsupportedEncodingException e1) {
+            logger.error("decrypt pass error by AES-CBC: " + e1.toString());
+        } catch (NoSuchAlgorithmException e2) {
+            logger.error("decrypt pass error by AES-CBC: " + e2.toString());
+        } catch (NoSuchPaddingException e3) {
+            logger.error("decrypt pass error by AES-CBC: " + e3.toString());
+        } catch (InvalidKeyException e4) {
+            logger.error("decrypt pass error by AES-CBC: " + e4.toString());
+        } catch (InvalidAlgorithmParameterException e5) {
+            logger.error("decrypt pass error by AES-CBC: " + e5.toString());
+        } catch (IllegalBlockSizeException e6) {
+            logger.error("decrypt pass error by AES-CBC: " + e6.toString());
+        } catch (BadPaddingException e7) {
+            logger.error("decrypt pass error by AES-CBC: " + e7.toString());
+        } catch (Exception e) {
+            logger.error("decrypt pass error by AES-CBC: " + e.toString());
+        }
+        return null;
+    }
+
+    /**将16进制转换为二进制
+     * @param hexStr
+     * @return
+     */
+    private static byte[] parseHexStr2Byte(String hexStr) {
+        if (hexStr.length() < 1)  {
+            return null;
+        }
+        byte[] result = new byte[hexStr.length()/2];
+        for (int i = 0;i< hexStr.length()/2; i++) {
+            int high = Integer.parseInt(hexStr.substring(i*2, i*2+1), 16);
+            int low = Integer.parseInt(hexStr.substring(i*2+1, i*2+2), 16);
+            result[i] = (byte) (high * 16 + low);
+        }
+        return result;
+    }
+
+    /**
+     * GDPR特性的AES-CBC模式解密
+     * @param value
+     * @param aesKey
+     * @return
+     */
+    public static String decryptByAesCbcGDPR(final String value, final String aesKey) {
+        if (StringUtils.isEmpty(value)) {
+            logger.info("the value is null,will return null");
+            return null;
+        }
+        if (StringUtils.isEmpty(aesKey)) {
+            logger.info("the aesKey is null,will return null");
+            return null;
+        }
+        try {
+            byte[] raw = aesKey.getBytes(StandardCharsets.UTF_8);
+            Security.addProvider(new BouncyCastleProvider());
+            SecretKeySpec skeySpec = new SecretKeySpec(raw, EncryptType.AES.getType());
+            Cipher cipher = Cipher.getInstance(EncryptType.AES_CBC_PKCS7.getType());
+            IvParameterSpec iv = new IvParameterSpec(AES_CBC_IV().getBytes(StandardCharsets.UTF_8));
+            cipher.init(Cipher.DECRYPT_MODE, skeySpec, iv);
+            byte[] encrypted = parseHexStr2Byte(value);
+            byte[] originalPassByte = cipher.doFinal(encrypted);
+            return new String(originalPassByte,StandardCharsets.UTF_8);
+        } catch (Exception e) {
+            logger.error("decrypt GDPR value error by AES-CBC" + e.getMessage());
+        }
+        return null;
+    }
+
+    //数据库密码 加密 向量 生成规则
+    public static String AES_CBC_IV(){
+        StringBuffer iv = new StringBuffer();
+        for (int i = 0; i < 10; i++) {
+            iv.append(i);
+        }
+        iv.append("abc");
+        iv.append("def");
+        return iv.toString();
+    }
+
+    public static String encryptByAesCbc(String encryPassword, String aesKey) {
+        if (StringUtils.isEmpty(encryPassword)) {
+            logger.info("the encryPassword is null,will return null");
+            return null;
+        }
+        if (StringUtils.isEmpty(aesKey)) {
+            logger.error("ecrypt pass error by AES-CBC: aesKey is null ");
+            return null;
+        }
+        try {
+            Cipher cipher = Cipher.getInstance(EncryptType.AES_CBC_PKCS7.getType());
+            byte[] raw = aesKey.getBytes(Constants.ENCODING);
+            SecretKeySpec skeySpec = new SecretKeySpec(raw, "AES");
+            IvParameterSpec iv = new IvParameterSpec(AES_CBC_IV.getBytes(Constants.ENCODING));//使用CBC模式,需要一个向量iv,可增加加密算法的强度
+            cipher.init(Cipher.ENCRYPT_MODE, skeySpec, iv);
+            byte[] encrypted = cipher.doFinal(encryPassword.getBytes(Constants.ENCODING));
+            return parseByte2HexStr(encrypted);
+        } catch (NoSuchAlgorithmException e1) {
+            logger.error("ecrypt pass error by AES-CBC: " + e1.toString());
+        } catch(NoSuchPaddingException e2) {
+            logger.error("ecrypt pass error by AES-CBC: " + e2.toString());
+        } catch (UnsupportedEncodingException e3) {
+            logger.error("ecrypt pass error by AES-CBC: " + e3.toString());
+        } catch (InvalidKeyException e4) {
+            logger.error("ecrypt pass error by AES-CBC: " + e4.toString());
+        } catch(InvalidAlgorithmParameterException e5) {
+            logger.error("ecrypt pass error by AES-CBC: " + e5.toString());
+        } catch (IllegalBlockSizeException e6) {
+            logger.error("ecrypt pass error by AES-CBC: " + e6.toString());
+        } catch (BadPaddingException e7) {
+            logger.error("ecrypt pass error by AES-CBC: " + e7.toString());
+        } catch (Exception e) {
+            logger.error("ecrypt pass error by AES-CBC: " + e.toString());
+        }
+        return null;
+    }
+
+    /**
+     * 将二进制转换成16进制
+     * @param buf
+     * @return
+     */
+    private static String parseByte2HexStr(byte buf[]) {
+        StringBuffer sb = new StringBuffer();
+        for (int i = 0; i < buf.length; i++) {
+            String hex = Integer.toHexString(buf[i] & 0xFF);
+            if (hex.length() == 1) {
+                hex = '0' + hex;
+            }
+            sb.append(hex.toLowerCase());
+        }
+        return sb.toString();
+    }
+}

+ 50 - 0
mybusiness/src/main/java/com/dahua/sdk/client/util/HexUtil.java

@@ -0,0 +1,50 @@
+package com.dahua.sdk.client.util;
+
+public class HexUtil {
+	
+	private static final String HEX_VALUE = "0123456789ABCDEF";
+	
+	/**
+	 * Bytes to Hex String
+	 * 
+	 * @param bytes bytes
+	 * @return hex string
+	 */
+	public static String bytesToHexString(byte[] bytes) {
+		StringBuilder sb = new StringBuilder();
+		if (null == bytes || bytes.length <= 0) {
+			return null;
+		}
+		for (int i = 0; i < bytes.length; i++) {
+			int v = bytes[i] & 0xFF;
+			String hv = Integer.toHexString(v);
+			if (hv.length() < 2) {
+				sb.append(0);
+			}
+			sb.append(hv);
+		}
+		return sb.toString().toUpperCase();
+	}
+
+	/**
+	 * Hex String to Bytes
+	 * 
+	 * @param str string
+	 * @return Bytes
+	 */
+	public static byte[] hexStringToBytes(String str) {
+		int len = str.length() / 2;
+		byte[] result = new byte[len];
+		char[] achar = str.toCharArray();
+		for (int i = 0; i < len; i++) {
+			int pos = i * 2;
+			result[i] = (byte) ((byte) toByte(achar[pos]) << 4 | toByte(achar[pos + 1]));
+		}
+		return result;
+	}
+
+	private static byte toByte(char c) {
+		return (byte) HEX_VALUE.indexOf(c);
+	}
+	
+}

+ 135 - 0
mybusiness/src/main/java/com/dahua/sdk/client/util/JsonParserUtils.java

@@ -0,0 +1,135 @@
+package com.dahua.sdk.client.util;
+
+import com.google.gson.JsonArray;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+import com.google.gson.JsonParser;
+
+import java.lang.reflect.Constructor;
+import java.util.Iterator;
+import java.util.Map.Entry;
+import java.util.Set;
+
+/**
+ * JSON字符串基本数据类型(String 、Integer、Float等)
+ * 属性值提取工具,支持深层查找
+ *
+ * 例如
+ * {
+ *   "name":"dahuatech",
+ *   "members":13000,
+ *   "depart":{
+ *       "name":"it",
+ *       "num":120
+ *   }
+ * }
+ * 可提取深层的num属性
+ * 如果提取name属性,则提取先找到的 "dahuatech" ,不提取 "it"
+ * @author 37374
+ * Date 2019-1-18
+ */
+public abstract class JsonParserUtils {
+
+
+	private static final JsonParser jsonParser = new JsonParser();
+
+	private static JsonElement getJsonField(String jsonStr,String field){
+		if(null ==jsonStr || "".equals(jsonStr)){
+			return null;
+		}
+
+		JsonElement ele = null;
+		JsonElement jsonTree = jsonParser.parse(jsonStr);
+		ele = recursiveJsonField(jsonTree,field);
+		return ele;
+	}
+
+	/**
+	 * 获取json字符串中基本类型属性
+	 * 例如 String 、Integer、Float
+	 * @param jsonStr JSON字符串
+	 * @param field 属性名
+	 * @param clazz JAVA基本类型包装类
+	 * @return
+	 */
+	public static <T> T getPrimitiveField(String jsonStr,String field,Class<T> clazz) {
+		T result = null;
+
+		JsonElement ele = getJsonField(jsonStr, field);
+		result = recursiveField(ele,field,clazz);
+		return result;
+	}
+
+	/**
+	 * 递归查找属性
+	 * @param jsonElement
+	 * @param field
+	 * @param clazz
+	 * @return
+	 */
+	@SuppressWarnings("unchecked")
+	private static <T> T recursiveField(JsonElement jsonElement,String field,Class<T> clazz) {
+		T result = null;
+		if(jsonElement == null){
+			return null;
+		}
+		if(jsonElement.isJsonPrimitive()){
+			String raw = jsonElement.getAsString();
+			Constructor<String> constructor;
+			try {
+				clazz.getConstructor(String.class);
+				constructor = (Constructor<String>) clazz.getConstructor(String.class);
+				result = (T) constructor.newInstance(raw);
+			} catch (Exception e) {
+				e.printStackTrace();
+			}
+		}else if(jsonElement.isJsonObject()){
+			JsonObject obj = jsonElement.getAsJsonObject();
+			JsonElement ele2 = obj.get(field);
+			result = recursiveField(ele2,field,clazz);
+		}
+		return result;
+	}
+
+	/**
+	 * 递归查找指定JSON节点
+	 * @param jsonTree JSON树
+	 * @param field 节点名称
+	 * @return
+	 */
+	private static JsonElement recursiveJsonField(JsonElement jsonTree, String field){
+		JsonElement result = null;
+		if(jsonTree.isJsonObject()){
+			JsonObject jsonObject = jsonTree.getAsJsonObject();
+			Set<Entry<String, JsonElement>> set = jsonObject.entrySet();
+			JsonElement currentEle = null;
+			for(Entry<String, JsonElement> entry : set){
+				if(field.equals(entry.getKey())){
+					result = entry.getValue();
+					break;
+				}else{
+					currentEle = entry.getValue();
+					result = recursiveJsonField(currentEle,field);
+					if(result != null){
+						break;
+					}
+				}
+
+			}
+		}else if(jsonTree.isJsonArray()){
+			JsonArray jsonArray = jsonTree.getAsJsonArray();
+			Iterator<JsonElement> ite = jsonArray.iterator();
+			JsonElement currentEle2 = null;
+			while(ite.hasNext()){
+				currentEle2 = ite.next();
+				result = recursiveJsonField(currentEle2,field);
+				if(result != null){
+					break;
+				}
+			}
+
+		}
+
+		return result;
+	}
+}

+ 406 - 0
mybusiness/src/main/java/com/dahua/sdk/client/util/RsaUtil.java

@@ -0,0 +1,406 @@
+package com.dahua.sdk.client.util;
+
+import com.dahua.sdk.client.bean.RSAPrivateBean;
+import com.dahua.sdk.client.common.Constants;
+import org.apache.commons.lang3.StringUtils;
+
+import javax.crypto.Cipher;
+import java.io.ByteArrayOutputStream;
+import java.security.*;
+import java.security.interfaces.RSAPrivateKey;
+import java.security.interfaces.RSAPublicKey;
+import java.security.spec.PKCS8EncodedKeySpec;
+import java.security.spec.X509EncodedKeySpec;
+import java.util.Arrays;
+import java.util.Base64;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.locks.ReentrantLock;
+
+public class RsaUtil {
+	private static final String KEY_ALGORITHM = "RSA";
+
+	private static final int BYTES_LEN_DECRYPT = 256;
+
+	private static final int BYTES_LEN_ENCRYPT = 245;
+
+	private static final int KEY_SIZE = 2048;  //  秘钥长度2048,最长加密245字节明文    一体机的license 用1024 且采用数据库写死的私钥解密 308....
+    
+    private static Map<String, Object> keyMap = null;
+
+    private static Map<Object, Object> keyPairMap = new ConcurrentHashMap<Object, Object>();
+
+	private static ReentrantLock lock = new ReentrantLock();
+
+	private static void removeKeyPairMap(String pubicKey) {
+		if (null != keyPairMap && null != pubicKey) {
+			keyPairMap.remove(pubicKey);
+		}
+	}
+
+    /**
+	 * 用私钥解密
+	 * 
+	 * @param data encrypt data
+	 * @param key key(hex format)
+	 * @return decrypt data
+	 * @throws Exception
+	 */
+	public static byte[] decryptByPrivateKey(byte[] data, String key) throws Exception {
+		// 对密钥解密
+		byte[] keyBytes = HexUtil.hexStringToBytes(key);
+
+		// 取得私钥
+		PKCS8EncodedKeySpec pkcs8KeySpec = new PKCS8EncodedKeySpec(keyBytes);
+		KeyFactory keyFactory = KeyFactory.getInstance(KEY_ALGORITHM);
+		Key privateKey = keyFactory.generatePrivate(pkcs8KeySpec);
+
+		// 对数据解密
+		Cipher cipher = Cipher.getInstance(keyFactory.getAlgorithm());
+		cipher.init(Cipher.DECRYPT_MODE, privateKey);
+		
+		byte[] result = null;
+		try {
+		    for (int i = 0; i < data.length; i += BYTES_LEN_DECRYPT) {
+	            int to = (i + BYTES_LEN_DECRYPT) < data.length ? (i + BYTES_LEN_DECRYPT) : data.length;
+	            byte[] temp = cipher.doFinal(Arrays.copyOfRange(data, i, to));
+	            result = sumBytes(result, temp);
+	        } 
+		}catch(Exception e) {
+		    result =  decryptByPrivateKey128(data,key);
+		    e.printStackTrace();
+		}
+		return result;
+	}
+	/**
+	 * 解密长度采用128进行解密
+	 * @description 
+	 * @author 46424
+	 * @date 2020-01-02 09:22:21
+	 * @param data
+	 * @param key
+	 * @return
+	 * @throws Exception
+	 *
+	 */
+	public static byte[] decryptByPrivateKey128(byte[] data,String key)throws Exception {
+	 // 对密钥解密
+        byte[] keyBytes = HexUtil.hexStringToBytes(key);
+
+        // 取得私钥
+        PKCS8EncodedKeySpec pkcs8KeySpec = new PKCS8EncodedKeySpec(keyBytes);
+        KeyFactory keyFactory = KeyFactory.getInstance(KEY_ALGORITHM);
+        Key privateKey = keyFactory.generatePrivate(pkcs8KeySpec);
+
+        // 对数据解密
+        Cipher cipher = Cipher.getInstance(keyFactory.getAlgorithm());
+        cipher.init(Cipher.DECRYPT_MODE, privateKey);
+        int inputLen = data.length;
+        ByteArrayOutputStream out = new ByteArrayOutputStream();
+        int offSet = 0;
+        byte[] cache;
+        int i = 0;
+        while (inputLen - offSet > 0) {
+            if (inputLen - offSet > 128) {
+                cache = cipher.doFinal(data, offSet, 128);
+            } else {
+                cache = cipher.doFinal(data, offSet, inputLen - offSet);
+            }
+            out.write(cache, 0, cache.length);
+            i++;
+            offSet = i * 128;
+        }
+        byte[] result = out.toByteArray();
+        out.close();
+        
+        return result;
+	}
+	
+	   /**
+     * 用私钥解密
+     * 
+     * @param data encrypt data
+     * @param keyBytes key(hex format)
+     * @return decrypt data
+     * @throws Exception
+     */
+    public static byte[] decryptByPrivateKey(byte[] data,  byte[] keyBytes) throws Exception {
+
+        // 取得私钥
+        PKCS8EncodedKeySpec pkcs8KeySpec = new PKCS8EncodedKeySpec(keyBytes);
+        KeyFactory keyFactory = KeyFactory.getInstance(KEY_ALGORITHM);
+        Key privateKey = keyFactory.generatePrivate(pkcs8KeySpec);
+
+        // 对数据解密
+        Cipher cipher = Cipher.getInstance(keyFactory.getAlgorithm());
+        cipher.init(Cipher.DECRYPT_MODE, privateKey);
+        
+        byte[] result = null;
+        for (int i = 0; i < data.length; i += BYTES_LEN_DECRYPT) {
+            int to = (i + BYTES_LEN_DECRYPT) < data.length ? (i + BYTES_LEN_DECRYPT) : data.length;
+            byte[] temp = cipher.doFinal(Arrays.copyOfRange(data, i, to));
+            result = sumBytes(result, temp);
+        }
+
+        return result;
+    }
+
+	/**
+	 * 用公钥解密
+	 * 
+	 * @param data encrypt data
+	 * @param key key(hex format)
+	 * @return decrypt data
+	 * @throws Exception
+	 */
+	public static byte[] decryptByPublicKey(byte[] data, String key) throws Exception {
+		// 对密钥解密
+		byte[] keyBytes = HexUtil.hexStringToBytes(key);
+
+		// 取得公钥
+		X509EncodedKeySpec x509KeySpec = new X509EncodedKeySpec(keyBytes);
+		KeyFactory keyFactory = KeyFactory.getInstance(KEY_ALGORITHM);
+		Key publicKey = keyFactory.generatePublic(x509KeySpec);
+
+		// 对数据解密
+		Cipher cipher = Cipher.getInstance(keyFactory.getAlgorithm());
+		cipher.init(Cipher.DECRYPT_MODE, publicKey);
+
+		byte[] result = null;
+		for (int i = 0; i < data.length; i += BYTES_LEN_DECRYPT) {
+			int to = (i + BYTES_LEN_DECRYPT) < data.length ? (i + BYTES_LEN_DECRYPT) : data.length;
+			byte[] temp = cipher.doFinal(Arrays.copyOfRange(data, i, to));
+			result = sumBytes(result, temp);
+		}
+
+		return result;
+	}
+
+	/**
+	 * 用公钥加密
+	 * 
+	 * @param data decrypt data
+	 * @param key key(hex format)
+	 * @return encrypt data
+	 * @throws Exception
+	 */
+	public static byte[] encryptByPublicKey(byte[] data, String key) throws Exception {
+		// 对公钥解密
+		byte[] keyBytes = HexUtil.hexStringToBytes(key);
+
+		// 取得公钥
+		X509EncodedKeySpec x509KeySpec = new X509EncodedKeySpec(keyBytes);
+		KeyFactory keyFactory = KeyFactory.getInstance(KEY_ALGORITHM);
+		Key publicKey = keyFactory.generatePublic(x509KeySpec);
+
+		// 对数据加密
+		Cipher cipher = Cipher.getInstance(keyFactory.getAlgorithm());
+		cipher.init(Cipher.ENCRYPT_MODE, publicKey);
+		
+		byte[] result = null;
+		for (int i = 0; i < data.length; i += BYTES_LEN_ENCRYPT) {
+			int to = (i + BYTES_LEN_ENCRYPT) < data.length ? (i + BYTES_LEN_ENCRYPT) : data.length;
+			byte[] temp = cipher.doFinal(Arrays.copyOfRange(data, i, to));
+			result = sumBytes(result, temp);
+		}
+
+		return result;
+	}
+
+	/**
+	 * 用私钥加密
+	 * 
+	 * @param data decrypt data
+	 * @param key key(hex format)
+	 * @return encrypt data
+	 * @throws Exception
+	 */
+	public static byte[] encryptByPrivateKey(byte[] data, String key) throws Exception {
+		// 对密钥解密
+		byte[] keyBytes = HexUtil.hexStringToBytes(key);
+
+		// 取得私钥
+		PKCS8EncodedKeySpec pkcs8KeySpec = new PKCS8EncodedKeySpec(keyBytes);
+		KeyFactory keyFactory = KeyFactory.getInstance(KEY_ALGORITHM);
+		Key privateKey = keyFactory.generatePrivate(pkcs8KeySpec);
+
+		// 对数据加密
+		Cipher cipher = Cipher.getInstance(keyFactory.getAlgorithm());
+		cipher.init(Cipher.ENCRYPT_MODE, privateKey);
+
+		byte[] result = null;
+		for (int i = 0; i < data.length; i += BYTES_LEN_ENCRYPT) {
+			int to = (i + BYTES_LEN_ENCRYPT) < data.length ? (i + BYTES_LEN_ENCRYPT) : data.length;
+			byte[] temp = cipher.doFinal(Arrays.copyOfRange(data, i, to));
+			result = sumBytes(result, temp);
+		}
+
+		return result;
+	}
+	
+	private static byte[] sumBytes(byte[] bytes1, byte[] bytes2) {
+		byte[] result = null;
+		int len1 = 0;
+		int len2 = 0;
+		if (null != bytes1) {
+			len1 = bytes1.length;
+		}
+		if (null != bytes2) {
+			len2 = bytes2.length;
+		}
+		if (len1 + len2 > 0) {
+			result = new byte[len1+len2];
+		}
+		if (len1 > 0) {
+			System.arraycopy(bytes1, 0, result, 0, len1);
+		}
+		if (len2 > 0) {
+			System.arraycopy(bytes2, 0, result, len1, len2);
+		}
+		return result;
+	}
+	
+	   /**
+     * 初始化密钥
+     * 
+     * @return
+     * @throws Exception
+     */
+    public static void initKey() throws Exception {
+    	ReentrantLock lock=new ReentrantLock();
+    	lock.lock();
+    	try {
+    		if(keyMap == null) {
+                Provider provider = Security.getProvider("SunRsaSign");
+                KeyPairGenerator keyPairGen = KeyPairGenerator.getInstance(KEY_ALGORITHM , provider);
+                keyPairGen.initialize(KEY_SIZE , new SecureRandom());
+        
+                KeyPair keyPair = keyPairGen.generateKeyPair();
+        
+                // 公钥
+                RSAPublicKey publicKey = (RSAPublicKey) keyPair.getPublic();
+        
+                // 私钥
+                RSAPrivateKey privateKey = (RSAPrivateKey) keyPair.getPrivate();
+               
+                keyMap = new HashMap<String, Object>(2);
+        
+                keyMap.put(Constants.PUBLIC_KEY, publicKey);
+                keyMap.put(Constants.PRIVATE_KEY, privateKey);
+                
+            }
+		} catch (Exception e) {
+			e.printStackTrace();
+		}finally{
+			lock.unlock();
+		}
+    }
+
+	/**
+	 * 随机生成公钥私钥对
+	 *
+	 * @return
+	 * @throws Exception
+	 */
+	public static RSAPublicKey generateRandomKey() throws Exception {
+		lock.lock();
+        RSAPublicKey publicKey = null;
+        RSAPrivateKey privateKey = null;
+		try {
+            Provider provider = Security.getProvider("SunRsaSign");
+            KeyPairGenerator keyPairGen = KeyPairGenerator.getInstance(KEY_ALGORITHM , provider);
+            keyPairGen.initialize(KEY_SIZE , new SecureRandom());
+
+            KeyPair keyPair = keyPairGen.generateKeyPair();
+
+            // 公钥
+            publicKey = (RSAPublicKey) keyPair.getPublic();
+
+            // 私钥
+            privateKey = (RSAPrivateKey) keyPair.getPrivate();
+
+            keyPairMap.put(Base64.getEncoder().encodeToString(publicKey.getEncoded()), new RSAPrivateBean(privateKey, System.currentTimeMillis()));
+		} catch (Exception e) {
+			e.printStackTrace();
+		}finally{
+			lock.unlock();
+		}
+		return publicKey;
+	}
+
+    public static Map<String, Object> getKeyMap() {
+        if(keyMap == null){
+            try {
+                initKey();
+            } catch (Exception e) {
+
+            }
+        }
+        return keyMap;
+    }
+
+    public static void removeKeyMap() {
+        keyMap = null;
+    }
+
+    public static Map<Object, Object> getKeyPairMap() {
+        return keyPairMap;
+    }
+
+    public static String decryptRSA(String encrypt) {
+        String pureText = "";
+        if (StringUtils.isEmpty(encrypt)) {
+            return pureText;
+        }
+        RSAPrivateKey privateKey = (RSAPrivateKey) RsaUtil.getKeyMap().get(Constants.PRIVATE_KEY);
+		try {
+			byte[] encryBytes = Base64.getDecoder().decode(encrypt);
+			byte[] decryBytes = RsaUtil.decryptByPrivateKey(encryBytes, privateKey.getEncoded());
+			if(decryBytes != null){
+				pureText = new String(decryBytes, Constants.ENCODING);
+			}
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+		return pureText;
+	}
+
+	public static String encryptByPublicKey(String data, String publicKey) {
+		String pureText = data;
+		if (StringUtils.isBlank(data) || StringUtils.isBlank(publicKey)) {
+			return pureText;
+		}
+		try {
+			byte[] dataBytes = data.getBytes("UTF-8");
+			byte[] encryBytes = RsaUtil.encryptByPublicKey(dataBytes, publicKey);
+			if(encryBytes != null){
+				pureText = HexUtil.bytesToHexString(encryBytes);
+			}
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+		return pureText;
+	}
+
+	public static String decryptRSAByPublicKey(String encrypt, String publicKey) {
+        String pureText = "";
+        if (StringUtils.isEmpty(encrypt)) {
+            return pureText;
+        }
+		RSAPrivateKey privateKey = ((RSAPrivateBean) RsaUtil.getKeyPairMap().get(publicKey)).getRsaPrivateKey();
+		try {
+			byte[] encryBytes = Base64.getDecoder().decode(encrypt);
+			byte[] decryBytes = RsaUtil.decryptByPrivateKey(encryBytes, privateKey.getEncoded());
+			if(decryBytes != null){
+				pureText = new String(decryBytes, Constants.ENCODING);
+			}
+			removeKeyPairMap(publicKey);
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+		return pureText;
+	}
+
+
+}

+ 65 - 0
mybusiness/src/main/java/com/dahua/sdk/client/util/StringUtil.java

@@ -0,0 +1,65 @@
+package com.dahua.sdk.client.util;
+
+public class StringUtil {
+
+    /**
+     *
+     * isEmpty:(判断对象是否为空)
+     *
+     * @param obj
+     * @return
+     * @throws
+     * @since Ver 1.1
+     */
+    public static boolean isEmpty(Object obj) {
+        if (obj == null) {
+            return true;
+        }
+        if (obj.equals("")) {
+            return true;
+        }
+        if (obj.toString().equalsIgnoreCase("null")) {
+            return true;
+        }
+        return false;
+    }
+
+    /**
+     * 是否整数
+     * @param s 检测对象
+     * @return 是/否
+     */
+    public static boolean isInteger(String s) {
+        try {
+            Integer.parseInt(s);
+            return true;
+        } catch (Exception e) {
+            return false;
+        }
+    }
+
+    /**
+     *
+     * isBlank:(判断对象是否为空,排除半角空格)
+     *
+     * @param obj
+     * @return
+     * @throws
+     * @since Ver 1.1
+     */
+    public static boolean isBlank(Object obj) {
+        if (obj == null) {
+            return true;
+        }
+        if (obj.equals("")) {
+            return true;
+        }
+        if (obj.toString().trim().equals("")) {
+            return true;
+        }
+        if (obj.toString().equalsIgnoreCase("null")) {
+            return true;
+        }
+        return false;
+    }
+}

+ 0 - 6
mybusiness/src/main/resources/templates/ksh/ksh.html

@@ -21,12 +21,6 @@
                 src="http://api.map.baidu.com/api?v=3.0&ak=PlhFWpA02aoURjAOpnWcRGqw7AI8EEyO"></script>
 
         <script th:src="@{/zhnc/hls.min.js}"></script>
-        <!--<script th:src="@{/zhnc/website/lib/polyfill.min.js}"></script>-->
-        <!--&lt;!&ndash; import Vue.js &ndash;&gt;-->
-        <!--<script th:src="@{/zhnc/website/lib/vue.js}"></script>-->
-        <!--&lt;!&ndash; import iView &ndash;&gt;-->
-        <!--<script th:src="@{/zhnc/website/lib/iview.js}" ></script>-->
-        <!--<script th:src="@{/zhnc/website/lib/DHWs.js}"></script>-->
 	</head>
     <style>
         /*地图标题*/