Merge branch 'wvp-28181-2.0' into database-structure-optimization
commit
c56a842194
|
@ -14,9 +14,6 @@ import org.springframework.boot.CommandLineRunner;
|
||||||
import org.springframework.core.annotation.Order;
|
import org.springframework.core.annotation.Order;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import javax.sip.InvalidArgumentException;
|
|
||||||
import javax.sip.SipException;
|
|
||||||
import java.text.ParseException;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -61,8 +58,10 @@ public class SipPlatformRunner implements CommandLineRunner {
|
||||||
sipCommanderForPlatform.unregister(parentPlatform, parentPlatformCatchOld.getSipTransactionInfo(), null, (eventResult)->{
|
sipCommanderForPlatform.unregister(parentPlatform, parentPlatformCatchOld.getSipTransactionInfo(), null, (eventResult)->{
|
||||||
platformService.login(parentPlatform);
|
platformService.login(parentPlatform);
|
||||||
});
|
});
|
||||||
} catch (InvalidArgumentException | ParseException | SipException e) {
|
} catch (Exception e) {
|
||||||
logger.error("[命令发送失败] 国标级联 注销: {}", e.getMessage());
|
logger.error("[命令发送失败] 国标级联 注销: {}", e.getMessage());
|
||||||
|
platformService.offline(parentPlatform, true);
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
package com.genersoft.iot.vmp.conf.security;
|
package com.genersoft.iot.vmp.conf.security;
|
||||||
|
|
||||||
import com.genersoft.iot.vmp.conf.security.dto.JwtUser;
|
import com.genersoft.iot.vmp.conf.security.dto.JwtUser;
|
||||||
import org.jose4j.json.JsonUtil;
|
import com.genersoft.iot.vmp.service.IUserService;
|
||||||
|
import com.genersoft.iot.vmp.storager.dao.dto.User;
|
||||||
import org.jose4j.jwk.RsaJsonWebKey;
|
import org.jose4j.jwk.RsaJsonWebKey;
|
||||||
|
import org.jose4j.jwk.RsaJwkGenerator;
|
||||||
import org.jose4j.jws.AlgorithmIdentifiers;
|
import org.jose4j.jws.AlgorithmIdentifiers;
|
||||||
import org.jose4j.jws.JsonWebSignature;
|
import org.jose4j.jws.JsonWebSignature;
|
||||||
import org.jose4j.jwt.JwtClaims;
|
import org.jose4j.jwt.JwtClaims;
|
||||||
|
@ -14,45 +16,69 @@ import org.jose4j.jwt.consumer.JwtConsumerBuilder;
|
||||||
import org.jose4j.lang.JoseException;
|
import org.jose4j.lang.JoseException;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.InitializingBean;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.security.PrivateKey;
|
import javax.annotation.Resource;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.ZoneOffset;
|
import java.time.ZoneOffset;
|
||||||
|
|
||||||
public class JwtUtils {
|
@Component
|
||||||
|
public class JwtUtils implements InitializingBean {
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(JwtUtils.class);
|
private static final Logger logger = LoggerFactory.getLogger(JwtUtils.class);
|
||||||
|
|
||||||
private static final String HEADER = "access-token";
|
private static final String HEADER = "access-token";
|
||||||
|
|
||||||
private static final String AUDIENCE = "Audience";
|
private static final String AUDIENCE = "Audience";
|
||||||
|
|
||||||
private static final long EXPIRED_THRESHOLD = 10 * 60;
|
|
||||||
|
|
||||||
private static final String keyId = "3e79646c4dbc408383a9eed09f2b85ae";
|
private static final String keyId = "3e79646c4dbc408383a9eed09f2b85ae";
|
||||||
private static final String privateKeyStr = "{\"kty\":\"RSA\",\"kid\":\"3e79646c4dbc408383a9eed09f2b85ae\",\"alg\":\"RS256\",\"n\":\"gndmVdiOTSJ5et2HIeTM5f1m61x5ojLUi5HDfvr-jRrESQ5kbKuySGHVwR4QhwinpY1wQqBnwc80tx7cb_6SSqsTOoGln6T_l3k2Pb54ClVnGWiW_u1kmX78V2TZOsVmZmwtdZCMi-2zWIyAdIEXE-gncIehoAgEoq2VAhaCURbJWro_EwzzQwNmCTkDodLAx4npXRd_qSu0Ayp0txym9OFovBXBULRvk4DPiy3i_bPUmCDxzC46pTtFOe9p82uybTehZfULZtXXqRm85FL9n5zkrsTllPNAyEGhgb0RK9sE5nK1m_wNNysDyfLC4EFf1VXTrKm14XNVjc2vqLb7Mw\",\"e\":\"AQAB\",\"d\":\"ed7U_k3rJ4yTk70JtRSIfjKGiEb67BO1TabcymnljKO7RU8nage84zZYuSu_XpQsHk6P1f0Gzxkicghm_Er-FrfVn2pp70Xu52z3yRd6BJUgWLDFk97ngScIyw5OiULKU9SrZk2frDpftNCSUcIgb50F8m0QAnBa_CdPsQKbuuhLv8V8tBAV7F_lAwvSBgu56wRo3hPz5dWH8YeXM7XBfQ9viFMNEKd21sP_j5C7ueUnXT66nBxe3ZJEU3iuMYM6D6dB_KW2GfZC6WmTgvGhhxJD0h7aYmfjkD99MDleB7SkpbvoODOqiQ5Epb7Nyh6kv5u4KUv2CJYtATLZkUeMkQ\",\"p\":\"uBUjWPWtlGksmOqsqCNWksfqJvMcnP_8TDYN7e4-WnHL4N-9HjRuPDnp6kHvCIEi9SEfxm7gNxlRcWegvNQr3IZCz7TnCTexXc5NOklB9OavWFla6u-s3Thn6Tz45-EUjpJr0VJMxhO-KxGmuTwUXBBp4vN6K2qV6rQNFmgkWzk\",\"q\":\"tW_i7cCec56bHkhITL_79dXHz_PLC_f7xlynmlZJGU_d6mqOKmLBNBbTMLnYW8uAFiFzWxDeDHh1o5uF0mSQR-Z1Fg35OftnpbWpy0Cbc2la5WgXQjOwtG1eLYIY2BD3-wQ1VYDBCvowr4FDi-sngxwLqvwmrJ0xjhi99O-Gzcs\",\"dp\":\"q1d5jE85Hz_6M-eTh_lEluEf0NtPEc-vvhw-QO4V-cecNpbrCBdTWBmr4dE3NdpFeJc5ZVFEv-SACyei1MBEh0ItI_pFZi4BmMfy2ELh8ptaMMkTOESYyVy8U7veDq9RnBcr5i1Nqr0rsBkA77-9T6gzdvycBZdzLYAkAmwzEvk\",\"dq\":\"q29A2K08Crs-jmp2Bi8Q_8QzvIX6wSBbwZ4ir24AO-5_HNP56IrPS0yV2GCB0pqCOGb6_Hz_koDvhtuYoqdqvMVAtMoXR3YJBUaVXPt65p4RyNmFwIPe31zHs_BNUTsXVRMw4c16mci03-Af1sEm4HdLfxAp6sfM3xr5wcnhcek\",\"qi\":\"rHPgVTyHUHuYzcxfouyBfb1XAY8nshwn0ddo81o1BccD4Z7zo5It6SefDHjxCAbcmbiCcXBSooLcY-NF5FMv3fg19UE21VyLQltHcVjRRp2tRs4OHcM8yaXIU2x6N6Z6BP2tOksHb9MOBY1wAQzFOAKg_G4Sxev6-_6ud6RISuc\"}";
|
|
||||||
private static final String publicKeyStr = "{\"kty\":\"RSA\",\"kid\":\"3e79646c4dbc408383a9eed09f2b85ae\",\"alg\":\"RS256\",\"n\":\"gndmVdiOTSJ5et2HIeTM5f1m61x5ojLUi5HDfvr-jRrESQ5kbKuySGHVwR4QhwinpY1wQqBnwc80tx7cb_6SSqsTOoGln6T_l3k2Pb54ClVnGWiW_u1kmX78V2TZOsVmZmwtdZCMi-2zWIyAdIEXE-gncIehoAgEoq2VAhaCURbJWro_EwzzQwNmCTkDodLAx4npXRd_qSu0Ayp0txym9OFovBXBULRvk4DPiy3i_bPUmCDxzC46pTtFOe9p82uybTehZfULZtXXqRm85FL9n5zkrsTllPNAyEGhgb0RK9sE5nK1m_wNNysDyfLC4EFf1VXTrKm14XNVjc2vqLb7Mw\",\"e\":\"AQAB\"}";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* token过期时间(分钟)
|
* token过期时间(分钟)
|
||||||
*/
|
*/
|
||||||
public static final long expirationTime = 30 * 24 * 60;
|
public static final long expirationTime = 30 * 24 * 60;
|
||||||
|
|
||||||
public static String createToken(String username, String password, Integer roleId) {
|
private static RsaJsonWebKey rsaJsonWebKey;
|
||||||
|
|
||||||
|
private static IUserService userService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
public void setUserService(IUserService userService) {
|
||||||
|
JwtUtils.userService = userService;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void afterPropertiesSet() {
|
||||||
try {
|
try {
|
||||||
|
rsaJsonWebKey = generateRsaJsonWebKey();
|
||||||
|
} catch (JoseException e) {
|
||||||
|
logger.error("生成RsaJsonWebKey报错。", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* 创建密钥对
|
||||||
|
* @throws JoseException JoseException
|
||||||
|
*/
|
||||||
|
private RsaJsonWebKey generateRsaJsonWebKey() throws JoseException {
|
||||||
|
// 生成一个RSA密钥对,该密钥对将用于JWT的签名和验证,包装在JWK中
|
||||||
|
RsaJsonWebKey rsaJsonWebKey = RsaJwkGenerator.generateJwk(2048);
|
||||||
|
// 给JWK一个密钥ID
|
||||||
|
rsaJsonWebKey.setKeyId(keyId);
|
||||||
|
return rsaJsonWebKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String createToken(String username) {
|
||||||
|
try {
|
||||||
|
/*
|
||||||
* “iss” (issuer) 发行人
|
* “iss” (issuer) 发行人
|
||||||
*
|
|
||||||
* “sub” (subject) 主题
|
* “sub” (subject) 主题
|
||||||
*
|
|
||||||
* “aud” (audience) 接收方 用户
|
* “aud” (audience) 接收方 用户
|
||||||
*
|
|
||||||
* “exp” (expiration time) 到期时间
|
* “exp” (expiration time) 到期时间
|
||||||
*
|
|
||||||
* “nbf” (not before) 在此之前不可用
|
* “nbf” (not before) 在此之前不可用
|
||||||
*
|
|
||||||
* “iat” (issued at) jwt的签发时间
|
* “iat” (issued at) jwt的签发时间
|
||||||
*/
|
*/
|
||||||
//Payload
|
|
||||||
JwtClaims claims = new JwtClaims();
|
JwtClaims claims = new JwtClaims();
|
||||||
claims.setGeneratedJwtId();
|
claims.setGeneratedJwtId();
|
||||||
claims.setIssuedAtToNow();
|
claims.setIssuedAtToNow();
|
||||||
|
@ -62,9 +88,7 @@ public class JwtUtils {
|
||||||
claims.setSubject("login");
|
claims.setSubject("login");
|
||||||
claims.setAudience(AUDIENCE);
|
claims.setAudience(AUDIENCE);
|
||||||
//添加自定义参数,必须是字符串类型
|
//添加自定义参数,必须是字符串类型
|
||||||
claims.setClaim("username", username);
|
claims.setClaim("userName", username);
|
||||||
claims.setClaim("password", password);
|
|
||||||
claims.setClaim("roleId", roleId);
|
|
||||||
|
|
||||||
//jws
|
//jws
|
||||||
JsonWebSignature jws = new JsonWebSignature();
|
JsonWebSignature jws = new JsonWebSignature();
|
||||||
|
@ -73,12 +97,10 @@ public class JwtUtils {
|
||||||
jws.setKeyIdHeaderValue(keyId);
|
jws.setKeyIdHeaderValue(keyId);
|
||||||
jws.setPayload(claims.toJson());
|
jws.setPayload(claims.toJson());
|
||||||
|
|
||||||
PrivateKey privateKey = new RsaJsonWebKey(JsonUtil.parseJson(privateKeyStr)).getPrivateKey();
|
jws.setKey(rsaJsonWebKey.getPrivateKey());
|
||||||
jws.setKey(privateKey);
|
|
||||||
|
|
||||||
//get token
|
//get token
|
||||||
String idToken = jws.getCompactSerialization();
|
return jws.getCompactSerialization();
|
||||||
return idToken;
|
|
||||||
} catch (JoseException e) {
|
} catch (JoseException e) {
|
||||||
logger.error("[Token生成失败]: {}", e.getMessage());
|
logger.error("[Token生成失败]: {}", e.getMessage());
|
||||||
}
|
}
|
||||||
|
@ -90,7 +112,6 @@ public class JwtUtils {
|
||||||
return HEADER;
|
return HEADER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static JwtUser verifyToken(String token) {
|
public static JwtUser verifyToken(String token) {
|
||||||
|
|
||||||
JwtUser jwtUser = new JwtUser();
|
JwtUser jwtUser = new JwtUser();
|
||||||
|
@ -103,7 +124,7 @@ public class JwtUtils {
|
||||||
.setRequireSubject()
|
.setRequireSubject()
|
||||||
//.setExpectedIssuer("")
|
//.setExpectedIssuer("")
|
||||||
.setExpectedAudience(AUDIENCE)
|
.setExpectedAudience(AUDIENCE)
|
||||||
.setVerificationKey(new RsaJsonWebKey(JsonUtil.parseJson(publicKeyStr)).getPublicKey())
|
.setVerificationKey(rsaJsonWebKey.getPublicKey())
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
JwtClaims claims = consumer.processToClaims(token);
|
JwtClaims claims = consumer.processToClaims(token);
|
||||||
|
@ -117,12 +138,12 @@ public class JwtUtils {
|
||||||
jwtUser.setStatus(JwtUser.TokenStatus.NORMAL);
|
jwtUser.setStatus(JwtUser.TokenStatus.NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
String username = (String) claims.getClaimValue("username");
|
String username = (String) claims.getClaimValue("userName");
|
||||||
String password = (String) claims.getClaimValue("password");
|
User user = userService.getUserByUsername(username);
|
||||||
Long roleId = (Long) claims.getClaimValue("roleId");
|
|
||||||
jwtUser.setUserName(username);
|
jwtUser.setUserName(username);
|
||||||
jwtUser.setPassword(password);
|
jwtUser.setPassword(user.getPassword());
|
||||||
jwtUser.setRoleId(roleId.intValue());
|
jwtUser.setRoleId(user.getRole().getId());
|
||||||
|
|
||||||
return jwtUser;
|
return jwtUser;
|
||||||
} catch (InvalidJwtException e) {
|
} catch (InvalidJwtException e) {
|
||||||
|
|
|
@ -2,12 +2,9 @@ package com.genersoft.iot.vmp.gb28181.bean;
|
||||||
|
|
||||||
import com.genersoft.iot.vmp.common.VideoManagerConstants;
|
import com.genersoft.iot.vmp.common.VideoManagerConstants;
|
||||||
import com.genersoft.iot.vmp.conf.DynamicTask;
|
import com.genersoft.iot.vmp.conf.DynamicTask;
|
||||||
|
import com.genersoft.iot.vmp.conf.UserSetting;
|
||||||
import com.genersoft.iot.vmp.gb28181.task.ISubscribeTask;
|
import com.genersoft.iot.vmp.gb28181.task.ISubscribeTask;
|
||||||
import com.genersoft.iot.vmp.gb28181.task.impl.MobilePositionSubscribeHandlerTask;
|
import com.genersoft.iot.vmp.gb28181.task.impl.MobilePositionSubscribeHandlerTask;
|
||||||
import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform;
|
|
||||||
import com.genersoft.iot.vmp.service.IPlatformService;
|
|
||||||
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
|
|
||||||
import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@ -24,6 +21,9 @@ public class SubscribeHolder {
|
||||||
@Autowired
|
@Autowired
|
||||||
private DynamicTask dynamicTask;
|
private DynamicTask dynamicTask;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private UserSetting userSetting;
|
||||||
|
|
||||||
private final String taskOverduePrefix = "subscribe_overdue_";
|
private final String taskOverduePrefix = "subscribe_overdue_";
|
||||||
|
|
||||||
private static ConcurrentHashMap<String, SubscribeInfo> catalogMap = new ConcurrentHashMap<>();
|
private static ConcurrentHashMap<String, SubscribeInfo> catalogMap = new ConcurrentHashMap<>();
|
||||||
|
@ -58,7 +58,7 @@ public class SubscribeHolder {
|
||||||
|
|
||||||
public void putMobilePositionSubscribe(String platformId, SubscribeInfo subscribeInfo) {
|
public void putMobilePositionSubscribe(String platformId, SubscribeInfo subscribeInfo) {
|
||||||
mobilePositionMap.put(platformId, subscribeInfo);
|
mobilePositionMap.put(platformId, subscribeInfo);
|
||||||
String key = VideoManagerConstants.SIP_SUBSCRIBE_PREFIX + "MobilePosition_" + platformId;
|
String key = VideoManagerConstants.SIP_SUBSCRIBE_PREFIX + userSetting.getServerId() + "MobilePosition_" + platformId;
|
||||||
// 添加任务处理GPS定时推送
|
// 添加任务处理GPS定时推送
|
||||||
dynamicTask.startCron(key, new MobilePositionSubscribeHandlerTask(platformId),
|
dynamicTask.startCron(key, new MobilePositionSubscribeHandlerTask(platformId),
|
||||||
subscribeInfo.getGpsInterval() * 1000);
|
subscribeInfo.getGpsInterval() * 1000);
|
||||||
|
@ -76,7 +76,7 @@ public class SubscribeHolder {
|
||||||
|
|
||||||
public void removeMobilePositionSubscribe(String platformId) {
|
public void removeMobilePositionSubscribe(String platformId) {
|
||||||
mobilePositionMap.remove(platformId);
|
mobilePositionMap.remove(platformId);
|
||||||
String key = VideoManagerConstants.SIP_SUBSCRIBE_PREFIX + "MobilePosition_" + platformId;
|
String key = VideoManagerConstants.SIP_SUBSCRIBE_PREFIX + userSetting.getServerId() + "MobilePosition_" + platformId;
|
||||||
// 结束任务处理GPS定时推送
|
// 结束任务处理GPS定时推送
|
||||||
dynamicTask.stop(key);
|
dynamicTask.stop(key);
|
||||||
String taskOverdueKey = taskOverduePrefix + "MobilePosition_" + platformId;
|
String taskOverdueKey = taskOverduePrefix + "MobilePosition_" + platformId;
|
||||||
|
|
|
@ -3,6 +3,8 @@ package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message;
|
||||||
import com.genersoft.iot.vmp.gb28181.bean.Device;
|
import com.genersoft.iot.vmp.gb28181.bean.Device;
|
||||||
import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
|
import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
|
||||||
import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent;
|
import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent;
|
||||||
|
import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.query.cmd.CatalogQueryMessageHandler;
|
||||||
|
import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
|
||||||
import org.dom4j.Element;
|
import org.dom4j.Element;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
|
@ -16,6 +18,9 @@ public abstract class MessageHandlerAbstract extends SIPRequestProcessorParent i
|
||||||
|
|
||||||
public Map<String, IMessageHandler> messageHandlerMap = new ConcurrentHashMap<>();
|
public Map<String, IMessageHandler> messageHandlerMap = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IVideoManagerStorage storage;
|
||||||
|
|
||||||
public void addHandler(String cmdType, IMessageHandler messageHandler) {
|
public void addHandler(String cmdType, IMessageHandler messageHandler) {
|
||||||
messageHandlerMap.put(cmdType, messageHandler);
|
messageHandlerMap.put(cmdType, messageHandler);
|
||||||
}
|
}
|
||||||
|
@ -24,7 +29,15 @@ public abstract class MessageHandlerAbstract extends SIPRequestProcessorParent i
|
||||||
public void handForDevice(RequestEvent evt, Device device, Element element) {
|
public void handForDevice(RequestEvent evt, Device device, Element element) {
|
||||||
String cmd = getText(element, "CmdType");
|
String cmd = getText(element, "CmdType");
|
||||||
IMessageHandler messageHandler = messageHandlerMap.get(cmd);
|
IMessageHandler messageHandler = messageHandlerMap.get(cmd);
|
||||||
|
|
||||||
if (messageHandler != null) {
|
if (messageHandler != null) {
|
||||||
|
//两个国标平台互相级联时由于上一步判断导致本该在平台处理的消息 放到了设备的处理逻辑
|
||||||
|
//所以对目录查询单独做了校验
|
||||||
|
if(messageHandler instanceof CatalogQueryMessageHandler){
|
||||||
|
ParentPlatform parentPlatform = storage.queryParentPlatByServerGBId(device.getDeviceId());
|
||||||
|
messageHandler.handForPlatform(evt, parentPlatform, element);
|
||||||
|
return;
|
||||||
|
}
|
||||||
messageHandler.handForDevice(evt, device, element);
|
messageHandler.handForDevice(evt, device, element);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,6 +30,7 @@ import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||||
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 目录查询的回复
|
* 目录查询的回复
|
||||||
|
@ -60,6 +61,7 @@ public class CatalogResponseMessageHandler extends SIPRequestProcessorParent imp
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private SipConfig sipConfig;
|
private SipConfig sipConfig;
|
||||||
|
private AtomicBoolean processing = new AtomicBoolean(false);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void afterPropertiesSet() throws Exception {
|
public void afterPropertiesSet() throws Exception {
|
||||||
|
@ -68,7 +70,6 @@ public class CatalogResponseMessageHandler extends SIPRequestProcessorParent imp
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handForDevice(RequestEvent evt, Device device, Element element) {
|
public void handForDevice(RequestEvent evt, Device device, Element element) {
|
||||||
boolean isEmpty = taskQueue.isEmpty();
|
|
||||||
taskQueue.offer(new HandlerCatchData(evt, device, element));
|
taskQueue.offer(new HandlerCatchData(evt, device, element));
|
||||||
// 回复200 OK
|
// 回复200 OK
|
||||||
try {
|
try {
|
||||||
|
@ -76,8 +77,8 @@ public class CatalogResponseMessageHandler extends SIPRequestProcessorParent imp
|
||||||
} catch (SipException | InvalidArgumentException | ParseException e) {
|
} catch (SipException | InvalidArgumentException | ParseException e) {
|
||||||
logger.error("[命令发送失败] 目录查询回复: {}", e.getMessage());
|
logger.error("[命令发送失败] 目录查询回复: {}", e.getMessage());
|
||||||
}
|
}
|
||||||
// 如果不为空则说明已经开启消息处理
|
// 已经开启消息处理则跳过
|
||||||
if (isEmpty) {
|
if (processing.compareAndSet(false, true)) {
|
||||||
taskExecutor.execute(() -> {
|
taskExecutor.execute(() -> {
|
||||||
while (!taskQueue.isEmpty()) {
|
while (!taskQueue.isEmpty()) {
|
||||||
// 全局异常捕获,保证下一条可以得到处理
|
// 全局异常捕获,保证下一条可以得到处理
|
||||||
|
@ -151,6 +152,7 @@ public class CatalogResponseMessageHandler extends SIPRequestProcessorParent imp
|
||||||
logger.error("[收到通道] 异常内容: ", e);
|
logger.error("[收到通道] 异常内容: ", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
processing.set(false);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -511,6 +511,10 @@ public class DeviceServiceImpl implements IDeviceService {
|
||||||
if (!ObjectUtils.isEmpty(device.getSdpIp())) {
|
if (!ObjectUtils.isEmpty(device.getSdpIp())) {
|
||||||
deviceInStore.setSdpIp(device.getSdpIp());
|
deviceInStore.setSdpIp(device.getSdpIp());
|
||||||
}
|
}
|
||||||
|
if (!ObjectUtils.isEmpty(device.getPassword())) {
|
||||||
|
deviceInStore.setPassword(device.getPassword());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// 目录订阅相关的信息
|
// 目录订阅相关的信息
|
||||||
if (device.getSubscribeCycleForCatalog() > 0) {
|
if (device.getSubscribeCycleForCatalog() > 0) {
|
||||||
|
@ -544,18 +548,23 @@ public class DeviceServiceImpl implements IDeviceService {
|
||||||
if (deviceInStore.getGeoCoordSys() != null) {
|
if (deviceInStore.getGeoCoordSys() != null) {
|
||||||
// 坐标系变化,需要重新计算GCJ02坐标和WGS84坐标
|
// 坐标系变化,需要重新计算GCJ02坐标和WGS84坐标
|
||||||
if (!deviceInStore.getGeoCoordSys().equals(device.getGeoCoordSys())) {
|
if (!deviceInStore.getGeoCoordSys().equals(device.getGeoCoordSys())) {
|
||||||
updateDeviceChannelGeoCoordSys(device);
|
deviceInStore.setGeoCoordSys(device.getGeoCoordSys());
|
||||||
|
updateDeviceChannelGeoCoordSys(deviceInStore);
|
||||||
}
|
}
|
||||||
}else {
|
}else {
|
||||||
device.setGeoCoordSys("WGS84");
|
deviceInStore.setGeoCoordSys("WGS84");
|
||||||
}
|
}
|
||||||
if (device.getCharset() == null) {
|
if (device.getCharset() == null) {
|
||||||
device.setCharset("GB2312");
|
deviceInStore.setCharset("GB2312");
|
||||||
}
|
}
|
||||||
|
//SSRC校验
|
||||||
|
deviceInStore.setSsrcCheck(device.isSsrcCheck());
|
||||||
|
//作为消息通道
|
||||||
|
deviceInStore.setAsMessageChannel(device.isAsMessageChannel());
|
||||||
|
|
||||||
// 更新redis
|
// 更新redis
|
||||||
redisCatchStorage.updateDevice(device);
|
deviceMapper.updateCustom(deviceInStore);
|
||||||
deviceMapper.updateCustom(device);
|
redisCatchStorage.removeDevice(deviceInStore.getDeviceId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -128,7 +128,7 @@ public class MediaServerServiceImpl implements IMediaServerService {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// 更新
|
// 更新
|
||||||
if (ssrcFactory.hasMediaServerSSRC(mediaServerItem.getId())) {
|
if (!ssrcFactory.hasMediaServerSSRC(mediaServerItem.getId())) {
|
||||||
ssrcFactory.initMediaServerSSRC(mediaServerItem.getId(), null);
|
ssrcFactory.initMediaServerSSRC(mediaServerItem.getId(), null);
|
||||||
}
|
}
|
||||||
// 查询redis是否存在此mediaServer
|
// 查询redis是否存在此mediaServer
|
||||||
|
@ -229,7 +229,7 @@ public class MediaServerServiceImpl implements IMediaServerService {
|
||||||
mediaServerMapper.update(mediaSerItem);
|
mediaServerMapper.update(mediaSerItem);
|
||||||
MediaServerItem mediaServerItemInRedis = getOne(mediaSerItem.getId());
|
MediaServerItem mediaServerItemInRedis = getOne(mediaSerItem.getId());
|
||||||
MediaServerItem mediaServerItemInDataBase = mediaServerMapper.queryOne(mediaSerItem.getId());
|
MediaServerItem mediaServerItemInDataBase = mediaServerMapper.queryOne(mediaSerItem.getId());
|
||||||
if (mediaServerItemInRedis == null || ssrcFactory.hasMediaServerSSRC(mediaSerItem.getId())) {
|
if (mediaServerItemInRedis == null || !ssrcFactory.hasMediaServerSSRC(mediaSerItem.getId())) {
|
||||||
ssrcFactory.initMediaServerSSRC(mediaServerItemInDataBase.getId(),null);
|
ssrcFactory.initMediaServerSSRC(mediaServerItemInDataBase.getId(),null);
|
||||||
}
|
}
|
||||||
String key = VideoManagerConstants.MEDIA_SERVER_PREFIX + userSetting.getServerId() + "_" + mediaServerItemInDataBase.getId();
|
String key = VideoManagerConstants.MEDIA_SERVER_PREFIX + userSetting.getServerId() + "_" + mediaServerItemInDataBase.getId();
|
||||||
|
@ -411,7 +411,7 @@ public class MediaServerServiceImpl implements IMediaServerService {
|
||||||
}
|
}
|
||||||
mediaServerMapper.update(serverItem);
|
mediaServerMapper.update(serverItem);
|
||||||
String key = VideoManagerConstants.MEDIA_SERVER_PREFIX + userSetting.getServerId() + "_" + zlmServerConfig.getGeneralMediaServerId();
|
String key = VideoManagerConstants.MEDIA_SERVER_PREFIX + userSetting.getServerId() + "_" + zlmServerConfig.getGeneralMediaServerId();
|
||||||
if (ssrcFactory.hasMediaServerSSRC(serverItem.getId())) {
|
if (!ssrcFactory.hasMediaServerSSRC(serverItem.getId())) {
|
||||||
ssrcFactory.initMediaServerSSRC(zlmServerConfig.getGeneralMediaServerId(), null);
|
ssrcFactory.initMediaServerSSRC(zlmServerConfig.getGeneralMediaServerId(), null);
|
||||||
}
|
}
|
||||||
redisTemplate.opsForValue().set(key, serverItem);
|
redisTemplate.opsForValue().set(key, serverItem);
|
||||||
|
|
|
@ -276,7 +276,7 @@ public class PlatformServiceImpl implements IPlatformService {
|
||||||
eventResult.statusCode, eventResult.msg);
|
eventResult.statusCode, eventResult.msg);
|
||||||
offline(parentPlatform, false);
|
offline(parentPlatform, false);
|
||||||
}, null);
|
}, null);
|
||||||
} catch (InvalidArgumentException | ParseException | SipException e) {
|
} catch (Exception e) {
|
||||||
logger.error("[命令发送失败] 国标级联定时注册: {}", e.getMessage());
|
logger.error("[命令发送失败] 国标级联定时注册: {}", e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,7 +57,7 @@ public class UserController {
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
throw new ControllerException(ErrorCode.ERROR100.getCode(), "用户名或密码错误");
|
throw new ControllerException(ErrorCode.ERROR100.getCode(), "用户名或密码错误");
|
||||||
}else {
|
}else {
|
||||||
String jwt = JwtUtils.createToken(username, password, user.getRole().getId());
|
String jwt = JwtUtils.createToken(username);
|
||||||
response.setHeader(JwtUtils.getHeader(), jwt);
|
response.setHeader(JwtUtils.getHeader(), jwt);
|
||||||
user.setAccessToken(jwt);
|
user.setAccessToken(jwt);
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,14 +19,14 @@ spring:
|
||||||
# [可选] 数据库 DB
|
# [可选] 数据库 DB
|
||||||
database: 7
|
database: 7
|
||||||
# [可选] 访问密码,若你的redis服务器没有设置密码,就不需要用密码去连接
|
# [可选] 访问密码,若你的redis服务器没有设置密码,就不需要用密码去连接
|
||||||
password:
|
password: luna
|
||||||
# [可选] 超时时间
|
# [可选] 超时时间
|
||||||
timeout: 10000
|
timeout: 10000
|
||||||
# mysql数据源
|
# mysql数据源
|
||||||
datasource:
|
datasource:
|
||||||
type: com.zaxxer.hikari.HikariDataSource
|
type: com.zaxxer.hikari.HikariDataSource
|
||||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||||
url: jdbc:mysql://127.0.0.1:3306/test_gb-89wulian?useUnicode=true&characterEncoding=UTF8&rewriteBatchedStatements=true&serverTimezone=PRC&useSSL=false&allowMultiQueries=true
|
url: jdbc:mysql://127.0.0.1:3306/wvp?useUnicode=true&characterEncoding=UTF8&rewriteBatchedStatements=true&serverTimezone=PRC&useSSL=false&allowMultiQueries=true
|
||||||
username: root
|
username: root
|
||||||
password: root
|
password: root
|
||||||
hikari:
|
hikari:
|
||||||
|
@ -38,7 +38,7 @@ spring:
|
||||||
max-lifetime: 1200000 # 是池中连接关闭后的最长生命周期(以毫秒为单位)
|
max-lifetime: 1200000 # 是池中连接关闭后的最长生命周期(以毫秒为单位)
|
||||||
#[可选] WVP监听的HTTP端口, 网页和接口调用都是这个端口
|
#[可选] WVP监听的HTTP端口, 网页和接口调用都是这个端口
|
||||||
server:
|
server:
|
||||||
port: 18978
|
port: 8080
|
||||||
# [可选] HTTPS配置, 默认不开启
|
# [可选] HTTPS配置, 默认不开启
|
||||||
ssl:
|
ssl:
|
||||||
# [可选] 是否开启HTTPS访问
|
# [可选] 是否开启HTTPS访问
|
||||||
|
@ -56,7 +56,7 @@ sip:
|
||||||
# 如果要监听多张网卡,可以使用逗号分隔多个IP, 例如: 192.168.1.4,10.0.0.4
|
# 如果要监听多张网卡,可以使用逗号分隔多个IP, 例如: 192.168.1.4,10.0.0.4
|
||||||
# 如果不明白,就使用0.0.0.0,大部分情况都是可以的
|
# 如果不明白,就使用0.0.0.0,大部分情况都是可以的
|
||||||
# 请不要使用127.0.0.1,任何包括localhost在内的域名都是不可以的。
|
# 请不要使用127.0.0.1,任何包括localhost在内的域名都是不可以的。
|
||||||
ip: 192.168.1.18
|
ip: 172.19.128.50
|
||||||
# [可选] 28181服务监听的端口
|
# [可选] 28181服务监听的端口
|
||||||
port: 8116
|
port: 8116
|
||||||
# 根据国标6.1.2中规定,domain宜采用ID统一编码的前十位编码。国标附录D中定义前8位为中心编码(由省级、市级、区级、基层编号组成,参照GB/T 2260-2007)
|
# 根据国标6.1.2中规定,domain宜采用ID统一编码的前十位编码。国标附录D中定义前8位为中心编码(由省级、市级、区级、基层编号组成,参照GB/T 2260-2007)
|
||||||
|
@ -73,21 +73,21 @@ sip:
|
||||||
|
|
||||||
#zlm 默认服务器配置
|
#zlm 默认服务器配置
|
||||||
media:
|
media:
|
||||||
id: 89wulian-one
|
id: zlmediakit-local
|
||||||
# [必须修改] zlm服务器的内网IP
|
# [必须修改] zlm服务器的内网IP
|
||||||
ip: 192.168.1.18
|
ip: 172.19.128.50
|
||||||
# [必须修改] zlm服务器的http.port
|
# [必须修改] zlm服务器的http.port
|
||||||
http-port: 80
|
http-port: 9092
|
||||||
# [可选] 返回流地址时的ip,置空使用 media.ip
|
# [可选] 返回流地址时的ip,置空使用 media.ip
|
||||||
stream-ip: 192.168.1.18
|
stream-ip: 172.19.128.50
|
||||||
# [可选] wvp在国标信令中使用的ip,此ip为摄像机可以访问到的ip, 置空使用 media.ip
|
# [可选] wvp在国标信令中使用的ip,此ip为摄像机可以访问到的ip, 置空使用 media.ip
|
||||||
sdp-ip: 192.168.1.18
|
sdp-ip: 172.19.128.50
|
||||||
# [可选] zlm服务器的hook所使用的IP, 默认使用sip.ip
|
# [可选] zlm服务器的hook所使用的IP, 默认使用sip.ip
|
||||||
hook-ip: 192.168.1.18
|
hook-ip: 172.19.128.50
|
||||||
# [可选] zlm服务器的http.sslport, 置空使用zlm配置文件配置
|
# [可选] zlm服务器的http.sslport, 置空使用zlm配置文件配置
|
||||||
http-ssl-port: 443
|
http-ssl-port: 1443
|
||||||
# [可选] zlm服务器的hook.admin_params=secret
|
# [可选] zlm服务器的hook.admin_params=secret
|
||||||
secret: 035c73f7-bb6b-4889-a715-d9eb2d1925cc
|
secret: 10000
|
||||||
# 启用多端口模式, 多端口模式使用端口区分每路流,兼容性更好。 单端口使用流的ssrc区分, 点播超时建议使用多端口测试
|
# 启用多端口模式, 多端口模式使用端口区分每路流,兼容性更好。 单端口使用流的ssrc区分, 点播超时建议使用多端口测试
|
||||||
rtp:
|
rtp:
|
||||||
# [可选] 是否启用多端口模式, 开启后会在portRange范围内选择端口用于媒体流传输
|
# [可选] 是否启用多端口模式, 开启后会在portRange范围内选择端口用于媒体流传输
|
||||||
|
|
|
@ -2,4 +2,4 @@ spring:
|
||||||
application:
|
application:
|
||||||
name: wvp
|
name: wvp
|
||||||
profiles:
|
profiles:
|
||||||
active: local
|
active: dev
|
Loading…
Reference in New Issue