fix: 如果鉴权码校验失败则失败
All checks were successful
iot-test-platform CI/CD / build-and-deploy (push) Successful in 17s
All checks were successful
iot-test-platform CI/CD / build-and-deploy (push) Successful in 17s
This commit is contained in:
@@ -11,13 +11,13 @@ import com.iot.transport.jt808.service.handler.MessageHandler;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 终端鉴权 ==> 平台通用应答
|
* 终端鉴权 ==> 平台通用应答
|
||||||
|
*
|
||||||
* @author huaxl
|
* @author huaxl
|
||||||
*/
|
*/
|
||||||
public class AuthenticationHandler extends MessageHandler {
|
public class AuthenticationHandler extends MessageHandler {
|
||||||
|
|
||||||
private final Logger logger = LoggerFactory.getLogger(getClass());
|
private final Logger logger = LoggerFactory.getLogger(getClass());
|
||||||
|
|
||||||
|
|
||||||
public AuthenticationHandler() {
|
public AuthenticationHandler() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
@@ -27,24 +27,33 @@ public class AuthenticationHandler extends MessageHandler {
|
|||||||
//
|
//
|
||||||
|
|
||||||
PackHead header = packageData.getPackHead();
|
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 {
|
try {
|
||||||
|
|
||||||
AuthenticationPack msg = new AuthenticationPack(packageData);
|
AuthenticationPack msg = new AuthenticationPack(packageData);
|
||||||
//this.msgProcessService.processAuthMsg(authenticationMsg);
|
// 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());
|
final String sessionId = Session.buildId(msg.getChannel());
|
||||||
Session session = sessionManager.findBySessionId(sessionId);
|
Session session = sessionManager.findBySessionId(sessionId);
|
||||||
if (session == null) {
|
if (session == null) {
|
||||||
session = Session.buildSession(msg.getChannel(), msg.getPackHead().getTerminalPhone());
|
session = Session.buildSession(msg.getChannel(), msg.getPackHead().getTerminalPhone());
|
||||||
}
|
}
|
||||||
session.setAuthenticated(true);
|
session.setAuthenticated(isSuccess);
|
||||||
session.setTerminalPhone(msg.getPackHead().getTerminalPhone());
|
session.setTerminalPhone(msg.getPackHead().getTerminalPhone());
|
||||||
sessionManager.put(session.getId(), session);
|
sessionManager.put(session.getId(), session);
|
||||||
|
|
||||||
ServerBodyPack respMsgBody = new ServerBodyPack();
|
ServerBodyPack respMsgBody = new ServerBodyPack();
|
||||||
respMsgBody.setReplyCode(ServerBodyPack.success);
|
respMsgBody.setReplyCode(isSuccess ? ServerBodyPack.success : ServerBodyPack.failure);
|
||||||
respMsgBody.setReplyFlowId(msg.getPackHead().getFlowId());
|
respMsgBody.setReplyFlowId(msg.getPackHead().getFlowId());
|
||||||
respMsgBody.setReplyId(msg.getPackHead().getId());
|
respMsgBody.setReplyId(msg.getPackHead().getId());
|
||||||
int flowId = super.getFlowId(msg.getChannel());
|
int flowId = super.getFlowId(msg.getChannel());
|
||||||
|
|||||||
Reference in New Issue
Block a user