|
|
|
@ -8,6 +8,7 @@ import lombok.AllArgsConstructor;
|
|
|
|
|
import org.slf4j.Logger; |
|
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
|
import org.springblade.core.mp.base.BaseServiceImpl; |
|
|
|
|
import org.springblade.core.redis.cache.BladeRedis; |
|
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
|
|
import java.security.NoSuchAlgorithmException; |
|
|
|
@ -20,6 +21,8 @@ public class FactoryTokenServiceImpl extends BaseServiceImpl<FactoryTokenMapper,
|
|
|
|
|
|
|
|
|
|
private static final Logger logger = LoggerFactory.getLogger(FactoryTokenServiceImpl.class); |
|
|
|
|
|
|
|
|
|
private final BladeRedis bladeRedis; |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public boolean verifyToken(String token, String corpId) throws NoSuchAlgorithmException { |
|
|
|
|
logger.info("#########verifyToken: 验证token开始"); |
|
|
|
@ -27,14 +30,27 @@ public class FactoryTokenServiceImpl extends BaseServiceImpl<FactoryTokenMapper,
|
|
|
|
|
// String tokenAbst = MD5Utils.md5Hex(token.getBytes(StandardCharsets.UTF_8));
|
|
|
|
|
|
|
|
|
|
//编写查询条件
|
|
|
|
|
QueryWrapper<FactoryToken> queryWrapper = new QueryWrapper<>(); |
|
|
|
|
queryWrapper.eq("token",token) |
|
|
|
|
.eq("corpid",corpId); |
|
|
|
|
FactoryToken factoryToken = baseMapper.selectOne(queryWrapper); |
|
|
|
|
String key ="corpId:"+corpId; |
|
|
|
|
FactoryToken factoryToken = bladeRedis.get(key); |
|
|
|
|
|
|
|
|
|
if(Objects.isNull(factoryToken)){ |
|
|
|
|
QueryWrapper<FactoryToken> queryWrapper = new QueryWrapper<>(); |
|
|
|
|
queryWrapper.eq("token",token); |
|
|
|
|
factoryToken = baseMapper.selectOne(queryWrapper); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(Objects.isNull(factoryToken)){ |
|
|
|
|
logger.error("#########verifyToken: token验证不通过 token={},corpid={}",token,corpId); |
|
|
|
|
logger.error("#########verifyToken: token1验证不通过 token={},corpid={}",token,corpId); |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
logger.info("#########verifyToken: 验证token 传入token {} 验证token {}",token,factoryToken.getToken()); |
|
|
|
|
if(!factoryToken.getToken().equals(token)){ |
|
|
|
|
logger.error("#########verifyToken: toke2n验证不通过 token={},corpid={}",token,corpId); |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Long expireTimeLong = factoryToken.getExpireTime().getTime(); |
|
|
|
|
Long now = new Date().getTime(); |
|
|
|
|
//判断是否过期
|
|
|
|
|