简单整合 试水

This commit is contained in:
shikong 2023-10-02 02:12:38 +08:00
parent 8a8dd66b8b
commit 67c3875ffb
2 changed files with 13 additions and 4 deletions

View File

@ -29,6 +29,11 @@
<artifactId>orm</artifactId> <artifactId>orm</artifactId>
</dependency> </dependency>
<dependency>
<groupId>cn.skcks.docking.gb28181</groupId>
<artifactId>gb28181-sip</artifactId>
</dependency>
<dependency> <dependency>
<groupId>cn.skcks.docking.gb28181</groupId> <groupId>cn.skcks.docking.gb28181</groupId>
<artifactId>common</artifactId> <artifactId>common</artifactId>

View File

@ -7,7 +7,8 @@ import cn.skcks.docking.gb28181.core.sip.dto.SipTransactionInfo;
import cn.skcks.docking.gb28181.core.sip.gb28181.constant.GB28181Constant; import cn.skcks.docking.gb28181.core.sip.gb28181.constant.GB28181Constant;
import cn.skcks.docking.gb28181.core.sip.gb28181.sip.GbSipDate; import cn.skcks.docking.gb28181.core.sip.gb28181.sip.GbSipDate;
import cn.skcks.docking.gb28181.core.sip.listener.SipListener; import cn.skcks.docking.gb28181.core.sip.listener.SipListener;
import cn.skcks.docking.gb28181.core.sip.message.auth.DigestServerAuthenticationHelper; import cn.skcks.docking.gb28181.sip.method.register.response.RegisterResponseBuilder;
import cn.skcks.docking.gb28181.sip.utils.DigestAuthenticationHelper;
import cn.skcks.docking.gb28181.core.sip.message.processor.MessageProcessor; import cn.skcks.docking.gb28181.core.sip.message.processor.MessageProcessor;
import cn.skcks.docking.gb28181.core.sip.message.sender.SipMessageSender; import cn.skcks.docking.gb28181.core.sip.message.sender.SipMessageSender;
import cn.skcks.docking.gb28181.core.sip.utils.SipUtil; import cn.skcks.docking.gb28181.core.sip.utils.SipUtil;
@ -81,18 +82,21 @@ public class RegisterRequestProcessor implements MessageProcessor {
} }
} }
RegisterResponseBuilder registerResponseBuilder = RegisterResponseBuilder.builder().build();
String password = sipConfig.getPassword(); String password = sipConfig.getPassword();
Authorization authorization = request.getAuthorization(); Authorization authorization = request.getAuthorization();
if(authorization == null && StringUtils.isNotBlank(password)){ if(authorization == null && StringUtils.isNotBlank(password)){
Response response = getMessageFactory().createResponse(Response.UNAUTHORIZED, request); Response response = registerResponseBuilder.createAuthorzatioinResponse(request,sipConfig.getDomain(), password);
DigestServerAuthenticationHelper.generateChallenge(getHeaderFactory(),response,sipConfig.getDomain());
sender.send(senderIp,response); sender.send(senderIp,response);
return; return;
} }
log.debug("认证信息 => {}", authorization); log.debug("认证信息 => {}", authorization);
boolean authPass = StringUtils.isBlank(password) || boolean authPass = StringUtils.isBlank(password) ||
DigestServerAuthenticationHelper.doAuthenticatePlainTextPassword(request,password); DigestAuthenticationHelper.doAuthenticatePlainTextPassword(request,password);
if(!authPass){ if(!authPass){
Response response = getMessageFactory().createResponse(Response.FORBIDDEN, request); Response response = getMessageFactory().createResponse(Response.FORBIDDEN, request);
response.setReasonPhrase("认证失败"); response.setReasonPhrase("认证失败");