From 3aeb164c8dbf74209f0a132f3149ace8d9571ce9 Mon Sep 17 00:00:00 2001 From: panlinlin <648540858@qq.com> Date: Fri, 8 Jan 2021 13:33:19 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=AF=B9=E6=B0=B4?= =?UTF-8?q?=E6=98=9F=E4=BA=91=E5=8F=B0=E6=8E=A7=E5=88=B6=E7=9A=84=E6=94=AF?= =?UTF-8?q?=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DigestServerAuthenticationHelper.java | 51 ------------------- .../transmit/cmd/impl/SIPCommander.java | 6 +-- 2 files changed, 3 insertions(+), 54 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/auth/DigestServerAuthenticationHelper.java b/src/main/java/com/genersoft/iot/vmp/gb28181/auth/DigestServerAuthenticationHelper.java index 16ed56a3..a754a76e 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/auth/DigestServerAuthenticationHelper.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/auth/DigestServerAuthenticationHelper.java @@ -235,55 +235,4 @@ public class DigestServerAuthenticationHelper { return mdString.equals(response); } - - - public static void main(String[] args) throws NoSuchAlgorithmException { - MessageDigest messageDigest2 = MessageDigest.getInstance(DEFAULT_ALGORITHM); - String realm = "DS-2CD2520F"; - String username = "admin"; - String passwd = "12345"; - - String nonce = "4d6a553452444d30525441364e6d4d304e6a68684e47553d"; - - String uri = "/ISAPI/Streaming/channels/101/picture"; - // qop 保护质量 包含auth(默认的)和auth-int(增加了报文完整性检测)两种策略 - String qop = "auth"; - - // 客户端随机数,这是一个不透明的字符串值,由客户端提供,并且客户端和服务器都会使用,以避免用明文文本。 - // 这使得双方都可以查验对方的身份,并对消息的完整性提供一些保护 - String cNonce = "C1A5298F939E87E8F962A5EDFC206918"; - - // nonce计数器,是一个16进制的数值,表示同一nonce下客户端发送出请求的数量 - int nc = 1; - - String A1 = username + ":" + realm + ":" + passwd; - System.out.println("A1: " + A1); - String A2 = "GET" + ":" + uri.toString(); - System.out.println("A2: " + A2); - byte mdbytes[] = messageDigest2.digest(A1.getBytes()); - String HA1 = toHexString(mdbytes); - System.out.println("HA1: " + HA1); - - mdbytes = messageDigest2.digest(A2.getBytes()); - String HA2 = toHexString(mdbytes); - System.out.println("HA2: " + HA2); - String cnonce = "93d4d37df32e1a85"; - String KD = HA1 + ":" + nonce; - - if (nc != -1) { - KD += ":" + "00000001"; - } - if (cnonce != null) { - KD += ":" + cnonce; - } - if (qop != null) { - KD += ":" + qop; - } - KD += ":" + HA2; - System.out.println("KD: " + KD); - mdbytes = messageDigest2.digest(KD.getBytes()); - String mdString = toHexString(mdbytes); - String response = "3993a815e5cdaf4470e9b4f9bd41cf4a"; - System.out.println(mdString); - } } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java index 5da4b8dd..26d0f234 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java @@ -232,7 +232,7 @@ public class SIPCommander implements ISIPCommander { ptzXml.append("\r\n"); ptzXml.append("\r\n"); - Request request = headerProvider.createMessageRequest(device, ptzXml.toString(), "ViaPtzBranch", "FromPtzTag", "ToPtzTag"); + Request request = headerProvider.createMessageRequest(device, ptzXml.toString(), "ViaPtzBranch", "FromPtzTag", null); transmitRequest(device, request); return true; @@ -268,7 +268,7 @@ public class SIPCommander implements ISIPCommander { ptzXml.append("\r\n"); ptzXml.append("\r\n"); - Request request = headerProvider.createMessageRequest(device, ptzXml.toString(), "ViaPtzBranch", "FromPtzTag", "ToPtzTag"); + Request request = headerProvider.createMessageRequest(device, ptzXml.toString(), "ViaPtzBranch", "FromPtzTag", null); transmitRequest(device, request); return true; } catch (SipException | ParseException | InvalidArgumentException e) { @@ -635,7 +635,7 @@ public class SIPCommander implements ISIPCommander { catalogXml.append("" + device.getDeviceId() + "\r\n"); catalogXml.append("\r\n"); - Request request = headerProvider.createMessageRequest(device, catalogXml.toString(), "ViaDeviceInfoBranch", "FromDeviceInfoTag", "ToDeviceInfoTag"); + Request request = headerProvider.createMessageRequest(device, catalogXml.toString(), "ViaDeviceInfoBranch", "FromDeviceInfoTag", null); transmitRequest(device, request); From 781247e1af1301507421c054b55a989147edd2fb Mon Sep 17 00:00:00 2001 From: panlinlin <648540858@qq.com> Date: Fri, 8 Jan 2021 14:46:55 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E8=AE=BE=E5=A4=87=E5=92=8C=E9=80=9A=E9=81=93=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E6=97=B6=E6=A3=80=E6=B5=8B=E5=AD=97=E6=AE=B5=E6=98=AF=E5=90=A6?= =?UTF-8?q?=E5=AD=98=E5=9C=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vmp/storager/dao/DeviceChannelMapper.java | 43 ++++++++++++++++--- .../iot/vmp/storager/dao/DeviceMapper.java | 27 ++++++------ 2 files changed, 51 insertions(+), 19 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceChannelMapper.java b/src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceChannelMapper.java index eecc0bb5..9312f23f 100644 --- a/src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceChannelMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceChannelMapper.java @@ -19,13 +19,42 @@ public interface DeviceChannelMapper { "'${ipAddress}', ${port}, '${password}', ${PTZType}, ${status})") int add(DeviceChannel channel); - @Update("UPDATE device_channel " + - "SET name=#{name}, manufacture=#{manufacture}, model=#{model}, owner=#{owner}, civilCode=#{civilCode}, " + - "block=#{block}, address=#{address}, parental=#{parental}, parentId=#{parentId}, safetyWay=#{safetyWay}, " + - "registerWay=#{registerWay}, certNum=#{certNum}, certifiable=#{certifiable}, errCode=#{errCode}, secrecy=#{secrecy}, " + - "ipAddress=#{ipAddress}, port=#{port}, password=#{password}, PTZType=#{PTZType}, status=#{status}, streamId=#{streamId}, " + - "hasAudio=#{hasAudio}" + - "WHERE deviceId=#{deviceId} AND channelId=#{channelId}") +// @Update("UPDATE device_channel " + +// "SET name=#{name}, manufacture=#{manufacture}, model=#{model}, owner=#{owner}, civilCode=#{civilCode}, " + +// "block=#{block}, address=#{address}, parental=#{parental}, parentId=#{parentId}, safetyWay=#{safetyWay}, " + +// "registerWay=#{registerWay}, certNum=#{certNum}, certifiable=#{certifiable}, errCode=#{errCode}, secrecy=#{secrecy}, " + +// "ipAddress=#{ipAddress}, port=#{port}, password=#{password}, PTZType=#{PTZType}, status=#{status}, streamId=#{streamId}, " + +// "hasAudio=#{hasAudio}" + +// "WHERE deviceId=#{deviceId} AND channelId=#{channelId}") + + + @Update(value = {" "}) int update(DeviceChannel channel); @Select(value = {" "}) int update(Device device); @Select("SELECT *, (SELECT count(0) FROM device_channel WHERE deviceId=de.deviceId) as channelCount FROM device de")