diff --git a/sa-token-core/src/main/java/cn/dev33/satoken/session/SaTerminalInfo.java b/sa-token-core/src/main/java/cn/dev33/satoken/session/SaTerminalInfo.java
index e2e5bb60..c0c0f522 100644
--- a/sa-token-core/src/main/java/cn/dev33/satoken/session/SaTerminalInfo.java
+++ b/sa-token-core/src/main/java/cn/dev33/satoken/session/SaTerminalInfo.java
@@ -243,18 +243,16 @@ public class SaTerminalInfo implements Serializable {
//
@Override
public String toString() {
- return "TokenSign [" +
+ return "SaTerminalInfo [" +
"index=" + index +
- ", tokenValue=" + tokenValue +
- ", deviceType=" + deviceType +
- ", deviceId=" + deviceId +
+ ", tokenValue='" + tokenValue +
+ ", deviceType='" + deviceType +
+ ", deviceId='" + deviceId +
", extraData=" + extraData +
", createTime=" + createTime +
- "]";
+ ']';
}
-
-
/*
* Expand in the future:
* deviceName 登录设备端名称,一般为浏览器名称
diff --git a/sa-token-demo/pom.xml b/sa-token-demo/pom.xml
index 515235c9..27585b8a 100644
--- a/sa-token-demo/pom.xml
+++ b/sa-token-demo/pom.xml
@@ -20,7 +20,7 @@
sa-token-demo-dubbo/sa-token-demo-dubbo3-provider
sa-token-demo-dubbo/sa-token-demo-dubbo3-consumer
sa-token-demo-freemarker
- sa-token-demo-grpc
+
sa-token-demo-hutool-timed-cache
sa-token-demo-jwt
sa-token-demo-oauth2/sa-token-demo-oauth2-server
diff --git a/sa-token-demo/sa-token-demo-solon/src/main/java/com/pj/satoken/SaTokenConfigure.java b/sa-token-demo/sa-token-demo-solon/src/main/java/com/pj/satoken/SaTokenConfigure.java
index 9951566e..8697cfd1 100644
--- a/sa-token-demo/sa-token-demo-solon/src/main/java/com/pj/satoken/SaTokenConfigure.java
+++ b/sa-token-demo/sa-token-demo-solon/src/main/java/com/pj/satoken/SaTokenConfigure.java
@@ -3,8 +3,7 @@ package com.pj.satoken;
import cn.dev33.satoken.context.SaHolder;
import cn.dev33.satoken.dao.SaTokenDao;
-import cn.dev33.satoken.dao.SaTokenDaoOfRedis;
-import cn.dev33.satoken.dao.SaTokenDaoOfRedisJson;
+import cn.dev33.satoken.dao.SaTokenDaoForRedisx;
import cn.dev33.satoken.solon.integration.SaTokenInterceptor;
import com.pj.util.AjaxJson;
import org.noear.solon.annotation.Bean;
@@ -61,7 +60,7 @@ public class SaTokenConfigure {
//如果需要 redis dao,加这段代表
@Bean
- public SaTokenDao saTokenDaoInit(@Inject("${sa-token-dao.redis}") SaTokenDaoOfRedisJson saTokenDao) {
+ public SaTokenDao saTokenDaoInit(@Inject("${sa-token-dao.redis}") SaTokenDaoForRedisx saTokenDao) {
return saTokenDao;
}
diff --git a/sa-token-demo/sa-token-demo-ssm/src/main/java/com/pj/satoken/SaTokenBeanInjection.java b/sa-token-demo/sa-token-demo-ssm/src/main/java/com/pj/satoken/SaTokenBeanInjection.java
index b0944713..d22a9b67 100644
--- a/sa-token-demo/sa-token-demo-ssm/src/main/java/com/pj/satoken/SaTokenBeanInjection.java
+++ b/sa-token-demo/sa-token-demo-ssm/src/main/java/com/pj/satoken/SaTokenBeanInjection.java
@@ -2,11 +2,13 @@ package com.pj.satoken;
import cn.dev33.satoken.application.ApplicationInfo;
import cn.dev33.satoken.config.SaTokenConfig;
-import cn.dev33.satoken.dao.SaTokenDaoRedisJackson;
+import cn.dev33.satoken.dao.SaTokenDaoForRedisTemplate;
+import cn.dev33.satoken.json.SaJsonTemplateForJackson;
import cn.dev33.satoken.log.SaLog;
+import cn.dev33.satoken.plugin.SaTokenPluginHolder;
import cn.dev33.satoken.spring.SaBeanInject;
import cn.dev33.satoken.spring.SaTokenContextForSpring;
-import cn.dev33.satoken.spring.json.SaJsonTemplateForJackson;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.connection.RedisConnectionFactory;
/**
@@ -19,13 +21,14 @@ public class SaTokenBeanInjection {
public SaTokenBeanInjection(
SaLog log,
SaTokenConfig config,
+ @Autowired(required = false) SaTokenPluginHolder pluginHolder,
RedisConnectionFactory connectionFactory,
String routePrefix
) {
System.out.println("---------------- 手动注入 Sa-Token 所需要的组件 start ----------------");
// 日志组件、配置信息
- SaBeanInject inject = new SaBeanInject(log, config);
+ SaBeanInject inject = new SaBeanInject(log, config, pluginHolder);
// 基于 Spring 的上下文处理器
inject.setSaTokenContext(new SaTokenContextForSpring());
@@ -34,9 +37,9 @@ public class SaTokenBeanInjection {
inject.setSaJsonTemplate(new SaJsonTemplateForJackson());
// 基于 Jackson 序列化的 Redis 持久化组件
- SaTokenDaoRedisJackson saTokenDaoRedisJackson = new SaTokenDaoRedisJackson();
- saTokenDaoRedisJackson.init(connectionFactory);
- inject.setSaTokenDao(saTokenDaoRedisJackson);
+ SaTokenDaoForRedisTemplate saTokenDaoForRedisTemplate = new SaTokenDaoForRedisTemplate();
+ saTokenDaoForRedisTemplate.init(connectionFactory);
+ inject.setSaTokenDao(saTokenDaoForRedisTemplate);
// 权限和角色数据
inject.setStpInterface(new StpInterfaceImpl());
diff --git a/sa-token-plugin/sa-token-hutool-timed-cache/src/main/java/cn/dev33/satoken/dao/SaTokenDaoForHutoolTimedCache.java b/sa-token-plugin/sa-token-hutool-timed-cache/src/main/java/cn/dev33/satoken/dao/SaTokenDaoForHutoolTimedCache.java
index 61ed7dfe..fc656792 100644
--- a/sa-token-plugin/sa-token-hutool-timed-cache/src/main/java/cn/dev33/satoken/dao/SaTokenDaoForHutoolTimedCache.java
+++ b/sa-token-plugin/sa-token-hutool-timed-cache/src/main/java/cn/dev33/satoken/dao/SaTokenDaoForHutoolTimedCache.java
@@ -51,6 +51,11 @@ public class SaTokenDaoForHutoolTimedCache implements SaTokenDaoByStringFollowOb
return timedCache.get(key, false);
}
+ @Override
+ public T getObject(String key, Class classType) {
+ return (T) getObject(key);
+ }
+
@Override
public void setObject(String key, Object object, long timeout) {
if(timeout == 0 || timeout <= SaTokenDao.NOT_VALUE_EXPIRE) {
diff --git a/sa-token-starter/sa-token-jboot-plugin/src/main/java/cn/dev33/satoken/jboot/SaTokenCacheDao.java b/sa-token-starter/sa-token-jboot-plugin/src/main/java/cn/dev33/satoken/jboot/SaTokenCacheDao.java
index 7beec111..2ad57592 100644
--- a/sa-token-starter/sa-token-jboot-plugin/src/main/java/cn/dev33/satoken/jboot/SaTokenCacheDao.java
+++ b/sa-token-starter/sa-token-jboot-plugin/src/main/java/cn/dev33/satoken/jboot/SaTokenCacheDao.java
@@ -167,6 +167,11 @@ public class SaTokenCacheDao implements SaTokenDaoBySessionFollowObject {
}
}
+ @Override
+ public T getObject(String key, Class classType) {
+ return (T) getObject(key);
+ }
+
@Override
public void setObject(String key, Object object, long timeout) {
if (timeout == 0 || timeout <= SaTokenDao.NOT_VALUE_EXPIRE) {
diff --git a/sa-token-starter/sa-token-jfinal-plugin/src/main/java/cn/dev33/satoken/jfinal/SaTokenDaoRedis.java b/sa-token-starter/sa-token-jfinal-plugin/src/main/java/cn/dev33/satoken/jfinal/SaTokenDaoRedis.java
index fbfe9863..2b7b26e1 100644
--- a/sa-token-starter/sa-token-jfinal-plugin/src/main/java/cn/dev33/satoken/jfinal/SaTokenDaoRedis.java
+++ b/sa-token-starter/sa-token-jfinal-plugin/src/main/java/cn/dev33/satoken/jfinal/SaTokenDaoRedis.java
@@ -150,6 +150,11 @@ public class SaTokenDaoRedis implements SaTokenDaoBySessionFollowObject {
}
}
+ @Override
+ public T getObject(String key, Class classType) {
+ return (T) getObject(key);
+ }
+
/**
* 写入Object,并设定存活时间 (单位: 秒)
*/
diff --git a/sa-token-test/sa-token-springboot-test/src/test/java/cn/dev33/satoken/core/session/SaSessionTest.java b/sa-token-test/sa-token-springboot-test/src/test/java/cn/dev33/satoken/core/session/SaSessionTest.java
index 8e704a32..1b9d2cdf 100644
--- a/sa-token-test/sa-token-springboot-test/src/test/java/cn/dev33/satoken/core/session/SaSessionTest.java
+++ b/sa-token-test/sa-token-springboot-test/src/test/java/cn/dev33/satoken/core/session/SaSessionTest.java
@@ -107,7 +107,7 @@ public class SaSessionTest {
// 测试token 签名
@Test
- public void testTokenSign() {
+ public void testSaTerminalInfo() {
SaSession session = new SaSession("session-1002");
// 添加 Token 签名
@@ -123,7 +123,7 @@ public class SaSessionTest {
session.removeTerminal("xxxx-xxxx-xxxx-xxxx-1");
Assertions.assertEquals(session.getTerminalList().size(), 1);
- // 删除一个不存在的,则不影响 TokenSign 列表
+ // 删除一个不存在的,则不影响 SaTerminalInfo 列表
session.removeTerminal("xxxx-xxxx-xxxx-xxxx-999");
Assertions.assertEquals(session.getTerminalList().size(), 1);
diff --git a/sa-token-test/sa-token-springboot-test/src/test/java/cn/dev33/satoken/core/session/SaTerminalInfoTest.java b/sa-token-test/sa-token-springboot-test/src/test/java/cn/dev33/satoken/core/session/SaTerminalInfoTest.java
index 6dd5ea36..d4254776 100644
--- a/sa-token-test/sa-token-springboot-test/src/test/java/cn/dev33/satoken/core/session/SaTerminalInfoTest.java
+++ b/sa-token-test/sa-token-springboot-test/src/test/java/cn/dev33/satoken/core/session/SaTerminalInfoTest.java
@@ -20,7 +20,7 @@ import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
/**
- * TokenSign 相关测试
+ * SaTerminalInfo 相关测试
*
* @author click33
* @since 2022-9-4
@@ -30,14 +30,14 @@ public class SaTerminalInfoTest {
// 测试
@Test
public void testSaTerminalInfo() {
- SaTerminalInfo tokenSign = new SaTerminalInfo();
- tokenSign.setDeviceType("PC");
- tokenSign.setTokenValue("ttt-value");
+ SaTerminalInfo terminal = new SaTerminalInfo();
+ terminal.setDeviceType("PC");
+ terminal.setTokenValue("ttt-value");
- Assertions.assertEquals(tokenSign.getDeviceType(), "PC");
- Assertions.assertEquals(tokenSign.getTokenValue(), "ttt-value");
+ Assertions.assertEquals(terminal.getDeviceType(), "PC");
+ Assertions.assertEquals(terminal.getTokenValue(), "ttt-value");
- Assertions.assertNotNull(tokenSign.toString());
+ Assertions.assertNotNull(terminal.toString());
}
}
diff --git a/sa-token-test/sa-token-springboot-test/src/test/java/cn/dev33/satoken/springboot/ManyLoginTest.java b/sa-token-test/sa-token-springboot-test/src/test/java/cn/dev33/satoken/springboot/ManyLoginTest.java
index e0a4a8da..33440b41 100644
--- a/sa-token-test/sa-token-springboot-test/src/test/java/cn/dev33/satoken/springboot/ManyLoginTest.java
+++ b/sa-token-test/sa-token-springboot-test/src/test/java/cn/dev33/satoken/springboot/ManyLoginTest.java
@@ -114,8 +114,8 @@ public class ManyLoginTest {
Assertions.assertEquals(dao.get("satoken:login:token:" + token1), "-4");
// Account-Session里的 token1 签名会被移除
- List tokenSignList = StpUtil.getSessionByLoginId(10001).getTerminalList();
- for (SaTerminalInfo terminal : tokenSignList) {
+ List terminalList = StpUtil.getSessionByLoginId(10001).getTerminalList();
+ for (SaTerminalInfo terminal : terminalList) {
Assertions.assertNotEquals(terminal.getTokenValue(), token1);
}
}