| | |
| | | |
| | | import com.dg.core.Constant; |
| | | import io.jsonwebtoken.Claims; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Qualifier; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | |
| | | } |
| | | |
| | | @Override |
| | | public String createToken(long userId, long userRole) { |
| | | public String createToken(String userId, String userRole) { |
| | | //使用uuid作为源token |
| | | String uuid = UUID.randomUUID().toString().replace("-", ""); |
| | | String token = DigestUtils.sha1DigestAsHex(uuid + userId + "e23ktjsdf") + "-" + userRole; |
| | |
| | | } |
| | | |
| | | public boolean checkToken(String token) { |
| | | if (token == null) { |
| | | if (StringUtils.isEmpty(token)) { |
| | | return false; |
| | | } |
| | | String userId = redis.boundValueOps(token).get(); |
| | |
| | | */ |
| | | @Override |
| | | public boolean checkHCToken(String token) { |
| | | if (token == null) { |
| | | if (StringUtils.isEmpty(token)) { |
| | | return false; |
| | | } |
| | | // token解析 |
| | |
| | | } |
| | | |
| | | @Override |
| | | public String getTokenByUserId(long userId) { |
| | | return redis.boundValueOps(String.valueOf(userId)).get(); |
| | | public String getTokenByUserId(String userId) { |
| | | return redis.boundValueOps(userId).get(); |
| | | } |
| | | |
| | | } |