|
@@ -6,6 +6,7 @@ import com.sooka.model.db.IntDetailed;
|
|
|
import com.sooka.service.AuthService;
|
|
|
import com.sooka.mapper.AuthMapper;
|
|
|
import com.sooka.utils.DateUtils;
|
|
|
+import com.sooka.utils.SecretKeyUtil;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import tk.mybatis.mapper.entity.Example;
|
|
@@ -43,14 +44,34 @@ public class AuthServiceImpl implements AuthService {
|
|
|
// if (list == null || list.size() != 1) {
|
|
|
// return ResultModel.error(ResultEnum.ERROR_AUTH_EXPIRES);
|
|
|
// }
|
|
|
+ // IntDetailed intDetailed = list.get(0);
|
|
|
|
|
|
// 新授权码到期验证
|
|
|
boolean isAuthExpires;
|
|
|
- IntDetailed intDetailed = list.get(0);
|
|
|
+ IntDetailed intDetailed;
|
|
|
if (list != null && list.size() == 1) {
|
|
|
- return ResultModel.error(ResultEnum.ERROR_AUTH_EXPIRES);
|
|
|
- }else {
|
|
|
+ intDetailed = list.get(0);
|
|
|
+ if(intDetailed.getRecordId() != null){ // 新接口解析密钥判断授权时效
|
|
|
+ // 解密后的明文是:123/政数局/2022-10-20 - 2022-10-29/b29c94d72ee74c6d94b573d90020ea59
|
|
|
+ String duration = SecretKeyUtil.AESDncode("3fc674da58", intDetailed.getSecretKey().split("/")[2]);
|
|
|
+ // 2022-10-20 - 2022-10-29
|
|
|
+ String startTime = duration.split(" - ")[0];
|
|
|
+ String endTime = duration.split(" - ")[1];
|
|
|
+ if(startTime == null && endTime == null){
|
|
|
+ isAuthExpires = false; // 授权有效
|
|
|
+ System.out.println("授权有效");
|
|
|
+ }else {
|
|
|
+ isAuthExpires = true; // 授权已到期
|
|
|
+ System.out.println("授权已到期");
|
|
|
+ }
|
|
|
+ }else { // legacy
|
|
|
+ isAuthExpires = false; // 旧接口按照原密钥接收数据,授权长期有效
|
|
|
+ System.out.println("旧接口按照原密钥接收数据,授权长期有效");
|
|
|
+ }
|
|
|
+ }else { // 授权失效或无此密钥及存在多个异常密钥,提示授权码到期请重新申请
|
|
|
+ intDetailed = null;
|
|
|
isAuthExpires = true;
|
|
|
+ System.out.println("授权失效或无此密钥及存在多个异常密钥,提示授权码到期请重新申请");
|
|
|
}
|
|
|
if (isAuthExpires) {
|
|
|
return ResultModel.error(ResultEnum.ERROR_AUTH_EXPIRES);
|
|
@@ -60,9 +81,10 @@ public class AuthServiceImpl implements AuthService {
|
|
|
return ResultModel.error(ResultEnum.ERROR_INT_SECRET_KEY_MISMATCH);
|
|
|
}
|
|
|
|
|
|
- if (!"1".equalsIgnoreCase(intDetailed.getStatus())) {
|
|
|
- return ResultModel.error(ResultEnum.ERROR_INTERFACE_DISABLED);
|
|
|
- }
|
|
|
+ // // 原申请接口状态验证
|
|
|
+ // if (!"1".equalsIgnoreCase(intDetailed.getStatus())) {
|
|
|
+ // return ResultModel.error(ResultEnum.ERROR_INTERFACE_DISABLED);
|
|
|
+ // }
|
|
|
|
|
|
return ResultModel.ok(list);
|
|
|
}
|