GB28181:基于JAVA的设备注册实现[part2]
程序员文章站
2022-03-17 14:14:51
...
GB28181:基于JAVA的设备注册实现[part2]
一、不鉴权
二、鉴权
三、伪代码
/**
* 处理注册相关业务
*
* @param requestEvent
* @param messageFactory
* @param headerFactory
* @param sipProvider
*/
private void doRequestRegister(RequestEvent requestEvent,AddressFactory addressFactory, MessageFactory messageFactory, HeaderFactory headerFactory, SipProvider sipProvider) {
Request request = requestEvent.getRequest();
try {
String deviceId = getDeviceIdByRequest(request);
log.info("Register deviceId is {}, toURI is {}", deviceId);
if (StringUtils.isEmpty(deviceId)) {
log.error("Register error, deviceId is empty!");
return;
}
//无需鉴权或者鉴权判断通过
if (isAuthClosed(deviceId) || isAuthorizationPass(request)) {
//返回成功 返回Response.OK
log.info("Register doSuccess!");
doSuccess(requestEvent, addressFactory, messageFactory, headerFactory, sipProvider);
}else if (isRegisterWithoutAuth(request)) {
doUnAuthorized(requestEvent, messageFactory, headerFactory, sipProvider, request, deviceId);
}else {
doLoginFail403(requestEvent, addressFactory, messageFactory, headerFactory, sipProvider);
}
}catch (Exception e) {
log.error("处理Register请求的时候出错 error, {}", e.getMessage());
e.printStackTrace();
}
}
四、有兴趣加群一起交流
扣 群 号:
541410132,注明:CSDN
源码:给个star吧https://gitee.com/yuntian_admin/srymy