From 96021addb41968a144b3face71661222473a04e2 Mon Sep 17 00:00:00 2001 From: shikong <919411476@qq.com> Date: Wed, 13 Sep 2023 02:47:59 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A8=A1=E6=8B=9F=E8=AE=BE=E5=A4=87=E6=B3=A8?= =?UTF-8?q?=E5=86=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gb28181/mocking/core/sip/listener/SipListenerImpl.java | 2 +- .../mocking/service/gb28181/register/RegisterService.java | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/gb28181-mocking-service/src/main/java/cn/skcks/docking/gb28181/mocking/core/sip/listener/SipListenerImpl.java b/gb28181-mocking-service/src/main/java/cn/skcks/docking/gb28181/mocking/core/sip/listener/SipListenerImpl.java index 8c74f99..bcbdd39 100644 --- a/gb28181-mocking-service/src/main/java/cn/skcks/docking/gb28181/mocking/core/sip/listener/SipListenerImpl.java +++ b/gb28181-mocking-service/src/main/java/cn/skcks/docking/gb28181/mocking/core/sip/listener/SipListenerImpl.java @@ -55,7 +55,7 @@ public class SipListenerImpl implements SipListener { log.debug("{} {}", method, response); // Success - if (((status >= Response.OK) && (status < Response.MULTIPLE_CHOICES)) || status == Response.UNAUTHORIZED) { + if (((status >= Response.OK) && (status < Response.MULTIPLE_CHOICES)) || status == Response.UNAUTHORIZED || status == Response.FORBIDDEN) { log.debug("传入响应 method => {}", method); Optional.ofNullable(responseProcessor.get(method)).ifPresent(processor -> { processor.process(responseEvent); diff --git a/gb28181-mocking-service/src/main/java/cn/skcks/docking/gb28181/mocking/service/gb28181/register/RegisterService.java b/gb28181-mocking-service/src/main/java/cn/skcks/docking/gb28181/mocking/service/gb28181/register/RegisterService.java index a18fd30..ecacd45 100644 --- a/gb28181-mocking-service/src/main/java/cn/skcks/docking/gb28181/mocking/service/gb28181/register/RegisterService.java +++ b/gb28181-mocking-service/src/main/java/cn/skcks/docking/gb28181/mocking/service/gb28181/register/RegisterService.java @@ -97,6 +97,7 @@ public class RegisterService { @Override public void onNext(SIPResponse response) { int statusCode = response.getStatusCode(); + if (statusCode == Response.UNAUTHORIZED && !usedAuthorization) { usedAuthorization = true; WWWAuthenticateHeader authorizationHeader = (WWWAuthenticateHeader) response.getHeader(WWWAuthenticateHeader.NAME); @@ -114,9 +115,9 @@ public class RegisterService { return; } - if (statusCode == Response.UNAUTHORIZED) { + if (statusCode == Response.UNAUTHORIZED || statusCode == Response.FORBIDDEN) { this.onComplete(); - String reason = MessageFormat.format("设备: {0}({1}), 注册失败, 认证失败", device.getDeviceCode(), device.getGbDeviceId()); + String reason = MessageFormat.format("设备: {0}({1}), 注册失败: 认证失败", device.getDeviceCode(), device.getGbDeviceId()); log.error(reason); result.complete(JsonResponse.error(reason)); return;