register 调整

This commit is contained in:
shikong 2023-09-28 14:03:33 +08:00
parent 3a00d027e4
commit 7eee14510e
2 changed files with 2 additions and 2 deletions

View File

@ -38,7 +38,7 @@ public class RegisterRequestBuilder extends RequestBuilder implements RegisterBu
@SneakyThrows @SneakyThrows
public Request createAuthorizationRequest(String callId, int expires, String id, String passwd, long cSeq, WWWAuthenticateHeader wwwAuthenticateHeader) { public Request createAuthorizationRequest(String callId, int expires, String id, String passwd, long cSeq, WWWAuthenticateHeader wwwAuthenticateHeader) {
SIPRequest request = (SIPRequest) createNoAuthorizationRequest(callId, expires); SIPRequest request = (SIPRequest) createNoAuthorizationRequest(callId, expires);
request.getCSeq().setSeqNumber(cSeq + 1); request.getCSeq().setSeqNumber(cSeq);
AuthorizationHeader authorization = DigestAuthenticationHelper.createAuthorization(METHOD, getTargetIp(), getTargetPort(), getTargetId(), id, passwd, (int) cSeq, wwwAuthenticateHeader); AuthorizationHeader authorization = DigestAuthenticationHelper.createAuthorization(METHOD, getTargetIp(), getTargetPort(), getTargetId(), id, passwd, (int) cSeq, wwwAuthenticateHeader);
return SipBuilder.addHeaders(request, authorization); return SipBuilder.addHeaders(request, authorization);
} }

View File

@ -95,7 +95,7 @@ public class RequestTest {
log.info("\n{}", authorzatioinResponse); log.info("\n{}", authorzatioinResponse);
SIPResponse sipResponse = (SIPResponse) authorzatioinResponse; SIPResponse sipResponse = (SIPResponse) authorzatioinResponse;
WWWAuthenticateHeader wwwAuthenticateHeader = (WWWAuthenticateHeader) sipResponse.getHeader(WWWAuthenticateHeader.NAME); WWWAuthenticateHeader wwwAuthenticateHeader = (WWWAuthenticateHeader) sipResponse.getHeader(WWWAuthenticateHeader.NAME);
long cSeq = sipResponse.getCSeq().getSeqNumber(); long cSeq = sipResponse.getCSeq().getSeqNumber() + 1;
// 重新发起带有认证信息的请求 // 重新发起带有认证信息的请求
Request authorizationRequest = registerRequestBuilder.createAuthorizationRequest(callId, 3600, localId, "123456", cSeq, wwwAuthenticateHeader); Request authorizationRequest = registerRequestBuilder.createAuthorizationRequest(callId, 3600, localId, "123456", cSeq, wwwAuthenticateHeader);
log.info("\n{}", authorizationRequest); log.info("\n{}", authorizationRequest);