参数名变更
This commit is contained in:
parent
41b9c2387e
commit
5ac9c7dc71
@ -1,7 +1,6 @@
|
|||||||
package com.rymcu.vertical.jwt.service;
|
package com.rymcu.vertical.jwt.service;
|
||||||
|
|
||||||
|
|
||||||
import com.rymcu.vertical.core.service.redis.RedisService;
|
|
||||||
import com.rymcu.vertical.jwt.def.JwtConstants;
|
import com.rymcu.vertical.jwt.def.JwtConstants;
|
||||||
import com.rymcu.vertical.jwt.model.TokenModel;
|
import com.rymcu.vertical.jwt.model.TokenModel;
|
||||||
import io.jsonwebtoken.Jwts;
|
import io.jsonwebtoken.Jwts;
|
||||||
@ -22,12 +21,11 @@ import java.util.concurrent.TimeUnit;
|
|||||||
public class RedisTokenManager implements TokenManager {
|
public class RedisTokenManager implements TokenManager {
|
||||||
@Autowired
|
@Autowired
|
||||||
private StringRedisTemplate redisTemplate;
|
private StringRedisTemplate redisTemplate;
|
||||||
@Autowired
|
|
||||||
private RedisService redisService;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 生成TOKEN
|
* 生成TOKEN
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public String createToken(String id) {
|
public String createToken(String id) {
|
||||||
//使用uuid作为源token
|
//使用uuid作为源token
|
||||||
String token = Jwts.builder().setId(id).setSubject(id).setIssuedAt(new Date()).signWith(SignatureAlgorithm.HS256, JwtConstants.JWT_SECRET).compact();
|
String token = Jwts.builder().setId(id).setSubject(id).setIssuedAt(new Date()).signWith(SignatureAlgorithm.HS256, JwtConstants.JWT_SECRET).compact();
|
||||||
@ -36,10 +34,12 @@ public class RedisTokenManager implements TokenManager {
|
|||||||
return token;
|
return token;
|
||||||
}
|
}
|
||||||
|
|
||||||
public TokenModel getToken(String token, String userid) {
|
@Override
|
||||||
return new TokenModel(userid, token);
|
public TokenModel getToken(String token, String account) {
|
||||||
|
return new TokenModel(account, token);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean checkToken(TokenModel model) {
|
public boolean checkToken(TokenModel model) {
|
||||||
if (model == null) {
|
if (model == null) {
|
||||||
return false;
|
return false;
|
||||||
@ -53,7 +53,8 @@ public class RedisTokenManager implements TokenManager {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deleteToken(String username) {
|
@Override
|
||||||
redisTemplate.delete(username);
|
public void deleteToken(String account) {
|
||||||
|
redisTemplate.delete(account);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,12 +27,12 @@ public interface TokenManager {
|
|||||||
* 从字符串中解析token
|
* 从字符串中解析token
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public TokenModel getToken(String token, String userid);
|
public TokenModel getToken(String token, String account);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 清除token
|
* 清除token
|
||||||
* @param username 登录用户账号
|
* @param account 登录用户账号
|
||||||
*/
|
*/
|
||||||
public void deleteToken(String username);
|
public void deleteToken(String account);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user