| | |
| | | import org.springframework.beans.factory.InitializingBean; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.util.ObjectUtils; |
| | | import org.springframework.util.StringUtils; |
| | | |
| | | import javax.sip.InvalidArgumentException; |
| | |
| | | String deviceId = uri.getUser(); |
| | | |
| | | AuthorizationHeader authHead = (AuthorizationHeader) request.getHeader(AuthorizationHeader.NAME); |
| | | if (authHead == null && !StringUtils.isEmpty(sipConfig.getPassword())) { |
| | | if (authHead == null && !ObjectUtils.isEmpty(sipConfig.getPassword())) { |
| | | logger.info("[注册请求] 未携带授权头 回复401: {}", requestAddress); |
| | | response = getMessageFactory().createResponse(Response.UNAUTHORIZED, request); |
| | | new DigestServerAuthenticationHelper().generateChallenge(getHeaderFactory(), response, sipConfig.getDomain()); |
| | |
| | | } |
| | | |
| | | // 校验密码是否正确 |
| | | passwordCorrect = StringUtils.isEmpty(sipConfig.getPassword()) || |
| | | passwordCorrect = ObjectUtils.isEmpty(sipConfig.getPassword()) || |
| | | new DigestServerAuthenticationHelper().doAuthenticatePlainTextPassword(request, sipConfig.getPassword()); |
| | | |
| | | if (!passwordCorrect) { |
| | |
| | | String received = viaHeader.getReceived(); |
| | | int rPort = viaHeader.getRPort(); |
| | | // 解析本地地址替代 |
| | | if (StringUtils.isEmpty(received) || rPort == -1) { |
| | | if (ObjectUtils.isEmpty(received) || rPort == -1) { |
| | | received = viaHeader.getHost(); |
| | | rPort = viaHeader.getPort(); |
| | | } |
| | |
| | | device.setStreamMode("UDP"); |
| | | device.setCharset("GB2312"); |
| | | device.setGeoCoordSys("WGS84"); |
| | | device.setTreeType("CivilCode"); |
| | | device.setDeviceId(deviceId); |
| | | device.setOnline(0); |
| | | } |
| | | device.setIp(received); |
| | | device.setPort(rPort); |
| | |
| | | // 判断TCP还是UDP |
| | | ViaHeader reqViaHeader = (ViaHeader) request.getHeader(ViaHeader.NAME); |
| | | String transport = reqViaHeader.getTransport(); |
| | | device.setTransport("TCP".equals(transport) ? "TCP" : "UDP"); |
| | | device.setTransport("TCP".equalsIgnoreCase(transport) ? "TCP" : "UDP"); |
| | | } |
| | | |
| | | sendResponse(evt, response); |