...
|
...
|
@@ -18,7 +18,7 @@ import java.util.concurrent.TimeUnit; |
|
|
@Component
|
|
|
public class RedisTokenManager implements ITokenManager {
|
|
|
|
|
|
private RedisTemplate<Long, String> redis;
|
|
|
private RedisTemplate<String, String> redis;
|
|
|
|
|
|
@Autowired
|
|
|
public void setRedis(RedisTemplate redis) {
|
...
|
...
|
@@ -27,7 +27,7 @@ public class RedisTokenManager implements ITokenManager { |
|
|
redis.setKeySerializer(new JdkSerializationRedisSerializer());
|
|
|
}
|
|
|
|
|
|
public TokenModel createToken(long userId) {
|
|
|
public TokenModel createToken(String userId) {
|
|
|
//使用uuid作为源token
|
|
|
String token = UUID.randomUUID().toString().replace("-", "");
|
|
|
TokenModel model = new TokenModel(userId, token);
|
...
|
...
|
@@ -45,7 +45,7 @@ public class RedisTokenManager implements ITokenManager { |
|
|
return null;
|
|
|
}
|
|
|
//使用userId和源token简单拼接成的token,可以增加加密措施
|
|
|
long userId = Long.parseLong(param[0]);
|
|
|
String userId = param[0];
|
|
|
String token = param[1];
|
|
|
return new TokenModel(userId, token);
|
|
|
}
|
...
|
...
|
@@ -63,7 +63,7 @@ public class RedisTokenManager implements ITokenManager { |
|
|
return true;
|
|
|
}
|
|
|
|
|
|
public void deleteToken(long userId) {
|
|
|
public void deleteToken(String userId) {
|
|
|
redis.delete(userId);
|
|
|
}
|
|
|
} |
...
|
...
|
|