解决session在重启后,内存中不存在的问题
This commit is contained in:
@@ -251,11 +251,16 @@ public class ProtocolProcessor {
|
||||
pwd = msg.payload().password();
|
||||
|
||||
MemorySessionStore.Session session = m_sessionsStore.getSession(clientId);
|
||||
if (session == null) {
|
||||
m_sessionsStore.createNewSession(msg.payload().userName(), clientId, true, false);
|
||||
session = m_sessionsStore.getSession(clientId);
|
||||
}
|
||||
|
||||
if (session != null && session.getUsername().equals(msg.payload().userName())) {
|
||||
pwd = AES.AESDecrypt(pwd, session.getSecret(), true);
|
||||
} else {
|
||||
LOG.error("Password decrypt failed of client {}", clientId);
|
||||
failedCredentials(channel);
|
||||
failedNoSession(channel);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -365,6 +370,11 @@ public class ProtocolProcessor {
|
||||
LOG.info("Client {} failed to connect with bad username or password.", session);
|
||||
}
|
||||
|
||||
private void failedNoSession(Channel session) {
|
||||
session.writeAndFlush(connAck(CONNECTION_REFUSED_SESSION_NOT_EXIST));
|
||||
LOG.info("Client {} failed to connect with bad username or password.", session);
|
||||
}
|
||||
|
||||
private void setIdleTime(ChannelPipeline pipeline, int idleTime) {
|
||||
if (pipeline.names().contains("idleStateHandler")) {
|
||||
pipeline.remove("idleStateHandler");
|
||||
|
||||
Reference in New Issue
Block a user