代码更新
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
package org.nl.wms.autotask;
|
package org.nl.acs.autotask;
|
||||||
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|||||||
@@ -1,51 +0,0 @@
|
|||||||
package org.nl.modules.security.satoken;
|
|
||||||
|
|
||||||
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.nl.modules.mnt.websocket.MsgType;
|
|
||||||
import org.nl.modules.mnt.websocket.SocketMsg;
|
|
||||||
import org.nl.modules.mnt.websocket.WebSocketServer;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.data.redis.connection.Message;
|
|
||||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
|
||||||
import org.springframework.data.redis.listener.KeyExpirationEventMessageListener;
|
|
||||||
import org.springframework.data.redis.listener.RedisMessageListenerContainer;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author: lyd
|
|
||||||
* @description:
|
|
||||||
* @Date: 2022/10/8
|
|
||||||
*/
|
|
||||||
@Slf4j
|
|
||||||
@Component
|
|
||||||
public class TokenKeyExpirationListener extends KeyExpirationEventMessageListener {
|
|
||||||
@Autowired
|
|
||||||
private StringRedisTemplate redisTemplate;
|
|
||||||
|
|
||||||
public TokenKeyExpirationListener(RedisMessageListenerContainer listenerContainer) {
|
|
||||||
super(listenerContainer);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onMessage(Message message, byte[] pattern) {
|
|
||||||
// 监听过期的key
|
|
||||||
String expireKey = new String(message.getBody(), StandardCharsets.UTF_8);
|
|
||||||
//获取key原本的value 获取不到 是null
|
|
||||||
String expireKeyValue = redisTemplate.opsForValue().get("my-satoken");
|
|
||||||
//我是根据tokenvalues作为主键ID的
|
|
||||||
String[] split = expireKey.split(":");
|
|
||||||
String s = split[split.length - 1];
|
|
||||||
try {
|
|
||||||
WebSocketServer.sendInfo(new SocketMsg("token会话过期!", MsgType.INFO), "exp-token");
|
|
||||||
} catch (IOException e) {
|
|
||||||
log.error(e.getMessage(), e);
|
|
||||||
}
|
|
||||||
log.info("expireKey---"+expireKey);
|
|
||||||
log.info("expireKeyValue---"+expireKeyValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -40,7 +40,7 @@ module.exports = {
|
|||||||
/**
|
/**
|
||||||
* @description token key
|
* @description token key
|
||||||
*/
|
*/
|
||||||
TokenKey: 'EL-ADMIN-TOEKN',
|
TokenKey: 'NL-ACS-TOEKN',
|
||||||
/**
|
/**
|
||||||
* @description 请求超时时间,毫秒(默认2分钟)
|
* @description 请求超时时间,毫秒(默认2分钟)
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,51 +0,0 @@
|
|||||||
package org.nl.modules.security.satoken;
|
|
||||||
|
|
||||||
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.nl.modules.mnt.websocket.MsgType;
|
|
||||||
import org.nl.modules.mnt.websocket.SocketMsg;
|
|
||||||
import org.nl.modules.mnt.websocket.WebSocketServer;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.data.redis.connection.Message;
|
|
||||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
|
||||||
import org.springframework.data.redis.listener.KeyExpirationEventMessageListener;
|
|
||||||
import org.springframework.data.redis.listener.RedisMessageListenerContainer;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author: lyd
|
|
||||||
* @description:
|
|
||||||
* @Date: 2022/10/8
|
|
||||||
*/
|
|
||||||
@Slf4j
|
|
||||||
@Component
|
|
||||||
public class TokenKeyExpirationListener extends KeyExpirationEventMessageListener {
|
|
||||||
@Autowired
|
|
||||||
private StringRedisTemplate redisTemplate;
|
|
||||||
|
|
||||||
public TokenKeyExpirationListener(RedisMessageListenerContainer listenerContainer) {
|
|
||||||
super(listenerContainer);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onMessage(Message message, byte[] pattern) {
|
|
||||||
// 监听过期的key
|
|
||||||
String expireKey = new String(message.getBody(), StandardCharsets.UTF_8);
|
|
||||||
//获取key原本的value 获取不到 是null
|
|
||||||
String expireKeyValue = redisTemplate.opsForValue().get("my-satoken");
|
|
||||||
//我是根据tokenvalues作为主键ID的
|
|
||||||
String[] split = expireKey.split(":");
|
|
||||||
String s = split[split.length - 1];
|
|
||||||
try {
|
|
||||||
WebSocketServer.sendInfo(new SocketMsg("token会话过期!", MsgType.INFO), "exp-token");
|
|
||||||
} catch (IOException e) {
|
|
||||||
log.error(e.getMessage(), e);
|
|
||||||
}
|
|
||||||
log.info("expireKey---"+expireKey);
|
|
||||||
log.info("expireKeyValue---"+expireKeyValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -40,7 +40,7 @@ module.exports = {
|
|||||||
/**
|
/**
|
||||||
* @description token key
|
* @description token key
|
||||||
*/
|
*/
|
||||||
TokenKey: 'EL-ADMIN-TOEKN',
|
TokenKey: 'NL-LMS-TOEKN',
|
||||||
/**
|
/**
|
||||||
* @description 请求超时时间,毫秒(默认2分钟)
|
* @description 请求超时时间,毫秒(默认2分钟)
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user