优先使用SIP认证用户名

This commit is contained in:
Leijie 2023-06-14 19:26:51 +08:00
parent fa80ba6f2b
commit 9432342559

View File

@ -10,6 +10,7 @@ import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
import com.genersoft.iot.vmp.utils.GitUtil;
import gov.nist.javax.sip.message.MessageFactoryImpl;
import gov.nist.javax.sip.message.SIPRequest;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.DigestUtils;
@ -36,7 +37,7 @@ public class SIPRequestHeaderPlarformProvider {
@Autowired
private SipConfig sipConfig;
@Autowired
private SipLayer sipLayer;
@ -96,8 +97,7 @@ public class SIPRequestHeaderPlarformProvider {
if (www == null) {
AuthorizationHeader authorizationHeader = SipFactory.getInstance().createHeaderFactory().createAuthorizationHeader("Digest");
String username = parentPlatform.getUsername();
if ( username == null || username == "" )
{
if (ObjectUtils.isEmpty(username)){
authorizationHeader.setUsername(parentPlatform.getDeviceGBId());
} else {
authorizationHeader.setUsername(username);
@ -148,7 +148,12 @@ public class SIPRequestHeaderPlarformProvider {
String RESPONSE = DigestUtils.md5DigestAsHex(reStr.toString().getBytes());
AuthorizationHeader authorizationHeader = SipFactory.getInstance().createHeaderFactory().createAuthorizationHeader(scheme);
authorizationHeader.setUsername(parentPlatform.getDeviceGBId());
String username = parentPlatform.getUsername();
if (ObjectUtils.isEmpty(username)){
authorizationHeader.setUsername(parentPlatform.getDeviceGBId());
} else {
authorizationHeader.setUsername(username);
}
authorizationHeader.setRealm(realm);
authorizationHeader.setNonce(nonce);
authorizationHeader.setURI(requestURI);