解决session在重启后,内存中不存在的问题

This commit is contained in:
heavyrain.lee
2019-05-24 16:33:35 +08:00
parent 3ef973ffc5
commit 675025c0ec
5 changed files with 19 additions and 5 deletions
@@ -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");