fix: 如果鉴权码校验失败则失败
All checks were successful
iot-test-platform CI/CD / build-and-deploy (push) Successful in 17s

This commit is contained in:
lzh
2026-01-19 17:34:43 +08:00
parent aef2405751
commit c5a144d6e0

View File

@@ -11,13 +11,13 @@ import com.iot.transport.jt808.service.handler.MessageHandler;
/**
* 终端鉴权 ==> 平台通用应答
*
* @author huaxl
*/
public class AuthenticationHandler extends MessageHandler {
private final Logger logger = LoggerFactory.getLogger(getClass());
public AuthenticationHandler() {
super();
}
@@ -27,24 +27,33 @@ public class AuthenticationHandler extends MessageHandler {
//
PackHead header = packageData.getPackHead();
logger.info("[终端鉴权],msgid={}, phone={},flowid={}", header.getId(), header.getTerminalPhone(), header.getFlowId());
logger.info("[终端鉴权],msgid={}, phone={},flowid={}", header.getId(), header.getTerminalPhone(),
header.getFlowId());
try {
AuthenticationPack msg = new AuthenticationPack(packageData);
// this.msgProcessService.processAuthMsg(authenticationMsg);
log.debug("终端鉴权:{}", msg);
log.info("终端鉴权:{}", msg);
boolean isSuccess = false;
if ("testtoken".equals(msg.getAuthCode())) {
isSuccess = true;
} else {
logger.warn("终端鉴权失败: msgId={}, phone={}, token={}", header.getId(), header.getTerminalPhone(),
msg.getAuthCode());
}
final String sessionId = Session.buildId(msg.getChannel());
Session session = sessionManager.findBySessionId(sessionId);
if (session == null) {
session = Session.buildSession(msg.getChannel(), msg.getPackHead().getTerminalPhone());
}
session.setAuthenticated(true);
session.setAuthenticated(isSuccess);
session.setTerminalPhone(msg.getPackHead().getTerminalPhone());
sessionManager.put(session.getId(), session);
ServerBodyPack respMsgBody = new ServerBodyPack();
respMsgBody.setReplyCode(ServerBodyPack.success);
respMsgBody.setReplyCode(isSuccess ? ServerBodyPack.success : ServerBodyPack.failure);
respMsgBody.setReplyFlowId(msg.getPackHead().getFlowId());
respMsgBody.setReplyId(msg.getPackHead().getId());
int flowId = super.getFlowId(msg.getChannel());